mirror of
https://github.com/thiloho/archtika.git
synced 2025-11-22 19:01:35 +01:00
Fix tests by generating random lowercase strings for prefixes
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { randomBytes } from "node:crypto";
|
||||
import { platform } from "node:os";
|
||||
|
||||
const username = randomBytes(8).toString("hex");
|
||||
const collabUsername = randomBytes(8).toString("hex");
|
||||
const collabUsername2 = randomBytes(8).toString("hex");
|
||||
const collabUsername3 = randomBytes(8).toString("hex");
|
||||
const collabUsername4 = randomBytes(8).toString("hex");
|
||||
const customPrefix = Buffer.from(randomBytes(16).map((byte) => (byte % 26) + 97)).toString();
|
||||
const customPrefix2 = Buffer.from(randomBytes(16).map((byte) => (byte % 26) + 97)).toString();
|
||||
const password = "T3stuser??!!";
|
||||
|
||||
const permissionLevels = [10, 20, 30];
|
||||
@@ -57,7 +60,7 @@ test.describe.serial("Collaborator tests", () => {
|
||||
await page.getByRole("link", { name: "Publish" }).click();
|
||||
await page.getByRole("button", { name: "Publish" }).click();
|
||||
await page.getByLabel("Prefix:").click();
|
||||
await page.getByLabel("Prefix:").fill("setup");
|
||||
await page.getByLabel("Prefix:").fill(customPrefix);
|
||||
await page.getByRole("button", { name: "Submit" }).click();
|
||||
|
||||
await page.goto("/");
|
||||
@@ -458,8 +461,13 @@ test.describe.serial("Collaborator tests", () => {
|
||||
test("Set custom domain prefix", async ({ page }) => {
|
||||
await page.getByRole("link", { name: "Blog" }).click();
|
||||
await page.getByRole("link", { name: "Publish" }).click();
|
||||
|
||||
const isMac = platform() === "darwin";
|
||||
const modifier = isMac ? "Meta" : "Control";
|
||||
await page.getByLabel("Prefix:").click();
|
||||
await page.getByLabel("Prefix:").fill("blog");
|
||||
await page.keyboard.press(`${modifier}+A`);
|
||||
await page.keyboard.press(`Backspace`);
|
||||
await page.getByLabel("Prefix:").fill(customPrefix2);
|
||||
await page.getByRole("button", { name: "Submit" }).click();
|
||||
|
||||
if ([10, 20].includes(permissionLevel)) {
|
||||
|
||||
@@ -9,6 +9,8 @@ const __dirname = dirname(__filename);
|
||||
|
||||
const username = randomBytes(8).toString("hex");
|
||||
const collabUsername = randomBytes(8).toString("hex");
|
||||
const customPrefix = Buffer.from(randomBytes(16).map((byte) => (byte % 26) + 97)).toString();
|
||||
const customPrefix2 = Buffer.from(randomBytes(16).map((byte) => (byte % 26) + 97)).toString();
|
||||
const password = "T3stuser??!!";
|
||||
|
||||
const test = base.extend<{ authenticatedPage: Page }>({
|
||||
@@ -189,12 +191,12 @@ test.describe.serial("Website tests", () => {
|
||||
|
||||
const clipPage = await context.newPage();
|
||||
await clipPage.goto("https://picsum.photos/400/400.jpg");
|
||||
await clipPage.keyboard.press(`${modifier}+KeyC`);
|
||||
await clipPage.keyboard.press(`${modifier}+C`);
|
||||
|
||||
await page.bringToFront();
|
||||
await page.keyboard.press("Enter");
|
||||
await page.keyboard.press("Enter");
|
||||
await page.keyboard.press(`${modifier}+KeyV`);
|
||||
await page.keyboard.press(`${modifier}+V`);
|
||||
|
||||
await expect(page.getByText("Successfully uploaded image")).toBeVisible();
|
||||
});
|
||||
@@ -353,7 +355,7 @@ test.describe.serial("Website tests", () => {
|
||||
await page.getByRole("link", { name: "Blog" }).click();
|
||||
await page.getByRole("link", { name: "Publish" }).click();
|
||||
await page.getByLabel("Prefix:").click();
|
||||
await page.getByLabel("Prefix:").fill("blog");
|
||||
await page.getByLabel("Prefix:").fill(customPrefix);
|
||||
await page.getByRole("button", { name: "Submit" }).click();
|
||||
await expect(page.getByText("Successfully created/updated")).toBeVisible();
|
||||
|
||||
@@ -361,7 +363,7 @@ test.describe.serial("Website tests", () => {
|
||||
await page.getByRole("link", { name: "Documentation" }).click();
|
||||
await page.getByRole("link", { name: "Publish" }).click();
|
||||
await page.getByLabel("Prefix:").click();
|
||||
await page.getByLabel("Prefix:").fill("docs");
|
||||
await page.getByLabel("Prefix:").fill(customPrefix2);
|
||||
await page.getByRole("button", { name: "Submit" }).click();
|
||||
await expect(page.getByText("Successfully created/updated")).toBeVisible();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user