use of org.xwiki.test.ui.po.editor.WikiEditPage in project xwiki-platform by xwiki.
the class NotificationsIT method testNotificationDisplayerClass.
@Test
public void testNotificationDisplayerClass() throws Exception {
// Create the pages and a custom displayer for "update" events
getUtil().login(SUPERADMIN_USER_NAME, SUPERADMIN_PASSWORD);
getUtil().gotoPage(getTestClassName(), "WebHome");
getUtil().createPage(getTestClassName(), "ARandomPageThatShouldBeModified", "Page used for the tests of the NotificationDisplayerClass XObject.", "Test page");
getUtil().createPage(getTestClassName(), "NotificationDisplayerClassTest", "Page used for the tests of the NotificationDisplayerClass XObject.", "Test page 2");
Map<String, String> notificationDisplayerParameters = new HashMap<String, String>() {
{
put("XWiki.Notifications.Code.NotificationDisplayerClass_0_eventType", "update");
put("XWiki.Notifications.Code.NotificationDisplayerClass_0_notificationTemplate", "This is a test template");
}
};
ObjectEditPage editObjects = getUtil().editObjects(getTestClassName(), "NotificationDisplayerClassTest");
editObjects.addObject("XWiki.Notifications.Code.NotificationDisplayerClass");
editObjects.getObjectsOfClass("XWiki.Notifications.Code.NotificationDisplayerClass").get(0).fillFieldsByName(notificationDisplayerParameters);
editObjects.clickSaveAndContinue(true);
// Login as first user, and enable notifications on document updates
getUtil().login(FIRST_USER_NAME, FIRST_USER_PASSWORD);
NotificationsUserProfilePage p = NotificationsUserProfilePage.gotoPage(FIRST_USER_NAME);
p.getApplication(SYSTEM).setCollapsed(false);
p.setEventTypeState(SYSTEM, UPDATE, ALERT_FORMAT, BootstrapSwitch.State.ON);
// Login as second user and modify ARandomPageThatShouldBeModified
getUtil().login(SECOND_USER_NAME, SECOND_USER_PASSWORD);
ViewPage viewPage = getUtil().gotoPage(getTestClassName(), "ARandomPageThatShouldBeModified");
viewPage.edit();
WikiEditPage editPage = new WikiEditPage();
editPage.setContent("Something");
editPage.clickSaveAndView(true);
// Login as the first user, ensure that the notification is displayed with a custom template
getUtil().login(FIRST_USER_NAME, FIRST_USER_PASSWORD);
getUtil().gotoPage(getTestClassName(), "WebHome");
NotificationsTrayPage tray = new NotificationsTrayPage();
assertEquals("This is a test template", tray.getNotificationRawContent(0));
}
use of org.xwiki.test.ui.po.editor.WikiEditPage in project xwiki-platform by xwiki.
the class WikiTemplateTest method createTemplateWiki.
private void createTemplateWiki() throws Exception {
// Go to the wiki creation wizard
WikiIndexPage wikiIndexPage = WikiIndexPage.gotoPage();
CreateWikiPage createWikiPage = wikiIndexPage.createWiki();
// Full the first step
createWikiPage.setPrettyName("My new template");
String wikiName = createWikiPage.getComputedName();
assertEquals(TEMPLATE_WIKI_ID, wikiName);
createWikiPage.setDescription("This is the template I do for the tests");
createWikiPage.setIsTemplate(true);
assertTrue(createWikiPage.isNextStepEnabled());
// Second step
CreateWikiPageStepUser createWikiPageStepUser = createWikiPage.goUserStep();
// Creation step
WikiCreationPage wikiCreationPage = createWikiPageStepUser.create();
assertEquals("Wiki creation", wikiCreationPage.getStepTitle());
// Ensure there is no error in the log
assertFalse(wikiCreationPage.hasLogError());
// Finalization
WikiHomePage wikiHomePage = wikiCreationPage.finalizeCreation();
// Go to the created subwiki, and modify the home page content
wikiHomePage.edit();
WikiEditPage wikiEditPage = new WikiEditPage();
wikiEditPage.setContent(TEMPLATE_CONTENT);
wikiEditPage.clickSaveAndView();
wikiEditPage.waitUntilPageIsLoaded();
// Go back to the wiki creation wizard, and verify the template is in the list of templates in the wizard
createWikiPage = wikiHomePage.createWiki();
assertTrue(createWikiPage.getTemplateList().contains("mynewtemplate"));
// Verify the wiki is in the wiki index page.
wikiIndexPage = WikiIndexPage.gotoPage().waitUntilPageIsLoaded();
WikiLink wikiLink = wikiIndexPage.getWikiLink("My new template");
if (wikiLink == null) {
throw new Exception("The wiki [My new template] is not in the wiki index.");
}
assertTrue(wikiLink.getURL().endsWith("/xwiki/wiki/mynewtemplate/view/Main/"));
}
use of org.xwiki.test.ui.po.editor.WikiEditPage in project xwiki-platform by xwiki.
the class CompareVersionsTest method setUp.
@Before
public void setUp() throws Exception {
String pageName = "PageWithManyVersions";
// Check if the test page exists.
testPage = getUtil().gotoPage(getTestClassName(), pageName);
if (testPage.exists()) {
// TODO: Remove when XWIKI-6688 (Possible race condition when clicking on a tab at the bottom of a page in
// view mode) is fixed.
testPage.waitForDocExtraPaneActive("comments");
// versions of the test page.
return;
}
// Since this test also verifies diffs when the parent/child relationship is modified, use this mode (which
// isn't the default) for testing purpose. Also note that in the "reference" mode there's no diff to display
// when the document is moved to a different parent since it means changing the identity of the document for
// now and thus changing it means getting a new document.
getUtil().setHierarchyMode("parentchild");
getDriver().navigate().refresh();
// Create the test page.
testPage = getUtil().createPage(getTestClassName(), pageName, "one\ntwo\nthree", "Test");
// Change the content and the meta data.
WikiEditPage wikiEditPage = testPage.editWiki();
wikiEditPage.setContent("one\n**two**\nfour");
wikiEditPage.setTitle("Compare verSions test");
wikiEditPage.setParent("Sandbox.WebHome");
wikiEditPage.setEditComment("Changed content and meta data.");
wikiEditPage.clickSaveAndContinue();
wikiEditPage.setTitle("Compare versions test");
wikiEditPage.setMinorEdit(true);
wikiEditPage.setEditComment("Fix typo in title.");
wikiEditPage.clickSaveAndContinue();
// Add objects.
ObjectEditPage objectEditPage = wikiEditPage.editObjects();
FormElement form = objectEditPage.addObject("XWiki.JavaScriptExtension");
Map<String, String> assignment = new HashMap<String, String>();
assignment.put("XWiki.JavaScriptExtension_0_name", "JavaScript code");
assignment.put("XWiki.JavaScriptExtension_0_code", "var tmp = alice;\nalice = bob;\nbob = tmp;");
assignment.put("XWiki.JavaScriptExtension_0_use", "onDemand");
form.fillFieldsByName(assignment);
objectEditPage.clickSaveAndContinue();
assignment.put("XWiki.JavaScriptExtension_0_name", "Code snippet");
assignment.put("XWiki.JavaScriptExtension_0_code", "var tmp = alice;\nalice = 2 * bob;\nbob = tmp;");
form.fillFieldsByName(assignment);
objectEditPage.clickSaveAndContinue();
// Create class.
ClassEditPage classEditPage = objectEditPage.editClass();
classEditPage.addProperty("age", "Number");
classEditPage.addProperty("color", "String");
classEditPage.getNumberClassEditElement("age").setNumberType("integer");
classEditPage.clickSaveAndContinue();
classEditPage.deleteProperty("color");
testPage = classEditPage.clickSaveAndView();
// Add tags.
TaggablePage taggablePage = new TaggablePage();
AddTagsPane addTagsPane = taggablePage.addTags();
addTagsPane.setTags("foo,bar");
addTagsPane.add();
taggablePage.removeTag("foo");
// Attach files.
AttachmentsPane attachmentsPane = testPage.openAttachmentsDocExtraPane();
// TODO: Update this code when we (re)add support for uploading multiple files at once.
for (String fileName : new String[] { "SmallAttachment.txt", "SmallAttachment2.txt", "SmallAttachment.txt" }) {
attachmentsPane.setFileToUpload(this.getClass().getResource('/' + fileName).getPath());
attachmentsPane.waitForUploadToFinish(fileName);
attachmentsPane.clickHideProgress();
}
attachmentsPane.deleteAttachmentByFileByName("SmallAttachment2.txt");
// Add comments.
getUtil().createUserAndLogin("Alice", "ecila");
testPage = getUtil().gotoPage(getTestClassName(), pageName);
CommentsTab commentsTab = testPage.openCommentsDocExtraPane();
commentsTab.postComment("first line\nsecond line", true);
commentsTab.editCommentByID(0, "first line\nline in between\nsecond line");
commentsTab.replyToCommentByID(0, "this is a reply");
commentsTab.deleteCommentByID(1);
}
use of org.xwiki.test.ui.po.editor.WikiEditPage in project xwiki-platform by xwiki.
the class DataTypesPage method createClass.
/**
* Starts the process of creating a new XClass.
*
* @param spaceName the name of the space where to create the class
* @param className the class name
* @return the wiki edit mode for the specified class
*/
public ClassSheetPage createClass(String spaceName, String className) {
this.documentPicker.setParent(spaceName);
this.documentPicker.setName(className);
this.createClassButton.click();
new WikiEditPage().clickSaveAndView();
return new ClassSheetPage();
}
use of org.xwiki.test.ui.po.editor.WikiEditPage in project xwiki-platform by xwiki.
the class CreatePageIT method createPagesFromTemplate.
/**
* Tests if a new page can be created from a template.
*/
@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 createPagesFromTemplate() throws Exception {
// Step 0: Setup the correct environment for the test
// All these pages are created during this test
getUtil().deleteSpace(getTestClassName());
getUtil().rest().deletePage(getTestClassName(), getTestMethodName());
EntityReference templateInstanceReference = getUtil().resolveDocumentReference(getTestClassName() + "." + TEMPLATE_NAME + "Instance" + ".WebHome");
getUtil().rest().delete(templateInstanceReference);
getUtil().rest().deletePage(getTestClassName(), "NewPage");
getUtil().rest().deletePage(getTestClassName(), TEMPLATE_NAME + "UnexistingInstance");
getUtil().rest().deletePage(getTestClassName(), "EmptyPage");
String templateContent = "Test Template Content";
String templateTitle = "Test Template Title";
String templateProviderName = TEMPLATE_NAME + "Provider";
String templateProviderFullName = getTestClassName() + "." + templateProviderName;
// Step 1: Create a Template and a Template Provider and try to create a new page by using the Add Menu and
// using the created Template
ViewPage templateProviderView = createTemplateAndTemplateProvider(templateProviderName, templateContent, templateTitle, false);
// Create the new document from template
CreatePagePage createPagePage = templateProviderView.createPage();
// Save the number of available templates so that we can make some checks later on.
int availableTemplateSize = createPagePage.getAvailableTemplateSize();
String templateInstanceName = TEMPLATE_NAME + "Instance";
createPagePage.getDocumentPicker().toggleLocationAdvancedEdit();
EditPage templateInstanceEditWysiwyg = createPagePage.createPageFromTemplate(templateInstanceName, getTestClassName(), null, templateProviderFullName);
WikiEditPage templateInstanceEdit = templateInstanceEditWysiwyg.clickSaveAndView().editWiki();
// Verify template instance location and content
assertEquals(templateInstanceName, templateInstanceEdit.getTitle());
assertEquals(getTestClassName() + "." + templateInstanceName, templateInstanceEdit.getMetaDataValue("space"));
assertEquals("WebHome", templateInstanceEdit.getMetaDataValue("page"));
assertEquals(templateContent, templateInstanceEdit.getContent());
// check the parent of the template instance
assertEquals(templateProviderFullName, templateInstanceEdit.getParent());
// Step 2: Create a wanted link and verify that clicking it displays the Template and that we can use it.
// Put a wanted link in the template instance
templateInstanceEdit.setContent("[[doc:NewPage]]");
ViewPage vp = templateInstanceEdit.clickSaveAndView();
// Verify that clicking on the wanted link pops up a box to choose the template.
EntityReference wantedLinkReference = getUtil().resolveDocumentReference(getTestClassName() + "." + TEMPLATE_NAME + "Instance" + ".NewPage");
vp.clickWantedLink(wantedLinkReference, true);
// TODO: a page object should be better here
List<WebElement> templates = getDriver().findElements(By.xpath("//input[@name='type' and @data-type='template']"));
// Note: We need to remove 1 to exclude the "Empty Page" template entry
assertEquals(availableTemplateSize, templates.size());
assertTrue(createPagePage.getAvailableTemplates().contains(templateProviderFullName));
// Step 3: Create a new page when located on a non-existing page
getUtil().gotoPage(getTestClassName(), TEMPLATE_NAME + "UnexistingInstance", "view", "spaceRedirect=false");
vp = new ViewPage();
assertFalse(vp.exists());
DocumentDoesNotExistPage unexistingPage = new DocumentDoesNotExistPage();
unexistingPage.clickEditThisPageToCreate();
CreatePagePage createUnexistingPage = new CreatePagePage();
// Make sure we're in create mode.
assertTrue(getUtil().isInCreateMode());
// count the available templates, make sure they're as many as before and that our template is among them
assertEquals(availableTemplateSize, createUnexistingPage.getAvailableTemplateSize());
assertTrue(createUnexistingPage.getAvailableTemplates().contains(templateProviderFullName));
// select it
createUnexistingPage.setTemplate(templateProviderFullName);
createUnexistingPage.setTerminalPage(true);
// and create
createUnexistingPage.clickCreate();
EditPage ep = new EditPage();
WikiEditPage unexistingPageEdit = ep.clickSaveAndView().editWiki();
// Verify template instance location and content
assertEquals(getTestClassName(), templateInstanceEdit.getMetaDataValue("space"));
assertEquals(TEMPLATE_NAME + "UnexistingInstance", templateInstanceEdit.getMetaDataValue("page"));
assertEquals(TEMPLATE_NAME + "UnexistingInstance", unexistingPageEdit.getTitle());
assertEquals(templateContent, unexistingPageEdit.getContent());
// test that this page has no parent
assertEquals("Main.WebHome", unexistingPageEdit.getParent());
// Step 4: Create an empty new page when there are Templates available
// Make sure we are on a page that exists so that Add > Page will show the space and page fields
CreatePagePage createEmptyPage = unexistingPageEdit.clickCancel().createPage();
assertTrue(createEmptyPage.getAvailableTemplateSize() > 0);
createEmptyPage.getDocumentPicker().toggleLocationAdvancedEdit();
EditPage editEmptyPage = createEmptyPage.createPage(getTestClassName(), "EmptyPage");
ViewPage emptyPage = editEmptyPage.clickSaveAndView();
// make sure it's empty
assertEquals("", emptyPage.getContent());
// make sure parent is the right one
assertEquals("/" + getTestClassName() + "/EmptyPage", emptyPage.getBreadcrumbContent());
// mare sure title is the right one
assertEquals("EmptyPage", emptyPage.getDocumentTitle());
// Step 5: Verify that restricting a Template to a space works
// Restrict the template to its own space
templateProviderView = getUtil().gotoPage(getTestClassName(), TEMPLATE_NAME + "Provider");
templateProviderView.editInline();
TemplateProviderInlinePage templateProviderInline = new TemplateProviderInlinePage();
List<String> allowedSpaces = new ArrayList<String>();
allowedSpaces.add(getTestClassName());
templateProviderInline.setVisibilityRestrictions(allowedSpaces);
templateProviderInline.setCreationRestrictions(allowedSpaces);
templateProviderView = templateProviderInline.clickSaveAndView();
// Verify we can still create a page from template in the test space
createPagePage = templateProviderView.createPage();
// Make sure we get in create mode.
assertTrue(getUtil().isInCreateMode());
assertEquals(availableTemplateSize, createPagePage.getAvailableTemplateSize());
assertTrue(createPagePage.getAvailableTemplates().contains(templateProviderFullName));
// Modify the target space and verify the form can't be submitted
createPagePage.setTemplate(templateProviderFullName);
createPagePage.getDocumentPicker().toggleLocationAdvancedEdit();
createPagePage.getDocumentPicker().setParent("Foo");
createPagePage.getDocumentPicker().setName("Bar");
String currentURL = getDriver().getCurrentUrl();
createPagePage.clickCreate();
assertEquals(currentURL, getDriver().getCurrentUrl());
// and check that an error is displayed to the user
createPagePage.waitForFieldErrorMessage();
// Verify the template we have removed is no longer available.
CreatePagePage.gotoPage();
// make sure that the template provider is not in the list of templates
assertFalse(createPagePage.getAvailableTemplates().contains(templateProviderFullName));
}
Aggregations