Skip to content

Commit

Permalink
Add functional tests xwikisas#16
Browse files Browse the repository at this point in the history
* modified tests
* modified translations
  • Loading branch information
ChiuchiuSorin committed Jan 17, 2024
1 parent c8c295f commit 27d5f75
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<hr/>
<ul>
<li>
$escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.xwiki.version',
$escapetool.xml($services.localization.render('adminTools.dashboard.backend.xwiki.version',
[$configuration.xwikiVersion]))
</li>
<ul>
Expand All @@ -39,46 +39,46 @@
</li>
</ul>
<li>
$escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.java',
$escapetool.xml($services.localization.render('adminTools.dashboard.backend.java',
[$configuration.javaVersion]))
</li>
<li>
$escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.usedServer',
$escapetool.xml($services.localization.render('adminTools.dashboard.backend.usedServer',
[$configuration.usedServerName, $configuration.usedServerVersion]))
</li>
<li>$escapetool.xml($services.localization.render('adminTools.dashboard.backend.os.legend'))
<ul>
<li>$escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.os.name',
$configuration.osName))</li>
<li>$escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.os.version',
$configuration.osVersion))</li>
<li>$escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.os.architecture',
$configuration.osArch))</li>
<li>$escapetool.xml($services.localization.render('adminTools.dashboard.backend.os.name',
[$configuration.osName]))</li>
<li>$escapetool.xml($services.localization.render('adminTools.dashboard.backend.os.version',
[$configuration.osVersion]))</li>
<li>$escapetool.xml($services.localization.render('adminTools.dashboard.backend.os.architecture',
[$configuration.osArch]))</li>
</ul>
</li>
#set($databaseName = $configuration.databaseName)
#if ("$databaseName" != '')
<li>$escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.usedDB',
<li>$escapetool.xml($services.localization.render('adminTools.dashboard.backend.usedDB',
[$databaseName, $configuration.databaseVersion]))</li>
#set ($isSupported = false)
#databaseIsSupported($databaseName $isSupported)
#if (!$isSupported)
#set($warningDatabaseMessage = $escapetool.xml($services.localization.render(
'adminTools.dashboard.section.backend.supportedDB.error', [$stringtool.join($supportedDatabases, ', ')]
'adminTools.dashboard.backend.supportedDB.error', [$stringtool.join($supportedDatabases, ', ')]
)))
#warning($warningDatabaseMessage)
#end
#else
#set($warningDatabaseMessage = $escapetool.xml($services.localization.render(
'adminTools.dashboard.section.backend.supportedDB.error', [$stringtool.join($supportedDatabases, ', ')])))
'adminTools.dashboard.backend.supportedDB.error', [$stringtool.join($supportedDatabases, ', ')])))
#warning($warningDatabaseMessage)
#end
</ul>
</div>
#viewLastNLinesMoldal("configuration")
#else
#set($warningMessage =
$escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.configuration.error',
$escapetool.xml($services.localization.render('adminTools.dashboard.backend.configuration.error',
[$stringtool.join($services.admintools.getSupportedServers(), ', ')])))
#warning($warningMessage)
#end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,22 +183,18 @@ void adminToolDownloadArchiveModal()
void adminToolsHomePageFilesNotAdmin(TestUtils testUtils)
{
testUtils.login(USER_NAME, PASSWORD);
String mainWindowHandle = testUtils.getDriver().getWindowHandle();

// Click the anchor, switch tabs to the new page and check the content. After this, close the new tab and
// change focus to the main page.
DashboardFilesSectionView filesSectionView = AdminToolsHomePage.getFilesSection();
filesSectionView.clickPropertiesHyperlink();
checkTabOpenForNonAdmin(testUtils, mainWindowHandle);

filesSectionView.clickConfigurationHyperlink();
checkTabOpenForNonAdmin(testUtils, mainWindowHandle);
WebElement filesSectionNonAdminView = filesSectionView.getNonAdminUserView();
assertTrue(filesSectionNonAdminView.getText().contains(
"[Access denied when checking [admin] access to [xwiki:AdminTools.WebHome] for user [xwiki:XWiki."
+ USER_NAME + "]]"));

DownloadArchiveModalView archiveModalView = filesSectionView.clickDownloadModalHyperlink();
archiveModalView.clickDownloadButton();
testUtils.getDriver().waitUntilPageIsReloaded();
WebElement tabContent = testUtils.getDriver().findElement(By.tagName("body"));
assertTrue(tabContent.getText().contains("Unauthorized"));
DashboardConfigurationSectionView configurationSectionView = AdminToolsHomePage.getConfigurationSection();
WebElement configurationSectionNonAdminView = configurationSectionView.getNonAdminUserView();
assertTrue(configurationSectionNonAdminView.getText().contains(
"[Access denied when checking [admin] access to [xwiki:AdminTools.WebHome] for user [xwiki:XWiki."
+ USER_NAME + "]]"));
}

