Test website publication and remove collab account

This commit is contained in:
thiloho
2024-09-01 13:37:28 +02:00
parent 187287ec4f
commit 7a6e7f16c5
3 changed files with 36 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
import { type PlaywrightTestConfig } from "@playwright/test"; import { type PlaywrightTestConfig, devices } from "@playwright/test";
const config: PlaywrightTestConfig = { const config: PlaywrightTestConfig = {
webServer: { webServer: {
@@ -9,7 +9,14 @@ const config: PlaywrightTestConfig = {
baseURL: "http://localhost:4173" baseURL: "http://localhost:4173"
}, },
testDir: "tests", testDir: "tests",
testMatch: /(.+\.)?(test|spec)\.ts/ testMatch: /(.+\.)?(test|spec)\.ts/,
// Firefox and Webkit are not packaged yet, see https://github.com/NixOS/nixpkgs/issues/288826
projects: [
{
name: "Chromium",
use: { ...devices["Desktop Chrome"] }
}
]
}; };
export default config; export default config;

View File

@@ -28,7 +28,13 @@ export const load: PageServerLoad = async ({ params, fetch, cookies, parent }) =
generateStaticFiles(websiteOverview); generateStaticFiles(websiteOverview);
const websitePreviewUrl = `${dev ? "http://localhost:18000" : process.env.ORIGIN}/previews/${websiteOverview.id}/index.html`; const websitePreviewUrl = `${
dev
? "http://localhost:18000"
: process.env.ORIGIN
? process.env.ORIGIN
: "http://localhost:18000"
}/previews/${websiteOverview.id}/index.html`;
return { return {
websiteOverview, websiteOverview,

View File

@@ -201,6 +201,14 @@ test.describe("Update website", () => {
}); });
}); });
test("Publish website", async ({ authenticatedPage: page }) => {
await page.getByRole("link", { name: "Blog" }).click();
await page.getByRole("link", { name: "Publish" }).click();
await page.getByRole("button", { name: "Publish" }).click();
await expect(page.getByText("Successfully published website")).toBeVisible();
await expect(page.getByText("Your website is published at")).toBeVisible();
});
test("Delete websites", async ({ authenticatedPage: page }) => { test("Delete websites", async ({ authenticatedPage: page }) => {
await page.getByRole("button", { name: "Delete" }).nth(1).click(); await page.getByRole("button", { name: "Delete" }).nth(1).click();
await page.getByRole("button", { name: "Delete website" }).click(); await page.getByRole("button", { name: "Delete website" }).click();
@@ -222,5 +230,16 @@ test("Delete account", async ({ authenticatedPage: page }) => {
.locator("#delete-account-modal") .locator("#delete-account-modal")
.getByRole("button", { name: "Delete account" }) .getByRole("button", { name: "Delete account" })
.click(); .click();
await expect(page.getByRole("heading", { name: "Login" })).toBeVisible();
await page.getByLabel("Username:").fill(collabUsername);
await page.getByLabel("Password:").fill(password);
await page.getByRole("button", { name: "Submit" }).click();
await page.getByRole("link", { name: "Account" }).click();
await page.getByRole("button", { name: "Delete account" }).click();
await page.getByLabel("Password:").click();
await page.getByLabel("Password:").fill(password);
await page
.locator("#delete-account-modal")
.getByRole("button", { name: "Delete account" })
.click();
}); });