use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class WatchlistMacroTest method testWatchAndRemoveEntries.
@Test
public void testWatchAndRemoveEntries() {
// create a new page
ViewPage testPageView = getUtil().createPage(this.testSpace, this.testPage, "{{watchlist /}}", "Watch list");
// check if new page is registered in the watchlist, but not its space
Assert.assertTrue("Newly created page is not watched", this.watchlistMacro.isWatched(this.testSpace, this.testPage));
Assert.assertFalse("Newly created space is watched", this.watchlistMacro.isWatched(this.testSpace));
Assert.assertFalse("Complete wiki is watched", this.watchlistMacro.isWikiWatched());
testPageView.watchSpace();
testPageView.watchWiki();
// now need to reload the watchlist; doing so by going away from the page and then back
getUtil().gotoPage("Main", "WebHome");
testPageView = getUtil().gotoPage(this.testSpace, this.testPage);
Assert.assertTrue("Newly created page is not watched", this.watchlistMacro.isWatched(this.testSpace, this.testPage));
Assert.assertTrue("Test space is not watched", this.watchlistMacro.isWatched(this.testSpace));
Assert.assertTrue("Complete wiki is not watched", this.watchlistMacro.isWikiWatched());
this.watchlistMacro.unWatch(null, null);
this.watchlistMacro.unWatch(this.testSpace, this.testPage);
// change should have taken effect immediately, but instead reload page to avoid timing effects:
getUtil().gotoPage("Main", "WebHome");
testPageView = getUtil().gotoPage(this.testSpace, this.testPage);
Assert.assertFalse("Newly created page is still watched", this.watchlistMacro.isWatched(this.testSpace, this.testPage));
Assert.assertTrue("Test space is not watched", this.watchlistMacro.isWatched(this.testSpace));
Assert.assertFalse("Complete wiki is still watched", this.watchlistMacro.isWikiWatched());
this.watchlistMacro.unWatch(this.testSpace, null);
// next page reload .... see above
getUtil().gotoPage("Main", "WebHome");
testPageView = getUtil().gotoPage(this.testSpace, this.testPage);
Assert.assertFalse("Test space is still watched", this.watchlistMacro.isWatched(this.testSpace));
}
use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class DocumentFieldsTest method titleAndContent.
@Test
public void titleAndContent() {
// Create a new application.
String appName = RandomStringUtils.randomAlphabetic(6);
ApplicationCreatePage appCreatePage = ApplicationCreatePage.gotoPage();
appCreatePage.setApplicationName(appName);
appCreatePage.waitForApplicationNamePreview();
ApplicationClassEditPage classEditPage = appCreatePage.clickNextStep();
// Add a standard field.
ClassFieldEditPane numberField = classEditPage.addField("Number");
// Add the Title and Content fields.
ClassFieldEditPane titleField = classEditPage.addField("Title");
ClassFieldEditPane contentField = classEditPage.addField("Content");
// Change the default field pretty names.
// See XWIKI-9154: The application live table uses the standard 'Page title' heading instead of the pretty name
// set for the Title field
titleField.setPrettyName("My Title");
contentField.setPrettyName("My Content");
// Set the default values that will be saved in the template.
numberField.setDefaultValue("13");
String defaultTitle = "Enter title here";
titleField.setDefaultValue(defaultTitle);
String defaultContent = "Enter content here";
contentField.setDefaultValue(defaultContent);
// Add live table columns for Title and Content.
ApplicationHomeEditPage homeEditPage = classEditPage.clickNextStep().clickNextStep().waitUntilPageIsLoaded();
homeEditPage.addLiveTableColumn("My Title");
homeEditPage.addLiveTableColumn("My Content");
// Add an application entry.
EntryNamePane entryNamePane = homeEditPage.clickFinish().clickAddNewEntry();
entryNamePane.setName("Test");
EntryEditPage entryEditPage = entryNamePane.clickAdd();
Assert.assertEquals("13", entryEditPage.getValue("number1"));
// The page name is used as the default value for the title field.
Assert.assertEquals("Test", entryEditPage.getDocumentTitle());
Assert.assertEquals("Test", entryEditPage.getTitle());
entryEditPage.setTitle("Foo");
Assert.assertEquals(defaultContent, entryEditPage.getContent());
entryEditPage.setContent("Bar");
// Check that the title and the content of the entry have been updated.
ViewPage entryViewPage = entryEditPage.clickSaveAndView();
Assert.assertEquals("Foo", entryViewPage.getDocumentTitle());
Assert.assertTrue(entryViewPage.getContent().contains("Bar"));
entryViewPage.clickBreadcrumbLink(appName);
// Check the entries live table.
LiveTableElement liveTable = new ApplicationHomePage().getEntriesLiveTable();
liveTable.waitUntilReady();
Assert.assertEquals(1, liveTable.getRowCount());
Assert.assertTrue(liveTable.hasRow("My Title", "Foo"));
Assert.assertTrue(liveTable.hasRow("My Content", "Bar"));
// Check that the title and the content of the class have not been changed.
getUtil().gotoPage(new LocalDocumentReference(Arrays.asList(appName, "Code"), appName + "Class"), "edit", "editor=wiki");
WikiEditPage editPage = new WikiEditPage();
Assert.assertEquals(appName + " Class", editPage.getTitle());
Assert.assertEquals("", editPage.getContent());
// Now edit the class and check if the default values for title and content are taken from the template.
editPage.editInline();
Assert.assertEquals(defaultTitle, new ClassFieldEditPane("title1").getDefaultValue());
Assert.assertEquals(defaultContent, new ClassFieldEditPane("content1").getDefaultValue());
}
use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class VersionTest method testRollbackToFirstVersion.
@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 testRollbackToFirstVersion() throws Exception {
getUtil().rest().deletePage(SPACE_NAME, PAGE_NAME);
// Create first version of the page
ViewPage vp = getUtil().createPage(SPACE_NAME, PAGE_NAME, CONTENT1, TITLE);
// Adds second version
WikiEditPage wikiEditPage = vp.editWiki();
wikiEditPage.setContent(CONTENT2);
wikiEditPage.clickSaveAndView();
// TODO: Remove when XWIKI-6688 (Possible race condition when clicking on a tab at the bottom of a page in
// view mode) is fixed.
vp.waitForDocExtraPaneActive("comments");
// Verify that we can rollback to the first version
HistoryPane historyTab = vp.openHistoryDocExtraPane();
vp = historyTab.rollbackToVersion("1.1");
// Rollback doesn't wait...
// Wait for the comment tab to be selected since we're currently on the history tab and rolling
// back is going to load a new page and make the focus active on the comments tab.
vp.waitForDocExtraPaneActive("comments");
Assert.assertEquals("First version of Content", vp.getContent());
historyTab = vp.openHistoryDocExtraPane();
Assert.assertEquals("Rollback to version 1.1", historyTab.getCurrentVersionComment());
Assert.assertEquals("Administrator", historyTab.getCurrentAuthor());
}
use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class ViewTest method viewPageWhenSpecialCharactersInName.
/**
* See also <a href="https://jira.xwiki.org/browse/XWIKI-8725">XWIKI-8725</a>.
*/
@Test
public void viewPageWhenSpecialCharactersInName() throws Exception {
// We test a page name containing a space and a dot
String pageName = getTestMethodName() + " 1.0";
// Delete page since we create it below and want to start the test clean
getUtil().rest().deletePage(getTestClassName(), pageName);
// Create the page
ViewPage vp = getUtil().createPage(getTestClassName(), pageName, "", pageName);
// Verify that the page we're on has the correct URL and name
String expectedURLPart = getTestClassName() + "/" + pageName.replaceAll(" ", "%20");
Assert.assertTrue("URL [" + vp.getPageURL() + "] doesn't contain expected part [" + expectedURLPart + "]", vp.getPageURL().contains(expectedURLPart));
Assert.assertEquals(pageName, vp.getMetaDataValue("page"));
}
use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class ApplicationNameTest method testEmptyAppNameWithEnter.
/**
* Try to create an application with an empty name using the Enter key.
*/
@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 testEmptyAppNameWithEnter() {
ApplicationCreatePage appCreatePage = ApplicationCreatePage.gotoPage();
Assert.assertFalse(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
// Press Enter key without typing the application name.
appCreatePage.getApplicationNameInput().sendKeys(Keys.RETURN);
appCreatePage.waitForApplicationNameError();
Assert.assertTrue(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
// Type the application name.
appCreatePage.setApplicationName("B");
appCreatePage.waitForApplicationNamePreview();
Assert.assertFalse(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
// Clear the application name using the Backspace key.
appCreatePage.getApplicationNameInput().sendKeys(Keys.BACK_SPACE);
appCreatePage.waitForApplicationNameError();
Assert.assertTrue(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
// Try to create the application even if the error message is displayed.
appCreatePage.getApplicationNameInput().sendKeys(Keys.RETURN);
Assert.assertTrue(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
// Fix the application name and move to the next step using the Enter key.
appCreatePage.setApplicationName(getTestMethodName());
appCreatePage.waitForApplicationNamePreview();
appCreatePage.getApplicationNameInput().sendKeys(Keys.RETURN);
Assert.assertEquals(getTestMethodName() + " Structure", new ViewPage().getDocumentTitle());
}
Aggregations