From d7ce05d83a04de225c0dd3f4161a440ac7aec736 Mon Sep 17 00:00:00 2001 From: Manuel Leduc Date: Fri, 5 Jan 2024 17:23:37 +0100 Subject: [PATCH] XWIKI-19041: Replace the Livetable from DocumentsMacro with a Live Data macro Docker tests. --- .../xwiki/index/test/ui/docker/AllDocsIT.java | 136 ++++++++++-------- .../org/xwiki/index/test/ui/docker/AllIT.java | 12 ++ .../xwiki/index/test/po/AllDocsLivetable.java | 52 ------- .../org/xwiki/index/test/po/AllDocsPage.java | 12 +- .../index/test/po/DocumentsMacroPage.java | 8 +- .../xwiki/index/test/po/SpaceIndexPage.java | 8 +- .../xwiki/index/test/ui/DocumentsMacroIT.java | 61 -------- .../it/org/xwiki/index/test/ui/SpacesIT.java | 90 ------------ .../main/resources/XWiki/DocumentsMacro.xml | 4 +- .../livedata/test/po/TableLayoutElement.java | 22 ++- .../it/org/xwiki/mail/test/ui/MailIT.java | 4 +- .../MailStatusAdministrationSectionPage.java | 14 +- 12 files changed, 141 insertions(+), 282 deletions(-) delete mode 100644 xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-pageobjects/src/main/java/org/xwiki/index/test/po/AllDocsLivetable.java delete mode 100644 xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-tests/src/test/it/org/xwiki/index/test/ui/DocumentsMacroIT.java delete mode 100644 xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-tests/src/test/it/org/xwiki/index/test/ui/SpacesIT.java diff --git a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-docker/src/test/it/org/xwiki/index/test/ui/docker/AllDocsIT.java b/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-docker/src/test/it/org/xwiki/index/test/ui/docker/AllDocsIT.java index 28ffc4f5a38d..e4b9c524492a 100644 --- a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-docker/src/test/it/org/xwiki/index/test/ui/docker/AllDocsIT.java +++ b/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-docker/src/test/it/org/xwiki/index/test/ui/docker/AllDocsIT.java @@ -22,9 +22,10 @@ import java.io.ByteArrayInputStream; import java.util.Arrays; +import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; -import org.xwiki.index.test.po.AllDocsLivetable; +import org.xwiki.index.test.po.AllDocsLiveData; import org.xwiki.index.test.po.AllDocsPage; import org.xwiki.livedata.test.po.TableLayoutElement; import org.xwiki.model.reference.DocumentReference; @@ -52,7 +53,20 @@ @UITest class AllDocsIT { + private static final String LOCATION_COLUMN_LABEL = "Location"; + + private static final String TYPE_COLUMN_LABEL = "Type"; + + private static final String NAME_COLUMN_LABEL = "Name"; + + private static final String SIZE_COLUMN_LABEL = "Size"; + + private static final String DATE_COLUMN_LABEL = "Date"; + + private static final String AUTHOR_COLUMN_LABEL = "Author"; + @Test + @Order(1) void verifyAllDocs(TestUtils setup, TestInfo testInfo, TestReference testReference) { // Fixture @@ -62,7 +76,7 @@ void verifyAllDocs(TestUtils setup, TestInfo testInfo, TestReference testReferen // tests validateActionsAndGuest(setup); - validateFilterDoc(setup, testReference); + validateFilterDoc(testReference); validateCopyLink(setup, testInfo, testReference); validateRenameLink(setup, testInfo, testReference); validateDeleteLink(setup, testReference); @@ -75,6 +89,7 @@ void verifyAllDocs(TestUtils setup, TestInfo testInfo, TestReference testReferen * This test is against XWiki Enterprise XE-701 https://jira.xwiki.org/browse/XE-701 (fixed in 2.5M1). */ @Test + @Order(2) void attachmentsTabFilteringAndSorting(TestUtils setup, TestReference testReference) throws Exception { // Create 2 pages with attachments so that this test filter returns only one. @@ -89,48 +104,48 @@ void attachmentsTabFilteringAndSorting(TestUtils setup, TestReference testRefere TableLayoutElement liveData = docsPage.clickAttachmentsTab().getTableLayout(); // Here we test if all the Columns are displayed. - assertTrue(liveData.hasColumn("Type"), "No Type column found"); - assertTrue(liveData.hasColumn("Name"), "No Name column found"); - assertTrue(liveData.hasColumn("Location"), "No Location column found"); - assertTrue(liveData.hasColumn("Size"), "No Size column found"); - assertTrue(liveData.hasColumn("Date"), "No Date column found"); - assertTrue(liveData.hasColumn("Author"), "No Author column found"); + assertTrue(liveData.hasColumn(TYPE_COLUMN_LABEL), "No Type column found"); + assertTrue(liveData.hasColumn(NAME_COLUMN_LABEL), "No Name column found"); + assertTrue(liveData.hasColumn(LOCATION_COLUMN_LABEL), "No Location column found"); + assertTrue(liveData.hasColumn(SIZE_COLUMN_LABEL), "No Size column found"); + assertTrue(liveData.hasColumn(DATE_COLUMN_LABEL), "No Date column found"); + assertTrue(liveData.hasColumn(AUTHOR_COLUMN_LABEL), "No Author column found"); String defaultLocationFilter = className + "."; - liveData.filterColumn("Location", defaultLocationFilter); + liveData.filterColumn(LOCATION_COLUMN_LABEL, defaultLocationFilter); assertEquals(2, liveData.countRows()); // Filter by attachment file name. - liveData.filterColumn("Name", "t1"); + liveData.filterColumn(NAME_COLUMN_LABEL, "t1"); assertEquals(1, liveData.countRows()); - assertEquals("attachment1.txt", liveData.getCell("Name", 1).getText()); + assertEquals("attachment1.txt", liveData.getCell(NAME_COLUMN_LABEL, 1).getText()); // Clear the filter. - liveData.filterColumn("Name", ""); + liveData.filterColumn(NAME_COLUMN_LABEL, ""); // Filter by attachment location. - liveData.filterColumn("Location", defaultLocationFilter + "Oth"); + liveData.filterColumn(LOCATION_COLUMN_LABEL, defaultLocationFilter + "Oth"); assertEquals(1, liveData.countRows()); - assertEquals(className + "OtherPage", liveData.getCell("Location", 1).getText()); + assertEquals(className + "OtherPage", liveData.getCell(LOCATION_COLUMN_LABEL, 1).getText()); // Reset the filter. - liveData.filterColumn("Location", defaultLocationFilter); + liveData.filterColumn(LOCATION_COLUMN_LABEL, defaultLocationFilter); // Sort by attachment file name. The live table should be already sorted by file name ascending. This will // reverse the order. - assertEquals("attachment2.txt", liveData.getCell("Name", 2).getText()); - liveData.sortBy("Name"); + assertEquals("attachment2.txt", liveData.getCell(NAME_COLUMN_LABEL, 2).getText()); + liveData.sortBy(NAME_COLUMN_LABEL); assertEquals(2, liveData.countRows()); - assertEquals("attachment2.txt", liveData.getCell("Name", 1).getText()); + assertEquals("attachment2.txt", liveData.getCell(NAME_COLUMN_LABEL, 1).getText()); // Sort by attachment location. - liveData.sortBy("Location"); - assertEquals(className + "Page", liveData.getCell("Location", 2).getText()); - liveData.sortBy("Location"); + liveData.sortBy(LOCATION_COLUMN_LABEL); + assertEquals(className + "Page", liveData.getCell(LOCATION_COLUMN_LABEL, 2).getText()); + liveData.sortBy(LOCATION_COLUMN_LABEL); assertEquals(2, liveData.countRows()); - assertEquals(className + "Page", liveData.getCell("Location", 1).getText()); + assertEquals(className + "Page", liveData.getCell(LOCATION_COLUMN_LABEL, 1).getText()); } /** @@ -141,15 +156,15 @@ private void validateActionsAndGuest(TestUtils setup) // Create a test user setup.createUserAndLogin("Foobar", "password"); AllDocsPage page = AllDocsPage.gotoPage(); - AllDocsLivetable livetable = page.clickIndexTab(); - assertTrue(livetable.hasColumn("Actions"), "No Actions column found"); + AllDocsLiveData livetable = page.clickIndexTab(); + assertTrue(livetable.getTableLayout().hasColumn("Actions"), "No Actions column found"); // Logs out to be guest to verify that the Action columns is no longer displayed setup.forceGuestUser(); page = AllDocsPage.gotoPage(); livetable = page.clickIndexTab(); - assertFalse(livetable.hasColumn("Actions"), "Actions column shouldn't be visible for guests"); + assertFalse(livetable.getTableLayout().hasColumn("Actions"), "Actions column shouldn't be visible for guests"); setup.loginAsSuperAdmin(); } @@ -157,19 +172,20 @@ private void validateActionsAndGuest(TestUtils setup) /** * Verify filtering works by filtering on the document name */ - private void validateFilterDoc(TestUtils setup, TestReference testReference) + private void validateFilterDoc(TestReference testReference) { String testName = testReference.getLastSpaceReference().getName(); AllDocsPage page = AllDocsPage.gotoPage(); - AllDocsLivetable livetable = page.clickIndexTab(); - livetable.filterColumn(2, testName); + AllDocsLiveData livetable = page.clickIndexTab(); + livetable.filterColumn(LOCATION_COLUMN_LABEL, testName); // We get one result for the page we've created - assertEquals(1, livetable.getRowCount()); - assertTrue(livetable.hasRow("Title", testName)); + TableLayoutElement tableLayout = livetable.getTableLayout(); + assertEquals(1, tableLayout.countRows()); + tableLayout.assertRow("Title", testName); // We get no result for a page created by user barbaz - livetable.filterColumn(4, "barbaz"); - assertEquals(0, livetable.getRowCount()); + livetable.filterColumn("Last Author", "barbaz"); + assertEquals(0, tableLayout.countRows()); } /** @@ -185,11 +201,12 @@ private void validateCopyLink(TestUtils setup, TestInfo testInfo, TestReference setup.deletePage(copyPageReference); AllDocsPage page = AllDocsPage.gotoPage(); - AllDocsLivetable livetable = page.clickIndexTab(); - livetable.filterColumn(2, testName); + AllDocsLiveData livetable = page.clickIndexTab(); + livetable.filterColumn(LOCATION_COLUMN_LABEL, testName); // We get one result for the page we've created - assertEquals(1, livetable.getRowCount()); - assertTrue(livetable.hasRow("Title", testName)); + TableLayoutElement tableLayout = livetable.getTableLayout(); + assertEquals(1, tableLayout.countRows()); + tableLayout.assertRow("Title", testName); // click on the copy action link. livetable.clickAction(1, "copy"); @@ -202,10 +219,11 @@ private void validateCopyLink(TestUtils setup, TestInfo testInfo, TestReference page = AllDocsPage.gotoPage(); livetable = page.clickIndexTab(); - livetable.filterColumn(2, testName); - assertEquals(2, livetable.getRowCount()); - livetable.filterColumn(2, copyPageName); - assertEquals(1, livetable.getRowCount()); + livetable.filterColumn(LOCATION_COLUMN_LABEL, testName); + tableLayout = livetable.getTableLayout(); + assertEquals(2, tableLayout.countRows()); + livetable.filterColumn(LOCATION_COLUMN_LABEL, copyPageName); + assertEquals(1, tableLayout.countRows()); setup.deletePage(copyPageReference); } @@ -219,11 +237,12 @@ private void validateRenameLink(TestUtils setup, TestInfo testInfo, TestReferenc Arrays.asList(testSpace, renamedPageName), "WebHome"); AllDocsPage page = AllDocsPage.gotoPage(); - AllDocsLivetable livetable = page.clickIndexTab(); - livetable.filterColumn(2, testName); + AllDocsLiveData livetable = page.clickIndexTab(); + livetable.filterColumn(LOCATION_COLUMN_LABEL, testName); // We get one result for the page we've created - assertEquals(1, livetable.getRowCount()); - assertTrue(livetable.hasRow("Title", testName)); + TableLayoutElement tableLayout = livetable.getTableLayout(); + assertEquals(1, tableLayout.countRows()); + tableLayout.assertRow("Title", testName); // click on the copy action link. livetable.clickAction(1, "rename"); @@ -236,9 +255,10 @@ private void validateRenameLink(TestUtils setup, TestInfo testInfo, TestReferenc page = AllDocsPage.gotoPage(); livetable = page.clickIndexTab(); - livetable.filterColumn(2, testName); - assertEquals(1, livetable.getRowCount()); - assertEquals(testSpace + renamedPageName, livetable.getCell(1, 2).getText()); + livetable.filterColumn(LOCATION_COLUMN_LABEL, testName); + tableLayout = livetable.getTableLayout(); + assertEquals(1, tableLayout.countRows()); + assertEquals(testSpace + renamedPageName, tableLayout.getCell(LOCATION_COLUMN_LABEL, 1).getText()); setup.deletePage(renamedPageReference); setup.createPage(testReference, "", testReference.getLastSpaceReference().getName()); @@ -249,11 +269,12 @@ private void validateDeleteLink(TestUtils setup, TestReference testReference) String testName = testReference.getLastSpaceReference().getName(); AllDocsPage page = AllDocsPage.gotoPage(); - AllDocsLivetable livetable = page.clickIndexTab(); - livetable.filterColumn(2, testName); + AllDocsLiveData livetable = page.clickIndexTab(); + livetable.filterColumn(LOCATION_COLUMN_LABEL, testName); // We get one result for the page we've created - assertEquals(1, livetable.getRowCount()); - assertTrue(livetable.hasRow("Title", testName)); + TableLayoutElement tableLayout = livetable.getTableLayout(); + assertEquals(1, tableLayout.countRows()); + tableLayout.assertRow("Title", testName); // click on the copy action link. livetable.clickAction(1, "delete"); @@ -262,8 +283,8 @@ private void validateDeleteLink(TestUtils setup, TestReference testReference) deletingPage.waitUntilFinished(); page = AllDocsPage.gotoPage(); livetable = page.clickIndexTab(); - livetable.filterColumn(2, testName); - assertEquals(0, livetable.getRowCount()); + livetable.filterColumn(LOCATION_COLUMN_LABEL, testName); + assertEquals(0, livetable.getTableLayout().countRows()); setup.createPage(testReference, "", testReference.getLastSpaceReference().getName()); } @@ -272,11 +293,12 @@ private void validateRightLink(TestUtils setup, TestReference testReference) String testName = testReference.getLastSpaceReference().getName(); AllDocsPage page = AllDocsPage.gotoPage(); - AllDocsLivetable livetable = page.clickIndexTab(); - livetable.filterColumn(2, testName); + AllDocsLiveData livetable = page.clickIndexTab(); + livetable.filterColumn(LOCATION_COLUMN_LABEL, testName); // We get one result for the page we've created - assertEquals(1, livetable.getRowCount()); - assertTrue(livetable.hasRow("Title", testName)); + TableLayoutElement tableLayout = livetable.getTableLayout(); + assertEquals(1, tableLayout.countRows()); + tableLayout.assertRow("Title", testName); // click on the copy action link. livetable.clickAction(1, "rights"); diff --git a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-docker/src/test/it/org/xwiki/index/test/ui/docker/AllIT.java b/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-docker/src/test/it/org/xwiki/index/test/ui/docker/AllIT.java index 16242b269c0c..202cde366e9c 100644 --- a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-docker/src/test/it/org/xwiki/index/test/ui/docker/AllIT.java +++ b/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-docker/src/test/it/org/xwiki/index/test/ui/docker/AllIT.java @@ -49,4 +49,16 @@ class NestedDeletedAttachmentsIT extends DeletedAttachmentsIT class NestedOrphanedPagesIT extends OrphanedPagesIT { } + + @Nested + @DisplayName("Documents Macro UI") + class NestedDocumentsMacroIT extends DocumentsMacroIT + { + } + + @Nested + @DisplayName("Spaces UI") + class NestedSpacesIT extends SpacesIT + { + } } diff --git a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-pageobjects/src/main/java/org/xwiki/index/test/po/AllDocsLivetable.java b/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-pageobjects/src/main/java/org/xwiki/index/test/po/AllDocsLivetable.java deleted file mode 100644 index 96bcde884696..000000000000 --- a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-pageobjects/src/main/java/org/xwiki/index/test/po/AllDocsLivetable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.xwiki.index.test.po; - -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; -import org.xwiki.test.ui.po.LiveTableElement; - -/** - * Represents the livetable for index all docs. - * - * @since 11.6RC1 - * @since 11.5 - * @version $Id$ - */ -public class AllDocsLivetable extends LiveTableElement -{ - public AllDocsLivetable() - { - super("alldocs"); - } - - public void filterColumn(int columnNumber, String filterValue) - { - String columnId = String.format("xwiki-livetable-alldocs-filter-%s", columnNumber); - this.filterColumn(columnId, filterValue); - } - - public void clickAction(int rowNumber, String actionName) - { - WebElement pageRow = this.getRow(rowNumber); - String xPathLocator = String.format("//a[contains(@class, 'action%s')]", actionName); - pageRow.findElement(By.xpath(xPathLocator)).click(); - } -} diff --git a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-pageobjects/src/main/java/org/xwiki/index/test/po/AllDocsPage.java b/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-pageobjects/src/main/java/org/xwiki/index/test/po/AllDocsPage.java index 4b97aec25c22..d8b3559fbb21 100644 --- a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-pageobjects/src/main/java/org/xwiki/index/test/po/AllDocsPage.java +++ b/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-pageobjects/src/main/java/org/xwiki/index/test/po/AllDocsPage.java @@ -64,14 +64,16 @@ public static String getURL() return getUtil().getURL("Main", "AllDocs"); } - public AllDocsLivetable clickIndexTab() + /** + * Click on the index tab. + * + * @return the Live Data listing all the documents + */ + public AllDocsLiveData clickIndexTab() { this.indexTab.click(); - AllDocsLivetable lt = new AllDocsLivetable(); - lt.waitUntilReady(); - - return lt; + return new AllDocsLiveData(); } public DocumentTreeElement clickTreeTab() diff --git a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-pageobjects/src/main/java/org/xwiki/index/test/po/DocumentsMacroPage.java b/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-pageobjects/src/main/java/org/xwiki/index/test/po/DocumentsMacroPage.java index 5a6e9c6dc635..d884bb71c212 100644 --- a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-pageobjects/src/main/java/org/xwiki/index/test/po/DocumentsMacroPage.java +++ b/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-pageobjects/src/main/java/org/xwiki/index/test/po/DocumentsMacroPage.java @@ -19,7 +19,7 @@ */ package org.xwiki.index.test.po; -import org.xwiki.test.ui.po.LiveTableElement; +import org.xwiki.livedata.test.po.LiveDataElement; import org.xwiki.test.ui.po.ViewPage; /** @@ -36,10 +36,8 @@ public static DocumentsMacroPage gotoPage() return new DocumentsMacroPage(); } - public LiveTableElement getDocumentsExampleLiveTable() + public LiveDataElement getDocumentsExampleLiveTable() { - LiveTableElement lt = new LiveTableElement("example"); - lt.waitUntilReady(); - return lt; + return new LiveDataElement("example"); } } diff --git a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-pageobjects/src/main/java/org/xwiki/index/test/po/SpaceIndexPage.java b/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-pageobjects/src/main/java/org/xwiki/index/test/po/SpaceIndexPage.java index db3627fd0a3c..006e8706a9da 100644 --- a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-pageobjects/src/main/java/org/xwiki/index/test/po/SpaceIndexPage.java +++ b/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-pageobjects/src/main/java/org/xwiki/index/test/po/SpaceIndexPage.java @@ -21,7 +21,7 @@ import java.util.Collections; -import org.xwiki.test.ui.po.LiveTableElement; +import org.xwiki.livedata.test.po.LiveDataElement; import org.xwiki.test.ui.po.ViewPage; /** @@ -35,7 +35,7 @@ public class SpaceIndexPage extends ViewPage /** * The live table that lists the documents from the space. */ - private LiveTableElement liveTable = new LiveTableElement("spaceindex"); + private final LiveDataElement liveDataElement = new LiveDataElement("spaceindex"); /** * Opens the document index for the specified page. @@ -52,8 +52,8 @@ public static SpaceIndexPage gotoPage(String spaceName) /** * @return the document index live table */ - public LiveTableElement getLiveTable() + public LiveDataElement getLiveData() { - return liveTable; + return this.liveDataElement; } } diff --git a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-tests/src/test/it/org/xwiki/index/test/ui/DocumentsMacroIT.java b/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-tests/src/test/it/org/xwiki/index/test/ui/DocumentsMacroIT.java deleted file mode 100644 index 72648faf1637..000000000000 --- a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-tests/src/test/it/org/xwiki/index/test/ui/DocumentsMacroIT.java +++ /dev/null @@ -1,61 +0,0 @@ - /* - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.xwiki.index.test.ui; - -import org.junit.Assert; -import org.junit.Test; -import org.xwiki.index.test.po.DocumentsMacroPage; -import org.xwiki.test.ui.AbstractGuestTest; -import org.xwiki.test.ui.po.LiveTableElement; - - /** - * Tests for the DocumentsMacro page. - * - * @version $Id$ - * @since 4.2M3 - */ - public class DocumentsMacroIT extends AbstractGuestTest - { - /** - * Verify that the {{documents}} macro works by going to the page defining this wiki macro since it contains - * an example usage and we can verify it displays the expected result. - */ - @Test - public void testDocumentsMacro() throws Exception - { - // Create a dummy page in the Main space and having Main.WebHome as its parent so that it appears in the - // Documents Macro livetable (since the example lists pages in the Main space having Main.WebHome as their - // parent). - getUtil().createPage("Main", getTestMethodName(), "", "Test Title", "xwiki/2.1", "Main.WebHome"); - - DocumentsMacroPage dmp = DocumentsMacroPage.gotoPage(); - LiveTableElement livetable = dmp.getDocumentsExampleLiveTable(); - - // Verify that we have a Page column - Assert.assertTrue("No Title column found", livetable.hasColumn("Title")); - - // Verify there are several rows displayed - Assert.assertTrue(livetable.getRowCount() > 0); - - // Verify that page titles are displayed by filtering on one page for which we know the title - livetable.filterColumn("xwiki-livetable-example-filter-2", getTestMethodName()); - Assert.assertTrue(livetable.hasRow("Title", "Test Title")); - } - } diff --git a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-tests/src/test/it/org/xwiki/index/test/ui/SpacesIT.java b/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-tests/src/test/it/org/xwiki/index/test/ui/SpacesIT.java deleted file mode 100644 index 2526dc46996b..000000000000 --- a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-test/xwiki-platform-index-test-tests/src/test/it/org/xwiki/index/test/ui/SpacesIT.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.xwiki.index.test.ui; - -import org.junit.Test; -import org.xwiki.index.test.po.SpaceIndexPage; -import org.xwiki.index.test.po.SpacesMacroPage; -import org.xwiki.test.ui.AbstractTest; -import org.xwiki.test.ui.browser.IgnoreBrowser; -import org.xwiki.test.ui.browser.IgnoreBrowsers; -import org.xwiki.test.ui.po.LiveTableElement; -import org.xwiki.test.ui.po.ViewPage; -import org.xwiki.test.ui.po.editor.WikiEditPage; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -/** - * Tests the Spaces Macro. - * - * @version $Id$ - * @since 7.0RC1 - */ -public class SpacesIT extends AbstractTest -{ - @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 spacesMacro() - { - // Create a page with special characters in space name - // See XE-1228: Broken links displayed in the Spaces widget if a space name contains a colon - // See XE-1298: Spaces macro doesn't list spaces that contain a colon in their name - String spaceName = getTestClassName() + ":" + getTestMethodName() + "&"; - String referenceEscapedSpaceName = getTestClassName() + "\\:" + getTestMethodName() + "&"; - // Make sure the new space's WebHome page doesn't exist. - getUtil().deletePage(spaceName, "WebHome"); - - // Create the new space using the UI and verify it leads to the space home page being edited. - SpacesMacroPage macroPage = SpacesMacroPage.gotoPage(); - macroPage.getSpacesMacroPane().createSpace(spaceName).clickCreate(); - WikiEditPage editPage = new WikiEditPage(); - - // Verify that space creation uses the space name as the space home page's title - assertEquals(spaceName, editPage.getDocumentTitle()); - - // Verify that the space created is correct by looking at the generate metadata in the HTML header - // (they contain the space reference amongst other data). - // Note: the value will be escaped since it is the space reference, not the space name. - assertEquals(referenceEscapedSpaceName, editPage.getMetaDataValue("space")); - - // Go back to the Spaces Macro page and verify that the link to space index works - // First, save the space's home page - editPage.clickSaveAndContinue(); - - macroPage = SpacesMacroPage.gotoPage(); - macroPage.getSpacesMacroPane().clickSpaceIndex(referenceEscapedSpaceName); - - // Assert the content of the space index live table. - LiveTableElement spaceIndexLiveTable = new SpaceIndexPage().getLiveTable(); - spaceIndexLiveTable.waitUntilReady(); - assertEquals(1, spaceIndexLiveTable.getRowCount()); - assertTrue(spaceIndexLiveTable.hasRow("Page", "WebHome")); - assertTrue(spaceIndexLiveTable.hasRow("Space", referenceEscapedSpaceName)); - - // Go back to the Spaces Macro page and this time verify that the link to the space home page works - macroPage = SpacesMacroPage.gotoPage(); - ViewPage spaceHomePage = macroPage.getSpacesMacroPane().clickSpaceHome(referenceEscapedSpaceName); - assertEquals(spaceName, spaceHomePage.getDocumentTitle()); - } -} diff --git a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-ui/src/main/resources/XWiki/DocumentsMacro.xml b/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-ui/src/main/resources/XWiki/DocumentsMacro.xml index 552292c41d3b..97056d70e8e3 100644 --- a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-ui/src/main/resources/XWiki/DocumentsMacro.xml +++ b/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-ui/src/main/resources/XWiki/DocumentsMacro.xml @@ -262,9 +262,9 @@ Generates: #set ($discard = $properties.add($colname.trim())) #end #else - #set($properties = ['doc.title', 'doc.location', 'doc.date', 'doc.author']) + #set ($properties = ['doc.title', 'doc.location', 'doc.date', 'doc.author']) #end -#set($sourceParameters = { +#set ($sourceParameters = { 'translationPrefix' : 'platform.index.', 'description' : 'This table lists documents found on this wiki based on passed criteria. The columns can be sorted and some can be filtered.' }) diff --git a/xwiki-platform-core/xwiki-platform-livedata/xwiki-platform-livedata-test/xwiki-platform-livedata-test-pageobjects/src/main/java/org/xwiki/livedata/test/po/TableLayoutElement.java b/xwiki-platform-core/xwiki-platform-livedata/xwiki-platform-livedata-test/xwiki-platform-livedata-test-pageobjects/src/main/java/org/xwiki/livedata/test/po/TableLayoutElement.java index f86fcd2b23b5..40a2823f4c85 100644 --- a/xwiki-platform-core/xwiki-platform-livedata/xwiki-platform-livedata-test/xwiki-platform-livedata-test-pageobjects/src/main/java/org/xwiki/livedata/test/po/TableLayoutElement.java +++ b/xwiki-platform-core/xwiki-platform-livedata/xwiki-platform-livedata-test/xwiki-platform-livedata-test-pageobjects/src/main/java/org/xwiki/livedata/test/po/TableLayoutElement.java @@ -688,8 +688,19 @@ public Set getPaginationSizes() */ public void clickAction(int rowNumber, String actionName) { - getRoot().findElement(By.cssSelector( - String.format("tbody tr:nth-child(%d) [name='%s']", rowNumber, actionName))) + clickAction(rowNumber, By.cssSelector(String.format(".actions-container .action.action_%s", actionName))); + } + + /** + * Clicks on an action based on a row and the provided selector. + * + * @param rowNumber the row number, for instance 3 for the third row + * @param selector the selector to find the action element in the row + */ + public void clickAction(int rowNumber, By selector) + { + getRowElement(rowNumber) + .findElement(selector) .click(); } @@ -732,10 +743,15 @@ public void editAndCancel(String columnLabel, int rowNumber, String fieldName, S */ public WebElement findElementInRow(int rowNumber, By by) { - return getRoot().findElement(By.cssSelector(String.format("tbody tr:nth-child(%d)", rowNumber))) + return getRowElement(rowNumber) .findElement(by); } + private WebElement getRowElement(int rowNumber) + { + return getRoot().findElement(By.cssSelector(String.format("tbody tr:nth-child(%d)", rowNumber))); + } + /** * Return a hamcrest {@link Matcher} on the text of a {@link WebElement}. For instance the {@link Matcher} will * match on the web element containing the following html source {@code

Test

} for the value {@code diff --git a/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-test/xwiki-platform-mail-test-docker/src/test/it/org/xwiki/mail/test/ui/MailIT.java b/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-test/xwiki-platform-mail-test-docker/src/test/it/org/xwiki/mail/test/ui/MailIT.java index 5837853fdff0..ebb6ef4d6e3f 100644 --- a/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-test/xwiki-platform-mail-test-docker/src/test/it/org/xwiki/mail/test/ui/MailIT.java +++ b/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-test/xwiki-platform-mail-test-docker/src/test/it/org/xwiki/mail/test/ui/MailIT.java @@ -264,7 +264,7 @@ private void verifyMailDelete() TableLayoutElement tableLayout = statusPage.getLiveData().getTableLayout(); tableLayout.filterColumn("Status", "send_success"); int count = tableLayout.countRows(); - tableLayout.clickAction(1, "mailsendingaction_delete"); + statusPage.clickAction(1, "mailsendingaction_delete"); // Wait for the success message to be displayed statusPage.waitUntilContent("\\QThe mail has been deleted successfully\\E"); @@ -279,7 +279,7 @@ private void verifyIndividualResend() MailStatusAdministrationSectionPage statusPage = MailStatusAdministrationSectionPage.gotoPage(); TableLayoutElement tableLayout = statusPage.getLiveData().getTableLayout(); tableLayout.filterColumn("Status", "send_error"); - tableLayout.clickAction(1, "mailsendingaction_resend"); + statusPage.clickAction(1, "mailsendingaction_resend"); // Refresh the page and verify the mail to to@doe.com is in send_success state now statusPage = MailStatusAdministrationSectionPage.gotoPage(); diff --git a/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-test/xwiki-platform-mail-test-pageobjects/src/main/java/org/xwiki/mail/test/po/MailStatusAdministrationSectionPage.java b/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-test/xwiki-platform-mail-test-pageobjects/src/main/java/org/xwiki/mail/test/po/MailStatusAdministrationSectionPage.java index 14957f727464..1cb9d1d07c5c 100644 --- a/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-test/xwiki-platform-mail-test-pageobjects/src/main/java/org/xwiki/mail/test/po/MailStatusAdministrationSectionPage.java +++ b/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-test/xwiki-platform-mail-test-pageobjects/src/main/java/org/xwiki/mail/test/po/MailStatusAdministrationSectionPage.java @@ -19,12 +19,13 @@ */ package org.xwiki.mail.test.po; +import org.openqa.selenium.By; import org.xwiki.administration.test.po.AdministrationSectionPage; import org.xwiki.livedata.test.po.LiveDataElement; /** * Represents the actions possible on the Mail Status Administration Page. - * + * * @version $Id$ * @since 6.4RC1 */ @@ -48,4 +49,15 @@ public LiveDataElement getLiveData() { return new LiveDataElement("sendmailstatus"); } + + /** + * Click on a mail action. + * + * @param rowNumber the row number in which to call the actions (start at 1 for the first row) + * @param actionName the name of the action (e.g., {@code mailsendingaction_resend}) + */ + public void clickAction(int rowNumber, String actionName) + { + getLiveData().getTableLayout().clickAction(rowNumber, By.cssSelector(String.format("[name='%s']", actionName))); + } }