From 47120c40b03bda714a3fe46a74bfb19416a90499 Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Wed, 10 Jan 2024 20:51:16 +0530 Subject: [PATCH] fix: admin account creation --- tests/create-admin.spec.ts | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/tests/create-admin.spec.ts b/tests/create-admin.spec.ts index fe7b08f..12b5f1c 100644 --- a/tests/create-admin.spec.ts +++ b/tests/create-admin.spec.ts @@ -9,8 +9,25 @@ import User from "./user"; test("Create admin fixture @setup", async ({ page }) => { const admin = new User(config.ADMIN_USERNAME); admin.setAdmin(); - 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"); + 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(admin.username); + await page.getByLabel("Email Address").fill(admin.email); + await page.getByLabel("Password", { exact: true }).fill(admin.password); + await page.getByLabel("Confirm Password").fill(admin.password); + await page.getByRole("button", { name: "Register Account" }).click(); + + await page.waitForURL(config.INSTANCE_URL.toString()); + + expect(page.locator(".positive > p:nth-child(1)")).toContainText( + "Account was successfully created. Welcome!" + ); + });