Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend test widget functionality #2109

Merged
merged 2 commits into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/e2e/maps/apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ export class ApisWidget {
await this.page.waitForSelector("api-list.block");
await this.page.waitForSelector("api-list div.table div.table-body div.table-row");
}

public async getApisCount(): Promise<number | undefined> {
return await this.page.evaluate(() =>
document.querySelector("api-list div.table div.table-body div.table-row")?.parentElement?.childElementCount
);
}
}
6 changes: 6 additions & 0 deletions tests/e2e/maps/products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ export class ProductseWidget {
await this.page.waitForSelector("product-list-runtime.block");
await this.page.waitForSelector("product-list-runtime div.table div.table-body div.table-row");
}

public async getProductsCount(): Promise<number | undefined> {
return await this.page.evaluate(() =>
document.querySelector("product-list-runtime div.table div.table-body div.table-row")?.parentElement?.childElementCount
);
}
}
5 changes: 5 additions & 0 deletions tests/e2e/maps/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ export class ProfileWidget {
await this.page.waitForSelector("profile-runtime .row");
await this.page.waitForSelector("subscriptions-runtime .table-row");
}

public async getUserEmail(): Promise<string | undefined | null> {
await this.page.waitForSelector("[data-bind='text: user().email']");
return await this.page.evaluate(() =>document.querySelector("[data-bind='text: user().email']")?.textContent);
}
}
3 changes: 3 additions & 0 deletions tests/e2e/maps/signup-basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export class SignupBasicWidget {
await this.page.type("#firstName", "Foo");
await this.page.type("#lastName", "Bar");
await this.page.click("#signup");
}

public async getConfirmationMessageValue(): Promise<string | undefined | null> {
await this.page.waitForSelector("#confirmationMessage");
return await this.page.evaluate(() => document.getElementById("confirmationMessage")?.textContent);
}
}
4 changes: 1 addition & 3 deletions tests/e2e/runtime/apis.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ describe("Apis page", async () => {
const apiWidget = new ApisWidget(page);
await apiWidget.apis();

expect(await page.evaluate(() =>
document.querySelector("api-list div.table div.table-body div.table-row")?.parentElement?.childElementCount
)).to.equal(apis.apiList.length);
expect(await apiWidget.getApisCount()).to.equal(apis.apiList.length);
});
});
4 changes: 1 addition & 3 deletions tests/e2e/runtime/products.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ describe("Products page", async () => {
const productWidget = new ProductseWidget(page);
await productWidget.products();

expect(await page.evaluate(() =>
document.querySelector("product-list-runtime div.table div.table-body div.table-row")?.parentElement?.childElementCount
)).to.equal(products.productList.length);
expect(await productWidget.getProductsCount()).to.equal(products.productList.length);
});
});
4 changes: 1 addition & 3 deletions tests/e2e/runtime/profile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ describe("User profile", async () => {
const profileWidget = new ProfileWidget(page);
await profileWidget.profile();

expect(await page.evaluate(() =>
document.querySelector("[data-bind='text: user().email']")?.textContent
)).to.equal(userInfo.email);
expect(await profileWidget.getUserEmail()).to.equal(userInfo.email);
});
});
2 changes: 1 addition & 1 deletion tests/e2e/runtime/signup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("User sign-up flow", async () => {
const signUpWidget = new SignupBasicWidget(page);
await signUpWidget.signUpWithBasic();

expect(await page.evaluate(() => document.getElementById("confirmationMessage")?.textContent))
expect(await signUpWidget.getConfirmationMessageValue())
.to.equal("Follow the instructions from the email to verify your account.");
});

Expand Down