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>
<div class="w-full">{{ shortName }}</div>
</a-tooltip>
<div v-else class="w-full">
<div v-else class="w-full" nc-data="truncate-label">
<slot />
</div>
<div ref="text" class="hidden">

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

@ -171,7 +171,7 @@ function onStopEdit() {
@dblclick.stop="onDblClick"
@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}`">
<MdiDrag
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().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.toastWait({ message: `updated successfully.` });
await this.rootPage
@ -94,10 +106,9 @@ export class ExpandedFormPage extends BasePage {
await childList.locator(`.ant-card:has-text("${param.title}")`).click();
}
async count() {
return await this.rootPage
.locator(`.nc-drawer-expanded-form .ant-drawer-content`)
.count();
async verifyCount({ count }: { count: number }) {
return await expect(this.rootPage
.locator(`.nc-drawer-expanded-form .ant-drawer-content`)).toHaveCount(count);
}
async validateRoleAccess(param: { role: string }) {
@ -111,9 +122,9 @@ export class ExpandedFormPage extends BasePage {
).toBeEnabled();
}
if (param.role === "viewer") {
await expect(await this.toggleCommentsButton.count()).toBe(0);
await expect(await this.toggleCommentsButton).toHaveCount(0);
} else {
await expect(await this.toggleCommentsButton.count()).toBe(1);
await expect(await this.toggleCommentsButton).toHaveCount(1);
}
// press escape to close the expanded form
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(
'[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++) {
// 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]);
}
}
@ -234,8 +232,8 @@ export class FormPage extends BasePage {
}
async verifyHeader(param: { subtitle: string; title: string }) {
await expect(await this.formHeading.inputValue()).toBe(param.title);
await expect(await this.formSubHeading.inputValue()).toBe(param.subtitle);
await expect.poll(async() => await this.formHeading.inputValue()).toBe(param.title);
await expect.poll(async() => await this.formSubHeading.inputValue()).toBe(param.subtitle);
}
async fillForm(param: { field: string; value: string }[]) {
@ -295,15 +293,13 @@ export class FormPage extends BasePage {
// data-pw="nc-form-input-help-text-label"
let fieldLabel = await this.get()
.locator(`.nc-form-drag-${field.replace(" ", "")}`)
.locator('div[data-pw="nc-form-input-label"]')
.innerText();
await expect(fieldLabel).toBe(expectText);
.locator('div[data-pw="nc-form-input-label"]');
await expect(fieldLabel).toHaveText(expectText);
let fieldHelpText = await this.get()
.locator(`.nc-form-drag-${field.replace(" ", "")}`)
.locator('div[data-pw="nc-form-input-help-text-label"]')
.innerText();
await expect(fieldHelpText).toBe(helpText);
.locator('div[data-pw="nc-form-input-help-text-label"]');
await expect(fieldHelpText).toHaveText(helpText);
}
async submitForm() {

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

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

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

@ -18,7 +18,7 @@ export class LinkRecord extends BasePage {
// title: Link Record
// button: Add new record
// icon: reload
await expect(await this.get().locator(`.ant-modal-title`).innerText()).toBe(
await expect(this.get().locator(`.ant-modal-title`)).toHaveText(
`Link record`
);
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 }) {
await expect(
await this.grid.get().locator(".nc-column-add:visible").count()
).toBe(param.role === "creator" ? 1 : 0);
this.grid.get().locator(".nc-column-add:visible")
).toHaveCount(param.role === "creator" ? 1 : 0);
await expect(
await this.grid.get().locator(".nc-ui-dt-dropdown:visible").count()
).toBe(param.role === "creator" ? 3 : 0);
this.grid.get().locator(".nc-ui-dt-dropdown:visible")
).toHaveCount(param.role === "creator" ? 3 : 0);
if (param.role === "creator") {
await this.grid
@ -244,8 +244,8 @@ export class ColumnPageObject extends BasePage {
.first()
.click();
await expect(
await this.rootPage.locator(".nc-dropdown-column-operations").count()
).toBe(1);
this.rootPage.locator(".nc-dropdown-column-operations")
).toHaveCount(1);
await this.grid
.get()
.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 }) {
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({
@ -75,9 +75,7 @@ export class GridPage extends BasePage {
const rowCount = await this.get().locator(".nc-grid-row").count();
await this.get().locator(".nc-grid-add-new-cell").click();
await expect
.poll(async () => await this.get().locator(".nc-grid-row").count())
.toBe(rowCount + 1);
await expect(this.get().locator(".nc-grid-row")).toHaveCount(rowCount + 1);
await this._fillRow({ index, columnHeader, value: rowValue });
@ -132,18 +130,14 @@ export class GridPage extends BasePage {
await this.get()
.locator(`td[data-pw="cell-Title-${index}"]`)
.waitFor({ state: "visible" });
await expect(
await this.get().locator(`td[data-pw="cell-Title-${index}"]`).count()
).toBe(1);
await expect(this.get().locator(`td[data-pw="cell-Title-${index}"]`)).toHaveCount(1);
}
async verifyRowDoesNotExist({ index }: { index: number }) {
await this.get()
.locator(`td[data-pw="cell-Title-${index}"]`)
.waitFor({ state: "hidden" });
return await expect(
await this.get().locator(`td[data-pw="cell-Title-${index}"]`).count()
).toBe(0);
return await expect(this.get().locator(`td[data-pw="cell-Title-${index}"]`)).toHaveCount(0);
}
async deleteRow(index: number) {
@ -167,7 +161,7 @@ export class GridPage extends BasePage {
});
// Click text=Insert New Row
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 }) {
@ -190,15 +184,9 @@ export class GridPage extends BasePage {
const rowCount = await this.rowCount();
for (let i = 0; i < rowCount; i++) {
await expect
.poll(
async () =>
await this.row(i)
.locator(`[pw-data="cell-Id-${i}"]`)
.locator("span.ant-checkbox-checked")
.count()
)
.toBe(1);
await expect(
this.row(i).locator(`[pw-data="cell-Id-${i}"]`).locator("span.ant-checkbox-checked")
).toHaveCount(1);
}
await this.rootPage.waitForTimeout(300);
}
@ -321,7 +309,7 @@ export class GridPage extends BasePage {
async validateRoleAccess(param: { role: string }) {
await this.column.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
);
}

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();
let tr = await this.get().locator(`.ant-collapse-header`);
let rowCount = await tr.count();
let tableList = [];
let tableList: string[] = [];
for (let i = 0; i < rowCount; i++) {
let tableName = await tr.nth(i).innerText();
tableList.push(tableName);
@ -31,7 +31,7 @@ export class ImportTemplatePage extends BasePage {
async getImportColumnList() {
// 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 rowCount = await tr.count();
for (let i = 0; i < rowCount; i++) {
@ -49,6 +49,7 @@ export class ImportTemplatePage extends BasePage {
return columnList;
}
// todo: Add polling logic to assertions
async import({ file, result }: { file: string; result: any }) {
let importFile = this.get().locator(`input[type="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 }) {
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[] }) {
@ -65,10 +65,10 @@ export class KanbanPage extends BasePage {
const stacks = await this.get().locator(`.nc-kanban-stack`).count();
for (let i = 0; i < stacks; 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
.locator(`.nc-kanban-stack-head`)
.innerText();
await expect(stackTitle).toBe(order[i]);
.locator(`.nc-kanban-stack-head >> [nc-data="truncate-label"]`);
await expect(stackTitle).toHaveText(order[i], { ignoreCase: true });
}
}
@ -91,8 +91,8 @@ export class KanbanPage extends BasePage {
const stacks = await this.get().locator(`.nc-kanban-stack`).count();
for (let i = 0; i < stacks; i++) {
const stack = await this.get().locator(`.nc-kanban-stack`).nth(i);
const stackCards = await stack.locator(`.nc-kanban-item`).count();
await expect(stackCards).toBe(count[i]);
const stackCards = stack.locator(`.nc-kanban-item`);
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);
for (let i = 0; i < order.length; i++) {
const card = await stack.locator(`.nc-kanban-item`).nth(i);
const cardTitle = await card.locator(`.nc-cell`).innerText();
await expect(cardTitle).toBe(order[i]);
const cardTitle = await card.locator(`.nc-cell`);
await expect(cardTitle).toHaveText(order[i]);
}
}
@ -133,12 +133,8 @@ export class KanbanPage extends BasePage {
.click();
}
async collapseStackCount() {
return await this.rootPage.locator(".nc-kanban-collapsed-stack").count();
}
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 }) {

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

@ -101,9 +101,7 @@ export class TreeViewPage extends BasePage {
);
}
} else {
await expect.poll(
async () => await this.get().locator(`.nc-project-tree-tbl-${title}`).count()
).toBe(0);
await expect(this.get().locator(`.nc-project-tree-tbl-${title}`)).toHaveCount(0);
}
}
@ -180,25 +178,22 @@ export class TreeViewPage extends BasePage {
async validateRoleAccess(param: { role: string }) {
// 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
);
// 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
);
// 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
);
// Right click context menu
await this.get().locator(`.nc-project-tree-tbl-Country`).click({
button: "right",
});
await expect(
await this.rootPage
.locator(`.nc-dropdown-tree-view-context-menu:visible`)
.count()
).toBe(param.role === "creator" ? 1 : 0);
await expect(this.rootPage.locator(`.nc-dropdown-tree-view-context-menu:visible`)
).toHaveCount(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
async verifyView({ title, index }: { title: string; index: number }) {
await expect(
await this.get()
.locator(".ant-menu-title-content")
.nth(index)
.textContent()
).toBe(`${title}${title}`);
this.get().locator('[nc-data="view-item"]').nth(index).locator('[nc-data="truncate-label"]')
).toHaveText(title, { ignoreCase: true});
}
async verifyViewNotPresent({
@ -97,15 +94,10 @@ export class ViewSidebarPage extends BasePage {
return true;
}
return await expect
.poll(async () => {
await this.get()
.locator(`.nc-views-menu`)
.locator(".ant-menu-title-content")
.nth(index)
.textContent();
})
.not.toBe(title);
return await expect(
this.get().locator(`.nc-views-menu`).locator(".ant-menu-title-content").nth(index)
)
.not.toHaveText(title);
}
async reorderViews({
@ -175,9 +167,9 @@ export class ViewSidebarPage extends BasePage {
async validateRoleAccess(param: { role: string }) {
let count = param.role === "creator" ? 1 : 0;
await expect(await this.createGridButton.count()).toBe(count);
await expect(await this.createGalleryButton.count()).toBe(count);
await expect(await this.createFormButton.count()).toBe(count);
await expect(await this.createKanbanButton.count()).toBe(count);
await expect(this.createGridButton).toHaveCount(count);
await expect(this.createGalleryButton).toHaveCount(count);
await expect(this.createFormButton).toHaveCount(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;
condition: boolean;
}) {
await expect(await this.get().locator('input.nc-text-field-hook-title').inputValue()).toBe(title);
await expect(await this.get().locator('.nc-text-field-hook-event >> .ant-select-selection-item').innerText()).toBe(hookEvent);
await expect(await this.get().locator('.nc-select-hook-notification-type >> .ant-select-selection-item').innerText()).toBe(notificationType);
await expect(await this.get().locator('.nc-select-hook-url-method >> .ant-select-selection-item').innerText()).toBe(urlMethod);
await expect(await this.get().locator('input.nc-text-field-hook-url-path').inputValue()).toBe(url);
await expect(await this.get().locator('label.nc-check-box-hook-condition >> input[type="checkbox"]').isChecked()).toBe(condition);
await expect.poll(
async () => await this.get().locator('input.nc-text-field-hook-title').inputValue()
).toBe(title);
await expect(this.get().locator('.nc-text-field-hook-event >> .ant-select-selection-item')).toHaveText(hookEvent);
await expect(this.get().locator('.nc-select-hook-notification-type >> .ant-select-selection-item')).toHaveText(notificationType);
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() {

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 }) {
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 }) {
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}) {
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;
for (const option of options) {
const optionInDom = await this.rootPage.locator(`div.ant-select-item-option`).nth(counter)
.evaluate((node) => (node as HTMLElement).innerText)
await expect(optionInDom).toBe(option);
await expect(this.rootPage.locator(`div.ant-select-item-option`).nth(counter)).toHaveText(option);
counter++;
}
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 cell = this.get({ index, columnHeader });
const chips = cell.locator(".chips > .chip");
const chipCount = await chips.count();
// verify chip count & contents
if(count) expect(chipCount).toEqual(count);
if(count) expect(chips).toHaveCount(count);
// verify only the elements that are passed in
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" });
// editable cell
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
);
// right click context menu
@ -191,23 +190,22 @@ export class CellPageObject extends BasePage {
await expect(
await this.rootPage
.locator(`.nc-dropdown-grid-context-menu:visible`)
.count()
).toBe(param.role === "creator" || param.role === "editor" ? 1 : 0);
).toHaveCount(param.role === "creator" || param.role === "editor" ? 1 : 0);
// virtual cell
const vCell = await this.get({ index: 0, columnHeader: "City List" });
await vCell.hover();
// 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
);
// in-cell expand (all have access)
await expect(
await vCell.locator(".nc-action-icon.nc-arrow-expand:visible").count()
).toBe(1);
await vCell.locator(".nc-action-icon.nc-arrow-expand:visible")
).toHaveCount(1);
await vCell.click();
// 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
);
}

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 }) {
await expect(
await this.get()
const checkbox = this.get()
.locator(`[pw-data="nc-fields-menu-${title}"]`)
.locator('input[type="checkbox"]')
.isChecked()
).toBe(checked);
.locator('input[type="checkbox"]');
if (checked) {
await expect(checkbox).toBeChecked();
} else {
await expect(checkbox).not.toBeChecked();
}
}
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;
value: string;
}) {
await expect(
await this.get().locator('.nc-filter-field-select').nth(index).innerText()
).toBe(column);
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);
await expect(this.get().locator('.nc-filter-field-select').nth(index)).toHaveText(column);
await expect(this.get().locator('.nc-filter-operation-select').nth(index)).toHaveText(operator);
await expect.poll(async () => this.get().locator('input.nc-filter-value-select').nth(index).inputValue()).toBe(value);
}
async verifyFilter({ title }: { title: string }) {
await expect(
await this.get()
.locator(`[pw-data="nc-fields-menu-${title}"]`)
.locator('input[type="checkbox"]')
.isChecked()
).toBe(true);
this.get().locator(`[pw-data="nc-fields-menu-${title}"]`).locator('input[type="checkbox"]')
).toBeChecked();
}
// 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;
direction: string;
}) {
await expect(
await this.get().locator('.nc-sort-field-select').nth(index).innerText()
).toBe(column);
await expect(
await this.get().locator('.nc-sort-dir-select >> span.ant-select-selection-item').nth(index).innerText()
).toBe(direction);
await expect(this.get().locator('.nc-sort-field-select').nth(index)).toHaveText(column);
await expect(await this.get().locator('.nc-sort-dir-select >> span.ant-select-selection-item').nth(index)).toHaveText(direction);
}
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"],
};
let text = await this.get().innerText();
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
);
}

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

