|
1 | 1 |
|
2 | | -describe('User roles', function () { |
3 | | - let cookieResult; |
4 | | - |
5 | | - beforeEach(function () { |
6 | | - browser.url('/'); |
7 | | - }); |
| 2 | +import UserRoleElement from './pageobjects/user_role.element'; |
8 | 3 |
|
9 | | - afterEach(function () { |
10 | | - browser.deleteCookie('testing_user_role'); |
11 | | - }); |
| 4 | +describe('User roles', function () { |
| 5 | + let cookieResult, |
| 6 | + userRoleElement, |
| 7 | + cookieValue; |
| 8 | + const guidManagerOrgX = 'org-manager-x-uid-601d-48c4-9705', |
| 9 | + guidManagerOrgY = 'org-manager-y-uid-601d-48c4-9705', |
| 10 | + cookieManagerOrgY = 'org_manager_org_y', |
| 11 | + cookieManagerOrgX = 'org_manager_org_x', |
| 12 | + cookieManagerSpaceXX = 'space_manager_space_xx', |
| 13 | + // cookieManagerSpaceYY = 'space_manager_space_yy', |
| 14 | + urlOrgY = '/#/org/user_role-org_y-ffe7-4aa8-8e85-94768d6bd250', |
| 15 | + urlOrgX = '/#/org/user_role-org_x-ffe7-4aa8-8e85-94768d6bd250'; |
12 | 16 |
|
13 | 17 | describe('User role cookie test', function () { |
| 18 | + afterEach(function () { |
| 19 | + browser.deleteCookie('testing_user_role'); |
| 20 | + }); |
| 21 | + |
14 | 22 | describe('when cookie is set and deleted', function () { |
15 | 23 | it('should reflect the cookie content', function () { |
16 | | - browser.setCookie({ name: 'testing_user_role', value: 'space_manager_space_xx' }); |
17 | | - browser.url('/uaa/userinfo'); |
| 24 | + browser.url('/'); |
| 25 | + browser.setCookie({ name: 'testing_user_role', value: cookieManagerSpaceXX }); |
18 | 26 | cookieResult = browser.getCookie('testing_user_role').value; |
19 | | - expect(cookieResult).toBe('space_manager_space_xx'); |
| 27 | + expect(cookieResult).toBe(cookieManagerSpaceXX); |
20 | 28 | }); |
21 | 29 | }); |
22 | 30 | }); |
23 | 31 |
|
24 | | - describe('Org page', function () { |
25 | | - beforeEach(function () { |
26 | | - browser.url('/#/org/user_role-org_x-ffe7-4aa8-8e85-94768d6bd250'); |
| 32 | + describe('A user on page for orgs', function () { |
| 33 | + describe('on page for org X should see only manager X has user permissions', function () { |
| 34 | + it('should navigates to org Y', function () { |
| 35 | + browser.url(urlOrgX); |
| 36 | + |
| 37 | + browser.waitForExist('.test-users'); |
| 38 | + userRoleElement = new UserRoleElement(browser, browser.element('.test-users')); |
| 39 | + |
| 40 | + expect(userRoleElement.isVisible()).toBe(true); |
| 41 | + }); |
| 42 | + |
| 43 | + it('should see manager X has Org Manager access', function () { |
| 44 | + expect(userRoleElement.isUserOrgManager(guidManagerOrgX)).toBe(true); |
| 45 | + }); |
| 46 | + |
| 47 | + it('should see manager Y does not have Org Manager access', function () { |
| 48 | + expect(userRoleElement.isUserOrgManager(guidManagerOrgY)).toBe(false); |
| 49 | + }); |
27 | 50 | }); |
28 | 51 |
|
29 | | - it('has a title', function () { |
30 | | - expect(browser.getTitle()).toBe('cloud.gov dashboard'); |
| 52 | + describe('on page for org Y should see only manager Y has user permissions', function () { |
| 53 | + it('should navigates to org Y', function () { |
| 54 | + browser.url(urlOrgY); |
| 55 | + |
| 56 | + browser.waitForExist('.test-users'); |
| 57 | + userRoleElement = new UserRoleElement(browser, browser.element('.test-users')); |
| 58 | + |
| 59 | + expect(userRoleElement.isVisible()).toBe(true); |
| 60 | + }); |
| 61 | + |
| 62 | + it('should see manager Y has Org Manager access', function () { |
| 63 | + expect(userRoleElement.isUserOrgManager(guidManagerOrgY)).toBe(true); |
| 64 | + }); |
| 65 | + |
| 66 | + it('should see manager X does not have Org Manager access', function () { |
| 67 | + expect(userRoleElement.isUserOrgManager(guidManagerOrgX)).toBe(false); |
| 68 | + }); |
31 | 69 | }); |
| 70 | + }); |
32 | 71 |
|
33 | | - it('has a page header', function () { |
34 | | - browser.waitForExist('.test-page-header-title', 2000); |
35 | | - const pageHeader = browser.element('.test-page-header-title'); |
36 | | - expect(pageHeader.getText()).toBe('fake-cf-user_role-org_x-testing'); |
| 72 | + describe('Testing user roles', function () { |
| 73 | + it('Setup userRoleElement', function () { |
| 74 | + browser.url(urlOrgX); |
| 75 | + browser.waitForExist('.test-users'); |
| 76 | + userRoleElement = new UserRoleElement(browser, browser.element('.test-users')); |
37 | 77 | }); |
38 | 78 |
|
39 | | - describe('org manager for org X then they should', function () { |
40 | | - it('be able to edit roles for org X', function () { |
41 | | - browser.setCookie({ name: 'testing_user_role', value: 'org_manager_org_x' }); |
42 | | - cookieResult = browser.getCookie('testing_user_role').value; |
43 | | - expect(cookieResult).toBe('org_manager_org_x'); |
| 79 | + describe('As org manager Y', function () { |
| 80 | + beforeEach(function () { |
| 81 | + // sets cookie to org Y manager |
| 82 | + cookieValue = cookieManagerOrgY; |
| 83 | + }); |
| 84 | + |
| 85 | + describe('shouldn\'t have permission to edit fields on org X pages', function () { |
| 86 | + it('should set url to org X', function () { |
| 87 | + browser.url(urlOrgX); |
| 88 | + }); |
44 | 89 |
|
45 | | - expect(true).toBe(true); |
| 90 | + it('verifies that the current user is a user with only permissions to org Y', function () { |
| 91 | + cookieResult = userRoleElement.setAndGetUserRole(cookieValue); |
| 92 | + expect(cookieResult).toBe(cookieManagerOrgY); |
| 93 | + }); |
| 94 | + |
| 95 | + it('verify org Y manager cannot modify org X page', function () { |
| 96 | + expect(userRoleElement.isFirstUserRoleEnabled()).toBe(false); |
| 97 | + }); |
46 | 98 | }); |
47 | 99 |
|
48 | | - it('not be able to edit roles for org Y', function () { |
49 | | - expect(true).toBe(true); |
| 100 | + describe('should have permission to edit fields on org Y pages', function () { |
| 101 | + it('should set url to org Y', function () { |
| 102 | + browser.url(urlOrgY); |
| 103 | + }); |
| 104 | + |
| 105 | + it('verifies that the current user is a user with only permissions to org Y', function () { |
| 106 | + cookieResult = userRoleElement.setAndGetUserRole(cookieValue); |
| 107 | + expect(cookieResult).toBe(cookieManagerOrgY); |
| 108 | + }); |
| 109 | + |
| 110 | + it('verify org Y manager can modify org Y page', function () { |
| 111 | + expect(userRoleElement.isFirstUserRoleEnabled()).toBe(true); |
| 112 | + }); |
50 | 113 | }); |
51 | 114 | }); |
52 | 115 |
|
53 | | - describe('space manager for org X space TT then they should', function () { |
54 | | - it('not be able to edit roles for org X', function () { |
55 | | - expect(true).toBe(true); |
| 116 | + describe('As org manager X', function () { |
| 117 | + beforeEach(function () { |
| 118 | + // sets cookie to org X manager |
| 119 | + cookieValue = cookieManagerOrgX; |
| 120 | + }); |
| 121 | + describe('shouldn\'t have permission to edit fields on org Y pages', function () { |
| 122 | + it('should set url to org Y', function () { |
| 123 | + browser.url(urlOrgY); |
| 124 | + }); |
| 125 | + |
| 126 | + it('verifies that the current user is a user with only permissions to org X', function () { |
| 127 | + cookieResult = userRoleElement.setAndGetUserRole(cookieValue); |
| 128 | + expect(cookieResult).toBe(cookieManagerOrgX); |
| 129 | + }); |
| 130 | + |
| 131 | + it('verify org X manager cannot modify org Y page', function () { |
| 132 | + expect(userRoleElement.isFirstUserRoleEnabled()).toBe(false); |
| 133 | + }); |
| 134 | + }); |
| 135 | + |
| 136 | + describe('should have permission to edit fields on org X pages', function () { |
| 137 | + it('should set url to org X', function () { |
| 138 | + browser.url(urlOrgX); |
| 139 | + }); |
| 140 | + |
| 141 | + it('verifies that the current user is a user with only permissions to org X', function () { |
| 142 | + cookieResult = userRoleElement.getUserRole(cookieManagerOrgX); |
| 143 | + expect(cookieResult).toBe(cookieManagerOrgX); |
| 144 | + }); |
| 145 | + |
| 146 | + it('verify org X manager can modify org X page', function () { |
| 147 | + expect(userRoleElement.isFirstUserRoleEnabled()).toBe(true); |
| 148 | + }); |
56 | 149 | }); |
57 | 150 | }); |
| 151 | + |
| 152 | + it('delete cookie after', function () { |
| 153 | + browser.deleteCookie('testing_user_role'); |
| 154 | + }); |
58 | 155 | }); |
59 | 156 |
|
60 | 157 | describe('Space page', function () { |
@@ -86,7 +183,6 @@ describe('User roles', function () { |
86 | 183 | }); |
87 | 184 |
|
88 | 185 | it('not be able to edit roles for space YY', function () { |
89 | | - expect(true).toBe(true); |
90 | 186 | }); |
91 | 187 | }); |
92 | 188 | }); |
|
0 commit comments