use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class EditObjectsTest method testChangeListTypeRelationalStorage.
/**
* Prove that a list can be changed from relational storage to plain storage and back without database corruption.
* XWIKI-1621: Changing parameters of list properties fails
*/
@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testChangeListTypeRelationalStorage() {
// Create class page
WikiEditPage wep = WikiEditPage.gotoPage("Test", "EditObjectsTestClass");
wep.setContent("this is the content");
ViewPage vp = wep.clickSaveAndView();
// Add class
ClassEditPage cep = vp.editClass();
cep.addProperty("prop", "StaticList");
StaticListClassEditElement slcee = cep.getStaticListClassEditElement("prop");
slcee.setMultiSelect(true);
slcee.setDisplayType(StaticListClassEditElement.DisplayType.INPUT);
vp = cep.clickSaveAndView();
Assert.assertEquals("this is the content", vp.getContent());
// Create object page
wep = WikiEditPage.gotoPage("Test", "EditObjectsTestObject");
wep.setContent("this is the content: {{velocity}}$doc.display('prop'){{/velocity}}");
vp = wep.clickSaveAndView();
// Add object
ObjectEditPage oep = vp.editObjects();
FormElement objectForm = oep.addObject("Test.EditObjectsTestClass");
objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "this|that|other");
vp = oep.clickSaveAndView();
Assert.assertEquals("this is the content: this that other", vp.getContent());
// Change list to relational storage.
cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
cep.getStaticListClassEditElement("prop").setRelationalStorage(true);
vp = cep.clickSaveAndView();
Assert.assertEquals("this is the content", vp.getContent());
// Make sure we can still edit the object.
oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "this|other");
vp = oep.clickSaveAndView();
Assert.assertEquals("this is the content: this other", vp.getContent());
// Change list to non-relational storage.
cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
cep.getStaticListClassEditElement("prop").setRelationalStorage(false);
vp = cep.clickSaveAndView();
Assert.assertEquals("this is the content", vp.getContent());
// Make sure we can still edit the object.
oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "that|other");
vp = oep.clickSaveAndView();
Assert.assertEquals("this is the content: that other", vp.getContent());
}
use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class KeyboardShortcutsTest method testKeyboardShortcuts.
@Test
@IgnoreBrowsers({ @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146"), @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177") })
public void testKeyboardShortcuts() {
ViewPage vp = getUtil().gotoPage("Sandbox", "WebHome");
// Test default edit mode (WYSIWYG for Sandbox.WebHome) key
vp.sendKeys("e");
// Test Cancel key
vp.sendKeys(Keys.chord(Keys.ALT, "c"));
vp.waitUntilPageIsLoaded();
Assert.assertTrue(getUtil().isInViewMode());
// Test Wiki edit key
vp.sendKeys("k");
vp.waitUntilPageIsLoaded();
Assert.assertTrue(getUtil().isInWikiEditMode());
// Test WYSIWYG edit mode key
vp = getUtil().gotoPage("Sandbox", "WebHome");
vp.sendKeys("g");
// Test Inline Form edit mode key
vp = getUtil().gotoPage("Sandbox", "WebHome");
vp.sendKeys("f");
vp.waitUntilPageIsLoaded();
Assert.assertTrue(getUtil().isInInlineEditMode());
// Test Rights edit mode key on a terminal document
vp = getUtil().gotoPage("Sandbox", "TestPage1");
vp.sendKeys("r");
vp.waitUntilPageIsLoaded();
Assert.assertTrue(getUtil().isInRightsEditMode());
// Test Rights edit mode key on a non terminal document
vp = getUtil().gotoPage("Sandbox", "WebHome");
vp.sendKeys("r");
vp.waitUntilPageIsLoaded();
Assert.assertTrue(getUtil().isInAdminMode());
AdministrationPage administrationPage = new AdministrationPage();
Assert.assertTrue(administrationPage.hasSection("PageRights"));
// Test Object edit mode key
vp = getUtil().gotoPage("Sandbox", "WebHome");
vp.sendKeys("o");
vp.waitUntilPageIsLoaded();
Assert.assertTrue(getUtil().isInObjectEditMode());
// Test Class edit mode key
vp = getUtil().gotoPage("Sandbox", "WebHome");
vp.sendKeys("s");
vp.waitUntilPageIsLoaded();
Assert.assertTrue(getUtil().isInClassEditMode());
// Test Delete key
vp = getUtil().gotoPage("Sandbox", "WebHome");
vp.sendKeys(Keys.DELETE);
vp.waitUntilPageIsLoaded();
Assert.assertTrue(getUtil().isInDeleteMode());
// Test Rename key
vp = getUtil().gotoPage("Sandbox", "WebHome");
vp.sendKeys(Keys.F2);
vp.waitUntilPageIsLoaded();
Assert.assertTrue(getUtil().isInRenameMode());
// Test View Source key
vp = getUtil().gotoPage("Sandbox", "WebHome");
vp.sendKeys("d");
vp.waitUntilPageIsLoaded();
Assert.assertTrue(getUtil().isInSourceViewMode());
}
use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class LanguageTest method testChangeLanguageInMonolingualModeUsingTheAdministrationPreference.
@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testChangeLanguageInMonolingualModeUsingTheAdministrationPreference() {
WikiEditPage edit = WikiEditPage.gotoPage("Test", "LanguageTest");
edit.setContent("{{velocity}}context = ($xcontext.language), doc = ($doc.language), " + "default = ($doc.defaultLanguage), tdoc = ($tdoc.language), " + "tdocdefault = ($tdoc.defaultLanguage){{/velocity}}");
ViewPage vp = edit.clickSaveAndView();
// Current language must be "en"
Assert.assertEquals("Invalid content", vp.getContent(), "context = (en), doc = (), default = (en), tdoc = (), tdocdefault = (en)");
// Change default language to "fr"
AdministrationPage adminPage = AdministrationPage.gotoPage();
LocalizationAdministrationSectionPage sectionPage = adminPage.clickLocalizationSection();
sectionPage.setDefaultLanguage("fr");
sectionPage.clickSave();
// Now language must be "fr"
vp = getUtil().gotoPage("Test", "LanguageTest");
Assert.assertTrue("Page not in French!", isPageInFrench());
Assert.assertEquals("Invalid content", vp.getContent(), "context = (fr), doc = (), default = (en), tdoc = (), tdocdefault = (en)");
}
use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class LanguageTest method testTranslateDocument.
@Test
public void testTranslateDocument() throws Exception {
LocalDocumentReference referenceDEFAULT = new LocalDocumentReference("LanguageTest", "Page");
LocalDocumentReference referenceFR = new LocalDocumentReference(referenceDEFAULT, Locale.FRENCH);
// Cleanup
getUtil().rest().delete(referenceFR);
getUtil().rest().delete(referenceDEFAULT);
// Set 2 locales
setLanguageSettings(true, "en", Arrays.asList("en", "fr"));
// Create default version
ViewPage viewPage = getUtil().createPage("LanguageTest", "Page", "en content", "en title");
// Edit the page
WikiEditPage editPage = viewPage.editWiki();
// Make sure current translation is the right one
assertTrue(getDriver().hasElement(By.xpath("//strong[text()='You are editing the original page (en).']")));
assertEquals(Arrays.asList(Locale.FRENCH), editPage.getNotExistingLocales());
assertEquals(Arrays.asList(), editPage.getExistingLocales());
// Translated to French
editPage = editPage.clickTranslate("fr");
editPage.setTitle("titre fr");
editPage.setContent("contenu fr");
viewPage = editPage.clickSaveAndView();
// Make sure both have the right content
Page page = getUtil().rest().get(referenceFR);
assertEquals("titre fr", page.getTitle());
assertEquals("contenu fr", page.getContent());
page = getUtil().rest().get(referenceDEFAULT);
assertEquals("en title", page.getTitle());
assertEquals("en content", page.getContent());
// Make sure two locales are listed for this page in the UI
assertEquals(new HashSet<>(Arrays.asList(Locale.ENGLISH, Locale.FRENCH)), new HashSet<>(viewPage.getLocales()));
// Switch to en
viewPage.clickLocale(Locale.ENGLISH);
// Verify edit mode informations
editPage = viewPage.editWiki();
assertEquals(Arrays.asList(), editPage.getNotExistingLocales());
assertEquals(Arrays.asList(Locale.FRENCH), editPage.getExistingLocales());
}
use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class LoginTest method testRedirectBackAfterLogin.
/**
* Verify that the initial URL is not lost after logging in when the session has expired.
* See XWIKI-5317.
*/
@Test
public void testRedirectBackAfterLogin() {
try {
// Test setup: disallow view right for unauthenticated users. We need to be logged as admin in order to
// do that. Since this is not what we are testing use the fast way to log in
GlobalRightsAdministrationSectionPage grasp = new GlobalRightsAdministrationSectionPage();
getDriver().get(getUtil().getURLToLoginAsAdminAndGotoPage(grasp.getURL()));
getUtil().recacheSecretToken();
getUtil().setDefaultCredentials(TestUtils.ADMIN_CREDENTIALS);
grasp.forceAuthenticatedView();
// Go to a page, log out and expire session by removing cookies, log in again and verify that the user is
// redirected to the initial page.
ViewPage page = getUtil().gotoPage("SomeSpace", "SomePage");
page.logout();
// Since view is disallowed for unauthenticated users, at this point we see a log in page.
LoginPage loginPage = new LoginPage();
// Remove all cookie to simulate a session expiry
getDriver().manage().deleteAllCookies();
loginPage.loginAsAdmin();
// We use startsWith since the URL contains a jsessionid and a srid.
Assert.assertTrue(getDriver().getCurrentUrl().startsWith(getUtil().getURL("SomeSpace", "SomePage")));
} finally {
GlobalRightsAdministrationSectionPage grasp = GlobalRightsAdministrationSectionPage.gotoPage();
if (!grasp.isAuthenticated()) {
getDriver().get(getUtil().getURLToLoginAsAdminAndGotoPage(grasp.getURL()));
}
grasp.unforceAuthenticatedView();
}
}
Aggregations