Browse Source

feat(testing): Added polling to most expect and added stabalization

pull/3848/head
Muhammed Mustafa 2 years ago
parent
commit
592c94e9d1
  1. 2
      packages/nc-gui/components/general/TruncateText.vue
  2. 2
      packages/nc-gui/components/smartsheet/sidebar/RenameableMenuItem.vue
  3. 27
      scripts/playwright/pages/Dashboard/ExpandedForm/index.ts
  4. 18
      scripts/playwright/pages/Dashboard/Form/index.ts
  5. 2
      scripts/playwright/pages/Dashboard/Grid/Column/LTAR/ChildList.ts
  6. 2
      scripts/playwright/pages/Dashboard/Grid/Column/LTAR/LinkRecord.ts
  7. 12
      scripts/playwright/pages/Dashboard/Grid/Column/index.ts
  8. 30
      scripts/playwright/pages/Dashboard/Grid/index.ts
  9. 5
      scripts/playwright/pages/Dashboard/Import/ImportTemplate.ts
  10. 22
      scripts/playwright/pages/Dashboard/Kanban/index.ts
  11. 17
      scripts/playwright/pages/Dashboard/TreeView.ts
  12. 28
      scripts/playwright/pages/Dashboard/ViewSidebar/index.ts
  13. 20
      scripts/playwright/pages/Dashboard/WebhookForm/index.ts
  14. 4
      scripts/playwright/pages/Dashboard/common/Cell/CheckboxCell.ts
  15. 2
      scripts/playwright/pages/Dashboard/common/Cell/RatingCell.ts
  16. 4
      scripts/playwright/pages/Dashboard/common/Cell/SelectOptionCell.ts
  17. 18
      scripts/playwright/pages/Dashboard/common/Cell/index.ts
  18. 13
      scripts/playwright/pages/Dashboard/common/Toolbar/Fields.ts
  19. 19
      scripts/playwright/pages/Dashboard/common/Toolbar/Filter.ts
  20. 8
      scripts/playwright/pages/Dashboard/common/Toolbar/Sort.ts
  21. 5
      scripts/playwright/pages/Dashboard/common/Toolbar/index.ts
  22. 16
      scripts/playwright/pages/Dashboard/commonBase/Erd.ts
  23. 14
      scripts/playwright/pages/Dashboard/index.ts
  24. 3
      scripts/playwright/tests/expandedFormUrl.spec.ts
  25. 3
      scripts/playwright/tests/viewKanban.spec.ts

2
packages/nc-gui/components/general/TruncateText.vue

@ -38,7 +38,7 @@ const shortName = computed(() =>
</template> </template>
<div class="w-full">{{ shortName }}</div> <div class="w-full">{{ shortName }}</div>
</a-tooltip> </a-tooltip>
<div v-else class="w-full"> <div v-else class="w-full" nc-data="truncate-label">
<slot /> <slot />
</div> </div>
<div ref="text" class="hidden"> <div ref="text" class="hidden">

2
packages/nc-gui/components/smartsheet/sidebar/RenameableMenuItem.vue

@ -171,7 +171,7 @@ function onStopEdit() {
@dblclick.stop="onDblClick" @dblclick.stop="onDblClick"
@click.stop="onClick" @click.stop="onClick"
> >
<div v-e="['a:view:open', { view: vModel.type }]" class="text-xs flex items-center w-full gap-2"> <div v-e="['a:view:open', { view: vModel.type }]" class="text-xs flex items-center w-full gap-2" nc-data="view-item">
<div class="flex w-auto" :pw-data="`view-sidebar-drag-handle-${vModel.alias || vModel.title}`"> <div class="flex w-auto" :pw-data="`view-sidebar-drag-handle-${vModel.alias || vModel.title}`">
<MdiDrag <MdiDrag
class="nc-drag-icon hidden group-hover:block transition-opacity opacity-0 group-hover:opacity-100 text-gray-500 !cursor-move" class="nc-drag-icon hidden group-hover:block transition-opacity opacity-0 group-hover:opacity-100 text-gray-500 !cursor-move"

27
scripts/playwright/pages/Dashboard/ExpandedForm/index.ts

@ -55,9 +55,21 @@ export class ExpandedFormPage extends BasePage {
} }
} }
async save() { async save({
waitForRowsData = true,
}: {
waitForRowsData?: boolean;
}) {
await this.get().locator('button:has-text("Save Row")').click(); await this.get().locator('button:has-text("Save Row")').click();
await this.get().press("Escape"); if(waitForRowsData) {
await this.waitForResponse({
uiAction: this.get().press("Escape"),
requestUrlPathToMatch: 'api/v1/db/data/noco/',
httpMethodsToMatch: ['GET'],
responseJsonMatcher: (json) => json['pageInfo'],
});
}
await this.get().waitFor({ state: "hidden" }); await this.get().waitFor({ state: "hidden" });
await this.toastWait({ message: `updated successfully.` }); await this.toastWait({ message: `updated successfully.` });
await this.rootPage await this.rootPage
@ -94,10 +106,9 @@ export class ExpandedFormPage extends BasePage {
await childList.locator(`.ant-card:has-text("${param.title}")`).click(); await childList.locator(`.ant-card:has-text("${param.title}")`).click();
} }
async count() { async verifyCount({ count }: { count: number }) {
return await this.rootPage return await expect(this.rootPage
.locator(`.nc-drawer-expanded-form .ant-drawer-content`) .locator(`.nc-drawer-expanded-form .ant-drawer-content`)).toHaveCount(count);
.count();
} }
async validateRoleAccess(param: { role: string }) { async validateRoleAccess(param: { role: string }) {
@ -111,9 +122,9 @@ export class ExpandedFormPage extends BasePage {
).toBeEnabled(); ).toBeEnabled();
} }
if (param.role === "viewer") { if (param.role === "viewer") {
await expect(await this.toggleCommentsButton.count()).toBe(0); await expect(await this.toggleCommentsButton).toHaveCount(0);
} else { } else {
await expect(await this.toggleCommentsButton.count()).toBe(1); await expect(await this.toggleCommentsButton).toHaveCount(1);
} }
// press escape to close the expanded form // press escape to close the expanded form
await this.rootPage.keyboard.press("Escape"); await this.rootPage.keyboard.press("Escape");

