Search in sources :

Example 1 with AddTagsPane

use of org.xwiki.tag.test.po.AddTagsPane 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);
}
Also used : ClassEditPage(org.xwiki.test.ui.po.editor.ClassEditPage) HashMap(java.util.HashMap) AttachmentsPane(org.xwiki.test.ui.po.AttachmentsPane) ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) CommentsTab(org.xwiki.test.ui.po.CommentsTab) TaggablePage(org.xwiki.tag.test.po.TaggablePage) AddTagsPane(org.xwiki.tag.test.po.AddTagsPane) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) FormElement(org.xwiki.test.ui.po.FormElement) Before(org.junit.Before)

Example 2 with AddTagsPane

use of org.xwiki.tag.test.po.AddTagsPane in project xwiki-platform by xwiki.

the class AddRemoveTagsTest method testStripLeadingAndTrailingSpacesFromTags.

/**
 * @see <a href="https://jira.xwiki.org/browse/XWIKI-3843">XWIKI-3843</a>: Strip leading and trailing white
 *      spaces to tags when white space is not the separator
 */
@Test
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177")
public void testStripLeadingAndTrailingSpacesFromTags() {
    String firstTag = RandomStringUtils.randomAlphanumeric(4);
    Assert.assertFalse(taggablePage.hasTag(firstTag));
    String secondTag = RandomStringUtils.randomAlphanumeric(4);
    Assert.assertFalse(taggablePage.hasTag(secondTag));
    AddTagsPane addTagsPane = taggablePage.addTags();
    addTagsPane.setTags("   " + firstTag + " ,  " + secondTag + "    ");
    Assert.assertTrue(addTagsPane.add());
    Assert.assertTrue(taggablePage.hasTag(firstTag));
    Assert.assertTrue(taggablePage.hasTag(secondTag));
}
Also used : AddTagsPane(org.xwiki.tag.test.po.AddTagsPane) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Example 3 with AddTagsPane

use of org.xwiki.tag.test.po.AddTagsPane in project xwiki-platform by xwiki.

the class AddRemoveTagsTest method testAddManyRemoveOneTag.

/**
 * Add many tags and remove one of them.
 */
@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 testAddManyRemoveOneTag() {
    String firstTag = RandomStringUtils.randomAlphanumeric(4);
    Assert.assertFalse(taggablePage.hasTag(firstTag));
    String secondTag = RandomStringUtils.randomAlphanumeric(4);
    Assert.assertFalse(taggablePage.hasTag(secondTag));
    AddTagsPane addTagsPane = taggablePage.addTags();
    addTagsPane.setTags(firstTag + "," + secondTag);
    Assert.assertTrue(addTagsPane.add());
    Assert.assertTrue(taggablePage.hasTag(firstTag));
    Assert.assertTrue(taggablePage.hasTag(secondTag));
    Assert.assertTrue(taggablePage.removeTag(firstTag));
    Assert.assertTrue(taggablePage.hasTag(secondTag));
}
Also used : AddTagsPane(org.xwiki.tag.test.po.AddTagsPane) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Example 4 with AddTagsPane

use of org.xwiki.tag.test.po.AddTagsPane in project xwiki-platform by xwiki.

the class AddRemoveTagsTest method testAddTagContainingPipe.

/**
 * Add a tag that contains the pipe character, which is used to separate stored tags.
 */
@Test
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177")
public void testAddTagContainingPipe() {
    String tag = RandomStringUtils.randomAlphanumeric(3) + "|" + RandomStringUtils.randomAlphanumeric(3);
    Assert.assertFalse(taggablePage.hasTag(tag));
    AddTagsPane addTagsPane = taggablePage.addTags();
    addTagsPane.setTags(tag);
    Assert.assertTrue(addTagsPane.add());
    Assert.assertTrue(taggablePage.hasTag(tag));
    // Reload the page and test again.
    getUtil().gotoPage(getTestClassName(), getTestMethodName());
    taggablePage = new TaggablePage();
    Assert.assertTrue(taggablePage.hasTag(tag));
}
Also used : TaggablePage(org.xwiki.tag.test.po.TaggablePage) AddTagsPane(org.xwiki.tag.test.po.AddTagsPane) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Example 5 with AddTagsPane

use of org.xwiki.tag.test.po.AddTagsPane in project xwiki-platform by xwiki.

the class AddRemoveTagsTest method testTagCaseIsIgnored.

/**
 * @see <a href="https://jira.xwiki.org/browse/XWIKI-6549">XWIKI-6549</a>: Prevent adding new tags that are
 *      equal ignoring case with existing tags
 */
@Test
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177")
public void testTagCaseIsIgnored() {
    String firstTag = "taG1";
    Assert.assertFalse(taggablePage.hasTag(firstTag));
    // Second tag is same as first tag but with different uppercase/lowercase chars.
    String secondTag = "Tag1";
    Assert.assertFalse(taggablePage.hasTag(secondTag));
    String thirdTag = "tag3";
    Assert.assertFalse(taggablePage.hasTag(thirdTag));
    AddTagsPane addTagsPane = taggablePage.addTags();
    addTagsPane.setTags(firstTag + "," + thirdTag + "," + secondTag);
    Assert.assertTrue(addTagsPane.add());
    Assert.assertTrue(taggablePage.hasTag(firstTag));
    Assert.assertFalse(taggablePage.hasTag(secondTag));
    Assert.assertTrue(taggablePage.hasTag(thirdTag));
}
Also used : AddTagsPane(org.xwiki.tag.test.po.AddTagsPane) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Aggregations

AddTagsPane (org.xwiki.tag.test.po.AddTagsPane)10 Test (org.junit.Test)9 AbstractTest (org.xwiki.test.ui.AbstractTest)9 IgnoreBrowser (org.xwiki.test.ui.browser.IgnoreBrowser)5 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)4 TaggablePage (org.xwiki.tag.test.po.TaggablePage)2 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 AttachmentsPane (org.xwiki.test.ui.po.AttachmentsPane)1 CommentsTab (org.xwiki.test.ui.po.CommentsTab)1 FormElement (org.xwiki.test.ui.po.FormElement)1 ClassEditPage (org.xwiki.test.ui.po.editor.ClassEditPage)1 ObjectEditPage (org.xwiki.test.ui.po.editor.ObjectEditPage)1 WikiEditPage (org.xwiki.test.ui.po.editor.WikiEditPage)1