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: Fix DBaaS tests after API update #9801

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

Fix DBaaS UI test failures stemming from API update ([#9801](https://github.com/linode/manager/pull/9801))
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import {
databaseClusterConfiguration,
databaseConfigurations,
mockDatabaseEngineTypes,
mockDatabaseNodeTypes,
} from 'support/constants/databases';
import {
mockCreateDatabase,
mockGetDatabases,
mockGetDatabaseEngines,
mockGetDatabaseTypes,
} from 'support/intercepts/databases';
import { mockGetEvents } from 'support/intercepts/events';
import { getRegionById } from 'support/util/regions';
Expand Down Expand Up @@ -71,9 +73,10 @@ describe('create a database cluster, mocked data', () => {
);
mockCreateDatabase(databaseMock).as('createDatabase');
mockGetDatabases([databaseMock]).as('getDatabases');
mockGetDatabaseTypes(mockDatabaseNodeTypes).as('getDatabaseTypes');

cy.visitWithLogin('/databases/create');
cy.wait(['@getAccount', '@getDatabaseEngines']);
cy.wait(['@getAccount', '@getDatabaseEngines', '@getDatabaseTypes']);

ui.entityHeader
.find()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import {
mockDeleteDatabase,
mockDeleteProvisioningDatabase,
mockGetDatabase,
mockGetDatabaseTypes,
} from 'support/intercepts/databases';
import { ui } from 'support/ui';
import {
databaseClusterConfiguration,
databaseConfigurations,
mockDatabaseNodeTypes,
} from 'support/constants/databases';

describe('Delete database clusters', () => {
Expand All @@ -40,12 +42,13 @@ describe('Delete database clusters', () => {
// Mock account to ensure 'Managed Databases' capability.
mockGetAccount(accountFactory.build()).as('getAccount');
mockGetDatabase(database).as('getDatabase');
mockGetDatabaseTypes(mockDatabaseNodeTypes).as('getDatabaseTypes');
mockDeleteDatabase(database.id, database.engine).as('deleteDatabase');

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

// Click "Delete Cluster" button.
ui.button
Expand Down Expand Up @@ -97,6 +100,7 @@ describe('Delete database clusters', () => {

mockGetAccount(accountFactory.build()).as('getAccount');
mockGetDatabase(database).as('getDatabase');
mockGetDatabaseTypes(mockDatabaseNodeTypes).as('getDatabaseTypes');
mockDeleteProvisioningDatabase(
database.id,
database.engine,
Expand All @@ -106,7 +110,7 @@ describe('Delete database clusters', () => {
cy.visitWithLogin(
`/databases/${database.engine}/${database.id}/settings`
);
cy.wait(['@getAccount', '@getDatabase']);
cy.wait(['@getAccount', '@getDatabase', '@getDatabaseTypes']);

// Click "Delete Cluster" button.
ui.button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import {
randomIp,
randomString,
} from 'support/util/random';
import { databaseFactory } from 'src/factories/databases';
import { databaseFactory, databaseTypeFactory } from 'src/factories/databases';
import { ui } from 'support/ui';
import { mockGetAccount } from 'support/intercepts/account';
import {
mockGetDatabase,
mockGetDatabaseCredentials,
mockGetDatabaseTypes,
mockResetPassword,
mockResetPasswordProvisioningDatabase,
mockUpdateDatabase,
Expand All @@ -22,6 +23,7 @@ import {
import {
databaseClusterConfiguration,
databaseConfigurations,
mockDatabaseNodeTypes,
} from 'support/constants/databases';
import { accountFactory } from '@src/factories';

Expand Down Expand Up @@ -169,6 +171,7 @@ describe('Update database clusters', () => {
// 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(
'resetRootPassword'
);
Expand All @@ -179,7 +182,7 @@ describe('Update database clusters', () => {
).as('getCredentials');

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

cy.get('[data-qa-cluster-config]').within(() => {
cy.findByText(configuration.region.label).should('be.visible');
Expand Down Expand Up @@ -282,6 +285,7 @@ describe('Update database clusters', () => {

mockGetAccount(accountFactory.build()).as('getAccount');
mockGetDatabase(database).as('getDatabase');
mockGetDatabaseTypes(mockDatabaseNodeTypes).as('getDatabaseTypes');

mockUpdateProvisioningDatabase(
database.id,
Expand All @@ -296,7 +300,7 @@ describe('Update database clusters', () => {
).as('resetRootPassword');

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

// Cannot update database label.
updateDatabaseLabel(initialLabel, updateAttemptLabel);
Expand Down
18 changes: 16 additions & 2 deletions packages/manager/cypress/support/constants/databases.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {
import type {
ClusterSize,
Engine,
Region,
DatabaseEngine,
DatabaseType,
} from '@linode/api-v4/types';
import { randomLabel } from 'support/util/random';
import { chooseRegion } from 'support/util/regions';
import { databaseEngineFactory } from '@src/factories';
import { databaseEngineFactory, databaseTypeFactory } from '@src/factories';

export interface databaseClusterConfiguration {
clusterSize: ClusterSize;
Expand Down Expand Up @@ -39,6 +40,19 @@ export const mockDatabaseEngineTypes: DatabaseEngine[] = [
}),
];

// The database type IDs in this array should correspond to the DBaaS cluster
// `linodeType` values used by the tests.
export const mockDatabaseNodeTypes: DatabaseType[] = [
databaseTypeFactory.build({
class: 'nanode',
id: 'g6-nanode-1',
}),
databaseTypeFactory.build({
class: 'dedicated',
id: 'g6-dedicated-16',
}),
];

// Array of database cluster configurations for which to test creation.
export const databaseConfigurations: databaseClusterConfiguration[] = [
{
Expand Down
20 changes: 19 additions & 1 deletion packages/manager/cypress/support/intercepts/databases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
* @file Cypress intercepts and mocks for Cloud Manager DBaaS operations.
*/

import {
import type {
Database,
DatabaseCredentials,
DatabaseEngine,
DatabaseType,
} from '@linode/api-v4/types';
import { makeErrorResponse } from 'support/util/errors';
import { apiMatcher } from 'support/util/intercepts';
Expand Down Expand Up @@ -235,6 +236,23 @@ export const mockDeleteProvisioningDatabase = (
);
};

/**
* Intercepts GET request to fetch DBaaS node types and mocks response.
*
* @param databaseTypes - Database node types.
*
* @returns Cypress chainable.
*/
export const mockGetDatabaseTypes = (
databaseTypes: DatabaseType[]
): Cypress.Chainable<null> => {
return cy.intercept(
'GET',
apiMatcher('databases/types*'),
paginateResponse(databaseTypes)
);
};

/**
* Intercepts GET request to fetch available DBaaS engines and mocks response.
*
Expand Down