@ -61,9 +61,7 @@ export abstract class ErdBasePage extends BasePage {
}
async verifyNodesCount(count: number) {
await expect.poll(
async () => await this.get().locator('.nc-erd-table-node').count()
).toBe(count);
await expect(this.get().locator('.nc-erd-table-node')).toHaveCount(count);
}
async verifyEdgesCount({
@ -75,15 +73,9 @@ export abstract class ErdBasePage extends BasePage {
circleCount: number;
rectangleCount: number;
}) {
await expect.poll(
async () => await this.get().locator('.vue-flow__edge').count()
).toBe(count);
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);
await expect(this.get().locator('.vue-flow__edge')).toHaveCount(count);
await expect(this.get().locator('.nc-erd-edge-circle')).toHaveCount(circleCount);
await expect(this.get().locator('.nc-erd-edge-rect')).toHaveCount(rectangleCount);
}
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 }) {
let title = await this.rootPage
.locator(`.nc-project-page-title`)
.textContent();
let menu = await this.rootPage
.locator(`.nc-new-project-menu`)
.textContent();
await expect(title).toContain(param.json.title.myProject);
await expect(menu).toContain(param.json.title.newProj);
const title = await this.rootPage
.locator(`.nc-project-page-title`);
const menu = this.rootPage
.locator(`.nc-new-project-menu`);
await expect(title).toHaveText(param.json.title.myProject);
await expect(menu).toHaveText(param.json.title.newProj);
await this.rootPage
.locator(`[placeholder="${param.json.activity.searchProject}"]`)
.waitFor();

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

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

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

@ -239,7 +239,8 @@ test.describe("View", () => {
columnTitle: "LanguageId",
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.verifyStackOrder({

Loading…
Cancel
Save