Skip to content

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-12237-tests-1747403119751.md
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', () => {
Expand Down Expand Up @@ -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', () => {
Copy link
Contributor

@coliu-akamai coliu-akamai May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('create firewall is disabled on landing page', () => {
it('confirms the create button is disabled on the FirewallLanding 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

View workflow job for this annotation

GitHub Actions / ESLint Review (manager)

[eslint] reported by reviewdog 🐢 Define a constant instead of duplicating this literal 3 times. Raw Output: {"ruleId":"sonarjs/no-duplicate-string","severity":1,"message":"Define a constant instead of duplicating this literal 3 times.","line":168,"column":15,"nodeType":"Literal","endLine":168,"endColumn":28}
});

/*
* - Verifies that restricted user cannot create firewall in drawer
*/
it('create firewall drawer is disabled', () => {
Copy link
Contributor

@coliu-akamai coliu-akamai May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('create firewall drawer is disabled', () => {
it('confirms the Create Firewall drawer is disabled', () => {

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
Copy link
Contributor

Choose a reason for hiding this comment

The 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:

image

We could either

  • add scrollIntoView() - ui.buttonGroup.findButtonByTitle('Create Firewall').scrollIntoView()
  • mock the Linode interfaces feature flag to be false (to hide the info banner)

// all form inputs are disabled
cy.get('input').each((input) => {
cy.wrap(input).should('be.disabled');
});
});
});
});