feat: refactor registration code to be reusable
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
a16d903d5a
commit
80d6e80112
2 changed files with 29 additions and 14 deletions
|
@ -45,22 +45,9 @@ test("Go to register page", async ({ page }) => {
|
|||
|
||||
// successful registration
|
||||
|
||||
// clear past inputs, if any
|
||||
await page.getByLabel("Username").clear();
|
||||
await page.getByLabel("Email Address").clear();
|
||||
await page.getByLabel("Password", { exact: true }).clear();
|
||||
await page.getByLabel("Confirm Password").clear();
|
||||
|
||||
await page.getByLabel("Username").fill(user.username);
|
||||
await page.getByLabel("Email Address").fill(user.email);
|
||||
await page.getByLabel("Password", { exact: true }).fill(user.password);
|
||||
await page.getByLabel("Confirm Password").fill(user.password);
|
||||
await page.getByRole("button", { name: "Register Account" }).click();
|
||||
await user.register(page);
|
||||
|
||||
await page.waitForURL(config.INSTANCE_URL.toString());
|
||||
await page.waitForSelector(".positive > p:nth-child(1)");
|
||||
console.log(page.locator(".positive > p:nth-child(1)"));
|
||||
|
||||
await expect(page).toHaveTitle(
|
||||
`${user.username} - Dashboard - Forgejo: Beyond coding. We forge.`
|
||||
);
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import { Page, expect } from "@playwright/test";
|
||||
import { getRandomString } from "./utils";
|
||||
import * as config from "./config";
|
||||
|
||||
export default class User {
|
||||
username: string;
|
||||
|
@ -12,4 +14,30 @@ export default class User {
|
|||
this.email = `${this.username}@playwright.local`;
|
||||
this.password = "628acdbd8b7b3f";
|
||||
}
|
||||
|
||||
async register(page: Page) {
|
||||
await page.goto(config.INSTANCE_URL.toString());
|
||||
await page.getByRole("link", { name: "Register" }).click();
|
||||
await page.waitForURL("**/user/sign_up");
|
||||
|
||||
await page.getByLabel("Username").clear();
|
||||
await page.getByLabel("Email Address").clear();
|
||||
await page.getByLabel("Password", { exact: true }).clear();
|
||||
await page.getByLabel("Confirm Password").clear();
|
||||
|
||||
await page.getByLabel("Username").fill(this.username);
|
||||
await page.getByLabel("Email Address").fill(this.email);
|
||||
await page.getByLabel("Password", { exact: true }).fill(this.password);
|
||||
await page.getByLabel("Confirm Password").fill(this.password);
|
||||
await page.getByRole("button", { name: "Register Account" }).click();
|
||||
await page.waitForURL(config.INSTANCE_URL.toString());
|
||||
|
||||
await expect(page).toHaveTitle(
|
||||
`${this.username} - Dashboard - Forgejo: Beyond coding. We forge.`
|
||||
);
|
||||
|
||||
expect(page.locator(".positive > p:nth-child(1)")).toContainText(
|
||||
"Account was successfully created. Welcome!"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue