use of org.xwiki.test.ui.po.LiveTableElement in project xwiki-platform by xwiki.
the class AllDocsTest method attachmentsTabFilteringAndSorting.
/**
* This test is against XWiki Enterprise XE-701 https://jira.xwiki.org/browse/XE-701 (fixed in 2.5M1) WARN:
* calling isReady() and waitUntilReady() from LiveTableElement.java inside this class fails.
*/
@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 attachmentsTabFilteringAndSorting() throws Exception {
// Create 2 pages with attachments so that this test filter returns only one.
// Note that we need to be logged in.
getUtil().createPageWithAttachment(getTestClassName(), "Page", null, null, "attachment1.txt", new ByteArrayInputStream("attachment content1".getBytes()), TestUtils.SUPER_ADMIN_CREDENTIALS);
getUtil().createPageWithAttachment(getTestClassName(), "OtherPage", null, null, "attachment2.txt", new ByteArrayInputStream("attachment content2".getBytes()), TestUtils.SUPER_ADMIN_CREDENTIALS);
AllDocsPage docsPage = AllDocsPage.gotoPage();
LiveTableElement liveTable = docsPage.clickAttachmentsTab();
// Here we test if all the Columns are displayed.
assertTrue("No Type column found", liveTable.hasColumn("Type"));
assertTrue("No Name column found", liveTable.hasColumn("Name"));
assertTrue("No Location column found", liveTable.hasColumn("Location"));
assertTrue("No Size column found", liveTable.hasColumn("Size"));
assertTrue("No Date column found", liveTable.hasColumn("Date"));
assertTrue("No Author column found", liveTable.hasColumn("Author"));
assertEquals(2, liveTable.getRowCount());
// Filter by attachment file name.
liveTable.filterColumn("xwiki-livetable-allattachments-filter-2", "t1");
assertEquals(1, liveTable.getRowCount());
assertEquals("attachment1.txt", liveTable.getCell(liveTable.getRow(1), 2).getText());
// Clear the filter.
liveTable.filterColumn("xwiki-livetable-allattachments-filter-2", "");
// Filter by attachment location.
liveTable.filterColumn("xwiki-livetable-allattachments-filter-3", "th");
assertEquals(1, liveTable.getRowCount());
assertEquals("AllDocsTestOtherPage", liveTable.getCell(liveTable.getRow(1), 3).getText());
// Clear the filter.
liveTable.filterColumn("xwiki-livetable-allattachments-filter-3", "");
// Sort by attachment file name. The live table should be already sorted by file name ascending. This will
// reverse the order.
assertEquals("attachment2.txt", liveTable.getCell(liveTable.getRow(2), 2).getText());
liveTable.sortBy("Name");
assertEquals(2, liveTable.getRowCount());
assertEquals("attachment2.txt", liveTable.getCell(liveTable.getRow(1), 2).getText());
// Sort by attachment location.
liveTable.sortBy("Location");
assertEquals("AllDocsTestPage", liveTable.getCell(liveTable.getRow(2), 3).getText());
liveTable.sortBy("Location");
assertEquals(2, liveTable.getRowCount());
assertEquals("AllDocsTestPage", liveTable.getCell(liveTable.getRow(1), 3).getText());
}
use of org.xwiki.test.ui.po.LiveTableElement in project xwiki-platform by xwiki.
the class SpacesTest method spacesMacro.
@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());
}
use of org.xwiki.test.ui.po.LiveTableElement in project xwiki-platform by xwiki.
the class MailStatusAdministrationSectionPage method getLiveTable.
/**
* @return the status live table
*/
public LiveTableElement getLiveTable() {
LiveTableElement lt = new LiveTableElement("sendmailstatus");
lt.waitUntilReady();
return lt;
}
use of org.xwiki.test.ui.po.LiveTableElement in project xwiki-platform by xwiki.
the class MailTest method testMail.
@Test
public void testMail() throws Exception {
// Step 0: Delete all pre-existing mails to start clean. This also verifies the deleteAll() script service
// API.
String content = "{{velocity}}$services.mailstorage.deleteAll(){{/velocity}}";
ViewPage deleteAllPage = getUtil().createPage(getTestClassName(), "DeleteAll", content, "");
// Verify that the page doesn't display any content (unless there's an error!)
assertEquals("", deleteAllPage.getContent());
// Step 1: Verify that there are 2 email sections in the Mail category
AdministrationPage wikiAdministrationPage = AdministrationPage.gotoPage();
Assert.assertTrue(wikiAdministrationPage.hasSection("Mail", "Mail Sending"));
Assert.assertTrue(wikiAdministrationPage.hasSection("Mail", "Mail Sending Status"));
Assert.assertTrue(wikiAdministrationPage.hasSection("Mail", "Advanced"));
// Verify we can click on Mail > Advanced
wikiAdministrationPage.clickSection("Mail", "Advanced");
// Step 2: Before validating that we can send email, let's verify that we can report errors when the mail
// setup is not correct
// Make sure there's an invalid mail server set.
wikiAdministrationPage.clickSection("Mail", "Mail Sending");
SendMailAdministrationSectionPage sendMailPage = new SendMailAdministrationSectionPage();
sendMailPage.setHost("invalidmailserver");
sendMailPage.clickSave();
// Send the mail that's supposed to fail and validate that it fails
sendMailWithInvalidMailSetup();
// Step 3: Navigate to each mail section and set the mail sending parameters (SMTP host/port)
wikiAdministrationPage = AdministrationPage.gotoPage();
wikiAdministrationPage.clickSection("Mail", "Mail Sending");
sendMailPage = new SendMailAdministrationSectionPage();
sendMailPage.setHost("localhost");
sendMailPage.setPort("3025");
// Make sure we don't wait between email sending in order to speed up the test (and not incur timeouts when
// we wait to receive the mails)
sendMailPage.setSendWaitTime("0");
// Keep all mail statuses including successful ones (so that we verify this works fine)
sendMailPage.setDiscardSuccessStatuses(false);
sendMailPage.clickSave();
// Step 3: Verify that there are no admin email sections when administering a space
// Select XWiki space administration.
AdministrationPage spaceAdministrationPage = AdministrationPage.gotoSpaceAdministrationPage("XWiki");
// 2018-01-31: Got a failure on CI showing that the first assert below this line was failing because the
// current page was still the one before move to the XWiki space admin. Thus taking extra step to ensure we
// wait. However I don't understand why this happens since getDriver().url() called by
// gotoSpaceAdministrationPage() should wait for the page to be loaded before returning.
getDriver().waitUntilCondition(driver -> spaceAdministrationPage.getMetaDataValue("reference").equals("xwiki:XWiki.WebPreferences"));
// All those sections should not be present
Assert.assertTrue(spaceAdministrationPage.hasNotSection("Mail", "Mail Sending"));
Assert.assertTrue(spaceAdministrationPage.hasNotSection("Mail", "Mail Sending Status"));
Assert.assertTrue(spaceAdministrationPage.hasNotSection("Mail", "Advanced"));
// Step 4: Prepare a Template Mail
getUtil().deletePage(getTestClassName(), "MailTemplate");
// Create a Wiki page containing a Mail Template (ie a XWiki.Mail object)
getUtil().createPage(getTestClassName(), "MailTemplate", "", "");
// Note: We use the following bindings in the Template subject and content so that we ensure that they are
// provided by default:
// - "$xwiki"
// - "$xcontext"
// - "$escapetool"
// - "$services"
// - "$request"
// Note: We also use the $name and $doc bindings to show that the user can add new bindings ($doc is not bound
// by default since there isn't always a notion of current doc in all places where mail sending is done).
// Note: We use $xwiki.getURL() in the content to verify that we generate full external URLs.
String velocityContent = "Hello $name from $escapetool.xml($services.model.resolveDocument(" + "$xcontext.getUser()).getName()) - Served from $request.getRequestURL().toString() - " + "url: $xwiki.getURL('Main.WebHome')";
getUtil().addObject(getTestClassName(), "MailTemplate", "XWiki.Mail", "subject", "#if ($xwiki.exists($doc.documentReference))Status for $name on $doc.fullName#{else}wrong#end", "language", "en", "html", "<strong>" + velocityContent + "</strong>", "text", velocityContent);
// We also add an attachment to the Mail Template page to verify that it is sent in the mail
ByteArrayInputStream bais = new ByteArrayInputStream("Content of attachment".getBytes());
getUtil().attachFile(getTestClassName(), "MailTemplate", "something.txt", bais, true, new UsernamePasswordCredentials("superadmin", "pass"));
// Step 5: Send a template email (with an attachment) to a single email address
sendTemplateMailToEmail();
// Step 6: Send a template email to all the users in the XWikiAllGroup Group (we'll create 2 users) + to
// two other users (however since they're part of the group they'll receive only one mail each, we thus test
// deduplicatio!).
sendTemplateMailToUsersAndGroup();
// Step 7: Navigate to the Mail Sending Status Admin page and assert that the Livetable displays the entry for
// the sent mails
wikiAdministrationPage = AdministrationPage.gotoPage();
wikiAdministrationPage.clickSection("Mail", "Mail Sending Status");
MailStatusAdministrationSectionPage statusPage = new MailStatusAdministrationSectionPage();
LiveTableElement liveTableElement = statusPage.getLiveTable();
liveTableElement.filterColumn("xwiki-livetable-sendmailstatus-filter-3", "Test");
liveTableElement.filterColumn("xwiki-livetable-sendmailstatus-filter-5", "send_success");
liveTableElement.filterColumn("xwiki-livetable-sendmailstatus-filter-6", "xwiki");
// Let's wait till we have at least 3 rows. Note that we wait because we could have received the mails above
// but the last mail's status in the database may not have been updated yet. Note that The first 2 are
// guaranteed to have been updated since we send mail in one thread one after another and we update the
// database after sending each mail.
liveTableElement.waitUntilRowCountGreaterThan(3);
liveTableElement.filterColumn("xwiki-livetable-sendmailstatus-filter-4", "john@doe.com");
assertTrue(liveTableElement.getRowCount() > 0);
assertTrue(liveTableElement.hasRow("Error", ""));
}
use of org.xwiki.test.ui.po.LiveTableElement in project xwiki-platform by xwiki.
the class ReleaseTest method testRelease.
@Test
public void testRelease() {
// Create a user and log in with it so that we test the application with a standard user
// Note that using the superadmin user would also fail since the uservatar macro doesn't work with it.
getUtil().createUserAndLogin(getTestClassName() + "User", "password");
// Delete pages that we create in the test (we have to be logged in).
getUtil().deletePage("Release", RELEASE_PAGE_NAME);
// Navigate to the Release app by clicking in the Application Panel.
// This verifies that the Release application is registered in the Applications Panel.
// It also verifies that the Translation is registered properly.
ApplicationsPanel applicationPanel = ApplicationsPanel.gotoPage();
ViewPage vp = applicationPanel.clickApplication("Release");
// Verify we're on the right page!
Assert.assertEquals(ReleaseHomePage.getSpace(), vp.getMetaDataValue("space"));
Assert.assertEquals(ReleaseHomePage.getPage(), vp.getMetaDataValue("page"));
ReleaseHomePage homePage = new ReleaseHomePage();
// Add new Release
ReleaseEntryEditPage entryPage = homePage.addRelease(RELEASE_VERSION);
vp = entryPage.waitUntilPageIsLoaded().clickSaveAndView();
// Go back to the home page by clicking in the breadcrumb
vp.clickBreadcrumbLink("Releases");
homePage.waitUntilPageIsLoaded();
// Assert Livetable:
// - verify that the Translation has been applied by checking the Translated livetable column name
// - verify that the Livetable contains our new Release entry
LiveTableElement lt = homePage.getReleaseLiveTable();
Assert.assertTrue(lt.hasRow("Version", RELEASE_VERSION));
}
Aggregations