Browse Source

feat(testing): Cleanup

pull/3848/head
Muhammed Mustafa 2 years ago
parent
commit
a45c4339d8
  1. 10
      scripts/playwright/pages/Base.ts
  2. 2
      scripts/playwright/pages/Dashboard/ExpandedForm/index.ts
  3. 2
      scripts/playwright/pages/Dashboard/Grid/Column/index.ts
  4. 2
      scripts/playwright/pages/Dashboard/Settings/Acl.ts
  5. 2
      scripts/playwright/pages/Dashboard/Settings/Metadata.ts
  6. 2
      scripts/playwright/pages/Dashboard/Settings/Teams.ts
  7. 2
      scripts/playwright/pages/Dashboard/TreeView.ts
  8. 8
      scripts/playwright/pages/Dashboard/ViewSidebar/index.ts
  9. 4
      scripts/playwright/pages/Dashboard/WebhookForm/index.ts
  10. 2
      scripts/playwright/pages/Dashboard/common/Toolbar/AddEditKanbanStack.ts
  11. 2
      scripts/playwright/pages/Dashboard/common/Toolbar/ShareView.ts
  12. 6
      scripts/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts
  13. 2
      scripts/playwright/tests/expandedFormUrl.spec.ts
  14. 6
      scripts/playwright/tests/rolesSuperUser.spec.ts
  15. 6
      scripts/playwright/tests/viewForm.spec.ts
  16. 2
      scripts/playwright/tests/viewGridShare.spec.ts

10
scripts/playwright/pages/Base.ts

