Browse Source

feat(testing): Stability

pull/3848/head
Muhammed Mustafa 2 years ago
parent
commit
533bf1581a
  1. 3
      scripts/playwright/pages/Base.ts
  2. 6
      scripts/playwright/pages/Dashboard/Settings/Acl.ts
  3. 4
      scripts/playwright/pages/Dashboard/TreeView.ts
  4. 4
      scripts/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts
  5. 4
      scripts/playwright/pages/Dashboard/common/Toolbar/index.ts
  6. 3
      scripts/playwright/pages/ProjectsPage/index.ts
  7. 13
      scripts/playwright/tests/01-webhook.spec.ts

3
scripts/playwright/pages/Base.ts

@ -16,8 +16,7 @@ export default abstract class BasePage {
await this.rootPage
.locator(".ant-message .ant-message-notice-content", { hasText: message })
.last()
.textContent()
.then((text) => expect(text).toContain(message));
.isVisible();
// await this.rootPage
// .locator(".ant-message .ant-message-notice-content", { hasText: message })

6
scripts/playwright/pages/Dashboard/Settings/Acl.ts

@ -21,7 +21,11 @@ export class AclPage extends BasePage {
}
async save() {
this.get().locator(`button:has-text("Save")`).click();
await this.waitForResponse({
uiAction: this.get().locator(`button:has-text("Save")`).click(),
httpMethodsToMatch: ["POST"],
requestUrlPathToMatch: '/visibility-rules'
})
await this.toastWait({ message: "Updated UI ACL for tables successfully" });
}
}

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

@ -47,8 +47,8 @@ export class TreeViewPage extends BasePage {
await this.waitForResponse({
uiAction: this.get().locator(`.nc-project-tree-tbl-${title}`).click(),
httpMethodsToMatch: ["GET"],
requestUrlPathToMatch: `/api/v1/db/meta/tables/`,
responseJsonMatcher: (json) => json.title === title,
requestUrlPathToMatch: `/api/v1/db/data/noco/`,
responseJsonMatcher: (json) => json.pageInfo,
});
await this.dashboard.waitForTabRender({ title, mode });
}

4
scripts/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts

@ -38,11 +38,11 @@ export class ToolbarViewMenuPage extends BasePage {
]);
// Save downloaded file somewhere
await download.saveAs("./at.txt");
await download.saveAs("./output/at.txt");
// verify downloaded content against expected content
const expectedData = fs.readFileSync(expectedDataFile, "utf8");
const file = fs.readFileSync("./at.txt", "utf8");
const file = fs.readFileSync("./output/at.txt", "utf8");
await expect(file).toEqual(expectedData);
}

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

@ -110,11 +110,11 @@ export class ToolbarPage extends BasePage {
]);
// Save downloaded file somewhere
await download.saveAs("./at.txt");
await download.saveAs("./output/at.txt");
// verify downloaded content against expected content
const expectedData = fs.readFileSync("./fixtures/expectedData.txt", "utf8");
const file = fs.readFileSync("./at.txt", "utf8");
const file = fs.readFileSync("./output/at.txt", "utf8");
await expect(file).toEqual(expectedData);
}

3
scripts/playwright/pages/ProjectsPage/index.ts

@ -163,5 +163,8 @@ export class ProjectsPage extends BasePage {
requestUrlPathToMatch: 'api/v1/db/meta/projects/',
httpMethodsToMatch: ['PATCH'],
});
// todo: vue navigation breaks if page changes very quickly
await this.rootPage.waitForTimeout(1000);
}
}

13
scripts/playwright/tests/01-webhook.spec.ts

@ -20,17 +20,24 @@ async function clearServerData({ request }) {
async function verifyHookTrigger(count: number, value: string, request) {
// Retry since there can be lag between the time the hook is triggered and the time the server receives the request
let response;
for (let i = 0; i < 6; i++) {
for (let i = 0; i < 20; i++) {
response = await request.get(hookPath + "/count");
if ((await response.json()) === count) {
break;
}
await new Promise((resolve) => setTimeout(resolve, 100));
await new Promise((resolve) => setTimeout(resolve, 150));
}
await expect(await response.json()).toBe(count);
if (count) {
response = await request.get(hookPath + "/last");
let response;
for (let i = 0; i < 20; i++) {
response = await request.get(hookPath + "/last");
if (((await response.json()).Title) === value) {
break;
}
await new Promise((resolve) => setTimeout(resolve, 150));
}
await expect((await response.json()).Title).toBe(value);
}
}

Loading…
Cancel
Save