From 7bd15d6bf0af2c03e8425cdf1e063c08e664e443 Mon Sep 17 00:00:00 2001 From: Johan Li Date: Wed, 17 Jan 2024 23:15:29 +0100 Subject: [PATCH] update fingerprint-scanner-simulator build --- Dockerfile | 4 ++-- tests/production/cacheHeaders.spec.ts | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index bcf5844..a11d3f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ RUN git lfs install RUN git clone --depth 1 https://github.com/JohanLi/uncharted-waters-2 RUN cd uncharted-waters-2 && npm install && PUBLIC_PATH=/uncharted-waters-2/ npm run build RUN git clone --depth 1 https://github.com/JohanLi/fingerprint-scanner-simulator -RUN cd fingerprint-scanner-simulator && npm install && BASE_PATH=/gta-online/fingerprint-scanner-simulator npm run build +RUN cd fingerprint-scanner-simulator && npm install -g pnpm && pnpm install --frozen-lockfile && BASE_PATH=/gta-online/fingerprint-scanner-simulator pnpm run build FROM node:20-alpine AS runner ENV NODE_ENV production @@ -31,7 +31,7 @@ RUN addgroup --system --gid 1001 nodejs RUN adduser --system --uid 1001 nextjs COPY --from=others /app/uncharted-waters-2/build ./public/uncharted-waters-2 -COPY --from=others /app/fingerprint-scanner-simulator/out ./public/gta-online/fingerprint-scanner-simulator +COPY --from=others /app/fingerprint-scanner-simulator/dist ./public/gta-online/fingerprint-scanner-simulator COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static diff --git a/tests/production/cacheHeaders.spec.ts b/tests/production/cacheHeaders.spec.ts index 87245e3..6f0688c 100644 --- a/tests/production/cacheHeaders.spec.ts +++ b/tests/production/cacheHeaders.spec.ts @@ -28,9 +28,11 @@ async function expectCache( } test.describe('Cache headers', () => { - test('johan.li', async ({ page }) => { - const js = page.waitForResponse((response) => - response.url().endsWith('.js'), + test('johan.li', async ({ page, baseURL }) => { + const js = page.waitForResponse( + (response) => + // https://static.cloudflareinsights.com/beacon.min.js interferes, hence the baseURL check + response.url().endsWith('.js') && response.url().startsWith(baseURL), ) const css = page.waitForResponse((response) => @@ -38,7 +40,7 @@ test.describe('Cache headers', () => { ) const image = page.waitForResponse((response) => - response.headers()['content-type'].startsWith('image/'), + response.headers()['content-type']?.startsWith('image/'), ) await page.goto('/') @@ -64,7 +66,7 @@ test.describe('Cache headers', () => { ) const image = page.waitForResponse((response) => - response.headers()['content-type'].startsWith('image/'), + response.headers()['content-type']?.startsWith('image/'), ) await page.goto('/uncharted-waters-2') @@ -77,9 +79,10 @@ test.describe('Cache headers', () => { ]) }) - test('Fingerprint Scanner Simulator', async ({ page }) => { - const js = page.waitForResponse((response) => - response.url().endsWith('.js'), + test('Fingerprint Scanner Simulator', async ({ page, baseURL }) => { + const js = page.waitForResponse( + (response) => + response.url().endsWith('.js') && response.url().startsWith(baseURL), ) const css = page.waitForResponse((response) => @@ -87,7 +90,7 @@ test.describe('Cache headers', () => { ) const image = page.waitForResponse((response) => - response.headers()['content-type'].startsWith('image/'), + response.headers()['content-type']?.startsWith('image/'), ) await page.goto('/gta-online/fingerprint-scanner-simulator')