@ -1,4 +1,4 @@
import { Page, expect, Locator } from "@playwright/test";
import { Page, Locator } from "@playwright/test";
type ResponseSelector = (json: any) => boolean;
@ -11,17 +11,11 @@ export default abstract class BasePage {
this.rootPage = rootPage;
}
async toastWait({ message }: { message: string }) {
// todo: text of toaster shows old one in the test assertion
async verifyToast({ message }: { message: string }) {
await this.rootPage
.locator(".ant-message .ant-message-notice-content", { hasText: message })
.last()
.isVisible();
// await this.rootPage
// .locator(".ant-message .ant-message-notice-content", { hasText: message })
// .last()
// .waitFor({ state: "detached" });
}
async waitForResponse({

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

@ -78,7 +78,7 @@ export class ExpandedFormPage extends BasePage {
await this.get().press("Escape");
await this.get().waitFor({ state: "hidden" });
await this.toastWait({ message: `updated successfully.` });
await this.verifyToast({ message: `updated successfully.` });
await this.rootPage
.locator('[pw-data="grid-load-spinner"]')
.waitFor({ state: "hidden" });

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

@ -210,7 +210,7 @@ export class ColumnPageObject extends BasePage {
responseJsonMatcher: (json) => json['pageInfo'],
});
await this.toastWait({
await this.verifyToast({
message: isUpdated ? "Column updated" : "Column created",
});
await this.get().waitFor({ state: "hidden" });

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

@ -26,6 +26,6 @@ export class AclPage extends BasePage {
httpMethodsToMatch: ["POST"],
requestUrlPathToMatch: '/visibility-rules'
})
await this.toastWait({ message: "Updated UI ACL for tables successfully" });
await this.verifyToast({ message: "Updated UI ACL for tables successfully" });
}
}

2
scripts/playwright/pages/Dashboard/Settings/Metadata.ts

@ -25,7 +25,7 @@ export class MetaDataPage extends BasePage {
async sync(){
await this.get().locator(`button:has-text("Sync Now")`).click();
await this.toastWait({message: 'Table metadata recreated successfully'});
await this.verifyToast({message: 'Table metadata recreated successfully'});
await this.get().locator(`.animate-spin`).waitFor({state: 'visible'});
await this.get().locator(`.animate-spin`).waitFor({state: 'detached'});
}

2
scripts/playwright/pages/Dashboard/Settings/Teams.ts

@ -44,7 +44,7 @@ export class TeamsPage extends BasePage {
const userRoleModal = this.rootPage.locator(`.nc-dropdown-user-role`);
await userRoleModal.locator(`.nc-role-option:has-text("${role}")`).click();
await this.inviteTeamModal.locator(`button:has-text("Invite")`).click();
await this.toastWait({ message: "Successfully updated the user details" });
await this.verifyToast({ message: "Successfully updated the user details" });
return await this.inviteTeamModal.locator(`.ant-alert-message`).innerText();
}

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

@ -149,7 +149,7 @@ export class TreeViewPage extends BasePage {
.locator('[placeholder="Enter table name"]')
.fill(newTitle);
await this.dashboard.get().locator('button:has-text("Submit")').click();
await this.toastWait({ message: "Table renamed successfully" });
await this.verifyToast({ message: "Table renamed successfully" });
}
async reorderTables({

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

@ -48,7 +48,7 @@ export class ViewSidebarPage extends BasePage {
uiAction: submitAction,
responseJsonMatcher: (json) => json.title === title,
});
await this.toastWait({ message: "View created successfully" });
await this.verifyToast({ message: "View created successfully" });
// Todo: Wait for view to be rendered
await this.rootPage.waitForTimeout(1000);
}
@ -132,7 +132,7 @@ export class ViewSidebarPage extends BasePage {
// .locator(".nc-modal-view-delete")
// .locator('button:has-text("Submit")')
// .waitFor({ state: "detached" });
await this.toastWait({ message: "View deleted successfully" });
await this.verifyToast({ message: "View deleted successfully" });
}
async renameView({ title, newTitle }: { title: string; newTitle: string }) {
@ -144,7 +144,7 @@ export class ViewSidebarPage extends BasePage {
.locator("input")
.fill(newTitle);
await this.get().press("Enter");
await this.toastWait({ message: "View renamed successfully" });
await this.verifyToast({ message: "View renamed successfully" });
}
async copyView({ title }: { title: string }) {
@ -162,7 +162,7 @@ export class ViewSidebarPage extends BasePage {
requestUrlPathToMatch: "/api/v1/db/meta/tables/",
uiAction: submitAction,
});
await this.toastWait({ message: "View created successfully" });
await this.verifyToast({ message: "View created successfully" });
}
async validateRoleAccess(param: { role: string }) {

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

@ -123,7 +123,7 @@ export class WebhookFormPage extends BasePage {
async test() {
await this.testButton.click();
await this.toastWait({ message: "Webhook tested successfully" });
await this.verifyToast({ message: "Webhook tested successfully" });
}
async delete({ index }: { index: number }) {
@ -131,7 +131,7 @@ export class WebhookFormPage extends BasePage {
await this.toolbar.actions.click("Webhooks");
await this.get().locator(`.nc-hook-delete-icon`).nth(index).click();
await this.toastWait({ message: "Hook deleted successfully" });
await this.verifyToast({ message: "Hook deleted successfully" });
// click escape to close the drawer
await this.get().press("Escape");

2
scripts/playwright/pages/Dashboard/common/Toolbar/AddEditKanbanStack.ts

@ -20,6 +20,6 @@ export class ToolbarAddEditStackPage extends BasePage {
.locator(`.nc-select-option >> input`)
.last()
.press("Enter");
await this.toastWait({ message: "Column updated" });
await this.verifyToast({ message: "Column updated" });
}
}

2
scripts/playwright/pages/Dashboard/common/Toolbar/ShareView.ts

@ -23,7 +23,7 @@ export class ToolbarShareViewPage extends BasePage {
await this.get()
.locator(`[data-pw="nc-modal-share-view__save-password"]`)
.click();
await this.toastWait({ message: "Successfully updated" });
await this.verifyToast({ message: "Successfully updated" });
}
async disablePassword() {

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

@ -79,17 +79,17 @@ export class ToolbarViewMenuPage extends BasePage {
switch (subMenu) {
case "Download as CSV":
await this.toastWait({
await this.verifyToast({
message: "Successfully exported all table data",
});
break;
case "Locked View":
await this.toastWait({
await this.verifyToast({
message: "Successfully Switched to locked view",
});
break;
case "Collaborative View":
await this.toastWait({
await this.verifyToast({
message: "Successfully Switched to collaborative view",
});
break;

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

@ -63,7 +63,7 @@ test.describe("Expanded form URL", () => {
await dashboard.rootPage.goto(
"/" + url.split("/").slice(3).join("/").split("?")[0] + "?rowId=999"
);
await dashboard.toastWait({ message: "Record not found" });
await dashboard.verifyToast({ message: "Record not found" });
// ensure grid is displayed after invalid URL access
await viewObj.verifyRowCount({ count: 25 });

6
scripts/playwright/tests/rolesSuperUser.spec.ts

@ -32,7 +32,7 @@ test.describe("Super user", () => {
.locator('[placeholder="Webhook URL"]')
.fill("http://test.com");
await slackModal.locator('button:has-text("Save")').click();
await dashboard.toastWait({ message: "Successfully installed" });
await dashboard.verifyToast({ message: "Successfully installed" });
// Modify configuration
await card.click();
@ -45,13 +45,13 @@ test.describe("Super user", () => {
.locator('[placeholder="Webhook URL"]')
.fill("http://test2.com");
await slackModal.locator('button:has-text("Save")').click();
await dashboard.toastWait({ message: "Successfully installed" });
await dashboard.verifyToast({ message: "Successfully installed" });
// Uninstall
await card.click();
await card.locator(".nc-app-store-card-reset").click();
slackModal = await appPage.locator(".nc-modal-plugin-uninstall");
await slackModal.locator('button:has-text("Confirm")').click();
await dashboard.toastWait({ message: "Plugin uninstalled successfully" });
await dashboard.verifyToast({ message: "Plugin uninstalled successfully" });
});
});

6
scripts/playwright/tests/viewForm.spec.ts

@ -163,7 +163,7 @@ test.describe("Form view", () => {
// enable 'email-me' option
await form.showAnotherFormAfter5SecRadioButton.click();
await form.emailMeRadioButton.click();
await dashboard.toastWait({
await dashboard.verifyToast({
message:
"Please activate SMTP plugin in App store for enabling email notification",
});
@ -177,7 +177,7 @@ test.describe("Form view", () => {
host: "smtp.gmail.com",
port: "587",
});
await dashboard.toastWait({
await dashboard.verifyToast({
message:
"Successfully installed and email notification will use SMTP configuration",
});
@ -197,7 +197,7 @@ test.describe("Form view", () => {
await dashboard.settings.selectTab({ tab: SettingTab.AppStore });
await dashboard.settings.appStore.uninstall({ name: "SMTP" });
await dashboard.toastWait({
await dashboard.verifyToast({
message: "Plugin uninstalled successfully",
});
await dashboard.settings.close();

2
scripts/playwright/tests/viewGridShare.spec.ts

@ -213,7 +213,7 @@ test.describe("Shared view", () => {
.locator('input[placeholder="Enter password"]')
.fill("incorrect p@ssword");
await sharedPage2.rootPage.click('button:has-text("Unlock")');
await sharedPage2.toastWait({ message: "INVALID_SHARED_VIEW_PASSWORD" });
await sharedPage2.verifyToast({ message: "INVALID_SHARED_VIEW_PASSWORD" });
// correct password
await sharedPage2.rootPage

Loading…
Cancel
Save