use of org.xwiki.index.tree.test.po.DocumentPickerModal in project xwiki-platform by xwiki.
the class CopyPageTest method testCopyOverwritePage.
@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testCopyOverwritePage() throws Exception {
String sourceSpaceName = getTestClassName();
String sourcePageName = getTestMethodName();
String targetSpaceName = getTestClassName() + "Copy";
String targetPageName = getTestMethodName() + "Copy";
// Delete page that may already exist
getUtil().rest().deletePage(sourceSpaceName, sourcePageName);
getUtil().rest().deletePage(targetSpaceName, targetPageName);
// Create a new page that will be overwritten.
getUtil().rest().savePage(new LocalDocumentReference(targetSpaceName, targetPageName), OVERWRITTEN_PAGE_CONTENT, targetPageName);
// Create a new page that will be copied.
ViewPage viewPage = getUtil().createPage(sourceSpaceName, sourcePageName, PAGE_CONTENT, sourcePageName);
// Click on Copy from the Page top menu.
viewPage.copy();
CopyPage copyPage = new CopyPage();
// Fill the target destination the page to be copied to.
DocumentPicker documentPicker = copyPage.getDocumentPicker();
documentPicker.setTitle(targetPageName);
documentPicker.browseDocuments();
DocumentPickerModal documentPickerModal = new DocumentPickerModal();
documentPickerModal.waitForDocumentSelected(sourceSpaceName, "WebHome").selectDocument(targetSpaceName, "WebHome");
documentPicker.waitForLocation(Arrays.asList("", targetSpaceName, targetPageName));
Assert.assertEquals(targetSpaceName, copyPage.getTargetSpaceName());
// Click copy button
CopyOverwritePromptPage copyOverwritePrompt = copyPage.clickCopyButtonExpectingOverwritePrompt();
// Check overwrite warning
Assert.assertEquals(OVERWRITE_PROMPT1 + targetSpaceName + '.' + targetPageName + OVERWRITE_PROMPT2, copyOverwritePrompt.getWarningMessage());
// Cancel the copy
viewPage = copyOverwritePrompt.clickCancelButton();
// Verify that we have been sent back to the original page
Assert.assertEquals(sourcePageName, viewPage.getDocumentTitle());
// Click on Copy from the Page top menu.
viewPage.copy();
copyPage = new CopyPage();
// Fill the target destination the page to be copied to.
copyPage.getDocumentPicker().toggleLocationAdvancedEdit().setParent(targetSpaceName).setName(targetPageName);
// Click copy button
copyOverwritePrompt = copyPage.clickCopyButtonExpectingOverwritePrompt();
// Click change target
copyOverwritePrompt.clickChangeTargetButton();
copyPage = new CopyPage();
// Check the source document
Assert.assertEquals(Arrays.asList("", sourceSpaceName, sourcePageName), copyPage.getSourceLocation().getPath());
Assert.assertEquals(sourceSpaceName, copyPage.getSourceSpaceName());
Assert.assertEquals(sourcePageName, copyPage.getSourcePageName());
// Check the default target document.
documentPicker = copyPage.getDocumentPicker();
Assert.assertEquals(sourcePageName, documentPicker.getTitle());
Assert.assertEquals(Arrays.asList("", sourceSpaceName, sourcePageName), documentPicker.getLocation().getPath());
Assert.assertEquals(sourceSpaceName, copyPage.getTargetSpaceName());
Assert.assertEquals(sourcePageName, copyPage.getTargetPageName());
// Fill the target destination the page to be copied to.
documentPicker.setTitle("My copy").toggleLocationAdvancedEdit().setParent(targetSpaceName).setName(targetPageName);
// Copy and confirm overwrite
copyOverwritePrompt = copyPage.clickCopyButtonExpectingOverwritePrompt();
CopyOrRenameStatusPage copyStatusPage = copyOverwritePrompt.clickCopyButton().waitUntilFinished();
// Check successful copy confirmation
Assert.assertEquals(COPY_SUCCESSFUL, copyStatusPage.getInfoMessage());
viewPage = copyStatusPage.gotoNewPage();
// Verify that the title of the copy has been updated (independent from the name of the copy).
Assert.assertEquals("My copy", viewPage.getDocumentTitle());
Assert.assertEquals(PAGE_CONTENT, viewPage.getContent());
}
use of org.xwiki.index.tree.test.po.DocumentPickerModal in project xwiki-platform by xwiki.
the class WizardTest method testCreateApplication.
/**
* Tests the application creation process from start to end.
*/
@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 testCreateApplication() {
// Step 1
// Set the application location.
appCreatePage.getLocationPicker().browseDocuments();
new DocumentPickerModal().selectDocument(getClass().getSimpleName(), this.testName.getMethodName(), "WebHome");
appCreatePage.getLocationPicker().waitForLocation(Arrays.asList("", getClass().getSimpleName(), this.testName.getMethodName(), ""));
// Enter the application name, making sure we also use some special chars.
// See XWIKI-11747: Impossible to create new entry with an application having UTF8 chars in its name
String appName = "Cities âé";
String[] appPath = new String[] { getClass().getSimpleName(), this.testName.getMethodName(), appName };
appCreatePage.setApplicationName(appName);
// Wait for the preview.
appCreatePage.waitForApplicationNamePreview();
// Move to the next step.
ApplicationClassEditPage classEditPage = appCreatePage.clickNextStep();
// Step 2
// Add a 'Short Text' field.
ClassFieldEditPane fieldEditPane = classEditPage.addField("Short Text");
// Set the field pretty name and default value
fieldEditPane.setPrettyName("City Name");
fieldEditPane.setDefaultValue("Paris");
// Move to the next step.
ApplicationTemplateProviderEditPage templateProviderEditPage = classEditPage.clickNextStep();
// Move back to the second step.
classEditPage = templateProviderEditPage.clickPreviousStep();
// Open the configuration panel and set the field name
fieldEditPane = new ClassFieldEditPane("shortText1");
fieldEditPane.openConfigPanel();
fieldEditPane.setName("cityName");
// Move to the next step.
templateProviderEditPage = classEditPage.clickNextStep();
// Step 3
templateProviderEditPage.setIcon("worl");
templateProviderEditPage.setDescription("A city page");
// Move to the next step.
ApplicationHomeEditPage homeEditPage = templateProviderEditPage.clickNextStep().waitUntilPageIsLoaded();
// Step 4
// Enter the application description.
String appDescription = "Simple application to manage data about various cities";
homeEditPage.setDescription(appDescription);
// Add the Short Text field from the previous step to the list of columns.
homeEditPage.addLiveTableColumn("City Name");
// Click the finish button which should lead us to the application home page.
ApplicationHomePage homePage = homeEditPage.clickFinish();
// Assert the application description is present.
Assert.assertTrue(homePage.getContent().contains(appDescription));
// Add a new entry.
String firstEntryName = "City 1 âé";
EntryNamePane entryNamePane = homePage.clickAddNewEntry();
entryNamePane.setName(firstEntryName);
EntryEditPage entryEditPage = entryNamePane.clickAdd();
// Assert the pretty name and the default value of the Short Text field.
// Apparently WebElement#getText() takes into account the text-transform CSS property.
Assert.assertEquals("CITY NAME", entryEditPage.getLabel("cityName"));
Assert.assertEquals("Paris", entryEditPage.getValue("cityName"));
// Change the field value.
entryEditPage.setValue("cityName", "London");
// Save and go back to the application home page.
entryEditPage.clickSaveAndView().clickBreadcrumbLink(appName);
homePage = new ApplicationHomePage();
// Assert the entry we have just created is listed in the live table.
LiveTableElement entriesLiveTable = homePage.getEntriesLiveTable();
entriesLiveTable.waitUntilReady();
Assert.assertTrue(entriesLiveTable.hasRow("City Name", "London"));
// Assert that only the entry we have just created is listed as child of the application home page. The rest of
// the documents (class, template, sheet, preferences) should be marked as hidden.
PagesLiveTableElement childrenLiveTable = homePage.viewChildren().getLiveTable();
childrenLiveTable.waitUntilReady();
Assert.assertEquals(1, childrenLiveTable.getRowCount());
Assert.assertTrue(childrenLiveTable.hasPageWithTitle(firstEntryName));
// Go back to the application home page.
getDriver().navigate().back();
// Click the edit button.
homePage.edit();
homeEditPage = new ApplicationHomeEditPage();
// Change the application description.
appDescription = "The best app!";
homeEditPage.setDescription(appDescription);
// Remove one of the live table columns.
homeEditPage.removeLiveTableColumn("Actions");
// Save
homePage = homeEditPage.clickSaveAndView();
// Assert that the application description has changed and that the column has been removed.
Assert.assertTrue(homePage.getContent().contains(appDescription));
entriesLiveTable = homePage.getEntriesLiveTable();
entriesLiveTable.waitUntilReady();
Assert.assertFalse(entriesLiveTable.hasColumn("Actions"));
// Click the link to edit the application.
classEditPage = homePage.clickEditApplication();
// Drag a Number field.
fieldEditPane = classEditPage.addField("Number");
// Set the field pretty name.
fieldEditPane.setPrettyName("Population Size");
// Fast forward.
homeEditPage = classEditPage.clickNextStep().clickNextStep();
// Just wait for the WYSIWYG editor (which is used for setting the application description) to load so that the
// page layout is stable before we click on the Finish button.
homeEditPage.setDescription(appDescription);
homePage = homeEditPage.clickFinish();
// Add a new entry.
String secondEntryName = "City 2 âé";
entryNamePane = homePage.clickAddNewEntry();
entryNamePane.setName(secondEntryName);
entryEditPage = entryNamePane.clickAdd();
// Assert the new field is displayed in the edit sheet (field name was auto-generated).
// Apparently WebElement#getText() takes into account the text-transform CSS property.
Assert.assertEquals("POPULATION SIZE", entryEditPage.getLabel("number1"));
// Save and go back to the application home page.
entryEditPage.clickSaveAndView().clickBreadcrumbLink(appName);
homePage = new ApplicationHomePage();
// Assert both entries are displayed in the live table.
entriesLiveTable = homePage.getEntriesLiveTable();
entriesLiveTable.waitUntilReady();
Assert.assertTrue(entriesLiveTable.hasRow("Page Title", firstEntryName));
Assert.assertTrue(entriesLiveTable.hasRow("Page Title", secondEntryName));
// Go to the App Within Minutes home page.
AppWithinMinutesHomePage appWithinMinutesHomePage = AppWithinMinutesHomePage.gotoPage();
// Assert that the created application is listed in the live table.
ApplicationsLiveTableElement appsLiveTable = appWithinMinutesHomePage.getAppsLiveTable();
appsLiveTable.waitUntilReady();
Assert.assertTrue(appsLiveTable.isApplicationListed(appPath));
// Delete the application entries.
homePage = appsLiveTable.viewApplication(appPath);
homePage.clickDeleteAllEntries().clickYes();
// Verify that the entries live table is empty.
entriesLiveTable = homePage.getEntriesLiveTable();
entriesLiveTable.waitUntilReady();
Assert.assertEquals(0, entriesLiveTable.getRowCount());
// Delete the application.
homePage.clickDeleteApplication().clickYes();
// Verify that the application is not listed anymore.
appsLiveTable = AppWithinMinutesHomePage.gotoPage().getAppsLiveTable();
appsLiveTable.waitUntilReady();
Assert.assertFalse(appsLiveTable.isApplicationListed(appPath));
}
Aggregations