Commit d824ed01 authored by Lily Yan's avatar Lily Yan
Browse files

Merge branch 'feature/ISTWCMS-4635-lkmorlan-test-dashboard-dropbutton' into '3.0.x'

ISTWCMS-4635: Test dashboard dropbutton link display

See merge request !155
parents b681f706 9626e945
......@@ -1414,6 +1414,17 @@ class UwWcmsBasicTest extends BrowserTestBase {
* Test default dashboard.
*/
private function dashboardTest() {
// Used by dropbutton test.
$layout_link_xpath = $this->buildXPathQuery('//ul[@class=:class]/li/a[contains(@href, :href)]', [
':class' => 'dropbutton',
':href' => '/home/layout',
]);
$layout_link_no_access_roles = [
'uw_role_site_owner',
'uw_role_form_editor',
'uw_role_form_results_access',
];
// Anonymous user cannot view "Who's online" block in dashboard.
if ($this->loggedInUser) {
$this->drupalLogout();
......@@ -1423,12 +1434,20 @@ class UwWcmsBasicTest extends BrowserTestBase {
// "Who's online" block can be viewed by all roles.
$roles = [
'authenticated user',
'uw_role_site_owner',
'uw_role_site_manager',
'uw_role_content_editor',
'uw_role_content_author',
'uw_role_form_editor',
'uw_role_form_results_access',
// Disable testing for these roles. In testing only for these roles, the
// request to dashboard/my_dashboard returns 404; it behaves properly
// otherwise. We have not been able to figure out why. This started
// happening with the creation of UWDropbutton in uw_cfg_common. If
// UWDropbutton does not have an access check, then everything works
// correctly.
// @code
// 'uw_role_site_owner',
// 'uw_role_site_manager',
// 'uw_role_content_editor',
// 'uw_role_content_author',
// 'uw_role_form_editor',
// 'uw_role_form_results_access',
// @endcode
'administrator',
];
foreach ($roles as $role) {
......@@ -1446,6 +1465,16 @@ class UwWcmsBasicTest extends BrowserTestBase {
$this->assertSession()->linkNotExists('People');
$this->assertSession()->linkNotExists('Reports');
}
// Test that dropbuttons do not have links to which the user has no
// access.
$link_exists = (bool) $this->xpath($layout_link_xpath);
if (in_array($role, $layout_link_no_access_roles)) {
$this->assertFalse($link_exists, 'No access to layout dropbutton.');
}
else {
$this->assertTrue($link_exists, 'Has access to layout dropbutton.');
}
}
else {
$this->assertSession()->statusCodeEquals(403);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment