-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"cookies": [ | ||
{ | ||
"name": "authjs.session-token", | ||
"value": "regularUserSession", | ||
"domain": "127.0.0.1", | ||
"path": "/", | ||
"expires": -1, | ||
"httpOnly": true, | ||
"secure": false, | ||
"sameSite": "Lax" | ||
} | ||
], | ||
"origins": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { db } from "@/drizzle/db"; | ||
import { users, sessions, accounts } from "@/drizzle/schema"; | ||
import { addDays } from "date-fns"; | ||
import { sql } from "drizzle-orm"; | ||
|
||
async function globalSetup() { | ||
await db.execute(sql`TRUNCATE ${users} CASCADE`); | ||
|
||
const [{ userId }] = await db | ||
.insert(users) | ||
.values({ id: "regularUserId", email: "[email protected]" }) | ||
.returning({ userId: users.id }); | ||
|
||
await db.insert(sessions).values({ | ||
userId, | ||
sessionToken: "regularUserSession", | ||
expires: addDays(new Date(), 180), | ||
}); | ||
|
||
await db.insert(accounts).values({ | ||
userId, | ||
provider: "mock", | ||
providerAccountId: "mockId", | ||
type: "email", | ||
}); | ||
} | ||
|
||
export default globalSetup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,32 @@ | ||
import { test, expect } from "@playwright/test"; | ||
|
||
test("renders project name", async ({ page }) => { | ||
await page.goto("http://localhost:3000/"); | ||
await page.goto("/"); | ||
|
||
await expect(page).toHaveTitle(/POPGDP/); | ||
}); | ||
|
||
test("renders without user signed in", async ({ page }) => { | ||
await page.goto("/"); | ||
|
||
await expect(page.getByRole("button", { name: "Sign in" })).toBeVisible(); | ||
|
||
await page.click("button:has-text('Sign in')"); | ||
|
||
await expect(page.getByRole("button", { name: "Sign in" })).toBeVisible(); | ||
|
||
await new Promise((resolve) => setTimeout(resolve, 5000)); | ||
|
||
await page.context().storageState({ path: "lol.json" }); | ||
}); | ||
|
||
test("renders with user signed in", async ({ browser }) => { | ||
const context = await browser.newContext({ | ||
storageState: "./tests/e2e/.auth/member.json", | ||
}); | ||
const page = await context.newPage(); | ||
|
||
await page.goto("/"); | ||
|
||
await expect(page.getByRole("button", { name: "Sign out" })).toBeVisible(); | ||
}); |