-
Notifications
You must be signed in to change notification settings - Fork 379
test: [M3-9595] - Firewall create page for restricted users #12237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Tests | ||
--- | ||
|
||
Test for firewall create page for restricted users ([#12237](https://github.com/linode/manager/pull/12237)) |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,11 +1,19 @@ | ||||||
import { grantsFactory, profileFactory } from '@linode/utilities'; | ||||||
import { createLinodeRequestFactory } from '@linode/utilities'; | ||||||
import { authenticate } from 'support/api/authentication'; | ||||||
import { mockGetUser } from 'support/intercepts/account'; | ||||||
import { interceptCreateFirewall } from 'support/intercepts/firewalls'; | ||||||
import { | ||||||
mockGetProfile, | ||||||
mockGetProfileGrants, | ||||||
} from 'support/intercepts/profile'; | ||||||
import { ui } from 'support/ui'; | ||||||
import { cleanUp } from 'support/util/cleanup'; | ||||||
import { createTestLinode } from 'support/util/linodes'; | ||||||
import { randomLabel, randomString } from 'support/util/random'; | ||||||
import { chooseRegion } from 'support/util/regions'; | ||||||
|
||||||
import { accountUserFactory } from 'src/factories'; | ||||||
authenticate(); | ||||||
|
||||||
describe('create firewall', () => { | ||||||
|
@@ -123,3 +131,64 @@ | |||||
}); | ||||||
}); | ||||||
}); | ||||||
|
||||||
describe('restricted user cannot create firewall', () => { | ||||||
beforeEach(() => { | ||||||
cleanUp(['lke-clusters', 'linodes', 'firewalls']); | ||||||
const mockProfile = profileFactory.build({ | ||||||
restricted: true, | ||||||
username: randomLabel(), | ||||||
}); | ||||||
|
||||||
const mockUser = accountUserFactory.build({ | ||||||
restricted: true, | ||||||
user_type: 'default', | ||||||
username: mockProfile.username, | ||||||
}); | ||||||
|
||||||
const mockGrants = grantsFactory.build({ | ||||||
global: { | ||||||
add_firewalls: false, | ||||||
}, | ||||||
}); | ||||||
|
||||||
mockGetProfile(mockProfile); | ||||||
mockGetProfileGrants(mockGrants); | ||||||
mockGetUser(mockUser); | ||||||
}); | ||||||
|
||||||
/* | ||||||
* - Verifies that restricted user cannot create firewall on landing page | ||||||
*/ | ||||||
it('create firewall is disabled on landing page', () => { | ||||||
cy.visitWithLogin('/firewalls'); | ||||||
ui.button | ||||||
.findByTitle('Create Firewall') | ||||||
.should('be.visible') | ||||||
.should('be.disabled'); | ||||||
Check warning on line 168 in packages/manager/cypress/e2e/core/firewalls/create-firewall.spec.ts
|
||||||
}); | ||||||
|
||||||
/* | ||||||
* - Verifies that restricted user cannot create firewall in drawer | ||||||
*/ | ||||||
it('create firewall drawer is disabled', () => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
cy.visitWithLogin('/firewalls/create'); | ||||||
|
||||||
ui.drawer | ||||||
.findByTitle('Create Firewall') | ||||||
.should('be.visible') | ||||||
.within(() => { | ||||||
cy.findByText( | ||||||
"You don't have permissions to create a new Firewall. Please contact an account administrator for details." | ||||||
); | ||||||
ui.buttonGroup | ||||||
.findButtonByTitle('Create Firewall') | ||||||
.should('be.visible') | ||||||
.should('be.disabled'); | ||||||
Comment on lines
+184
to
+187
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm seeing that when Linode interfaces is enabled, the button group may be hidden depending on screensize, making the test fail: We could either
|
||||||
// all form inputs are disabled | ||||||
cy.get('input').each((input) => { | ||||||
cy.wrap(input).should('be.disabled'); | ||||||
}); | ||||||
}); | ||||||
}); | ||||||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.