Browse Source

playwright test for delete project

and data test ids
feat/export-nest-dir-restructure
starbirdtech383 2 years ago
parent
commit
5d6f5fd385
  1. 4
      packages/nc-gui/pages/index/index/index.vue
  2. 29
      tests/playwright/pages/ProjectsPage/index.ts

4
packages/nc-gui/pages/index/index/index.vue

@ -319,12 +319,12 @@ const copyProjectMeta = async () => {
/>
<a-dropdown :trigger="['click']" overlay-class-name="nc-dropdown-import-menu" @click.stop>
<GeneralIcon icon="threeDotVertical" class="nc-import-menu outline-0" />
<GeneralIcon icon="threeDotVertical" class="nc-import-menu outline-0" :data-testid="`p-three-dot-${record.title}`"/>
<template #overlay>
<a-menu class="!py-0 rounded text-sm">
<a-menu-item key="duplicate" v-e="['c:project:duplicate']" @click.stop="duplicateProject(record)">
<div class="color-transition nc-project-menu-item group">
<div class="color-transition nc-project-menu-item group" :data-testid="`dupe-project-${record.title}`">
<GeneralIcon icon="copy" class="group-hover:text-accent" />
Duplicate
</div>

29
tests/playwright/pages/ProjectsPage/index.ts

@ -37,6 +37,35 @@ export class ProjectsPage extends BasePage {
await this.rootPage.locator('.nc-container').waitFor({ state: 'visible' });
}
// duplicate project
async duplicateProject({
name = 'sample',
withoutPrefix,
}: {
name?: string;
type?: string;
withoutPrefix?: boolean;
}) {
if (!withoutPrefix) name = this.prefixTitle(name);
// click three-dot
await this.rootPage.getByTestId('p-three-dot-' + name).click();
// check duplicate visible
await expect(this.rootPage.getByTestId('dupe-project-' + name)).toBeVisible();
// click duplicate
await this.rootPage.getByTestId('dupe-project-' + name).click();
// click duplicate confirmation "Do you want to duplicate 'sampleREST0' project?"
// assert message on duplicate confirmation page
const dupeProjectSubmitAction = () => this.rootPage.getByRole('button', { name: 'Yes' }).click();
await this.waitForResponse({
uiAction: dupeProjectSubmitAction,
httpMethodsToMatch: ['POST'],
requestUrlPathToMatch: 'api/v1/db/meta/duplicate/',
});
// wait for duplicate create completed and render kebab
await this.get().locator(`[data-testid="p-three-dot-${name} copy"]`).waitFor();
}
async checkProjectCreateButton({ exists = true }) {
await expect(this.rootPage.locator('.nc-new-project-menu:visible')).toHaveCount(exists ? 1 : 0);
}

Loading…
Cancel
Save