/**
Expand All @@ -215,20 +211,10 @@ private void switchToNewTab(TestUtils testUtils, String mainWindowHandle)
assertNotEquals(mainWindowHandle, testUtils.getDriver().getWindowHandle());
}

private void checkTabOpenForNonAdmin(TestUtils testUtils, String mainWindowHandle)
{
switchToNewTab(testUtils, mainWindowHandle);
WebElement tabContent = testUtils.getDriver().findElement(By.tagName("body"));
assertTrue(tabContent.getText().contains("Unauthorized"));
testUtils.getDriver().close();
testUtils.getDriver().switchTo().window(mainWindowHandle);
}

private void checkXWikiFileOpen(TestUtils testUtils, String mainWindowHandle)
{
switchToNewTab(testUtils, mainWindowHandle);
String fileContent = testUtils.getDriver().findElement(By.tagName("pre")).getText();
System.out.println(fileContent);
for (String excludedLine : excludedLines) {
assertFalse(fileContent.contains(excludedLine));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,9 @@ public LastNLinesModalView clickViewLastLogsModal()
return new LastNLinesModalView(By.id("configurationViewLastNLinesModal"),
BACKEND_SECTION_VIEW_LAST_LOGS_MODAL_ID);
}

public WebElement getNonAdminUserView()
{
return this.getDriver().findElement(By.cssSelector(".xwikirenderingerror"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,9 @@ public void clickConfigurationHyperlink()
{
filesContent.findElement(By.id("filesConfig")).click();
}

public WebElement getNonAdminUserView()
{
return this.getDriver().findElement(By.cssSelector(".xwikirenderingerror"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public WebElement getLogsCheckBox()

public WebElement getDateFilters()
{
return content.findElement(By.className("dateFields"));
return content.findElement(By.className("download-logs-date-fields"));
}

public void clickDownloadButton()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ adminTools.extension.title=Admin Tools
## Config
adminTools.dashboard.backend.configuration.error=Server path was not found. Please manually add the path to the server on the Admin Tools configuration page.
adminTools.dashboard.backend.description=Get info about your backend
adminTools.dashboard.backend.java=Detected java version
adminTools.dashboard.backend.os.architecture=OS architecture
adminTools.dashboard.backend.java=Detected java version {0}
adminTools.dashboard.backend.os.architecture=OS architecture {0}
adminTools.dashboard.backend.os.legend=OS info
adminTools.dashboard.backend.os.name=OS name
adminTools.dashboard.backend.os.version=OS version
adminTools.dashboard.backend.supportedDB.error=Database not found. Currently supported databases
adminTools.dashboard.backend.supportedServers.error=Currently supported servers
adminTools.dashboard.backend.os.name=OS name {0}
adminTools.dashboard.backend.os.version=OS version {0}
adminTools.dashboard.backend.supportedDB.error=Database not found. Currently supported databases {0}
adminTools.dashboard.backend.supportedServers.error=Currently supported servers {0}
adminTools.dashboard.backend.title=Backend
adminTools.dashboard.backend.usedDB=Used database
adminTools.dashboard.backend.usedServer=Used server
adminTools.dashboard.backend.xwiki.version=XWiki installation version
adminTools.dashboard.backend.usedDB=Used database {0}, version {1}
adminTools.dashboard.backend.usedServer=Used server {0}, version {1}
adminTools.dashboard.backend.xwiki.version=XWiki installation version {0}

## Files
adminTools.dashboard.download.description=Get the files you need. View them directly in the browser or download them as an archive.
Expand Down

0 comments on commit 27d5f75

Please sign in to comment.