Skip to content

Commit

Permalink
using dev server to e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Einars <contact@dle.dev>
  • Loading branch information
polaroidkidd committed Oct 29, 2023
1 parent 701a416 commit a72dbb8
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .env.ci
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions .github/workflows/PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/server/auth/lucia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -52,7 +52,7 @@ type DevAuth = LuciaAuth<
}
>;
export const eventualAuth: Promise<ProdAuth | DevAuth> = new Promise((resolve) => {
if (dev || IS_CI === 'true') {
if (dev) {
import('redis').then((Redis) => {
console.info('Using dev redis');
const redisClient = Redis.createClient({
Expand Down
4 changes: 2 additions & 2 deletions src/lib/server/repository/prismaClient.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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';

const prismaConfiguration = {
datasources: {
db: {
url: dev ? DATABASE_URL : DATA_PROXY
url: dev || IS_CI === 'true' ? DATABASE_URL : DATA_PROXY
}
}
};
Expand Down

0 comments on commit a72dbb8

Please sign in to comment.