18
scripts/playwright/pages/Dashboard/Form/index.ts

@ -160,10 +160,8 @@ export class FormPage extends BasePage {
let fieldLabels = await this.get().locator( let fieldLabels = await this.get().locator(
'[data-pw="nc-form-input-label"]' '[data-pw="nc-form-input-label"]'
); );
await expect(await fieldLabels.count()).toBe(fields.length); await expect(await fieldLabels).toHaveCount(fields.length);
for (let i = 0; i < fields.length; i++) { for (let i = 0; i < fields.length; i++) {
// using toContainText instead of toBe because of the extra
// text (*) in the label for required fields
await expect(await fieldLabels.nth(i)).toContainText(fields[i]); await expect(await fieldLabels.nth(i)).toContainText(fields[i]);
} }
} }
@ -234,8 +232,8 @@ export class FormPage extends BasePage {
} }
async verifyHeader(param: { subtitle: string; title: string }) { async verifyHeader(param: { subtitle: string; title: string }) {
await expect(await this.formHeading.inputValue()).toBe(param.title); await expect.poll(async() => await this.formHeading.inputValue()).toBe(param.title);
await expect(await this.formSubHeading.inputValue()).toBe(param.subtitle); await expect.poll(async() => await this.formSubHeading.inputValue()).toBe(param.subtitle);
} }
async fillForm(param: { field: string; value: string }[]) { async fillForm(param: { field: string; value: string }[]) {
@ -295,15 +293,13 @@ export class FormPage extends BasePage {
// data-pw="nc-form-input-help-text-label" // data-pw="nc-form-input-help-text-label"
let fieldLabel = await this.get() let fieldLabel = await this.get()
.locator(`.nc-form-drag-${field.replace(" ", "")}`) .locator(`.nc-form-drag-${field.replace(" ", "")}`)
.locator('div[data-pw="nc-form-input-label"]') .locator('div[data-pw="nc-form-input-label"]');
.innerText(); await expect(fieldLabel).toHaveText(expectText);
await expect(fieldLabel).toBe(expectText);
let fieldHelpText = await this.get() let fieldHelpText = await this.get()
.locator(`.nc-form-drag-${field.replace(" ", "")}`) .locator(`.nc-form-drag-${field.replace(" ", "")}`)
.locator('div[data-pw="nc-form-input-help-text-label"]') .locator('div[data-pw="nc-form-input-help-text-label"]');
.innerText(); await expect(fieldHelpText).toHaveText(helpText);
await expect(fieldHelpText).toBe(helpText);
} }
async submitForm() { async submitForm() {

2
scripts/playwright/pages/Dashboard/Grid/Column/LTAR/ChildList.ts

@ -25,7 +25,7 @@ export class ChildList extends BasePage {
// title: Child list // title: Child list
// button: Link to 'City' // button: Link to 'City'
// icon: reload // icon: reload
await expect(await this.get().locator(`.ant-modal-title`).innerText()).toBe( await expect(this.get().locator(`.ant-modal-title`)).toHaveText(
`Child list` `Child list`
); );
await expect( await expect(

2
scripts/playwright/pages/Dashboard/Grid/Column/LTAR/LinkRecord.ts

@ -18,7 +18,7 @@ export class LinkRecord extends BasePage {
// title: Link Record // title: Link Record
// button: Add new record // button: Add new record
// icon: reload // icon: reload
await expect(await this.get().locator(`.ant-modal-title`).innerText()).toBe( await expect(this.get().locator(`.ant-modal-title`)).toHaveText(
`Link record` `Link record`
); );
await expect( await expect(

12
scripts/playwright/pages/Dashboard/Grid/Column/index.ts

@ -231,11 +231,11 @@ export class ColumnPageObject extends BasePage {
async verifyRoleAccess(param: { role: string }) { async verifyRoleAccess(param: { role: string }) {
await expect( await expect(
await this.grid.get().locator(".nc-column-add:visible").count() this.grid.get().locator(".nc-column-add:visible")
).toBe(param.role === "creator" ? 1 : 0); ).toHaveCount(param.role === "creator" ? 1 : 0);
await expect( await expect(
await this.grid.get().locator(".nc-ui-dt-dropdown:visible").count() this.grid.get().locator(".nc-ui-dt-dropdown:visible")
).toBe(param.role === "creator" ? 3 : 0); ).toHaveCount(param.role === "creator" ? 3 : 0);
if (param.role === "creator") { if (param.role === "creator") {
await this.grid await this.grid
@ -244,8 +244,8 @@ export class ColumnPageObject extends BasePage {
.first() .first()
.click(); .click();
await expect( await expect(
await this.rootPage.locator(".nc-dropdown-column-operations").count() this.rootPage.locator(".nc-dropdown-column-operations")
).toBe(1); ).toHaveCount(1);
await this.grid await this.grid
.get() .get()
.locator(".nc-ui-dt-dropdown:visible") .locator(".nc-ui-dt-dropdown:visible")

30
scripts/playwright/pages/Dashboard/Grid/index.ts

@ -39,7 +39,7 @@ export class GridPage extends BasePage {
} }
async verifyRowCount({ count }: { count: number }) { async verifyRowCount({ count }: { count: number }) {
return await expect(await this.get().locator(".nc-grid-row").count()).toBe(count); return await expect(this.get().locator(".nc-grid-row")).toHaveCount(count);
} }
private async _fillRow({ private async _fillRow({
@ -75,9 +75,7 @@ export class GridPage extends BasePage {
const rowCount = await this.get().locator(".nc-grid-row").count(); const rowCount = await this.get().locator(".nc-grid-row").count();
await this.get().locator(".nc-grid-add-new-cell").click(); await this.get().locator(".nc-grid-add-new-cell").click();
await expect await expect(this.get().locator(".nc-grid-row")).toHaveCount(rowCount + 1);
.poll(async () => await this.get().locator(".nc-grid-row").count())
.toBe(rowCount + 1);
await this._fillRow({ index, columnHeader, value: rowValue }); await this._fillRow({ index, columnHeader, value: rowValue });
@ -132,18 +130,14 @@ export class GridPage extends BasePage {
await this.get() await this.get()
.locator(`td[data-pw="cell-Title-${index}"]`) .locator(`td[data-pw="cell-Title-${index}"]`)
.waitFor({ state: "visible" }); .waitFor({ state: "visible" });
await expect( await expect(this.get().locator(`td[data-pw="cell-Title-${index}"]`)).toHaveCount(1);
await this.get().locator(`td[data-pw="cell-Title-${index}"]`).count()
).toBe(1);
} }
async verifyRowDoesNotExist({ index }: { index: number }) { async verifyRowDoesNotExist({ index }: { index: number }) {
await this.get() await this.get()
.locator(`td[data-pw="cell-Title-${index}"]`) .locator(`td[data-pw="cell-Title-${index}"]`)
.waitFor({ state: "hidden" }); .waitFor({ state: "hidden" });
return await expect( return await expect(this.get().locator(`td[data-pw="cell-Title-${index}"]`)).toHaveCount(0);
await this.get().locator(`td[data-pw="cell-Title-${index}"]`).count()
).toBe(0);
} }
async deleteRow(index: number) { async deleteRow(index: number) {
@ -167,7 +161,7 @@ export class GridPage extends BasePage {
}); });
// Click text=Insert New Row // Click text=Insert New Row
await this.rootPage.locator("text=Insert New Row").click(); await this.rootPage.locator("text=Insert New Row").click();
await expect(await this.get().locator(".nc-grid-row").count()).toBe(rowCount + 1); await expect(await this.get().locator(".nc-grid-row")).toHaveCount(rowCount + 1);
} }
async openExpandedRow({ index }: { index: number }) { async openExpandedRow({ index }: { index: number }) {
@ -190,15 +184,9 @@ export class GridPage extends BasePage {
const rowCount = await this.rowCount(); const rowCount = await this.rowCount();
for (let i = 0; i < rowCount; i++) { for (let i = 0; i < rowCount; i++) {
await expect await expect(
.poll( this.row(i).locator(`[pw-data="cell-Id-${i}"]`).locator("span.ant-checkbox-checked")
async () => ).toHaveCount(1);
await this.row(i)
.locator(`[pw-data="cell-Id-${i}"]`)
.locator("span.ant-checkbox-checked")
.count()
)
.toBe(1);
} }
await this.rootPage.waitForTimeout(300); await this.rootPage.waitForTimeout(300);
} }
@ -321,7 +309,7 @@ export class GridPage extends BasePage {
async validateRoleAccess(param: { role: string }) { async validateRoleAccess(param: { role: string }) {
await this.column.verifyRoleAccess(param); await this.column.verifyRoleAccess(param);
await this.cell.verifyRoleAccess(param); await this.cell.verifyRoleAccess(param);
await expect(await this.get().locator(".nc-grid-add-new-cell").count()).toBe( await expect(this.get().locator(".nc-grid-add-new-cell")).toHaveCount(
param.role === "creator" || param.role === "editor" ? 1 : 0 param.role === "creator" || param.role === "editor" ? 1 : 0
); );
} }

5
scripts/playwright/pages/Dashboard/Import/ImportTemplate.ts

@ -21,7 +21,7 @@ export class ImportTemplatePage extends BasePage {
await this.get().locator(`.ant-collapse-header`).nth(0).waitFor(); await this.get().locator(`.ant-collapse-header`).nth(0).waitFor();
let tr = await this.get().locator(`.ant-collapse-header`); let tr = await this.get().locator(`.ant-collapse-header`);
let rowCount = await tr.count(); let rowCount = await tr.count();
let tableList = []; let tableList: string[] = [];
for (let i = 0; i < rowCount; i++) { for (let i = 0; i < rowCount; i++) {
let tableName = await tr.nth(i).innerText(); let tableName = await tr.nth(i).innerText();
tableList.push(tableName); tableList.push(tableName);
@ -31,7 +31,7 @@ export class ImportTemplatePage extends BasePage {
async getImportColumnList() { async getImportColumnList() {
// return an array // return an array
let columnList = []; let columnList: {type: string; name: string}[] = [];
let tr = await this.get().locator(`tr.ant-table-row-level-0:visible`); let tr = await this.get().locator(`tr.ant-table-row-level-0:visible`);
let rowCount = await tr.count(); let rowCount = await tr.count();
for (let i = 0; i < rowCount; i++) { for (let i = 0; i < rowCount; i++) {
@ -49,6 +49,7 @@ export class ImportTemplatePage extends BasePage {
return columnList; return columnList;
} }
// todo: Add polling logic to assertions
async import({ file, result }: { file: string; result: any }) { async import({ file, result }: { file: string; result: any }) {
let importFile = this.get().locator(`input[type="file"]`); let importFile = this.get().locator(`input[type="file"]`);
await importFile.setInputFiles(file); await importFile.setInputFiles(file);

22
scripts/playwright/pages/Dashboard/Kanban/index.ts

@ -57,7 +57,7 @@ export class KanbanPage extends BasePage {
async verifyStackCount(param: { count: number }) { async verifyStackCount(param: { count: number }) {
const { count } = param; const { count } = param;
await expect(await this.get().locator(`.nc-kanban-stack`).count()).toBe(count); await expect(this.get().locator(`.nc-kanban-stack`)).toHaveCount(count);
} }
async verifyStackOrder(param: { order: string[] }) { async verifyStackOrder(param: { order: string[] }) {
@ -65,10 +65,10 @@ export class KanbanPage extends BasePage {
const stacks = await this.get().locator(`.nc-kanban-stack`).count(); const stacks = await this.get().locator(`.nc-kanban-stack`).count();
for (let i = 0; i < stacks; i++) { for (let i = 0; i < stacks; i++) {
const stack = await this.get().locator(`.nc-kanban-stack`).nth(i); const stack = await this.get().locator(`.nc-kanban-stack`).nth(i);
// Since otherwise stack title will be repeated as title is in two divs, with one having hidden class
const stackTitle = await stack const stackTitle = await stack
.locator(`.nc-kanban-stack-head`) .locator(`.nc-kanban-stack-head >> [nc-data="truncate-label"]`);
.innerText(); await expect(stackTitle).toHaveText(order[i], { ignoreCase: true });
await expect(stackTitle).toBe(order[i]);
} }
} }
@ -91,8 +91,8 @@ export class KanbanPage extends BasePage {
const stacks = await this.get().locator(`.nc-kanban-stack`).count(); const stacks = await this.get().locator(`.nc-kanban-stack`).count();
for (let i = 0; i < stacks; i++) { for (let i = 0; i < stacks; i++) {
const stack = await this.get().locator(`.nc-kanban-stack`).nth(i); const stack = await this.get().locator(`.nc-kanban-stack`).nth(i);
const stackCards = await stack.locator(`.nc-kanban-item`).count(); const stackCards = stack.locator(`.nc-kanban-item`);
await expect(stackCards).toBe(count[i]); await expect(stackCards).toHaveCount(count[i]);
} }
} }
@ -101,8 +101,8 @@ export class KanbanPage extends BasePage {
const stack = await this.get().locator(`.nc-kanban-stack`).nth(stackIndex); const stack = await this.get().locator(`.nc-kanban-stack`).nth(stackIndex);
for (let i = 0; i < order.length; i++) { for (let i = 0; i < order.length; i++) {
const card = await stack.locator(`.nc-kanban-item`).nth(i); const card = await stack.locator(`.nc-kanban-item`).nth(i);
const cardTitle = await card.locator(`.nc-cell`).innerText(); const cardTitle = await card.locator(`.nc-cell`);
await expect(cardTitle).toBe(order[i]); await expect(cardTitle).toHaveText(order[i]);
} }
} }
@ -133,12 +133,8 @@ export class KanbanPage extends BasePage {
.click(); .click();
} }
async collapseStackCount() {
return await this.rootPage.locator(".nc-kanban-collapsed-stack").count();
}
async verifyCollapseStackCount(param: { count: number }) { async verifyCollapseStackCount(param: { count: number }) {
await expect(await this.collapseStackCount()).toBe(param.count); await expect(this.rootPage.locator(".nc-kanban-collapsed-stack")).toHaveCount(param.count);
} }
async addCard(param: { stackIndex: number }) { async addCard(param: { stackIndex: number }) {

17
scripts/playwright/pages/Dashboard/TreeView.ts

@ -101,9 +101,7 @@ export class TreeViewPage extends BasePage {
); );
} }
} else { } else {
await expect.poll( await expect(this.get().locator(`.nc-project-tree-tbl-${title}`)).toHaveCount(0);
async () => await this.get().locator(`.nc-project-tree-tbl-${title}`).count()
).toBe(0);
} }
} }
@ -180,25 +178,22 @@ export class TreeViewPage extends BasePage {
async validateRoleAccess(param: { role: string }) { async validateRoleAccess(param: { role: string }) {
// Add new table button // Add new table button
await expect(await this.get().locator(`.nc-add-new-table`).count()).toBe( await expect(this.get().locator(`.nc-add-new-table`)).toHaveCount(
param.role === "creator" ? 1 : 0 param.role === "creator" ? 1 : 0
); );
// Import menu // Import menu
await expect(await this.get().locator(`.nc-import-menu`).count()).toBe( await expect(this.get().locator(`.nc-import-menu`)).toHaveCount(
param.role === "creator" ? 1 : 0 param.role === "creator" ? 1 : 0
); );
// Invite Team button // Invite Team button
await expect(await this.get().locator(`.nc-share-base`).count()).toBe( await expect(this.get().locator(`.nc-share-base`)).toHaveCount(
param.role === "creator" ? 1 : 0 param.role === "creator" ? 1 : 0
); );
// Right click context menu // Right click context menu
await this.get().locator(`.nc-project-tree-tbl-Country`).click({ await this.get().locator(`.nc-project-tree-tbl-Country`).click({
button: "right", button: "right",
}); });
await expect( await expect(this.rootPage.locator(`.nc-dropdown-tree-view-context-menu:visible`)
await this.rootPage ).toHaveCount(param.role === "creator" ? 1 : 0);
.locator(`.nc-dropdown-tree-view-context-menu:visible`)
.count()
).toBe(param.role === "creator" ? 1 : 0);
} }
} }

28
scripts/playwright/pages/Dashboard/ViewSidebar/index.ts

@ -76,11 +76,8 @@ export class ViewSidebarPage extends BasePage {
// Todo: Make selection better // Todo: Make selection better
async verifyView({ title, index }: { title: string; index: number }) { async verifyView({ title, index }: { title: string; index: number }) {
await expect( await expect(
await this.get() this.get().locator('[nc-data="view-item"]').nth(index).locator('[nc-data="truncate-label"]')
.locator(".ant-menu-title-content") ).toHaveText(title, { ignoreCase: true});
.nth(index)
.textContent()
).toBe(`${title}${title}`);
} }
async verifyViewNotPresent({ async verifyViewNotPresent({
@ -97,15 +94,10 @@ export class ViewSidebarPage extends BasePage {
return true; return true;
} }
return await expect return await expect(
.poll(async () => { this.get().locator(`.nc-views-menu`).locator(".ant-menu-title-content").nth(index)
await this.get() )
.locator(`.nc-views-menu`) .not.toHaveText(title);
.locator(".ant-menu-title-content")
.nth(index)
.textContent();
})
.not.toBe(title);
} }
async reorderViews({ async reorderViews({
@ -175,9 +167,9 @@ export class ViewSidebarPage extends BasePage {
async validateRoleAccess(param: { role: string }) { async validateRoleAccess(param: { role: string }) {
let count = param.role === "creator" ? 1 : 0; let count = param.role === "creator" ? 1 : 0;
await expect(await this.createGridButton.count()).toBe(count); await expect(this.createGridButton).toHaveCount(count);
await expect(await this.createGalleryButton.count()).toBe(count); await expect(this.createGalleryButton).toHaveCount(count);
await expect(await this.createFormButton.count()).toBe(count); await expect(this.createFormButton).toHaveCount(count);
await expect(await this.createKanbanButton.count()).toBe(count); await expect(this.createKanbanButton).toHaveCount(count);
} }
} }

20
scripts/playwright/pages/Dashboard/WebhookForm/index.ts

@ -188,12 +188,20 @@ export class WebhookFormPage extends BasePage {
urlMethod: string; urlMethod: string;
condition: boolean; condition: boolean;
}) { }) {
await expect(await this.get().locator('input.nc-text-field-hook-title').inputValue()).toBe(title); await expect.poll(
await expect(await this.get().locator('.nc-text-field-hook-event >> .ant-select-selection-item').innerText()).toBe(hookEvent); async () => await this.get().locator('input.nc-text-field-hook-title').inputValue()
await expect(await this.get().locator('.nc-select-hook-notification-type >> .ant-select-selection-item').innerText()).toBe(notificationType); ).toBe(title);
await expect(await this.get().locator('.nc-select-hook-url-method >> .ant-select-selection-item').innerText()).toBe(urlMethod); await expect(this.get().locator('.nc-text-field-hook-event >> .ant-select-selection-item')).toHaveText(hookEvent);
await expect(await this.get().locator('input.nc-text-field-hook-url-path').inputValue()).toBe(url); await expect(this.get().locator('.nc-select-hook-notification-type >> .ant-select-selection-item')).toHaveText(notificationType);
await expect(await this.get().locator('label.nc-check-box-hook-condition >> input[type="checkbox"]').isChecked()).toBe(condition); await expect(this.get().locator('.nc-select-hook-url-method >> .ant-select-selection-item')).toHaveText(urlMethod);
await expect.poll(async() => await this.get().locator('input.nc-text-field-hook-url-path').inputValue()).toBe(url);
const conditionCheckbox = this.get().locator('label.nc-check-box-hook-condition >> input[type="checkbox"]')
if(condition) {
await expect(conditionCheckbox).toBeChecked();
} else {
await expect(conditionCheckbox).not.toBeChecked();
}
} }
async goBackFromForm() { async goBackFromForm() {

4
scripts/playwright/pages/Dashboard/common/Cell/CheckboxCell.ts

@ -23,10 +23,10 @@ export class CheckboxCellPageObject extends BasePage {
} }
async verifyChecked({ index, columnHeader }: { index?: number, columnHeader: string }) { async verifyChecked({ index, columnHeader }: { index?: number, columnHeader: string }) {
await expect(await this.get({index, columnHeader}).locator('.nc-cell-hover-show').isVisible()).toBe(false); await expect(this.get({index, columnHeader}).locator('.nc-cell-hover-show')).not.toBeVisible();
} }
async verifyUnchecked({ index, columnHeader }: { index?: number, columnHeader: string }) { async verifyUnchecked({ index, columnHeader }: { index?: number, columnHeader: string }) {
await expect(await this.get({index, columnHeader}).locator('.nc-cell-hover-show').isVisible()).toBe(true); await expect(this.get({index, columnHeader}).locator('.nc-cell-hover-show')).toBeVisible();
} }
} }

2
scripts/playwright/pages/Dashboard/common/Cell/RatingCell.ts

@ -15,7 +15,7 @@ export class RatingCellPageObject extends BasePage {
} }
async verify({index, columnHeader, rating}: {index?: number, columnHeader: string, rating: number}) { async verify({index, columnHeader, rating}: {index?: number, columnHeader: string, rating: number}) {
await expect(await this.get({index, columnHeader}).locator(`div[role="radio"][aria-checked="true"]`).count()).toBe(rating); await expect(await this.get({index, columnHeader}).locator(`div[role="radio"][aria-checked="true"]`)).toHaveCount(rating);
} }
} }

4
scripts/playwright/pages/Dashboard/common/Cell/SelectOptionCell.ts

@ -62,9 +62,7 @@ export class SelectOptionCellPageObject extends BasePage {
let counter = 0; let counter = 0;
for (const option of options) { for (const option of options) {
const optionInDom = await this.rootPage.locator(`div.ant-select-item-option`).nth(counter) await expect(this.rootPage.locator(`div.ant-select-item-option`).nth(counter)).toHaveText(option);
.evaluate((node) => (node as HTMLElement).innerText)
await expect(optionInDom).toBe(option);
counter++; counter++;
} }
await this.get({index, columnHeader}).click(); await this.get({index, columnHeader}).click();

18
scripts/playwright/pages/Dashboard/common/Cell/index.ts

@ -155,14 +155,13 @@ export class CellPageObject extends BasePage {
// const count = value.length; // const count = value.length;
const cell = this.get({ index, columnHeader }); const cell = this.get({ index, columnHeader });
const chips = cell.locator(".chips > .chip"); const chips = cell.locator(".chips > .chip");
const chipCount = await chips.count();
// verify chip count & contents // verify chip count & contents
if(count) expect(chipCount).toEqual(count); if(count) expect(chips).toHaveCount(count);
// verify only the elements that are passed in // verify only the elements that are passed in
for (let i = 0; i < value.length; ++i) { for (let i = 0; i < value.length; ++i) {
await expect(await chips.nth(i).textContent()).toBe(value[i]); await expect(await chips.nth(i)).toHaveText(value[i]);
} }
} }
@ -183,7 +182,7 @@ export class CellPageObject extends BasePage {
const cell = await this.get({ index: 0, columnHeader: "Country" }); const cell = await this.get({ index: 0, columnHeader: "Country" });
// editable cell // editable cell
await cell.dblclick(); await cell.dblclick();
await expect(await cell.locator(`input`).count()).toBe( await expect(await cell.locator(`input`)).toHaveCount(
param.role === "creator" || param.role === "editor" ? 1 : 0 param.role === "creator" || param.role === "editor" ? 1 : 0
); );
// right click context menu // right click context menu
@ -191,23 +190,22 @@ export class CellPageObject extends BasePage {
await expect( await expect(
await this.rootPage await this.rootPage
.locator(`.nc-dropdown-grid-context-menu:visible`) .locator(`.nc-dropdown-grid-context-menu:visible`)
.count() ).toHaveCount(param.role === "creator" || param.role === "editor" ? 1 : 0);
).toBe(param.role === "creator" || param.role === "editor" ? 1 : 0);
// virtual cell // virtual cell
const vCell = await this.get({ index: 0, columnHeader: "City List" }); const vCell = await this.get({ index: 0, columnHeader: "City List" });
await vCell.hover(); await vCell.hover();
// in-cell add // in-cell add
await expect(await vCell.locator(".nc-action-icon.nc-plus:visible").count()).toBe( await expect(await vCell.locator(".nc-action-icon.nc-plus:visible")).toHaveCount(
param.role === "creator" || param.role === "editor" ? 1 : 0 param.role === "creator" || param.role === "editor" ? 1 : 0
); );
// in-cell expand (all have access) // in-cell expand (all have access)
await expect( await expect(
await vCell.locator(".nc-action-icon.nc-arrow-expand:visible").count() await vCell.locator(".nc-action-icon.nc-arrow-expand:visible")
).toBe(1); ).toHaveCount(1);
await vCell.click(); await vCell.click();
// unlink // unlink
await expect(await vCell.locator(".nc-icon.unlink-icon:visible").count()).toBe( await expect(await vCell.locator(".nc-icon.unlink-icon:visible")).toHaveCount(
param.role === "creator" || param.role === "editor" ? 1 : 0 param.role === "creator" || param.role === "editor" ? 1 : 0
); );
} }

13
scripts/playwright/pages/Dashboard/common/Toolbar/Fields.ts

@ -24,12 +24,15 @@ export class ToolbarFieldsPage extends BasePage {
} }
async verify({ title, checked }: { title: string, checked: boolean }) { async verify({ title, checked }: { title: string, checked: boolean }) {
await expect( const checkbox = this.get()
await this.get()
.locator(`[pw-data="nc-fields-menu-${title}"]`) .locator(`[pw-data="nc-fields-menu-${title}"]`)
.locator('input[type="checkbox"]') .locator('input[type="checkbox"]');
.isChecked()
).toBe(checked); if (checked) {
await expect(checkbox).toBeChecked();
} else {
await expect(checkbox).not.toBeChecked();
}
} }
async click({ title }: { title: string }) { async click({ title }: { title: string }) {

19
scripts/playwright/pages/Dashboard/common/Toolbar/Filter.ts

@ -25,24 +25,15 @@ export class ToolbarFilterPage extends BasePage {
operator: string; operator: string;
value: string; value: string;
}) { }) {
await expect( await expect(this.get().locator('.nc-filter-field-select').nth(index)).toHaveText(column);
await this.get().locator('.nc-filter-field-select').nth(index).innerText() await expect(this.get().locator('.nc-filter-operation-select').nth(index)).toHaveText(operator);
).toBe(column); await expect.poll(async () => this.get().locator('input.nc-filter-value-select').nth(index).inputValue()).toBe(value);
await expect(
await this.get().locator('.nc-filter-operation-select').nth(index).innerText()
).toBe(operator);
await expect(
await this.get().locator('input.nc-filter-value-select').nth(index).inputValue()
).toBe(value);
} }
async verifyFilter({ title }: { title: string }) { async verifyFilter({ title }: { title: string }) {
await expect( await expect(
await this.get() this.get().locator(`[pw-data="nc-fields-menu-${title}"]`).locator('input[type="checkbox"]')
.locator(`[pw-data="nc-fields-menu-${title}"]`) ).toBeChecked();
.locator('input[type="checkbox"]')
.isChecked()
).toBe(true);
} }
// Todo: Handle the case of operator does not need a value // Todo: Handle the case of operator does not need a value

8
scripts/playwright/pages/Dashboard/common/Toolbar/Sort.ts

@ -23,12 +23,8 @@ export class ToolbarSortPage extends BasePage {
column: string; column: string;
direction: string; direction: string;
}) { }) {
await expect( await expect(this.get().locator('.nc-sort-field-select').nth(index)).toHaveText(column);
await this.get().locator('.nc-sort-field-select').nth(index).innerText() await expect(await this.get().locator('.nc-sort-dir-select >> span.ant-select-selection-item').nth(index)).toHaveText(direction);
).toBe(column);
await expect(
await this.get().locator('.nc-sort-dir-select >> span.ant-select-selection-item').nth(index).innerText()
).toBe(direction);
} }
async addSort({ async addSort({

5
scripts/playwright/pages/Dashboard/common/Toolbar/index.ts

@ -186,12 +186,11 @@ export class ToolbarPage extends BasePage {
viewer: ["Fields", "Filter", "Sort", "Download"], viewer: ["Fields", "Filter", "Sort", "Download"],
}; };
let text = await this.get().innerText();
for (let item of menuItems[param.role]) { for (let item of menuItems[param.role]) {
await expect(text).toContain(item); await expect(this.get()).toContainText(item);
} }
await expect(await this.get().locator(".nc-add-new-row-btn").count()).toBe( await expect(this.get().locator(".nc-add-new-row-btn")).toHaveCount(
param.role === "creator" || param.role === "editor" ? 1 : 0 param.role === "creator" || param.role === "editor" ? 1 : 0
); );
} }

16
scripts/playwright/pages/Dashboard/commonBase/Erd.ts

@ -61,9 +61,7 @@ export abstract class ErdBasePage extends BasePage {
} }
async verifyNodesCount(count: number) { async verifyNodesCount(count: number) {
await expect.poll( await expect(this.get().locator('.nc-erd-table-node')).toHaveCount(count);
async () => await this.get().locator('.nc-erd-table-node').count()
).toBe(count);
} }
async verifyEdgesCount({ async verifyEdgesCount({
@ -75,15 +73,9 @@ export abstract class ErdBasePage extends BasePage {
circleCount: number; circleCount: number;
rectangleCount: number; rectangleCount: number;
}) { }) {
await expect.poll( await expect(this.get().locator('.vue-flow__edge')).toHaveCount(count);
async () => await this.get().locator('.vue-flow__edge').count() await expect(this.get().locator('.nc-erd-edge-circle')).toHaveCount(circleCount);
).toBe(count); await expect(this.get().locator('.nc-erd-edge-rect')).toHaveCount(rectangleCount);
await expect.poll(
async () => await this.get().locator('.nc-erd-edge-circle').count()
).toBe(circleCount);
await expect.poll(
async () => await this.get().locator('.nc-erd-edge-rect').count()
).toBe(rectangleCount);
} }
async verifyJunctionTableLabel({tableTitle, tableName}: {tableName: string; tableTitle: string}) { async verifyJunctionTableLabel({tableTitle, tableName}: {tableName: string; tableTitle: string}) {

14
scripts/playwright/pages/Dashboard/index.ts

@ -190,14 +190,12 @@ export class DashboardPage extends BasePage {
} }
async verifyLanguage(param: { json: any }) { async verifyLanguage(param: { json: any }) {
let title = await this.rootPage const title = await this.rootPage
.locator(`.nc-project-page-title`) .locator(`.nc-project-page-title`);
.textContent(); const menu = this.rootPage
let menu = await this.rootPage .locator(`.nc-new-project-menu`);
.locator(`.nc-new-project-menu`) await expect(title).toHaveText(param.json.title.myProject);
.textContent(); await expect(menu).toHaveText(param.json.title.newProj);
await expect(title).toContain(param.json.title.myProject);
await expect(menu).toContain(param.json.title.newProj);
await this.rootPage await this.rootPage
.locator(`[placeholder="${param.json.activity.searchProject}"]`) .locator(`[placeholder="${param.json.activity.searchProject}"]`)
.waitFor(); .waitFor();

3
scripts/playwright/tests/expandedFormUrl.spec.ts

@ -84,8 +84,7 @@ test.describe("Expanded form URL", () => {
header: "Kabul", header: "Kabul",
url: "rowId=1", url: "rowId=1",
}); });
let expandFormCount = await dashboard.expandedForm.count(); await dashboard.expandedForm.verifyCount({count: 2});
await expect(expandFormCount).toBe(2);
// close child card // close child card
await dashboard.expandedForm.cancel(); await dashboard.expandedForm.cancel();

3
scripts/playwright/tests/viewKanban.spec.ts

@ -239,7 +239,8 @@ test.describe("View", () => {
columnTitle: "LanguageId", columnTitle: "LanguageId",
value: "1", value: "1",
}); });
await dashboard.expandedForm.save(); // todo: Check why kanban doesnt reload the rows data
await dashboard.expandedForm.save({ waitForRowsData: false });
await kanban.verifyStackCount({ count: 7 }); await kanban.verifyStackCount({ count: 7 });
await kanban.verifyStackOrder({ await kanban.verifyStackOrder({

Loading…
Cancel
Save