From a72dbb89758b3cfc61a969513dc10a977ac11679 Mon Sep 17 00:00:00 2001 From: Daniel Einars Date: Sun, 29 Oct 2023 16:58:26 +0100 Subject: [PATCH] using dev server to e2e tests Signed-off-by: Daniel Einars --- .env.ci | 2 ++ .github/workflows/PR.yml | 1 + package.json | 2 +- playwright.config.ci.ts | 2 +- src/lib/server/auth/lucia.ts | 4 ++-- src/lib/server/repository/prismaClient.ts | 4 ++-- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.env.ci b/.env.ci index 9820c21..96c8776 100644 --- a/.env.ci +++ b/.env.ci @@ -3,6 +3,7 @@ ############ # DB DATABASE_URL="postgres://admin:pass123@localhost:6500/sk-db" +# Prisma: Data Proxy DATA_PROXY="" # Only used in Prod builds # REDIS @@ -14,4 +15,5 @@ IMAGE_API_TOKEN="" # Only used in Prod builds IMAGE_API="http://localhost:6501/image" PUBLIC_IMAGE_DELIVERY="http://localhost:6501/image" +# CI Flag IS_CI=true diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml index 5800678..d1b1d20 100644 --- a/.github/workflows/PR.yml +++ b/.github/workflows/PR.yml @@ -16,6 +16,7 @@ env: IMAGE_API_TOKEN: ${{ secrets.IMAGE_API_TOKEN }} IMAGE_API: ${{ secrets.IMAGE_API }} PUBLIC_IMAGE_DELIVERY: ${{ secrets.PUBLIC_IMAGE_DELIVERY }} + IS_CI: true jobs: INSTALL: name: Install Dependencies diff --git a/package.json b/package.json index d58eae5..9d18935 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "build:prod": "pnpm clean && pnpm prisma:gen:prod && vite build --mode production", "build:ci": "pnpm clean && pnpm prisma:gen:ci && vite build --mode ci", "preview": "pnpm build:ci && vite preview", - "preview:cf": "pnpm build:prod && wrangler pages dev ./.svelte-kit/cloudflare", + "preview:cf": "pnpm build:ci && wrangler pages dev ./.svelte-kit/cloudflare", "test:integration:debug": "playwright test --debug", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", diff --git a/playwright.config.ci.ts b/playwright.config.ci.ts index 8cb0c5e..8a8d18a 100644 --- a/playwright.config.ci.ts +++ b/playwright.config.ci.ts @@ -2,7 +2,7 @@ import { devices, type PlaywrightTestConfig } from '@playwright/test'; const config: PlaywrightTestConfig = { webServer: { - command: 'pnpm preview', + command: 'pnpm dev', port: 4000 }, retries: 1, diff --git a/src/lib/server/auth/lucia.ts b/src/lib/server/auth/lucia.ts index 5d33a4d..b5dca17 100644 --- a/src/lib/server/auth/lucia.ts +++ b/src/lib/server/auth/lucia.ts @@ -6,7 +6,7 @@ import { error, redirect } from '@sveltejs/kit'; import { sveltekit } from 'lucia/middleware'; import { dev } from '$app/environment'; -import { IS_CI, REDIS_TOKEN, REDIS_URL } from '$env/static/private'; +import { REDIS_TOKEN, REDIS_URL } from '$env/static/private'; import { redis, upstash } from '@lucia-auth/adapter-session-redis'; import type { Auth as LuciaAuth, Configuration } from 'lucia'; @@ -52,7 +52,7 @@ type DevAuth = LuciaAuth< } >; export const eventualAuth: Promise = new Promise((resolve) => { - if (dev || IS_CI === 'true') { + if (dev) { import('redis').then((Redis) => { console.info('Using dev redis'); const redisClient = Redis.createClient({ diff --git a/src/lib/server/repository/prismaClient.ts b/src/lib/server/repository/prismaClient.ts index 1fc463e..d6541b2 100644 --- a/src/lib/server/repository/prismaClient.ts +++ b/src/lib/server/repository/prismaClient.ts @@ -1,4 +1,4 @@ -import { DATABASE_URL, DATA_PROXY } from '$env/static/private'; +import { DATABASE_URL, DATA_PROXY, IS_CI } from '$env/static/private'; import { Prisma as PrismaEdge, PrismaClient as PrismaClientEdge } from '@prisma/client/edge'; import { Prisma as PrismaNode, PrismaClient as PrismaClientNode } from '@prisma/client'; import { dev } from '$app/environment'; @@ -6,7 +6,7 @@ import { dev } from '$app/environment'; const prismaConfiguration = { datasources: { db: { - url: dev ? DATABASE_URL : DATA_PROXY + url: dev || IS_CI === 'true' ? DATABASE_URL : DATA_PROXY } } };