Search in sources :

Example 36 with ViewPage

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));
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Example 37 with ViewPage

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());
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) EntryEditPage(org.xwiki.appwithinminutes.test.po.EntryEditPage) ClassFieldEditPane(org.xwiki.appwithinminutes.test.po.ClassFieldEditPane) LiveTableElement(org.xwiki.test.ui.po.LiveTableElement) EntryNamePane(org.xwiki.appwithinminutes.test.po.EntryNamePane) ApplicationHomeEditPage(org.xwiki.appwithinminutes.test.po.ApplicationHomeEditPage) ViewPage(org.xwiki.test.ui.po.ViewPage) ApplicationCreatePage(org.xwiki.appwithinminutes.test.po.ApplicationCreatePage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) ApplicationHomePage(org.xwiki.appwithinminutes.test.po.ApplicationHomePage) ApplicationClassEditPage(org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 38 with ViewPage

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());
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) HistoryPane(org.xwiki.test.ui.po.HistoryPane) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Example 39 with ViewPage

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"));
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) Test(org.junit.Test)

Example 40 with ViewPage

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());
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) ApplicationCreatePage(org.xwiki.appwithinminutes.test.po.ApplicationCreatePage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Aggregations

ViewPage (org.xwiki.test.ui.po.ViewPage)93 Test (org.junit.Test)75 AbstractTest (org.xwiki.test.ui.AbstractTest)41 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)26 WikiEditPage (org.xwiki.test.ui.po.editor.WikiEditPage)18 ObjectEditPage (org.xwiki.test.ui.po.editor.ObjectEditPage)11 IgnoreBrowser (org.xwiki.test.ui.browser.IgnoreBrowser)10 DocumentReference (org.xwiki.model.reference.DocumentReference)8 CreatePagePage (org.xwiki.test.ui.po.CreatePagePage)8 FormElement (org.xwiki.test.ui.po.FormElement)7 HistoryPane (org.xwiki.test.ui.po.HistoryPane)7 ClassEditPage (org.xwiki.test.ui.po.editor.ClassEditPage)7 WebElement (org.openqa.selenium.WebElement)6 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)6 AttachmentsPane (org.xwiki.test.ui.po.AttachmentsPane)6 URL (java.net.URL)5 ApplicationClassEditPage (org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage)5 ClassFieldEditPane (org.xwiki.appwithinminutes.test.po.ClassFieldEditPane)5 ExtensionId (org.xwiki.extension.ExtensionId)5 ExtensionAdministrationPage (org.xwiki.extension.test.po.ExtensionAdministrationPage)5