Cool to have a test for this, thanks Alex.
However I think that in the near future we need to find a way to write these type of tests
as unit tests instead of functional tests since otherwise we're going to have too many
functional tests, which will lead to the following problems:
- take a lot of time to execute (and hence are not executed often + need more machines,
etc)
- are hard to debug when they fail (since they're not unit tests)
- do not make us improve the design of the code
WDYT?
Thanks
-Vincent
PS: I haven't looked at this example in particular and my comment is general. Maybe
this is testing old code which would need some heavy refactoring before we can write a
unit test for it.
On Aug 27, 2010, at 11:33 AM, abusenius (SVN) wrote:
Author: abusenius
Date: 2010-08-27 11:33:57 +0200 (Fri, 27 Aug 2010)
New Revision: 30768
Modified:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/LoginTest.java
Log:
XWIKI-5434: Added a functional test
Modified:
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/LoginTest.java
===================================================================
---
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/LoginTest.java 2010-08-27
09:30:38 UTC (rev 30767)
+++
enterprise/trunk/distribution-test/ui-tests/src/test/it/org/xwiki/it/ui/LoginTest.java 2010-08-27
09:33:57 UTC (rev 30768)
@@ -26,6 +26,7 @@
import org.xwiki.it.ui.administration.elements.GlobalRightsPage;
import org.xwiki.it.ui.framework.AbstractTest;
import org.xwiki.it.ui.framework.elements.LoginPage;
+import org.xwiki.it.ui.framework.elements.editor.WikiEditPage;
import org.xwiki.it.ui.xe.elements.HomePage;
/**
@@ -114,4 +115,31 @@
rights.unforceAuthenticatedView();
}
}
+
+ @Test
+ public void testRedirectPreservesPOSTParameters() throws InterruptedException
+ {
+ String test = "Test string " + System.currentTimeMillis();
+ final String space = "Main";
+ final String page = "POSTTest";
+ LoginPage loginPage = this.homePage.clickLogin();
+ loginPage.loginAsAdmin();
+ // start editing a page
+ WikiEditPage editPage = new WikiEditPage();
+ editPage.switchToEdit(space, page);
+ editPage.setTitle(test);
+ editPage.setContent(test);
+ // emulate expired session: delete the cookies
+ getDriver().manage().deleteAllCookies();
+ // try to save
+ editPage.clickSaveAndView();
+ // we should have been redirected to login
+
Assert.assertTrue(getDriver().getCurrentUrl().startsWith(getUtil().getURL("XWiki",
"XWikiLogin", "login")));
+ loginPage.loginAsAdmin();
+ // we should have been redirected back to view, and the page should have been
saved
+ Assert.assertTrue(getDriver().getCurrentUrl().startsWith(getUtil().getURL(space,
page)));
+ editPage.switchToEdit(space, page);
+ Assert.assertEquals(test, editPage.getTitle());
+ Assert.assertEquals(test, editPage.getContent());
+ }
}
_______________________________________________
notifications mailing list
notifications(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/notifications