Skip to content

Commit

Permalink
working config
Browse files Browse the repository at this point in the history
  • Loading branch information
doctorpangloss committed Oct 2, 2023
1 parent b9d0abe commit 93767ee
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
3 changes: 2 additions & 1 deletion spellsource-web/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from "@playwright/test";

export const baseURL = "http://127.0.0.1:3000";
export default defineConfig({
webServer: [
{
Expand Down Expand Up @@ -28,6 +29,6 @@ export default defineConfig({
},
],
use: {
baseURL: "http://127.0.0.1:3000",
baseURL: baseURL,
},
});
3 changes: 1 addition & 2 deletions spellsource-web/src-dev/e2e/collections.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect, test } from "../playwright/fixtures";

test("should navigate to collection and see premade decks", async (context) => {
const { page } = context;
test("should navigate to collection and see premade decks", async ({ page }) => {
await page.goto("/home");
await page.getByLabel("Collection").click();
const listCount = await page.getByLabel("Premade Deck List").locator("li").count();
Expand Down
27 changes: 12 additions & 15 deletions spellsource-web/src-dev/playwright/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { test as baseTest } from "@playwright/test";
import { v4 as uuidv4 } from "uuid";
import fs from "fs";
import path from "path";
import { baseURL } from "../../playwright.config";

export * from "@playwright/test";
export const test = baseTest.extend<{}, { workerStorageState: string }>({
Expand All @@ -16,38 +17,34 @@ export const test = baseTest.extend<{}, { workerStorageState: string }>({
await use(fileName);
return;
}
const context = await browser.newContext({ storageState: undefined, baseURL: baseURL });
const page = await context.newPage();

const page = await browser.newPage({ storageState: undefined });
await page.goto(`/`);
await page.getByLabel("Login").click();
await page.waitForURL(/realms\/hiddenswitch\//, { waitUntil: "domcontentloaded" });
await page.getByText("Register").click();
await page.waitForURL(/realms\/hiddenswitch\/login-actions\//, { waitUntil: "domcontentloaded" });

// Step 1: Visit "/"
await page.goto("/");
await page.getByRole("link", { name: "Login" }).click();
await page.getByRole("link", { name: "Register" }).click();

// Step 4: Populate the Email field
const randomEmail = `user+${uuidv4()}@spellsource.com`;
await page.getByLabel("Email").fill(randomEmail);

// Step 5: Populate the Username field
const randomUsername = uuidv4();
await page.getByLabel("Username").fill(randomUsername);

// Step 6: Populate the Password and "Confirm password" fields
const randomPassword = uuidv4();
await page.getByLabel("Password").fill(randomPassword);
await page.getByLabel("Password", { exact: true }).fill(randomPassword);
await page.getByLabel("Confirm Password").fill(randomPassword);

// Step 7: Choose "With Premade Decks" in the "Starting Collection" dropdown
await page.getByLabel("Starting Collection").selectOption("With Premade Decks");

// Step 8: Click the Register input/submit
await page.getByRole("button", { name: "Register" }).click();

// Wait for registration to complete and possibly for redirection to a certain page
await page.waitForURL("/home");
await page.waitForURL(`${baseURL}/home`);

await page.context().storageState({ path: fileName });
await context.storageState({ path: fileName });
await page.close();
await context.close();
await use(fileName);
},
{ scope: "worker" },
Expand Down
5 changes: 3 additions & 2 deletions spellsource-web/src/components/auth-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import React from "react";

export const AuthButton = () => {
const { status } = useSession();

const label = status !== "authenticated" ? "Login" : "Logout";
return (
<a
aria-label={label}
className={styles.loginButton}
onClick={async () => {
if (status === "unauthenticated") {
Expand All @@ -18,7 +19,7 @@ export const AuthButton = () => {
}
}}
>
{status !== "authenticated" ? "Login" : "Logout"}
{label}
</a>
);
};

0 comments on commit 93767ee

Please sign in to comment.