Skip to content
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

test: Update Object Storage tests to mock account capabilities as needed #10602

Merged
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-10602-tests-1718985699307.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

Update Object Storage tests to mock account capabilities as needed for multi cluster ([#10602](https://github.com/linode/manager/pull/10602))
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { makeFeatureFlagData } from 'support/util/feature-flags';
import { randomLabel } from 'support/util/random';
import { ui } from 'support/ui';
import { cleanUp } from 'support/util/cleanup';
import { mockGetAccount } from 'support/intercepts/account';
import { accountFactory } from 'src/factories';

authenticate();
describe('object storage access key end-to-end tests', () => {
Expand All @@ -37,6 +39,7 @@ describe('object storage access key end-to-end tests', () => {
interceptGetAccessKeys().as('getKeys');
interceptCreateAccessKey().as('createKey');

mockGetAccount(accountFactory.build({ capabilities: [] }));
mockAppendFeatureFlags({
objMultiCluster: makeFeatureFlagData(false),
});
Expand Down Expand Up @@ -131,6 +134,7 @@ describe('object storage access key end-to-end tests', () => {
).then(() => {
const keyLabel = randomLabel();

mockGetAccount(accountFactory.build({ capabilities: [] }));
mockAppendFeatureFlags({
objMultiCluster: makeFeatureFlagData(false),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ import {
randomString,
} from 'support/util/random';
import { ui } from 'support/ui';
import { regionFactory } from 'src/factories';
import { accountFactory, regionFactory } from 'src/factories';
import { mockGetRegions } from 'support/intercepts/regions';
import { buildArray } from 'support/util/arrays';
import { Scope } from '@linode/api-v4';
import { mockGetAccount } from 'support/intercepts/account';

describe('object storage access keys smoke tests', () => {
/*
Expand All @@ -44,6 +45,7 @@ describe('object storage access keys smoke tests', () => {
secret_key: randomString(39),
});

mockGetAccount(accountFactory.build({ capabilities: [] }));
mockAppendFeatureFlags({
objMultiCluster: makeFeatureFlagData(false),
});
Expand Down Expand Up @@ -115,6 +117,7 @@ describe('object storage access keys smoke tests', () => {
secret_key: randomString(39),
});

mockGetAccount(accountFactory.build({ capabilities: [] }));
mockAppendFeatureFlags({
objMultiCluster: makeFeatureFlagData(false),
});
Expand Down Expand Up @@ -164,6 +167,11 @@ describe('object storage access keys smoke tests', () => {
const mockRegions = [...mockRegionsObj, ...mockRegionsNoObj];

beforeEach(() => {
mockGetAccount(
accountFactory.build({
capabilities: ['Object Storage Access Key Regions'],
})
);
mockAppendFeatureFlags({
objMultiCluster: makeFeatureFlagData(true),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ import {
profileFactory,
regionFactory,
objectStorageKeyFactory,
accountFactory,
} from '@src/factories';
import { mockGetAccountSettings } from 'support/intercepts/account';
import {
mockGetAccount,
mockGetAccountSettings,
} from 'support/intercepts/account';
import {
mockCancelObjectStorage,
mockCreateAccessKey,
Expand Down Expand Up @@ -56,6 +60,7 @@ describe('Object Storage enrollment', () => {
* - Confirms that consistent pricing information is shown for all regions in the enable modal.
*/
it('can enroll in Object Storage', () => {
mockGetAccount(accountFactory.build({ capabilities: [] }));
mockAppendFeatureFlags({
objMultiCluster: makeFeatureFlagData(false),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

import 'cypress-file-upload';
import { createBucket } from '@linode/api-v4/lib/object-storage';
import { objectStorageBucketFactory } from 'src/factories';
import { accountFactory, objectStorageBucketFactory } from 'src/factories';
import { authenticate } from 'support/api/authentication';
import { interceptGetNetworkUtilization } from 'support/intercepts/account';
import {
interceptGetNetworkUtilization,
mockGetAccount,
} from 'support/intercepts/account';
import {
interceptCreateBucket,
interceptDeleteBucket,
Expand Down Expand Up @@ -132,6 +135,7 @@ describe('object storage end-to-end tests', () => {
interceptDeleteBucket(bucketLabel, bucketCluster).as('deleteBucket');
interceptGetNetworkUtilization().as('getNetworkUtilization');

mockGetAccount(accountFactory.build({ capabilities: [] }));
mockAppendFeatureFlags({
objMultiCluster: makeFeatureFlagData(false),
}).as('getFeatureFlags');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import {
import { makeFeatureFlagData } from 'support/util/feature-flags';
import { randomLabel, randomString } from 'support/util/random';
import { ui } from 'support/ui';
import { regionFactory } from 'src/factories';
import { accountFactory, regionFactory } from 'src/factories';
import { mockGetAccount } from 'support/intercepts/account';

describe('object storage smoke tests', () => {
/*
Expand Down Expand Up @@ -56,6 +57,11 @@ describe('object storage smoke tests', () => {
objects: 0,
});

mockGetAccount(
accountFactory.build({
capabilities: ['Object Storage Access Key Regions'],
})
);
mockAppendFeatureFlags({
objMultiCluster: makeFeatureFlagData(true),
}).as('getFeatureFlags');
Expand Down Expand Up @@ -160,6 +166,7 @@ describe('object storage smoke tests', () => {
hostname: bucketHostname,
});

mockGetAccount(accountFactory.build({ capabilities: [] }));
mockAppendFeatureFlags({
objMultiCluster: makeFeatureFlagData(false),
}).as('getFeatureFlags');
Expand Down Expand Up @@ -286,7 +293,7 @@ describe('object storage smoke tests', () => {
* - Mocks existing buckets.
* - Deletes mocked bucket, confirms that landing page reflects deletion.
*/
it('can delete object storage bucket - smoke', () => {
it('can delete object storage bucket - smoke - Multi Cluster Disabled', () => {
const bucketLabel = randomLabel();
const bucketCluster = 'us-southeast-1';
const bucketMock = objectStorageBucketFactory.build({
Expand All @@ -296,6 +303,12 @@ describe('object storage smoke tests', () => {
objects: 0,
});

mockGetAccount(accountFactory.build({ capabilities: [] }));
mockAppendFeatureFlags({
objMultiCluster: makeFeatureFlagData(false),
});
mockGetFeatureFlagClientstream();

mockGetBuckets([bucketMock]).as('getBuckets');
mockDeleteBucket(bucketLabel, bucketCluster).as('deleteBucket');

Expand Down Expand Up @@ -324,4 +337,58 @@ describe('object storage smoke tests', () => {
cy.wait('@deleteBucket');
cy.findByText('S3-compatible storage solution').should('be.visible');
});

/*
* - Tests core object storage bucket deletion flow using mocked API responses.
* - Mocks existing buckets.
* - Deletes mocked bucket, confirms that landing page reflects deletion.
*/
it('can delete object storage bucket - smoke - Multi Cluster Enabled', () => {
const bucketLabel = randomLabel();
const bucketCluster = 'us-southeast-1';
const bucketMock = objectStorageBucketFactory.build({
label: bucketLabel,
cluster: bucketCluster,
hostname: `${bucketLabel}.${bucketCluster}.linodeobjects.com`,
objects: 0,
});

mockGetAccount(
accountFactory.build({
capabilities: ['Object Storage Access Key Regions'],
})
);
mockAppendFeatureFlags({
objMultiCluster: makeFeatureFlagData(true),
});
mockGetFeatureFlagClientstream();

mockGetBuckets([bucketMock]).as('getBuckets');
mockDeleteBucket(bucketLabel, bucketMock.region!).as('deleteBucket');

cy.visitWithLogin('/object-storage');
cy.wait('@getBuckets');

cy.findByText(bucketLabel)
.should('be.visible')
.closest('tr')
.within(() => {
cy.findByText('Delete').should('be.visible').click();
});

ui.dialog
.findByTitle(`Delete Bucket ${bucketLabel}`)
.should('be.visible')
.within(() => {
cy.findByLabelText('Bucket Name').click().type(bucketLabel);
ui.buttonGroup
.findButtonByTitle('Delete')
.should('be.enabled')
.should('be.visible')
.click();
});

cy.wait('@deleteBucket');
cy.findByText('S3-compatible storage solution').should('be.visible');
});
});
Loading