Browse Source

fix: Fixed issue with test

pull/6499/head
Muhammed Mustafa 12 months ago
parent
commit
f59c4c712e
  1. 9
      packages/nc-gui/components/general/DeleteModal.vue
  2. 1
      tests/playwright/package.json
  3. 7
      tests/playwright/pages/Account/Users.ts
  4. 6
      tests/playwright/pages/Dashboard/ViewSidebar/index.ts
  5. 16
      tests/playwright/pages/Dashboard/common/Cell/AttachmentCell.ts
  6. 3
      tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts
  7. 9
      tests/playwright/tests/db/usersAccounts/accountUserManagement.spec.ts

9
packages/nc-gui/components/general/DeleteModal.vue

@ -57,7 +57,14 @@ onKeyStroke('Enter', () => {
{{ $t('general.cancel') }}
</NcButton>
<NcButton key="submit" type="danger" html-type="submit" :loading="isLoading" @click="onDelete">
<NcButton
key="submit"
type="danger"
html-type="submit"
:loading="isLoading"
data-testid="nc-delete-modal-delete-btn"
@click="onDelete"
>
{{ `${$t('general.delete')} ${props.entityName}` }}
<template #loading>
{{ $t('general.deleting') }}

1
tests/playwright/package.json

@ -34,6 +34,7 @@
"ci:test:shard:2": "pnpm exec playwright test --workers=2 --shard=2/4",
"ci:test:shard:3": "pnpm exec playwright test --workers=2 --shard=3/4",
"ci:test:shard:4": "pnpm exec playwright test --workers=2 --shard=4/4",
"ci:test:flaky:repeat": "pnpm exec playwright test --workers=4 --grep @flaky --repeat-each=3",
"ci:test:mysql": "E2E_DB_TYPE=mysql pnpm exec playwright test --workers=2",
"ci:test:pg": "E2E_DB_TYPE=pg pnpm exec playwright test --workers=2",
"preinstall": "npx only-allow pnpm"

7
tests/playwright/pages/Account/Users.ts

@ -39,6 +39,8 @@ export class AccountUsersPage extends BasePage {
}
async invite({ email, role }: { email: string; role: string }) {
email = this.prefixEmail(email);
await this.inviteUserBtn.click();
await this.inviteUserModal.locator(`input[placeholder="E-mail"]`).fill(email);
await this.inviteUserModal.locator(`.nc-user-roles`).click();
@ -47,6 +49,9 @@ export class AccountUsersPage extends BasePage {
await this.inviteUserModal.locator(`button:has-text("Invite")`).click();
await this.verifyToast({ message: 'Successfully added user' });
// TODO: Wait on the invite api and get the invite url a better way as we are not waiting if the url is reflected in the UI
await this.rootPage.waitForTimeout(1000);
// http://localhost:3000/#/signup/a5e7bf3a-cbb0-46bc-87f7-c2ae21796707
return (await this.inviteUserModal.locator(`.ant-alert-message`).innerText()).split('\n')[0];
}
@ -63,6 +68,8 @@ export class AccountUsersPage extends BasePage {
async getUserRow({ email }: { email: string }) {
// ensure page is loaded
email = this.prefixEmail(email);
await this.get().waitFor();
return this.get().locator(`tr:has-text("${email}")`);
}

6
tests/playwright/pages/Dashboard/ViewSidebar/index.ts

@ -127,14 +127,16 @@ export class ViewSidebarPage extends BasePage {
.locator('.nc-sidebar-view-node-context-btn')
.click();
await this.rootPage.waitForTimeout(750);
await this.rootPage
.locator(`[data-testid="view-sidebar-view-actions-${title}"]`)
.locator('.nc-view-delete-icon')
.locator('.ant-dropdown-menu-title-content:has-text("Delete")')
.click({
force: true,
});
await this.rootPage.locator('button:has-text("Delete"):visible').click();
await this.rootPage.getByTestId('nc-delete-modal-delete-btn').click();
}
async renameView({ title, newTitle }: { title: string; newTitle: string }) {

16
tests/playwright/pages/Dashboard/common/Cell/AttachmentCell.ts

@ -51,20 +51,8 @@ export class AttachmentCellPageObject extends BasePage {
async verifyFileCount({ index, columnHeader, count }: { index: number; columnHeader: string; count: number }) {
// retry below logic for 5 times, with 1 second delay
let retryCount = 0;
while (retryCount < 5) {
const attachments = this.get({ index, columnHeader }).locator('.nc-attachment');
// console.log(await attachments.count());
if ((await attachments.count()) === count) {
break;
}
retryCount++;
await this.rootPage.waitForTimeout(1000);
if (retryCount === 5) {
expect(await attachments.count()).toBe(count);
}
}
const attachments = this.get({ index, columnHeader }).locator('.nc-attachment');
await expect(await attachments).toHaveCount(count);
}
async expandModalClose() {

3
tests/playwright/pages/Dashboard/common/Toolbar/Filter.ts

@ -356,6 +356,9 @@ export class ToolbarFilterPage extends BasePage {
} else {
await this.get().locator('.nc-filter-item-remove-btn').click();
}
// TODO: Filter reset await not working all the time
await this.rootPage.waitForTimeout(650);
await this.toolbar.clickFilter();
}

9
tests/playwright/tests/db/usersAccounts/accountUserManagement.spec.ts

@ -11,8 +11,8 @@ import { isEE } from '../../../setup/db';
let api: Api<any>;
const roleDb = [
{ email: 'org_creator@nocodb.com', role: 'Organization Level Creator', url: '' },
{ email: 'org_viewer@nocodb.com', role: 'Organization Level Viewer', url: '' },
{ email: `org_creator_@nocodb.com`, role: 'Organization Level Creator', url: '' },
{ email: `org_viewer_@nocodb.com`, role: 'Organization Level Viewer', url: '' },
];
test.describe('User roles', () => {
@ -113,16 +113,15 @@ test.describe('User roles', () => {
await signupPage.signUp({
email: roleDb[roleIdx].email,
password: getDefaultPwd(),
withoutPrefix: true,
});
// wait for page rendering to complete after sign up
await dashboard.rootPage.waitForTimeout(1000);
if (roleDb[roleIdx].role === 'Organization Level Creator') {
expect(await dashboard.leftSidebar.btn_newProject.isVisible()).toBeTruthy();
await expect(dashboard.leftSidebar.btn_newProject).toBeVisible();
} else {
expect(await dashboard.leftSidebar.btn_newProject.isVisible()).toBeFalsy();
await expect(dashboard.leftSidebar.btn_newProject).toHaveCount(0);
}
}
});

Loading…
Cancel
Save