Browse Source

test: updated test for expanded form

pull/6464/head
DarkPhoenix2704 1 year ago
parent
commit
cb05f06f32
  1. 16
      packages/nc-gui/components/smartsheet/expanded-form/index.vue
  2. 38
      tests/playwright/pages/Dashboard/ExpandedForm/index.ts
  3. 1
      tests/playwright/pages/Dashboard/Gallery/index.ts
  4. 1
      tests/playwright/pages/Dashboard/Grid/index.ts
  5. 8
      tests/playwright/tests/db/features/expandedFormUrl.spec.ts

16
packages/nc-gui/components/smartsheet/expanded-form/index.vue

@ -348,7 +348,7 @@ export default {
class="nc-drawer-expanded-form"
:class="{ active: isExpanded }"
>
<div class="flex w-full items-center relative pb-2 justify-between">
<div class="flex w-full items-center nc-expanded-form-header relative pb-2 justify-between">
<div class="flex gap-3">
<div class="flex gap-1">
<NcButton v-if="props.showNextPrevIcons" type="secondary" size="small" class="nc-prev-arrow" @click="$emit('prev')">
@ -379,7 +379,11 @@ export default {
{{ $t('general.reload') }}
</div>
</NcMenuItem>
<NcMenuItem v-if="isUIAllowed('dataEdit') && !isNew" class="text-gray-700" @click="!isNew && onDuplicateRow">
<NcMenuItem
v-if="isUIAllowed('dataEdit') && !isNew"
class="text-gray-700"
@click="!isNew ? onDuplicateRow() : () => {}"
>
<div v-e="['c:row-expand:duplicate']" class="flex gap-2 items-center">
<component :is="iconMap.copy" class="cursor-pointer nc-duplicate-row" />
Duplicate record
@ -398,7 +402,7 @@ export default {
</NcMenu>
</template>
</NcDropdown>
<NcButton type="secondary" size="small" @click="onClose">
<NcButton type="secondary" size="small" class="nc-expand-form-close-btn" @click="onClose">
<MdiClose class="text-md text-gray-700" />
</NcButton>
</div>
@ -497,15 +501,15 @@ export default {
v-if="isUIAllowed('dataEdit')"
class="w-full absolute bottom-0 z-10 bg-white flex justify-end border-1 border-gray-200 p-2 rounded-b-lg"
>
<NcButton type="primary" size="medium" @click="save"> Save </NcButton>
<NcButton type="primary" size="medium" class="nc-expand-form-save-btn" @click="save"> Save </NcButton>
</div>
</div>
<div
v-if="!isNew"
v-if="!isNew && commentsDrawer && isUIAllowed('commentList')"
class="nc-comments-drawer border-1 border-gray-200 w-2/6 rounded-lg min-w-0"
:class="{ active: commentsDrawer && isUIAllowed('commentList') }"
>
<LazySmartsheetExpandedFormComments v-if="commentsDrawer && isUIAllowed('commentList')" />
<LazySmartsheetExpandedFormComments />
</div>
</div>
</a-modal>

38
tests/playwright/pages/Dashboard/ExpandedForm/index.ts

@ -10,9 +10,7 @@ export class ExpandedFormPage extends BasePage {
readonly duplicateRowButton: Locator;
readonly deleteRowButton: Locator;
readonly btn_copyUrl: Locator;
readonly btn_save: Locator;
readonly btn_toggleComments: Locator;
readonly btn_moreActions: Locator;
constructor(dashboard: DashboardPage) {
@ -22,10 +20,8 @@ export class ExpandedFormPage extends BasePage {
this.duplicateRowButton = this.dashboard.get().locator('.nc-duplicate-row:visible');
this.deleteRowButton = this.dashboard.get().locator('.nc-delete-row:visible');
this.btn_copyUrl = this.dashboard.get().locator('.nc-copy-row-url:visible');
this.btn_toggleComments = this.dashboard.get().locator('.nc-toggle-comments:visible');
this.btn_save = this.dashboard.get().locator('button.nc-expand-form-save-btn');
this.btn_moreActions = this.dashboard.get().locator('.nc-expand-form-more-actions');
this.btn_moreActions = this.get().locator('.nc-expand-form-more-actions');
}
get() {
@ -33,7 +29,7 @@ export class ExpandedFormPage extends BasePage {
}
async click3DotsMenu(menuItem: string) {
await this.get().locator('.nc-icon-transition.ant-dropdown-trigger').last().click();
await this.get().locator('.nc-expand-form-more-actions').last().click();
// add delay; wait for the menu to appear
await this.rootPage.waitForTimeout(500);
@ -43,14 +39,14 @@ export class ExpandedFormPage extends BasePage {
}
async clickDuplicateRow() {
await this.click3DotsMenu('Duplicate Row');
await this.click3DotsMenu('Duplicate Record');
// wait for loader to disappear
// await this.dashboard.waitForLoaderToDisappear();
await this.rootPage.waitForTimeout(2000);
}
async clickDeleteRow() {
await this.click3DotsMenu('Delete Row');
await this.click3DotsMenu('Delete Record');
await this.rootPage.locator('.ant-btn-primary:has-text("Confirm")').click();
}
@ -64,12 +60,6 @@ export class ExpandedFormPage extends BasePage {
return await isDisabled.count();
}
async getShareRowUrl() {
await this.btn_copyUrl.click();
await this.verifyToast({ message: 'Copied to clipboard' });
return await this.getClipboardText();
}
async gotoUsingUrlAndRowId({ rowId }: { rowId: string }) {
const url = this.dashboard.rootPage.url();
const expandedFormUrl = '/' + url.split('/').slice(3).join('/').split('?')[0] + `?rowId=${rowId}`;
@ -150,11 +140,11 @@ export class ExpandedFormPage extends BasePage {
async escape() {
await this.rootPage.keyboard.press('Escape');
await this.get().waitFor({ state: 'hidden' });
await this.get().locator('.nc-drawer-expanded-form').waitFor({ state: 'hidden' });
}
async close() {
await this.click3DotsMenu('Close');
await this.get().locator('.nc-expand-form-close-btn').last().click();
}
async openChildCard(param: { column: string; title: string }) {
@ -167,22 +157,20 @@ export class ExpandedFormPage extends BasePage {
}
async verifyCount({ count }: { count: number }) {
return await expect(this.rootPage.locator(`.nc-drawer-expanded-form .ant-drawer-content`)).toHaveCount(count);
return await expect(this.rootPage.locator(`.nc-drawer-expanded-form`)).toHaveCount(count);
}
async verifyRoleAccess(param: { role: string }) {
const role = param.role.toLowerCase();
expect(await this.btn_copyUrl.count()).toBe(1);
expect(await this.btn_moreActions.count()).toBe(1);
// expect(await this.btn_moreActions.count()).toBe(1);
await this.btn_moreActions.click();
const menu = this.rootPage.locator('.ant-dropdown:visible');
await menu.waitFor({ state: 'visible' });
const menuItems = menu.locator('.ant-dropdown-menu-item');
for (let i = 0; i < (await menuItems.count()); i++) {
if (role === 'owner' || role === 'editor' || role === 'creator') {
const menuText = ['Reload', 'Duplicate row', 'Delete row', 'Close'];
const menuText = ['Reload', 'Duplicate record', 'Delete record'];
expect(await getTextExcludeIconText(menuItems.nth(i))).toBe(menuText[i]);
} else {
const menuText = ['Reload', 'Close'];
@ -191,15 +179,15 @@ export class ExpandedFormPage extends BasePage {
}
if (role === 'owner' || role === 'editor' || role === 'creator') {
expect(await this.btn_save.isEnabled()).toBeTruthy();
expect(await this.btn_save.count()).toBe(1);
} else {
expect(await this.btn_save.isEnabled()).toBeFalsy();
expect(await this.btn_save.count()).toBe(0);
}
if (role === 'viewer') {
expect(await this.btn_toggleComments.count()).toBe(0);
expect(await this.get().locator('.nc-comments-drawer').count()).toBe(0);
} else {
expect(await this.btn_toggleComments.count()).toBe(1);
expect(await this.get().locator('.nc-comments-drawer').count()).toBe(1);
}
// press escape to close the expanded form

1
tests/playwright/pages/Dashboard/Gallery/index.ts

@ -30,7 +30,6 @@ export class GalleryPage extends BasePage {
y: 1,
},
});
await (await this.rootPage.locator('.ant-drawer-body').elementHandle())?.waitForElementState('stable');
}
// todo: Wait for render to complete

1
tests/playwright/pages/Dashboard/Grid/index.ts

@ -224,7 +224,6 @@ export class GridPage extends BasePage {
async openExpandedRow({ index }: { index: number }) {
await this.row(index).locator(`td[data-testid="cell-Id-${index}"]`).hover();
await this.row(index).locator(`div[data-testid="nc-expand-${index}"]`).click();
await (await this.rootPage.locator('.ant-drawer-body').elementHandle())?.waitForElementState('stable');
}
async selectRow(index: number) {

8
tests/playwright/tests/db/features/expandedFormUrl.spec.ts

@ -41,13 +41,15 @@ test.describe('Expanded form URL', () => {
}
// expand row & verify URL
// New Expanded Modal don't have functionality to copy URL. Hence gettting URL from root page
await viewObj.openExpandedRow({ index: 0 });
const url = await dashboard.expandedForm.getShareRowUrl();
const url = await dashboard.rootPage.url();
await dashboard.expandedForm.escape();
await dashboard.rootPage.goto(url);
await dashboard.expandedForm.verify({
header: 'Test Table: Row 0',
header: 'Row 0 All Test Table',
url,
});
}
@ -180,6 +182,8 @@ test.describe('Expanded record duplicate & delete options', () => {
// expand row & delete
await dashboard.grid.openExpandedRow({ index: 3 });
await dashboard.expandedForm.clickDeleteRow();
await dashboard.expandedForm.escape();
await dashboard.rootPage.reload();
await dashboard.grid.verifyRowCount({ count: 3 });
// expand row, duplicate & verify menu

Loading…
Cancel
Save