Runner: json-Typ vor eigener Erkennung (R21), Erstdeploy-Rueckfall, json-index beim Veroeffentlichen
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8a028ce75a
commit
c256b78dae
5 files changed
+92
-14
No files matched your search
@@ -91,10 +91,71 @@ test('Build-Ausgabe mit index.html wird unverändert veröffentlicht', async ()
|
||||
assert.deepEqual(readdirSync(s.out).sort(), ['index.html', 'o.html']);
|
||||
});
|
||||
|
||||
test('fehlgeschlagener Build bleibt ein Fehler (alter Stand bleibt)', async () => {
|
||||
const s = setup({ files: { 'package.json': JSON.stringify({ scripts: { build: 'x' } }) }, dockerImpl: (args) => ({ code: args.includes('build') ? 1 : 0 }) });
|
||||
const BUILD_PKG = JSON.stringify({ scripts: { build: 'x' } });
|
||||
const failBuild = (args) => ({ code: args.includes('build') ? 1 : 0 });
|
||||
|
||||
test('bestehender <sub>-Ordner + fehlgeschlagener Build ⇒ failed, alter Stand unverändert', async () => {
|
||||
const s = setup({ files: { 'package.json': BUILD_PKG, 'x.html': 'QUELLE' }, dockerImpl: failBuild });
|
||||
mkdirSync(s.out, { recursive: true }); writeFileSync(join(s.out, 'index.html'), 'ALT');
|
||||
const r = await wait(s.jobs, s.jobs.submit(job()));
|
||||
assert.equal(r.state, 'failed');
|
||||
assert.equal(readFileSync(join(s.out, 'index.html'), 'utf8'), 'ALT');
|
||||
});
|
||||
|
||||
test('erstes Deploy + fehlgeschlagener Build ⇒ Quellstand statisch (Kandidat), result static, Hinweis', async () => {
|
||||
const s = setup({ files: { 'package.json': BUILD_PKG, 'x.html': 'QUELLE' }, dockerImpl: failBuild });
|
||||
const r = await wait(s.jobs, s.jobs.submit(job()));
|
||||
assert.equal(r.state, 'done'); assert.equal(r.result, 'static'); assert.match(r.hint, /Build fehlgeschlagen/);
|
||||
assert.equal(readFileSync(join(s.out, 'index.html'), 'utf8'), 'QUELLE');
|
||||
assert.ok(r.log.some((l) => /erstes Deploy/.test(l)));
|
||||
});
|
||||
|
||||
test('erstes Deploy + Installationsfehler ⇒ statischer Quellstand', async () => {
|
||||
const s = setup({ files: { 'package.json': BUILD_PKG }, dockerImpl: () => ({ code: 1 }) });
|
||||
const r = await wait(s.jobs, s.jobs.submit(job({ displayName: 'Shop' })));
|
||||
assert.equal(r.result, 'static');
|
||||
assert.match(readFileSync(join(s.out, 'index.html'), 'utf8'), /<h1>Shop<\/h1>/);
|
||||
});
|
||||
|
||||
test('R21: json type static + index.html + build-Skript ⇒ static, kein Container', async () => {
|
||||
const s = setup({ files: { 'package.json': BUILD_PKG, 'index.html': 'S', '.webklar-preview.json': '{"type":"static"}' }, dockerImpl: () => { throw new Error('kein Container'); } });
|
||||
const r = await wait(s.jobs, s.jobs.submit(job()));
|
||||
assert.equal(r.state, 'done'); assert.equal(r.result, 'static');
|
||||
});
|
||||
|
||||
test('R21: json type node_build ⇒ build (auch mit index.html); kein Dev-Rückfall', async () => {
|
||||
const mk = (extra) => setup({ files: { 'package.json': JSON.stringify({ scripts: { build: 'x', dev: 'y' } }), 'index.html': 'S', '.webklar-preview.json': '{"type":"node_build"}', ...extra },
|
||||
dockerImpl: (args) => { if (args.includes('build')) { mkdirSync(join(workOf(args), 'dist'), { recursive: true }); writeFileSync(join(workOf(args), 'dist', 'index.html'), 'B'); } return { code: 0 }; } });
|
||||
let s = mk();
|
||||
let r = await wait(s.jobs, s.jobs.submit(job()));
|
||||
assert.equal(r.result, 'build'); assert.equal(readFileSync(join(s.out, 'index.html'), 'utf8'), 'B');
|
||||
s = setup({ files: { 'package.json': JSON.stringify({ scripts: { build: 'x', dev: 'y' } }), '.webklar-preview.json': '{"type":"node_build"}' }, dockerImpl: failBuild });
|
||||
mkdirSync(s.out, { recursive: true });
|
||||
r = await wait(s.jobs, s.jobs.submit(job()));
|
||||
assert.equal(r.state, 'failed');
|
||||
});
|
||||
|
||||
test('R21: ohne json-Typ + index.html + build-Skript ⇒ build', async () => {
|
||||
const s = setup({ files: { 'package.json': BUILD_PKG, 'index.html': 'S' }, dockerImpl: (args) => { if (args.includes('build')) { mkdirSync(join(workOf(args), 'dist'), { recursive: true }); writeFileSync(join(workOf(args), 'dist', 'index.html'), 'B'); } return { code: 0 }; } });
|
||||
const r = await wait(s.jobs, s.jobs.submit(job()));
|
||||
assert.equal(r.result, 'build');
|
||||
});
|
||||
|
||||
test('R21: Modus build aus dem Portal schlägt json type static', async () => {
|
||||
const s = setup({ files: { 'package.json': BUILD_PKG, 'index.html': 'S', '.webklar-preview.json': '{"type":"static"}' }, dockerImpl: (args) => { if (args.includes('build')) { mkdirSync(join(workOf(args), 'dist'), { recursive: true }); writeFileSync(join(workOf(args), 'dist', 'index.html'), 'B'); } return { code: 0 }; } });
|
||||
const r = await wait(s.jobs, s.jobs.submit(job({ mode: 'build' })));
|
||||
assert.equal(r.result, 'build');
|
||||
});
|
||||
|
||||
test('json index-Unterordner wird beim Veröffentlichen genutzt (static und Build-Rückfall)', async () => {
|
||||
let s = setup({ files: { 'public/index.html': 'PUB', 'root.html': 'r', '.webklar-preview.json': '{"index":"public"}' } });
|
||||
await wait(s.jobs, s.jobs.submit(job()));
|
||||
assert.deepEqual(readdirSync(s.out), ['index.html']);
|
||||
s = setup({ files: { 'package.json': BUILD_PKG, 'public/home.html': 'H', '.webklar-preview.json': '{"index":"public"}' }, dockerImpl: failBuild });
|
||||
const r = await wait(s.jobs, s.jobs.submit(job()));
|
||||
assert.equal(r.result, 'static');
|
||||
assert.equal(readFileSync(join(s.out, 'index.html'), 'utf8'), 'H');
|
||||
assert.ok(!existsSync(join(s.out, 'package.json')));
|
||||
});
|
||||
|
||||
test('validateJob: displayName optional, ≤100 Zeichen, keine Steuerzeichen', () => {
|
||||
|
||||
@@ -250,6 +250,7 @@ test('I8: npm ci scheitert ⇒ Wiederholung mit npm install (Protokoll, Build l
|
||||
|
||||
test('I8: auch npm install scheitert ⇒ Installationsfehler', async () => {
|
||||
const s = setup({ files: { 'package.json': PKG(), 'package-lock.json': '{}' }, dockerImpl: () => ({ code: 1 }) });
|
||||
mkdirSync(join(s.config.previewsRoot, 'demo'));
|
||||
const r = await wait(s.jobs, s.jobs.submit(job()));
|
||||
assert.equal(r.state, 'failed'); assert.match(r.error, /Installation fehlgeschlagen/);
|
||||
assert.equal(s.calls.length, 2);
|
||||
|
||||
Reference in new issue
Block a user