Skip to content

Commit

Permalink
feat: [UIE-8194] - DBaaS major and minor upgrades - 4
Browse files Browse the repository at this point in the history
  • Loading branch information
corya-akamai committed Nov 5, 2024
1 parent d60510e commit ae81c26
Show file tree
Hide file tree
Showing 8 changed files with 256 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

DBaaS major minor updates integration ([#11199](https://github.com/linode/manager/pull/11199))
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import React from 'react';
import MongoDBIcon from 'src/assets/icons/mongodb.svg';
import MySQLIcon from 'src/assets/icons/mysql.svg';
import PostgreSQLIcon from 'src/assets/icons/postgresql.svg';

import { databaseEngineMap } from '../DatabaseLanding/DatabaseRow';
import { getDatabasesDescription } from 'src/features/Databases/utilities';

import type { DatabaseEngine } from '@linode/api-v4';

Expand Down Expand Up @@ -101,9 +100,10 @@ export const getEngineOptions = (engines: DatabaseEngine[]) => {
.map((engineObject) => ({
...engineObject,
flag: engineIcons[engineObject.engine],
label: `${databaseEngineMap[engineObject.engine]} v${
engineObject.version
}`,
label: getDatabasesDescription({
engine: engineObject.engine,
version: engineObject.version,
}),
value: `${engineObject.engine}/${engineObject.version}`,
}))
.sort((a, b) => (a.version > b.version ? -1 : 1)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import * as React from 'react';
import { CircleProgress } from 'src/components/CircleProgress';
import { ErrorState } from 'src/components/ErrorState/ErrorState';
import { TooltipIcon } from 'src/components/TooltipIcon';
import { DatabaseEngineVersion } from 'src/features/Databases/DatabaseEngineVersion';
import { useDatabaseTypesQuery } from 'src/queries/databases/databases';
import { useInProgressEvents } from 'src/queries/events/events';
import { useRegionsQuery } from 'src/queries/regions/regions';
import { formatStorageUnits } from 'src/utilities/formatStorageUnits';
import { convertMegabytesTo } from 'src/utilities/unitConversions';

import { databaseEngineMap } from '../../DatabaseLanding/DatabaseRow';
import { DatabaseStatusDisplay } from '../DatabaseStatusDisplay';
import {
StyledStatusBox,
Expand All @@ -24,18 +24,13 @@ import {
import type { Region } from '@linode/api-v4';
import type {
Database,
DatabaseInstance,
DatabaseType,
} from '@linode/api-v4/lib/databases/types';

interface Props {
database: Database;
}

export const getDatabaseVersionNumber = (
version: DatabaseInstance['version']
) => version.split('/')[1];

export const DatabaseResizeCurrentConfiguration = ({ database }: Props) => {
const {
data: types,
Expand Down Expand Up @@ -94,7 +89,13 @@ export const DatabaseResizeCurrentConfiguration = ({ database }: Props) => {
</StyledSummaryTextBox>
<StyledSummaryTextTypography>
<span style={{ fontFamily: theme.font.bold }}>Version</span>{' '}
{databaseEngineMap[database.engine]} v{database.version}
<DatabaseEngineVersion
databaseEngine={database.engine}
databaseID={database.id}
databasePendingUpdates={database.updates.pending}
databasePlatform={database.platform}
databaseVersion={database.version}
/>
</StyledSummaryTextTypography>
<StyledSummaryTextTypography>
<span style={{ fontFamily: theme.font.bold }}>Nodes</span>{' '}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,63 @@ import * as React from 'react';
import { databaseFactory } from 'src/factories/databases';
import { renderWithTheme } from 'src/utilities/testHelpers';

import * as utils from '../../utilities';
import DatabaseSettings from './DatabaseSettings';

const v1 = () => {
return {
isDatabasesEnabled: true,
isDatabasesV1Enabled: true,
isDatabasesV2Beta: false,
isDatabasesV2Enabled: false,
isDatabasesV2GA: false,
isUserExistingBeta: false,
isUserNewBeta: false,
};
};

const v2Beta = () => {
return {
isDatabasesEnabled: true,
isDatabasesV1Enabled: true,
isDatabasesV2Beta: true,
isDatabasesV2Enabled: true,
isDatabasesV2GA: false,
isUserExistingBeta: false,
isUserNewBeta: true,
};
};

const v2GA = () => ({
isDatabasesEnabled: true,
isDatabasesV1Enabled: true,
isDatabasesV2Beta: false,
isDatabasesV2Enabled: true,
isDatabasesV2GA: true,
isUserExistingBeta: false,
isUserNewBeta: false,
});

const spy = vi.spyOn(utils, 'useIsDatabasesEnabled');
spy.mockReturnValue(v2GA());

describe('DatabaseSettings Component', () => {
const database = databaseFactory.build();
it('Should exist and be renderable', () => {
expect(DatabaseSettings).toBeDefined();
renderWithTheme(<DatabaseSettings database={database} />);
});

it('Should render a Paper component with headers for Manage Access, Reseting the Root password, and Deleting the Cluster', () => {
it('Should render a Paper component with headers for Access Controls, Reseting the Root password, and Deleting the Cluster', () => {
const { container, getAllByRole } = renderWithTheme(
<DatabaseSettings database={database} />
);
const paper = container.querySelector('.MuiPaper-root');
expect(paper).not.toBeNull();
const headings = getAllByRole('heading');
expect(headings[0].textContent).toBe('Manage Access');
expect(headings[1].textContent).toBe('Reset the Root Password');
expect(headings[2].textContent).toBe('Delete the Cluster');
expect(headings[0].textContent).toBe('Access Controls');

Check failure on line 60 in packages/manager/src/features/Databases/DatabaseDetail/DatabaseSettings/DatabaseSettings.test.tsx

View workflow job for this annotation

GitHub Actions / test-manager

src/features/Databases/DatabaseDetail/DatabaseSettings/DatabaseSettings.test.tsx > DatabaseSettings Component > Should render a Paper component with headers for Access Controls, Reseting the Root password, and Deleting the Cluster

AssertionError: expected 'Manage Access' to be 'Access Controls' // Object.is equality Expected: "Access Controls" Received: "Manage Access" ❯ src/features/Databases/DatabaseDetail/DatabaseSettings/DatabaseSettings.test.tsx:60:37
expect(headings[1].textContent).toBe('Reset Root Password');
expect(headings[2].textContent).toBe('Delete Cluster');
});

it.each([
Expand All @@ -33,7 +71,7 @@ describe('DatabaseSettings Component', () => {
);
const button1 = getByTitle('Reset Root Password');
const button2 = getByTitle('Save Changes');
const button3 = getByRole('button', { name: 'Manage Access' });
const button3 = getByRole('button', { name: 'Manage Access Controls' });

Check failure on line 74 in packages/manager/src/features/Databases/DatabaseDetail/DatabaseSettings/DatabaseSettings.test.tsx

View workflow job for this annotation

GitHub Actions / test-manager

src/features/Databases/DatabaseDetail/DatabaseSettings/DatabaseSettings.test.tsx > DatabaseSettings Component > should disable buttons when disabled is true

TestingLibraryElementError: Unable to find an accessible element with the role "button" and name "Manage Access Controls" Here are the accessible roles: heading: Name "Manage Access": <h3 class="MuiTypography-root MuiTypography-h3 css-9g9f26-MuiTypography-root" /> Name "Reset Root Password": <h3 class="MuiTypography-root MuiTypography-h3 css-1637llw-sectionTitle css-9g9f26-MuiTypography-root" /> Name "Delete Cluster": <h3 class="MuiTypography-root MuiTypography-h3 css-1637llw-sectionTitle css-9g9f26-MuiTypography-root" /> Name "Maintenance": <h3 class="MuiTypography-root MuiTypography-h3 css-10qifdj-MuiTypography-root" /> Name "Maintenance updates": <h3 class="MuiTypography-root MuiTypography-h3 css-10qifdj-MuiTypography-root" /> Name "Set a Weekly Maintenance Window": <h3 class="MuiTypography-root MuiTypography-h3 css-1637llw-sectionTitle css-9g9f26-MuiTypography-root" /> -------------------------------------------------- paragraph: Name "": <p class="MuiTypography-root MuiTypography-body1 css-4ofmxk-MuiTypography-root" /> Name "": <p class="MuiTypography-root MuiTypography-body1 css-6ye6nj-sectionText css-4ofmxk-MuiTypography-root" /> Name "": <p class="MuiTypography-root MuiTypography-body1 css-6ye6nj-sectionText css-4ofmxk-MuiTypography-root" /> Name "": <p class="MuiTypography-root MuiTypography-body1 css-cdz35h-MuiTypography-root" /> Name "": <p class="MuiTypography-root MuiTypography-body1 css-1p5ygtj-MuiTypography-root" /> Name "": <p class="MuiTypography-root MuiTypography-body1 css-cdz35h-MuiTypography-root" /> Name "": <p class="MuiTypography-root MuiTypography-body1 css-6ye6nj-sectionText css-4ofmxk-MuiTypography-root" /> -------------------------------------------------- button: Name "Manage Access": <button aria-disabled="true" class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary css-1f9lt71-addAccessControlBtn css-wkum4l-MuiButtonBase-root-MuiButton-root" data-testid="button-access-control" tabindex="0" type="button" /> Name "Remove": <button aria-disabled="true" class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary css-b4omc2-MuiButtonBase-root-MuiButton-root-StyledActionButton" data-testid="button" tabindex="0" type="button" /> Name "Remove": <button aria-disabled="true" class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary css-b4omc2-MuiButtonBase-root-MuiButton-root-StyledActionButton" data-testid="button" tabindex="0" type="button" /> Name "Remove": <button aria-disabled="true" class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary css-b4omc2-MuiButtonBase-root-MuiButton-root-StyledActionButton" data-testid="button" tabindex="0" type="button" /> Name "Reset Root Password": <button aria-disabled="true" class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary MuiButton-r

Check failure on line 74 in packages/manager/src/features/Databases/DatabaseDetail/DatabaseSettings/DatabaseSettings.test.tsx

View workflow job for this annotation

GitHub Actions / test-manager

src/features/Databases/DatabaseDetail/DatabaseSettings/DatabaseSettings.test.tsx > DatabaseSettings Component > should enable buttons when disabled is false

TestingLibraryElementError: Unable to find an accessible element with the role "button" and name "Manage Access Controls" Here are the accessible roles: heading: Name "Manage Access": <h3 class="MuiTypography-root MuiTypography-h3 css-9g9f26-MuiTypography-root" /> Name "Reset Root Password": <h3 class="MuiTypography-root MuiTypography-h3 css-1637llw-sectionTitle css-9g9f26-MuiTypography-root" /> Name "Delete Cluster": <h3 class="MuiTypography-root MuiTypography-h3 css-1637llw-sectionTitle css-9g9f26-MuiTypography-root" /> Name "Maintenance": <h3 class="MuiTypography-root MuiTypography-h3 css-10qifdj-MuiTypography-root" /> Name "Maintenance updates": <h3 class="MuiTypography-root MuiTypography-h3 css-10qifdj-MuiTypography-root" /> Name "Set a Weekly Maintenance Window": <h3 class="MuiTypography-root MuiTypography-h3 css-1637llw-sectionTitle css-9g9f26-MuiTypography-root" /> -------------------------------------------------- paragraph: Name "": <p class="MuiTypography-root MuiTypography-body1 css-4ofmxk-MuiTypography-root" /> Name "": <p class="MuiTypography-root MuiTypography-body1 css-6ye6nj-sectionText css-4ofmxk-MuiTypography-root" /> Name "": <p class="MuiTypography-root MuiTypography-body1 css-6ye6nj-sectionText css-4ofmxk-MuiTypography-root" /> Name "": <p class="MuiTypography-root MuiTypography-body1 css-cdz35h-MuiTypography-root" /> Name "": <p class="MuiTypography-root MuiTypography-body1 css-1p5ygtj-MuiTypography-root" /> Name "": <p class="MuiTypography-root MuiTypography-body1 css-cdz35h-MuiTypography-root" /> Name "": <p class="MuiTypography-root MuiTypography-body1 css-6ye6nj-sectionText css-4ofmxk-MuiTypography-root" /> -------------------------------------------------- button: Name "Manage Access": <button aria-disabled="false" class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary css-1f9lt71-addAccessControlBtn css-wkum4l-MuiButtonBase-root-MuiButton-root" data-testid="button-access-control" tabindex="0" type="button" /> Name "Remove": <button aria-disabled="false" class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary css-1td0z7f-MuiButtonBase-root-MuiButton-root-StyledActionButton" data-testid="button" tabindex="0" type="button" /> Name "Remove": <button aria-disabled="false" class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary css-1td0z7f-MuiButtonBase-root-MuiButton-root-StyledActionButton" data-testid="button" tabindex="0" type="button" /> Name "Remove": <button aria-disabled="false" class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary css-1td0z7f-MuiButtonBase-root-MuiButton-root-StyledActionButton" data-testid="button" tabindex="0" type="button" /> Name "Reset Root Password": <button aria-disabled="false" class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary Mui

if (isDisabled) {
expect(button1).toBeDisabled();
Expand All @@ -45,6 +83,106 @@ describe('DatabaseSettings Component', () => {
}
});

it('should not render Maintenance for V1 view legacy db', async () => {
spy.mockReturnValue(v1());

const database = databaseFactory.build({
engine: 'postgresql',
platform: 'rdbms-legacy',
version: '14.6',
});

const { container } = renderWithTheme(
<DatabaseSettings database={database} />
);

const maintenance = container.querySelector(
'[data-qa-settings-section="Maintenance"]'
);

expect(maintenance).not.toBeInTheDocument();
});

it('should not render Maintenance for V2 beta view legacy db', async () => {
spy.mockReturnValue(v2Beta());

const database = databaseFactory.build({
engine: 'postgresql',
platform: 'rdbms-legacy',
version: '14.6',
});

const { container } = renderWithTheme(
<DatabaseSettings database={database} />
);

const maintenance = container.querySelector(
'[data-qa-settings-section="Maintenance"]'
);

expect(maintenance).not.toBeInTheDocument();
});

it('should not render Maintenance for V2 beta view default db', async () => {
spy.mockReturnValue(v2Beta());

const database = databaseFactory.build({
engine: 'postgresql',
platform: 'rdbms-default',
version: '14.6',
});

const { container } = renderWithTheme(
<DatabaseSettings database={database} />
);

const maintenance = container.querySelector(
'[data-qa-settings-section="Maintenance"]'
);

expect(maintenance).not.toBeInTheDocument();
});

it('should not render Maintenance for V2 GA view legacy db', async () => {
spy.mockReturnValue(v2GA());

const database = databaseFactory.build({
engine: 'postgresql',
platform: 'rdbms-legacy',
version: '14.6',
});

const { container } = renderWithTheme(
<DatabaseSettings database={database} />
);

const maintenance = container.querySelector(
'[data-qa-settings-section="Maintenance"]'
);

expect(maintenance).not.toBeInTheDocument();
});

it('should render Maintenance for V2 GA view default db', async () => {
spy.mockReturnValue(v2GA());

const database = databaseFactory.build({
engine: 'postgresql',
platform: 'rdbms-default',
version: '14.6',
});

const { container } = renderWithTheme(
<DatabaseSettings database={database} />
);

const maintenance = container.querySelector(
'[data-qa-settings-section="Maintenance"]'
);

expect(maintenance).toBeInTheDocument();
});

it('Should render Maintenance Window with radio buttons', () => {
const database = databaseFactory.build({
platform: 'rdbms-legacy',
Expand Down
Loading

0 comments on commit ae81c26

Please sign in to comment.