Skip to content

Commit c2bb882

Browse files
test: [M3-9595] - Firewall create page for restricted users (#12237)
* add restricted user tests * Added changeset: Test for firewall create page for restricted users * edits after pr review * edit test descriptions after pr review
1 parent 70b1703 commit c2bb882

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Tests
3+
---
4+
5+
Test for firewall create page for restricted users ([#12237](https://github.com/linode/manager/pull/12237))

packages/manager/cypress/e2e/core/firewalls/create-firewall.spec.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
import { grantsFactory, profileFactory } from '@linode/utilities';
12
import { createLinodeRequestFactory } from '@linode/utilities';
23
import { authenticate } from 'support/api/authentication';
4+
import { mockGetUser } from 'support/intercepts/account';
35
import { interceptCreateFirewall } from 'support/intercepts/firewalls';
6+
import {
7+
mockGetProfile,
8+
mockGetProfileGrants,
9+
} from 'support/intercepts/profile';
410
import { ui } from 'support/ui';
511
import { cleanUp } from 'support/util/cleanup';
612
import { createTestLinode } from 'support/util/linodes';
713
import { randomLabel, randomString } from 'support/util/random';
814
import { chooseRegion } from 'support/util/regions';
15+
16+
import { accountUserFactory } from 'src/factories';
917
authenticate();
1018

1119
describe('create firewall', () => {
@@ -123,3 +131,65 @@ describe('create firewall', () => {
123131
});
124132
});
125133
});
134+
135+
describe('restricted user cannot create firewall', () => {
136+
beforeEach(() => {
137+
cleanUp(['lke-clusters', 'linodes', 'firewalls']);
138+
const mockProfile = profileFactory.build({
139+
restricted: true,
140+
username: randomLabel(),
141+
});
142+
143+
const mockUser = accountUserFactory.build({
144+
restricted: true,
145+
user_type: 'default',
146+
username: mockProfile.username,
147+
});
148+
149+
const mockGrants = grantsFactory.build({
150+
global: {
151+
add_firewalls: false,
152+
},
153+
});
154+
155+
mockGetProfile(mockProfile);
156+
mockGetProfileGrants(mockGrants);
157+
mockGetUser(mockUser);
158+
});
159+
160+
/*
161+
* - Verifies that restricted user cannot create firewall on landing page
162+
*/
163+
it('confirms the create button is disabled on the Firewall Landing page', () => {
164+
cy.visitWithLogin('/firewalls');
165+
ui.button
166+
.findByTitle('Create Firewall')
167+
.should('be.visible')
168+
.should('be.disabled');
169+
});
170+
171+
/*
172+
* - Verifies that restricted user cannot create firewall in drawer
173+
*/
174+
it('confirms the Create Firewall button is disabled in create drawer', () => {
175+
cy.visitWithLogin('/firewalls/create');
176+
177+
ui.drawer
178+
.findByTitle('Create Firewall')
179+
.should('be.visible')
180+
.within(() => {
181+
cy.findByText(
182+
"You don't have permissions to create a new Firewall. Please contact an account administrator for details."
183+
);
184+
ui.buttonGroup.findButtonByTitle('Create Firewall').scrollIntoView();
185+
ui.buttonGroup
186+
.findButtonByTitle('Create Firewall')
187+
.should('be.visible')
188+
.should('be.disabled');
189+
// all form inputs are disabled
190+
cy.get('input').each((input) => {
191+
cy.wrap(input).should('be.disabled');
192+
});
193+
});
194+
});
195+
});

0 commit comments

Comments
 (0)