forgejo-frontend-integration/tests/auth.spec.ts

59 lines
1.9 KiB
TypeScript
Raw Normal View History

2024-01-09 23:35:51 +05:30
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
import { test, expect } from "@playwright/test";
import * as config from "./config";
import User from "./user";
test("has title", async ({ page }) => {
await page.goto(config.INSTANCE_URL.toString());
2024-01-10 01:57:49 +05:30
await expect(page).toHaveTitle("Forgejo: Beyond coding. We forge.");
});
test("Go to explore page", async ({ page }) => {
await page.goto(config.INSTANCE_URL.toString());
await page.getByRole("link", { name: "Explore" }).click();
await page.waitForURL("**/explore/repos");
2024-01-10 01:57:49 +05:30
await expect(page).toHaveTitle("Explore - Forgejo: Beyond coding. We forge.");
});
test("Go to register page", async ({ page }) => {
const user = new User("gotoregisterpage");
console.log(`running with user ${user.username}`);
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(user.email);
await page.getByLabel("Password", { exact: true }).fill(user.password);
// passwords don't match
await page.getByLabel("Confirm Password").fill(user.username);
await page.getByRole("button", { name: "Register Account" }).click();
await expect(page).toHaveTitle(
2024-01-10 01:57:49 +05:30
"Register - Forgejo: Beyond coding. We forge."
);
expect(page.locator(".negative > p:nth-child(1)")).toContainText(
"passwords do not match"
);
// successful registration
await user.register(page);
2024-01-10 02:06:26 +05:30
await page.waitForURL(config.INSTANCE_URL.toString());
await expect(page).toHaveTitle(
2024-01-10 01:57:49 +05:30
`${user.username} - Dashboard - Forgejo: Beyond coding. We forge.`
);
expect(page.locator(".positive > p:nth-child(1)")).toContainText(
"Account was successfully created. Welcome!"
);
});