Repository: linode/manager
Pull request #12237: test: [M3-9595] - Firewall create page for restricted users
Author: login: dmcintyr-akamai
Labels: name: Approved
description: Multiple approvals and ready to merge!
Created: 2025-05-16T12:23:54Z | Merged: 2025-05-20T14:31:09Z

## Description 📝

Add test for firewall create page for restricted users on packages/manager/cypress/e2e/core/firewalls/create-firewall.spec.ts.

## Changes  🔄

Verify that 'Create Firewall' button is disabled on landing page (/firewalls) and drawer (/firewalls/create). Inputs within drawer should all be disabled as well. 

## How to test 🧪

pnpm run cy:run -s cypress/e2e/core/firewalls/create-firewall.spec.ts 
<details>
<summary> Author Checklists </summary>

## As an Author, to speed up the review process, I considered 🤔

👀 Doing a self review
❔ Our [contribution guidelines](https://github.com/linode/manager/blob/develop/docs/CONTRIBUTING.md)
🤏 Splitting feature into small PRs
➕ Adding a [changeset](https://github.com/linode/manager/blob/develop/docs/CONTRIBUTING.md#writing-a-changeset)
🧪 Providing/improving test coverage
 🔐 Removing all sensitive information from the code and PR description
🚩 Using a feature flag to protect the release
👣 Providing comprehensive reproduction steps
📑 Providing or updating our documentation
🕛 Scheduling a pair reviewing session
📱 Providing mobile support
♿  Providing accessibility support

<br/>

- [x] I have read and considered all applicable items listed above.

## As an Author, before moving this PR from Draft to Open, I confirmed ✅

- [x] All unit tests are passing
- [x] TypeScript compilation succeeded without errors
- [x] Code passes all linting rules

</details>
 


Diff:
diff --git a/packages/manager/.changeset/pr-12237-tests-1747403119751.md b/packages/manager/.changeset/pr-12237-tests-1747403119751.md
new file mode 100644
index 00000000000..1984157b2bb
--- /dev/null
+++ b/packages/manager/.changeset/pr-12237-tests-1747403119751.md
@@ -0,0 +1,5 @@
+---
+"@linode/manager": Tests
+---
+
+Test for firewall create page for restricted users ([#12237](https://github.com/linode/manager/pull/12237))
diff --git a/packages/manager/cypress/e2e/core/firewalls/create-firewall.spec.ts b/packages/manager/cypress/e2e/core/firewalls/create-firewall.spec.ts
index 593d2007d86..f8a0a34eb79 100644
--- a/packages/manager/cypress/e2e/core/firewalls/create-firewall.spec.ts
+++ b/packages/manager/cypress/e2e/core/firewalls/create-firewall.spec.ts
@@ -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,65 @@ describe('create firewall', () => {
     });
   });
 });
+
+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('confirms the create button is disabled on the Firewall Landing page', () => {
+    cy.visitWithLogin('/firewalls');
+    ui.button
+      .findByTitle('Create Firewall')
+      .should('be.visible')
+      .should('be.disabled');
+  });
+
+  /*
+   * - Verifies that restricted user cannot create firewall in drawer
+   */
+  it('confirms the Create Firewall button is disabled in create drawer', () => {
+    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').scrollIntoView();
+        ui.buttonGroup
+          .findButtonByTitle('Create Firewall')
+          .should('be.visible')
+          .should('be.disabled');
+        // all form inputs are disabled
+        cy.get('input').each((input) => {
+          cy.wrap(input).should('be.disabled');
+        });
+      });
+  });
+});


Reviews:
user: login: coliu-akamai
body: thanks @dmcintyr-akamai! approving pending Linode Interfaces banner issue is addressed
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-05-16T15:48:02Z
user: login: dmcintyr-akamai
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-19T13:54:13Z
user: login: hana-akamai
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-05-19T17:23:58Z
user: login: jdamore-linode
body: Couple nitpicks with the names but the tests are solid! Thanks @dmcintyr-akamai!
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-05-19T21:06:19Z

Review comments:
diff_hunk: @@ -123,3 +131,64 @@ describe('create firewall', () => {
     });
   });
 });
