mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-29 18:26:34 +02:00
Add test
This commit is contained in:
parent
3c959eba2b
commit
30f6d0d447
4 changed files with 13 additions and 9 deletions
|
@ -1,5 +1,6 @@
|
|||
PORT=3002
|
||||
NEXT_PUBLIC_BASE_URL=http://localhost:3002
|
||||
AUTH_URL=http://localhost:3002
|
||||
SECRET_PASSWORD=abcdef1234567890abcdef1234567890
|
||||
DATABASE_URL=postgres://postgres:postgres@localhost:5450/rallly
|
||||
SUPPORT_EMAIL=support@rallly.co
|
||||
|
|
|
@ -60,6 +60,7 @@ export function withAuthMigration(
|
|||
res.cookies.set(newCookieName, encodedCookie, {
|
||||
httpOnly: true,
|
||||
secure: isSecureCookie,
|
||||
expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 7),
|
||||
sameSite: "lax",
|
||||
path: "/",
|
||||
});
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import hkdf from "@panva/hkdf";
|
||||
import { nanoid } from "@rallly/utils/nanoid";
|
||||
import { EncryptJWT } from "jose";
|
||||
import type { JWT } from "next-auth/jwt";
|
||||
|
||||
|
@ -32,6 +31,6 @@ export async function encode(params: JWTEncodeParams) {
|
|||
.setProtectedHeader({ alg: "dir", enc: "A256GCM" })
|
||||
.setIssuedAt()
|
||||
.setExpirationTime(now() + maxAge)
|
||||
.setJti(nanoid())
|
||||
.setJti("some-random-id")
|
||||
.encrypt(encryptionSecret);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { expect, test } from "@playwright/test";
|
||||
import { prisma } from "@rallly/database";
|
||||
import { nanoid } from "@rallly/utils/nanoid";
|
||||
|
||||
import { encode } from "./helpers/next-auth-v4";
|
||||
|
||||
|
@ -12,8 +11,8 @@ test.describe.serial(() => {
|
|||
data: {
|
||||
id: "legacy-guest-poll",
|
||||
title: "Test Poll",
|
||||
adminUrlId: nanoid(),
|
||||
participantUrlId: nanoid(),
|
||||
adminUrlId: "admin-url-id",
|
||||
participantUrlId: "participant-url-id",
|
||||
guestId: legacyGuestId,
|
||||
},
|
||||
});
|
||||
|
@ -28,7 +27,7 @@ test.describe.serial(() => {
|
|||
|
||||
test("should see poll on login page", async ({ page }) => {
|
||||
const context = page.context();
|
||||
const token = await encode({
|
||||
const legacyToken = await encode({
|
||||
token: {
|
||||
sub: legacyGuestId,
|
||||
},
|
||||
|
@ -39,15 +38,19 @@ test.describe.serial(() => {
|
|||
await context.addCookies([
|
||||
{
|
||||
name: "next-auth.session-token",
|
||||
value: token,
|
||||
value: legacyToken,
|
||||
httpOnly: true,
|
||||
expires: Date.now() / 1000 + 60 * 60 * 24 * 7,
|
||||
secure: false,
|
||||
sameSite: "Lax",
|
||||
path: "/",
|
||||
domain: "localhost",
|
||||
path: "/",
|
||||
},
|
||||
]);
|
||||
await page.goto("/login");
|
||||
|
||||
await page.goto("/");
|
||||
|
||||
// Check if the poll title exists in the page content
|
||||
await expect(page.getByText("Test Poll")).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue