2024-01-09 23:35:51 +05:30
|
|
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
2024-01-09 23:31:52 +05:30
|
|
|
import { test, expect } from "@playwright/test";
|
|
|
|
import * as config from "./config";
|
|
|
|
|
|
|
|
test("has title", async ({ page }) => {
|
|
|
|
await page.goto(config.INSTANCE_URL.toString());
|
|
|
|
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");
|
|
|
|
|
|
|
|
await expect(page).toHaveTitle("Explore - Forgejo: Beyond coding. We Forge.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("Go to register page", async ({ 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").fill(config.USER_1.username);
|
|
|
|
await page.getByLabel("Email Address").fill(config.USER_1.email);
|
|
|
|
await page
|
|
|
|
.getByLabel("Password", { exact: true })
|
|
|
|
.fill(config.USER_1.password);
|
|
|
|
// passwords don't match
|
|
|
|
await page.getByLabel("Confirm Password").fill(config.USER_1.username);
|
|
|
|
|
|
|
|
await page.getByRole("button", { name: "Register Account" }).click();
|
|
|
|
|
|
|
|
await expect(page).toHaveTitle(
|
|
|
|
"Register - Forgejo: Beyond coding. We Forge."
|
|
|
|
);
|
|
|
|
expect(page.locator(".negative > p:nth-child(1)")).toContainText(
|
|
|
|
"passwords do not match"
|
|
|
|
);
|
|
|
|
|
|
|
|
// 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(config.USER_1.username);
|
|
|
|
await page.getByLabel("Email Address").fill(config.USER_1.email);
|
|
|
|
await page
|
|
|
|
.getByLabel("Password", { exact: true })
|
|
|
|
.fill(config.USER_1.password);
|
|
|
|
await page.getByLabel("Confirm Password").fill(config.USER_1.password);
|
|
|
|
await page.getByRole("button", { name: "Register Account" }).click();
|
|
|
|
|
|
|
|
await page.waitForURL("http://localhost:3001/");
|
|
|
|
await page.waitForSelector(".positive > p:nth-child(1)");
|
|
|
|
console.log(page.locator(".positive > p:nth-child(1)"));
|
|
|
|
|
|
|
|
await expect(page).toHaveTitle(
|
|
|
|
`${config.USER_1.username} - Dashboard - Forgejo: Beyond coding. We Forge.`
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(page.locator(".positive > p:nth-child(1)")).toContainText(
|
|
|
|
"Account was successfully created. Welcome!"
|
|
|
|
);
|
|
|
|
});
|