mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-17 21:49:36 +02:00
test(editor): Stub the lazy credentials button in NodeView test and report signal-killed vitest runs (no-changelog) (#38695)
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
4d9cd43168
commit
2b346002db
|
|
@ -100,6 +100,9 @@ describe('NodeView', () => {
|
|||
// test here needs it, and on a writable canvas the import can still be in
|
||||
// flight when the environment tears down, which fails the whole run.
|
||||
LazyNodeCreation: true,
|
||||
// Same for the setup-credentials button: its import chain pulls in the
|
||||
// ready-to-run stores and their bundled workflow fixtures.
|
||||
LazySetupWorkflowCredentialsButton: true,
|
||||
WorkflowCanvas: defineComponent({
|
||||
emits: ['copy:nodes'],
|
||||
setup(_, { expose }) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { isAbsolute } from 'node:path';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { buildRunnerArgs } from './test-scoped-runner.js';
|
||||
import { buildRunnerArgs, resolveExitCode } from './test-scoped-runner.js';
|
||||
|
||||
const rootDir = '/repo/root';
|
||||
|
||||
|
|
@ -38,3 +38,26 @@ describe('buildRunnerArgs', () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolveExitCode', () => {
|
||||
it('passes a normal exit status through unchanged', () => {
|
||||
const error = vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||
expect(resolveExitCode({ status: 0, signal: null })).toBe(0);
|
||||
expect(resolveExitCode({ status: 1, signal: null })).toBe(1);
|
||||
expect(error).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('reports the spawn error when vitest does not start', () => {
|
||||
const error = vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||
const enoent = new Error('spawnSync vitest ENOENT');
|
||||
expect(resolveExitCode({ status: null, signal: null, error: enoent })).toBe(1);
|
||||
expect(error).toHaveBeenCalledWith(expect.stringContaining('ENOENT'));
|
||||
expect(error).not.toHaveBeenCalledWith(expect.stringContaining('signal'));
|
||||
});
|
||||
|
||||
it('names the signal and fails when vitest exits without a status', () => {
|
||||
const error = vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||
expect(resolveExitCode({ status: null, signal: 'SIGKILL' })).toBe(1);
|
||||
expect(error).toHaveBeenCalledWith(expect.stringContaining('SIGKILL'));
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -58,5 +58,25 @@ export function runTestScoped(options: TestScopedOptions): number {
|
|||
// Pass cwd explicitly so an override via --package-dir is honoured
|
||||
// (otherwise spawnSync inherits the caller's cwd and vitest would
|
||||
// resolve config + tests from the wrong project).
|
||||
return spawnSync('vitest', args, { stdio: 'inherit', cwd: options.packageDir }).status ?? 1;
|
||||
const result = spawnSync('vitest', args, { stdio: 'inherit', cwd: options.packageDir });
|
||||
return resolveExitCode(result);
|
||||
}
|
||||
|
||||
// A signal-killed vitest has no status and prints no summary, so name the signal.
|
||||
// A spawn failure has no status either; with inherited stdio, only `error` reports it.
|
||||
export function resolveExitCode(result: {
|
||||
status: number | null;
|
||||
signal: NodeJS.Signals | null;
|
||||
error?: Error;
|
||||
}): number {
|
||||
if (result.status !== null) return result.status;
|
||||
if (result.error) {
|
||||
console.error(`[janitor:test-scoped] vitest failed to start: ${result.error.message}`);
|
||||
return 1;
|
||||
}
|
||||
console.error(
|
||||
`[janitor:test-scoped] vitest exited without a status (signal: ${result.signal ?? 'unknown'}). ` +
|
||||
'The process was killed before it could report results; check the runner for memory pressure.',
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user