Files
shared/scripts/media/list-skipped-tests.mjs
T
Gabriel20xxandClaude Sonnet 5 ee59571552 Rename ProjectConfigurator, restructure Projects workspace, retire MediaCollection naming
- Rename MediaConfig -> ProjectConfigurator throughout; drop the Parameters
  tab/page; rename the Mounts tab to Projects and restructure it into three
  sections: Central services, Main services, Third-party services
- Add a self-describe contract (GET /api/info returning name/tabs/mountTypes)
  and a server-side discovery proxy (POST /api/discover-service) so adding a
  main service only requires a URL
- Add ProjectConfigurator HA: multiple instances now sync their settings with
  each other (GET /api/settings/export, POST /api/settings/sync, a periodic
  background puller), last-write-wins per key by updated_at
- Add a generic, project-agnostic file-storage API on CarrierNode
  (GET/POST/DELETE /api/mount/{project}/{type}[/*]) driven by the same
  configured_mounts data the Projects workspace already writes, usable by any
  registered project, not just the media family
- Add last_login_at tracking to the shared auth Store/User (schema, queries,
  UpdateLastLogin) and surface it through the shared web-ui ManagedUser type
  and UserManagement component
- Retire the "MediaCollection" name: Go module -> repos.gfranz.ch/Gabriel20xx/shared/media-backend,
  binary -> mediabackend, session cookie default -> "session", media-webui
  merged into webui, media-shared-assets renamed to legacy-assets and pruned
  to the one file MediaDesktop still uses

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-04 15:02:16 +02:00

105 lines
4.4 KiB
JavaScript

#!/usr/bin/env node
import { spawn } from 'node:child_process';
import { createRequire } from 'node:module';
import path from 'node:path';
// Run vitest with JSON reporter and parse skipped tests/suites.
// Usage: node scripts/list-skipped-tests.mjs
// Exits with code 0 if none skipped, 1 if any skipped.
//
// TODO(shared extraction): as of this repo's extraction from the old monorepo, it has no
// vitest suite anywhere (webui/ has no vitest devDependency/config; shared/packages/node-backend
// uses plain `node --test`; backend/ is Go), so `require.resolve('vitest/package.json')` below
// will fail immediately. The hardcoded `--config ../vitest.config.mjs` below also assumed this
// script runs from a subdirectory (e.g. the old repo-root tests/ dir) one level below a
// vitest.config.mjs — that layout does not exist in this repo either. Left unfixed rather than
// guessed at: revisit once/if a real vitest suite is introduced in this repo, and point the
// --config flag at wherever that config actually lives.
// Resolve local vitest binary (avoid relying on npx which can be absent in some CI / shells)
function resolveVitestBin() {
try {
const require = createRequire(import.meta.url);
const pkgPath = require.resolve('vitest/package.json');
const binDir = path.dirname(pkgPath);
// Vitest exposes a bin field pointing to dist/cli.js; require it to ensure path stability
const pkg = require('vitest/package.json');
if (pkg && pkg.bin && pkg.bin.vitest) {
return path.join(binDir, pkg.bin.vitest);
}
// Fallback: common location
return path.join(binDir, 'dist', 'cli.js');
} catch (err) {
console.error('[list-skipped-tests] Unable to resolve vitest binary:', err.message);
process.exit(2);
}
}
const vitestBin = resolveVitestBin();
const nodeExec = process.execPath; // Use current Node runtime
// Always pass explicit config to ensure identical file set as normal test run.
// Use 'run' subcommand to execute once (no watch) and JSON reporter for machine parsing.
const args = [vitestBin, 'run', '--config', '../vitest.config.mjs', '--reporter=json'];
const child = spawn(nodeExec, args, { stdio: ['ignore', 'pipe', 'inherit'] });
let jsonBlock = '';
child.stdout.on('data', d => {
const text = d.toString();
// Capture last JSON object emitted by vitest reporter (it prints progress lines + final JSON)
jsonBlock += text;
});
// eslint-disable-next-line no-unused-vars
child.on('close', _code => {
// Attempt to find the final JSON object (Vitest prints *only* JSON in our current mode but be defensive)
const match = jsonBlock.match(/(\{[\s\S]*\})\s*$/);
if (!match) {
console.error('[list-skipped-tests] Failed to parse Vitest JSON output');
process.exit(2);
}
let report;
try {
report = JSON.parse(match[1]);
} catch (e) {
console.error('[list-skipped-tests] JSON parse error', e);
process.exit(2);
}
// Vitest JSON reporter structure (observed):
// { numTotalTests, testResults: [ { name, assertionResults: [ { title, status } ] } ] }
// Legacy / alternative structure: { testFiles: [ { file, tests:[{ state }] } ] }
const skipped = [];
let totalFiles = 0;
if (Array.isArray(report.testResults)) {
totalFiles = report.testResults.length;
for (const tr of report.testResults) {
const filePath = tr.name || tr.file || 'unknown';
(tr.assertionResults || []).forEach(ar => {
// Vitest marks skipped tests with status === 'skipped'. Support 'todo' & 'pending' for completeness.
if (ar.status === 'skipped' || ar.status === 'todo' || ar.status === 'pending') {
skipped.push({ file: filePath, test: ar.fullName || ar.title, state: ar.status });
}
});
}
} else if (Array.isArray(report.testFiles)) {
// fallback structure
totalFiles = report.testFiles.length;
for (const f of report.testFiles) {
if (!f) continue;
const filePath = f.file || f.name || 'unknown';
(f.tests || []).forEach(t => {
if (t.state === 'skip' || t.state === 'todo' || t.state === 'pending') {
skipped.push({ file: filePath, test: t.name, state: t.state });
}
});
}
} else {
console.error('[list-skipped-tests] Unrecognized Vitest JSON structure');
process.exit(2);
}
const summary = { totalFiles, skippedCount: skipped.length, skipped };
console.log(JSON.stringify(summary, null, 2));
process.exit(skipped.length > 0 ? 1 : 0);
});