-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [UIE-8196] - DBaaS create encourage users to add IP allow_list
- Loading branch information
1 parent
7735a37
commit a63bd41
Showing
6 changed files
with
308 additions
and
42 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-11124-upcoming-features-1729198459249.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Upcoming Features | ||
--- | ||
|
||
DBaaS encourage setting access controls during create ([#11124](https://github.com/linode/manager/pull/11124)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
packages/manager/src/features/Databases/DatabaseCreate/DatabaseCreateAccessControls.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { fireEvent } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { renderWithTheme } from 'src/utilities/testHelpers'; | ||
import { DatabaseCreateAccessControls } from './DatabaseCreateAccessControls'; | ||
import { IsDatabasesEnabled, useIsDatabasesEnabled } from '../utilities'; | ||
|
||
vi.mock('src/features/Databases/utilities'); | ||
|
||
describe('DatabaseCreateAccessControls', () => { | ||
beforeEach(() => { | ||
vi.resetAllMocks(); | ||
}); | ||
|
||
it('Should render enabled', () => { | ||
vi.mocked(useIsDatabasesEnabled).mockReturnValue({ | ||
isDatabasesV2GA: true, | ||
} as IsDatabasesEnabled); | ||
|
||
const ips = [{ address: '' }]; | ||
const { container, getAllByText, getAllByTestId } = renderWithTheme( | ||
<DatabaseCreateAccessControls | ||
ips={ips} | ||
onBlur={() => {}} | ||
onChange={() => {}} | ||
/> | ||
); | ||
|
||
expect(getAllByText('Add Access Controls')).toHaveLength(1); | ||
expect(getAllByTestId('domain-transfer-input')).toHaveLength(1); | ||
expect(getAllByTestId('button')).toHaveLength(1); | ||
|
||
const specificRadio = container.querySelector( | ||
'[data-qa-dbaas-radio="Specific"]' | ||
); | ||
const noneRadio = container.querySelector('[data-qa-dbaas-radio="None"]'); | ||
const enabledButtons = container.querySelectorAll( | ||
'[aria-disabled="false"]' | ||
); | ||
|
||
expect(specificRadio).toBeInTheDocument(); | ||
expect(noneRadio).toBeInTheDocument(); | ||
expect(enabledButtons).toHaveLength(1); | ||
}); | ||
|
||
it('Should render ips', () => { | ||
vi.mocked(useIsDatabasesEnabled).mockReturnValue({ | ||
isDatabasesV2GA: true, | ||
} as IsDatabasesEnabled); | ||
|
||
const ips = [ | ||
{ address: '1.1.1.1/32' }, | ||
{ address: '2.2.2.2' }, | ||
{ address: '3.3.3.3/128' }, | ||
]; | ||
const { container, getAllByText, getAllByTestId } = renderWithTheme( | ||
<DatabaseCreateAccessControls | ||
ips={ips} | ||
onBlur={() => {}} | ||
onChange={() => {}} | ||
/> | ||
); | ||
|
||
expect(getAllByText('Add Access Controls')).toHaveLength(1); | ||
expect(getAllByTestId('domain-transfer-input')).toHaveLength(3); | ||
expect(getAllByTestId('button')).toHaveLength(3); | ||
|
||
const specificRadio = container.querySelector( | ||
'[data-qa-dbaas-radio="Specific"]' | ||
); | ||
const noneRadio = container.querySelector('[data-qa-dbaas-radio="None"]'); | ||
const enabledButtons = container.querySelectorAll( | ||
'[aria-disabled="false"]' | ||
); | ||
|
||
expect(specificRadio).toBeInTheDocument(); | ||
expect(noneRadio).toBeInTheDocument(); | ||
expect(enabledButtons).toHaveLength(3); | ||
}); | ||
|
||
it('Should disable ips', () => { | ||
vi.mocked(useIsDatabasesEnabled).mockReturnValue({ | ||
isDatabasesV2GA: true, | ||
} as IsDatabasesEnabled); | ||
|
||
const ips = [{ address: '1.1.1.1/32' }]; | ||
const { container, getAllByText, getAllByTestId } = renderWithTheme( | ||
<DatabaseCreateAccessControls | ||
ips={ips} | ||
onBlur={() => {}} | ||
onChange={() => {}} | ||
/> | ||
); | ||
|
||
expect(getAllByText('Add Access Controls')).toHaveLength(1); | ||
expect(getAllByTestId('domain-transfer-input')).toHaveLength(1); | ||
expect(getAllByTestId('button')).toHaveLength(1); | ||
|
||
let enabledButtons = container.querySelectorAll('[aria-disabled="false"]'); | ||
expect(enabledButtons).toHaveLength(1); | ||
|
||
const noneRadio = container.querySelector('[data-qa-dbaas-radio="None"]'); | ||
fireEvent.click(noneRadio as Element); | ||
|
||
enabledButtons = container.querySelectorAll('[aria-disabled="false"]'); | ||
expect(enabledButtons).toHaveLength(0); | ||
}); | ||
}); |
Oops, something went wrong.