+
+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');
+  });
+
+  /*
+   * - Verifies that restricted user cannot create firewall in drawer
+   */
+  it('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');
path: packages/manager/cypress/e2e/core/firewalls/create-firewall.spec.ts
user: login: coliu-akamai
body: I'm seeing that when Linode interfaces is enabled, the button group may be hidden depending on screensize, making the test fail:

![image](https://github.com/user-attachments/assets/0e5915a8-e4c4-4550-abaa-61da00232a56)

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)

created_at: 2025-05-16T15:40:51Z
author_association: CONTRIBUTOR
diff_hunk: @@ -123,3 +131,64 @@ describe('create firewall', () => {
     });
   });
 });
+
+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', () => {
path: packages/manager/cypress/e2e/core/firewalls/create-firewall.spec.ts
user: login: coliu-akamai
body: ```suggestion
  it('confirms the create button is disabled on the FirewallLanding page', () => {
```
created_at: 2025-05-16T15:41:32Z
author_association: CONTRIBUTOR
diff_hunk: @@ -123,3 +131,64 @@ describe('create firewall', () => {
     });
   });
 });
+
+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');
+  });
+
+  /*
+   * - Verifies that restricted user cannot create firewall in drawer
+   */
+  it('create firewall drawer is disabled', () => {
path: packages/manager/cypress/e2e/core/firewalls/create-firewall.spec.ts
user: login: coliu-akamai
body: ```suggestion
  it('confirms the Create Firewall drawer is disabled', () => {
```
created_at: 2025-05-16T15:41:50Z
author_association: CONTRIBUTOR
diff_hunk: @@ -123,3 +131,64 @@ describe('create firewall', () => {
     });
   });
 });
+
+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');
+  });
+
+  /*
+   * - Verifies that restricted user cannot create firewall in drawer
+   */
+  it('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');
path: packages/manager/cypress/e2e/core/firewalls/create-firewall.spec.ts
user: login: dmcintyr-akamai
body: i added scrollIntoView
created_at: 2025-05-19T13:54:13Z
author_association: CONTRIBUTOR
diff_hunk: @@ -123,3 +131,65 @@ describe('create firewall', () => {
     });
   });
 });
+
+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('confirms the create button is disabled on the FirewallLanding page', () => {
+    cy.visitWithLogin('/firewalls');
+    ui.button
+      .findByTitle('Create Firewall')
+      .should('be.visible')
+      .should('be.disabled');
+  });
+
+  /*
+   * - Verifies that restricted user cannot create firewall in drawer
+   */
+  it('confirms the Create Firewall is disabled', () => {
path: packages/manager/cypress/e2e/core/firewalls/create-firewall.spec.ts
user: login: jdamore-linode
body: ```suggestion
  it('confirms the Create Firewall button is disabled in create drawer', () => {
```
(or something like that)
created_at: 2025-05-19T19:00:30Z
author_association: CONTRIBUTOR
diff_hunk: @@ -123,3 +131,65 @@ describe('create firewall', () => {
     });
   });
 });
+
+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('confirms the create button is disabled on the FirewallLanding page', () => {
path: packages/manager/cypress/e2e/core/firewalls/create-firewall.spec.ts
user: login: jdamore-linode
body: ```suggestion
  it('confirms the create button is disabled on the Firewall Landing page', () => {
```
created_at: 2025-05-19T19:00:38Z
author_association: CONTRIBUTOR

PR comments:
user: login: linode-gh-bot
created_at: 2025-05-19T14:46:59Z
body: <!-- PULL REQUEST COMMENT: cloud-manager-ci-comment -->
<!-- BEGIN COMMENT SECTION: cloud-manager-ui-tests -->
## Cloud Manager UI test results
### :tada: 595 passing tests on [test run #4 ↗︎](https://baker.linode.com/job/manager/job/manager-test/job/PR-12237/4/display/redirect)

<table><thead><tr><td><strong>:x: Failing</strong></td><td><strong>:white_check_mark: Passing</strong></td><td><strong>:arrow_right_hook: Skipped</strong></td><td><strong>:clock1: Duration</strong></td></tr></thead><tbody><tr><td><code>0 Failing</code></td><td><code>595 Passing</code></td><td><code>4 Skipped</code></td><td><code>114m 40s</code></td></tr></tbody></table>
<!-- END COMMENT SECTION: cloud-manager-ui-tests -->
author_association: NONE