fix: enable confirmation before deleting a test suite [INS-3286] (#6737)

This commit is contained in:
Hexxa 2023-11-02 09:58:49 +08:00 committed by GitHub
parent e9e1d27add
commit 3eb6141603
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 17 deletions

View File

@ -1,9 +1,22 @@
import { test } from '../../playwright/test';
test('can name design documents', async ({ page }) => {
await page.getByRole('button', { name: ' New Document' }).click();
await page.getByPlaceholder('my-spec.yaml').fill('jurassic park');
await page.getByPlaceholder('my-spec.yaml').press('Enter');
await page.getByTestId('project').click();
await page.getByLabel('jurassic park').click();
test.describe('design document operations', async () => {
test('can name design documents', async ({ page }) => {
await page.getByRole('button', { name: ' New Document' }).click();
await page.getByPlaceholder('my-spec.yaml').fill('jurassic park');
await page.getByPlaceholder('my-spec.yaml').press('Enter');
await page.getByTestId('project').click();
await page.getByLabel('jurassic park').click();
});
test('can delete a test suite with confirmation modal', async ({ page }) => {
await page.getByRole('button', { name: ' New Document' }).click();
await page.getByPlaceholder('my-spec.yaml').fill('jurassic park');
await page.getByPlaceholder('my-spec.yaml').press('Enter');
await page.getByTestId('workspace-test').click();
await page.getByText('New test suite').click();
await page.getByLabel('Test Suites').getByLabel('Project Actions').click();
await page.getByRole('menuitemradio', { name: 'Delete suite' }).click();
await page.locator('.modal__content').getByRole('button', { name: 'Delete' }).click();
});
});

View File

@ -445,6 +445,7 @@ const OrganizationRoute = () => {
: ''
} ${isPending ? 'animate-pulse' : ''} no-underline transition-colors text-center outline-none min-w-[4rem] uppercase text-[--color-font] text-xs px-[--padding-xs] py-[--padding-xxs] rounded-full`
}
data-testid={`workspace-${item.id}`}
>
{item.name}
</NavLink>

View File

@ -30,6 +30,8 @@ import {
import * as models from '../../models';
import { Environment } from '../../models/environment';
import type { UnitTestSuite } from '../../models/unit-test-suite';
import { showModal } from '../../ui/components/modals';
import { AskModal } from '../../ui/components/modals/ask-modal';
import { invariant } from '../../utils/invariant';
import { WorkspaceDropdown } from '../components/dropdowns/workspace-dropdown';
import { WorkspaceSyncDropdown } from '../components/dropdowns/workspace-sync-dropdown';
@ -109,7 +111,7 @@ const TestRoute: FC = () => {
id: string;
name: string;
icon: IconName;
action: (suiteId: string) => void;
action: (suiteId: string, suiteName: string) => void;
}[] = [
{
id: 'run-tests',
@ -150,14 +152,24 @@ const TestRoute: FC = () => {
id: 'delete-suite',
name: 'Delete suite',
icon: 'trash',
action: suiteId => {
deleteUnitTestSuiteFetcher.submit(
{},
{
action: `/organization/${organizationId}/project/${projectId}/workspace/${workspaceId}/test/test-suite/${suiteId}/delete`,
method: 'POST',
}
);
action: (suiteId, suiteName) => {
showModal(AskModal, {
title: 'Delete suite',
message: `Do you really want to delete "${suiteName}"?`,
yesText: 'Delete',
noText: 'Cancel',
onDone: async (isYes: boolean) => {
if (isYes) {
deleteUnitTestSuiteFetcher.submit(
{},
{
action: `/organization/${organizationId}/project/${projectId}/workspace/${workspaceId}/test/test-suite/${suiteId}/delete`,
method: 'POST',
}
);
}
},
});
},
},
];
@ -330,7 +342,7 @@ const TestRoute: FC = () => {
</Button>
</div>
<GridList
aria-label="Tets Suites"
aria-label="Test Suites"
items={unitTestSuites.map(suite => ({
id: suite._id,
key: suite._id,
@ -388,7 +400,7 @@ const TestRoute: FC = () => {
onAction={key => {
testSuiteActionList
.find(({ id }) => key === id)
?.action(item._id);
?.action(item._id, item.name);
}}
items={testSuiteActionList}
className="border select-none text-sm min-w-max border-solid border-[--hl-sm] shadow-lg bg-[--color-bg] py-2 rounded-md overflow-y-auto max-h-[85vh] focus:outline-none"