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: [M3-8616] - Fix failures in DBaaS update tests #10975

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
2 changes: 2 additions & 0 deletions docs/development-guide/09-mocking-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const linodeList = linodeFactory.buildList(10, { region: "eu-west" });
// [{ id: 3, label: 'linode-3', region: 'eu-west' }, ...9 more ]
```

Because our factories are used by our dev tools, unit tests, and end-to-end tests, we should avoid creating factories with random or unpredictable default values (e.g. by using utilities like `pickRandom` to assign property values).

### Intercepting Requests

The [Mock Service Worker](https://mswjs.io/) package intercepts requests at the network level and returns the response you defined in the relevant factory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
mockDatabaseNodeTypes,
} from 'support/constants/databases';
import { accountFactory } from '@src/factories';
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';

/**
* Updates a database cluster's label.
Expand Down Expand Up @@ -142,6 +143,32 @@ const resetRootPassword = () => {
};

describe('Update database clusters', () => {
beforeEach(() => {
const mockAccount = accountFactory.build({
capabilities: [
'Akamai Cloud Pulse',
'Block Storage',
'Cloud Firewall',
'Disk Encryption',
'Kubernetes',
'Linodes',
'LKE HA Control Planes',
'Machine Images',
'Managed Databases',
'NodeBalancers',
'Object Storage Access Key Regions',
'Object Storage Endpoint Types',
'Object Storage',
'Placement Group',
'Vlans',
],
});
mockAppendFeatureFlags({
dbaasV2: { enabled: false, beta: false },
});
mockGetAccount(mockAccount);
});

databaseConfigurations.forEach(
(configuration: databaseClusterConfiguration) => {
describe(`updates a ${configuration.linodeType} ${configuration.engine} v${configuration.version}.x ${configuration.clusterSize}-node cluster`, () => {
Expand All @@ -166,10 +193,9 @@ describe('Update database clusters', () => {
engine: configuration.dbType,
status: 'active',
allow_list: [allowedIp],
platform: 'rdbms-legacy',
});

// Mock account to ensure 'Managed Databases' capability.
mockGetAccount(accountFactory.build()).as('getAccount');
mockGetDatabase(database).as('getDatabase');
mockGetDatabaseTypes(mockDatabaseNodeTypes).as('getDatabaseTypes');
mockResetPassword(database.id, database.engine).as(
Expand All @@ -182,7 +208,7 @@ describe('Update database clusters', () => {
).as('getCredentials');

cy.visitWithLogin(`/databases/${database.engine}/${database.id}`);
cy.wait(['@getAccount', '@getDatabase', '@getDatabaseTypes']);
cy.wait(['@getDatabase', '@getDatabaseTypes']);

cy.get('[data-qa-cluster-config]').within(() => {
cy.findByText(configuration.region.label).should('be.visible');
Expand Down Expand Up @@ -283,6 +309,7 @@ describe('Update database clusters', () => {
primary: undefined,
secondary: undefined,
},
platform: 'rdbms-legacy',
});

const errorMessage =
Expand Down
Loading