Browse Source

fix: Fixed tests

pull/6499/head
Muhammed Mustafa 1 year ago
parent
commit
142bb9b88c
  1. 42
      tests/playwright/pages/Dashboard/Form/index.ts
  2. 11
      tests/playwright/pages/Dashboard/Grid/Group.ts
  3. 11
      tests/playwright/pages/Dashboard/Grid/index.ts
  4. 3
      tests/playwright/tests/db/features/metaLTAR.spec.ts

42
tests/playwright/pages/Dashboard/Form/index.ts

@ -146,8 +146,24 @@ export class FormPage extends BasePage {
}
async configureHeader(param: { subtitle: string; title: string }) {
await this.formHeading.fill(param.title);
await this.formSubHeading.fill(param.subtitle);
await this.waitForResponse({
uiAction: async () => {
await this.formHeading.click();
await this.formHeading.fill(param.title);
await this.formSubHeading.click();
},
requestUrlPathToMatch: 'api/v1/db/meta/forms',
httpMethodsToMatch: ['PATCH'],
});
await this.waitForResponse({
uiAction: async () => {
await this.formSubHeading.click();
await this.formSubHeading.fill(param.subtitle);
await this.formHeading.click();
},
requestUrlPathToMatch: 'api/v1/db/meta/forms',
httpMethodsToMatch: ['PATCH'],
});
}
async verifyHeader(param: { subtitle: string; title: string }) {
@ -177,14 +193,21 @@ export class FormPage extends BasePage {
label: string;
helpText: string;
}) {
const waitForResponse = async (action: () => Promise<any>) =>
await this.waitForResponse({
uiAction: action,
requestUrlPathToMatch: 'api/v1/db/meta/form-columns',
httpMethodsToMatch: ['PATCH'],
});
await this.get()
.locator(`.nc-form-drag-${field.replace(' ', '')}`)
.locator('div[data-testid="nc-form-input-label"]')
.click();
await this.getFormFieldsInputLabel().fill(label);
await this.getFormFieldsInputHelpText().fill(helpText);
await waitForResponse(() => this.getFormFieldsInputLabel().fill(label));
await waitForResponse(() => this.getFormFieldsInputHelpText().fill(helpText));
if (required) {
await this.getFormFieldsRequired().click();
await waitForResponse(() => this.getFormFieldsRequired().click());
}
await this.formHeading.click();
}
@ -241,7 +264,14 @@ export class FormPage extends BasePage {
}
async configureSubmitMessage(param: { message: string }) {
await this.afterSubmitMsg.fill(param.message);
await this.waitForResponse({
uiAction: async () => {
await this.afterSubmitMsg.click();
await this.afterSubmitMsg.fill(param.message);
},
requestUrlPathToMatch: 'api/v1/db/meta/forms',
httpMethodsToMatch: ['PATCH'],
});
}
submitAnotherForm() {

11
tests/playwright/pages/Dashboard/Grid/Group.ts

@ -100,15 +100,16 @@ export class GroupPageObject extends BasePage {
const addNewRowBtn = this.get({ indexMap }).locator('.nc-grid-add-new-row');
await addNewRowBtn.scrollIntoViewIfNeeded();
await (await addNewRowBtn.elementHandle()).waitForElementState('stable');
await this.rootPage.waitForTimeout(100);
const rowCount = await this.get({ indexMap }).locator('.nc-grid-row').count();
await this.rootPage.waitForTimeout(200);
await this.rootPage.waitForLoadState('networkidle');
await this.rootPage.waitForTimeout(200);
await this.rootPage.waitForLoadState('domcontentloaded');
await this.get({ indexMap }).locator('.nc-grid-add-new-row').click();
// add delay for UI to render (can wait for count to stabilize by reading it multiple times)
await this.rootPage.waitForTimeout(100);
expect(await this.get({ indexMap }).locator('.nc-grid-row').count()).toBe(rowCount + 1);
const rowCount = index + 1;
await expect(this.get({ indexMap }).locator('.nc-grid-row')).toHaveCount(rowCount);
await this._fillRow({ indexMap, index, columnHeader, value: rowValue });

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

@ -115,15 +115,16 @@ export class GridPage extends BasePage {
if (index !== 0) await this.get().locator('.nc-grid-row').nth(0).waitFor({ state: 'attached' });
await (await this.get().locator('.nc-grid-add-new-cell').elementHandle())?.waitForElementState('stable');
await this.rootPage.waitForTimeout(100);
const rowCount = await this.get().locator('.nc-grid-row').count();
await this.rootPage.waitForTimeout(200);
await this.rootPage.waitForLoadState('networkidle');
await this.rootPage.waitForTimeout(200);
await this.rootPage.waitForLoadState('domcontentloaded');
await this.get().locator('.nc-grid-add-new-cell').click();
// add delay for UI to render (can wait for count to stabilize by reading it multiple times)
await this.rootPage.waitForTimeout(100);
await expect(this.get().locator('.nc-grid-row')).toHaveCount(rowCount + 1);
const rowCount = index + 1;
await expect(this.get().locator('.nc-grid-row')).toHaveCount(rowCount);
await this._fillRow({ index, columnHeader, value: rowValue });

3
tests/playwright/tests/db/features/metaLTAR.spec.ts

@ -56,7 +56,10 @@ test.describe.serial('Test table', () => {
grid = dashboard.grid;
// create a new xcdb project
await dashboard.rootPage.waitForTimeout(650);
const xcdb = await createXcdb(context);
await dashboard.rootPage.waitForTimeout(650);
await dashboard.rootPage.reload();
await dashboard.treeView.openProject({ title: 'xcdb', context });

Loading…
Cancel
Save