Skip to content

Commit

Permalink
test: [M3-7511, M3-9147] restricted user has disabled inputs on objec…
Browse files Browse the repository at this point in the history
…t storage creation (#11560)

* M3-7511 refactoring, add tests for landing page

* M3-7511 restore disabled tests

* M3-7511 corrections

* Added changeset: tests of object storage creation form for restricted user

* M3-7511 edits after pr feedback

* M3-7511 edits after pr comments

* Update packages/manager/.changeset/pr-11560-tests-1737658018185.md

Co-authored-by: Mariah Jacobs <114685994+mjac0bs@users.noreply.github.com>

---------

Co-authored-by: Mariah Jacobs <114685994+mjac0bs@users.noreply.github.com>
  • Loading branch information
dmcintyr-akamai and mjac0bs authored Jan 29, 2025
1 parent b162db8 commit 92b419c
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11560-tests-1737658018185.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

Add Cypress tests for object storage creation form for restricted user ([#11560](https://github.com/linode/manager/pull/11560))
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { mockGetAccount } from 'support/intercepts/account';
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
import { mockGetProfile } from 'support/intercepts/profile';
import { mockGetAccessKeys } from 'support/intercepts/object-storage';
import { accountFactory, objectStorageKeyFactory } from 'src/factories';
import { profileFactory } from 'src/factories/profile';
import { ui } from 'support/ui';

describe('Object Storage gen2 access keys tests', () => {
Expand Down Expand Up @@ -85,3 +87,55 @@ describe('Object Storage gen2 access keys tests', () => {
});
});
});

/**
* When a restricted user navigates to object-storage/access-keys/create, an error is shown in the "Create Access Key" drawer noting that the user does not have access key creation permissions
*/
describe('Object Storage Gen2 create access key modal has disabled fields for restricted user', () => {
beforeEach(() => {
mockAppendFeatureFlags({
objMultiCluster: true,
objectStorageGen2: { enabled: true },
}).as('getFeatureFlags');
mockGetAccount(
accountFactory.build({
capabilities: [
'Object Storage',
'Object Storage Endpoint Types',
'Object Storage Access Key Regions',
],
})
).as('getAccount');
// restricted user
mockGetProfile(
profileFactory.build({
email: 'mock-user@linode.com',
restricted: true,
})
).as('getProfile');
});

// access keys creation
it('create access keys form', () => {
cy.visitWithLogin('/object-storage/access-keys/create');

cy.wait(['@getFeatureFlags', '@getAccount', '@getProfile']);
// error message
ui.drawer
.findByTitle('Create Access Key')
.should('be.visible')
.within(() => {
cy.findByText(
/You don't have bucket_access to create an Access Key./
).should('be.visible');
// label
cy.findByLabelText(/Label.*/)
.should('be.visible')
.should('be.disabled');
// region
ui.regionSelect.find().should('be.visible').should('be.disabled');
// submit button is disabled
cy.findByTestId('submit').should('be.visible').should('be.disabled');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
mockGetBucketAccess,
mockCreateBucketError,
} from 'support/intercepts/object-storage';
import { mockGetProfile } from 'support/intercepts/profile';
import { mockGetRegions } from 'support/intercepts/regions';
import { ui } from 'support/ui';
import { checkRateLimitsTable } from 'support/util/object-storage-gen2';
Expand All @@ -18,6 +19,7 @@ import {
objectStorageEndpointsFactory,
regionFactory,
} from 'src/factories';
import { profileFactory } from 'src/factories/profile';
import { chooseRegion } from 'support/util/regions';
import type { ACLType, ObjectStorageEndpoint } from '@linode/api-v4';

Expand Down Expand Up @@ -716,3 +718,55 @@ describe('Object Storage Gen2 create bucket tests', () => {
});
});
});

/**
* When a restricted user navigates to object-storage/buckets/create, an error is shown in the "Create Bucket" drawer noting that the user does not have bucket creation permissions
*/
describe('Object Storage Gen2 create bucket modal has disabled fields for restricted user', () => {
beforeEach(() => {
mockAppendFeatureFlags({
objMultiCluster: true,
objectStorageGen2: { enabled: true },
}).as('getFeatureFlags');
mockGetAccount(
accountFactory.build({
capabilities: [
'Object Storage',
'Object Storage Endpoint Types',
'Object Storage Access Key Regions',
],
})
).as('getAccount');
// restricted user
mockGetProfile(
profileFactory.build({
email: 'mock-user@linode.com',
restricted: true,
})
).as('getProfile');
});

// bucket creation
it('create bucket form', () => {
cy.visitWithLogin('/object-storage/buckets/create');
cy.wait(['@getFeatureFlags', '@getAccount', '@getProfile']);

// error message
ui.drawer
.findByTitle('Create Bucket')
.should('be.visible')
.within(() => {
cy.findByText(/You don't have permissions to create a Bucket./).should(
'be.visible'
);
cy.findByLabelText(/Label.*/)
.should('be.visible')
.should('be.disabled');
ui.regionSelect.find().should('be.visible').should('be.disabled');
// submit button should be enabled
cy.findByTestId('create-bucket-button')
.should('be.visible')
.should('be.enabled');
});
});
});

0 comments on commit 92b419c

Please sign in to comment.