Removes a duplicate from the upload script and its backups

The script body had been saved twice, so a production upload would have run
twice and left web.config backups on the host. Browser tests also get longer
limits on the slow CI runner; the page behaves the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-01 23:47:56 +01:00
co-authored by Claude Opus 5.5
parent 79b1a66b97
commit 2006fa01d9
5 changed files with 82 additions and 71 deletions
+44 -1
View File
@@ -531,7 +531,7 @@ describe.skipIf(toolsMissing || lftpMissing)('upload-production.sh', () => {
// De volgorde zelf volgt uit de rondes hierboven (na ronde 1 staat er
// nog geen HTML); hier alleen dat het script ze in die volgorde doet
const rounds = [...run.stdout.matchAll(/^== Ronde (d)/gm)].map(
const rounds = [...run.stdout.matchAll(/^== Ronde (\d)/gm)].map(
(match) => match[1],
);
expect(rounds).toEqual(['1', '2', '3']);
@@ -540,6 +540,17 @@ describe.skipIf(toolsMissing || lftpMissing)('upload-production.sh', () => {
expect(await tree(target)).toEqual(expected);
});
it('laat bij een tweede deploy geen back-upbestanden met ~ achter', async () => {
const { dist, target } = await setup();
expect((await upload(dist, target)).code).toBe(0);
// Nu bestaat web.config al op de host, en alles wordt overschreven
await write(dist, 'robots.txt', 'nieuwe inhoud');
expect((await upload(dist, target)).code).toBe(0);
const files = await tree(target);
expect(files.filter((file) => file.includes('~'))).toEqual([]);
expect(files).toContain('web.config');
});
it('weigert een ongeldige build en uploadt dan niets', async () => {
const { dist, target } = await setup();
await rm(join(dist, 'index.html'));
@@ -624,6 +635,38 @@ touch '${slash(marker)}'
},
);
it('zet in elke lftp-sessie de back-ups uit en de TLS-eisen aan', async () => {
const dist = await makeDist();
const bin = await makeTemp('andreaslop-fakebin-');
const log = join(bin, 'opdrachten');
await writeFile(
join(bin, 'lftp'),
`#!/bin/sh
printf '%s\\n' "$2" >> '${slash(log)}'
`,
{ mode: 0o755 },
);
const run = await runScript(
'upload-production.sh',
[basename(dist), 'wwwroot'],
{
PATH: `${bin}${delimiter}${process.env.PATH ?? ''}`,
LFTP_OPEN: 'file:///',
},
dirname(dist),
);
expect(run.code).toBe(0);
const sessions = (await readFile(log, 'utf8'))
.split('\n')
.filter(Boolean);
// Ronde 1, web.config, ronde 2 (HTML) en ronde 3
expect(sessions).toHaveLength(4);
for (const commands of sessions) {
expect(commands).toContain('set xfer:make-backup no;');
expect(commands).toContain('set ftp:ssl-force true;');
}
});
it.each(['wwwroot', 'sites/andreaslop.nl', '/srv/site', 'wwwroot/'])(
'laat de doelmap %j door',
async (remote) => {
+11 -2
View File
@@ -1,7 +1,12 @@
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
import type { Page } from 'playwright-core';
import sitePages from '../src/sitePages.ts';
import { eventually, openPage, waitForHydration } from './support/browser.ts';
import {
eventually,
inCi,
openPage,
waitForHydration,
} from './support/browser.ts';
import { startServer } from './support/server.ts';
// FR-PR-09, FR-PR-10, V-D6: Reveal is zichtbaar in de HTML en in de eerste
@@ -168,9 +173,13 @@ describe('Reveal bij het scrollen', () => {
await target!.evaluate((element) =>
element.scrollIntoView({ block: 'center', behavior: 'instant' }),
);
// De overgang duurt 0,8 s; 1,5 s laat lokaal ruimte voor de
// IntersectionObserver. Op de Pi (CI-run 598: opacity 0,987 na 1,5 s)
// vertraagt de zwaar belaste hoofdthread die, dus daar ruimer: een
// vastgelopen overgang haalt 10 s ook niet.
await expect
.poll(() => target!.evaluate((e) => getComputedStyle(e).opacity), {
timeout: 1500,
timeout: inCi ? 10_000 : 1500,
interval: 50,
})
.toBe('1');
+11 -1
View File
@@ -37,6 +37,11 @@ afterAll(async () => {
browser = undefined;
});
// Op de CI-runner zijn de wachttijden van de browsertests 3 tot 6 keer zo
// lang als lokaal (zie testTimeout in vitest.e2e.config.ts)
export const inCi = Boolean(process.env.CI);
const CI_TIMEOUT = 90_000;
export interface OpenedPage {
page: Page;
status: number;
@@ -86,6 +91,11 @@ export async function openPage(
reducedMotion,
});
contexts.add(context);
// Playwright wacht standaard 30 s op een navigatie of een voorwaarde. Op de
// CI-runner (Raspberry Pi) duurde het laden van een pagina met foto's of
// de hydratatie daar soms langer (CI-run 598: goto en waitForHydration
// op 30 s afgebroken). Lokaal blijft 30 s.
if (inCi) context.setDefaultTimeout(CI_TIMEOUT);
const page = await context.newPage();
const messages: string[] = [];
@@ -137,4 +147,4 @@ export async function waitForHydration(page: Page) {
// Vitest kent de wachtende matchers van Playwright niet; expect.poll herhaalt
// de vraag aan de pagina tot het antwoord klopt of de tijd om is.
export const eventually = <T>(read: () => Promise<T>) =>
expect.poll(read, { timeout: 15_000, interval: 100 });
expect.poll(read, { timeout: inCi ? CI_TIMEOUT : 15_000, interval: 100 });