Compare commits
4 Commits
958773125d
...
038a41648a
Author | SHA1 | Date |
---|---|---|
Aravinth Manivannan | 038a41648a | |
Aravinth Manivannan | 1adc85f826 | |
Aravinth Manivannan | 2f699f9fe8 | |
Aravinth Manivannan | d62f482c9c |
|
@ -44,6 +44,58 @@ test("Test registration error: password mismatch", async ({ page }) => {
|
|||
);
|
||||
});
|
||||
|
||||
test("Test registration error: dupe user", async ({ page }) => {
|
||||
const user = new User("dupeuser");
|
||||
const admin = new User(config.ADMIN_USERNAME);
|
||||
admin.setAdmin();
|
||||
|
||||
|
||||
await page.goto(config.INSTANCE_URL.toString());
|
||||
await page.getByRole("link", { name: "Register" }).click();
|
||||
await page.waitForURL("**/user/sign_up");
|
||||
|
||||
await page.getByLabel("Username").fill(admin.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 expect(page).toHaveTitle(
|
||||
"Register - Forgejo: Beyond coding. We forge."
|
||||
);
|
||||
await page.locator(".negative > p:nth-child(1)").waitFor();
|
||||
expect(page.locator(".negative > p:nth-child(1)")).toContainText(
|
||||
"The username is already taken."
|
||||
);
|
||||
});
|
||||
|
||||
test("Test registration error: dupe email", async ({ page }) => {
|
||||
const user = new User("dupemeail");
|
||||
const admin = new User(config.ADMIN_USERNAME);
|
||||
admin.setAdmin();
|
||||
|
||||
await page.goto(config.INSTANCE_URL.toString());
|
||||
await page.getByRole("link", { name: "Register" }).click();
|
||||
await page.waitForURL("**/user/sign_up");
|
||||
|
||||
await page.getByLabel("Username").fill(user.username);
|
||||
await page.getByLabel("Email Address").fill(admin.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 expect(page).toHaveTitle(
|
||||
"Register - Forgejo: Beyond coding. We forge."
|
||||
);
|
||||
await page.locator(".negative > p:nth-child(1)").waitFor();
|
||||
expect(page.locator(".negative > p:nth-child(1)")).toContainText(
|
||||
"The email address is already used."
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
test("Test successful registration", async ({ page }) => {
|
||||
const user = new User("register");
|
||||
|
||||
|
|
|
@ -9,12 +9,8 @@ import User from "./user";
|
|||
test("Create admin fixture @setup", async ({ page }) => {
|
||||
const admin = new User(config.ADMIN_USERNAME);
|
||||
admin.setAdmin();
|
||||
|
||||
try {
|
||||
await admin.register(page);
|
||||
await admin.logout(page);
|
||||
await expect(page).toHaveTitle("Forgejo: Beyond coding. We forge.");
|
||||
} catch {
|
||||
console.log("looks like admin is already registered");
|
||||
}
|
||||
await admin.register(page);
|
||||
await admin.logout(page);
|
||||
await expect(page).toHaveTitle("Forgejo: Beyond coding. We forge.");
|
||||
console.log("looks like admin is already registered");
|
||||
});
|
||||
|
|
|
@ -41,6 +41,7 @@ export default class User {
|
|||
let dropdown = page.locator("div.dropdown:nth-child(4)");
|
||||
await dropdown.click();
|
||||
// await dropdown.getByRole("link", { name: "Sign Out" }).click();
|
||||
await dropdown.getByText("Sign Out").waitFor();
|
||||
await dropdown.getByText("Sign Out").click();
|
||||
await page.waitForURL(config.INSTANCE_URL.toString());
|
||||
|
||||
|
|
Loading…
Reference in New Issue