fix(core): Fix lint and typecheck errors in ClockRepository and WaitTracker tests
- Fix import order in clock.repository.test.ts - Replace unnecessary type assertions with generic params in clock.repository.ts - Fix Promise<void> -> Promise<string> type mismatch in wait-tracker.test.ts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import { Container } from '@n8n/di';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type { DataSource } from '@n8n/typeorm';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
|
||||
import { ClockRepository } from '../clock.repository';
|
||||
|
||||
|
||||
@@ -12,16 +12,16 @@ export class ClockRepository {
|
||||
|
||||
async getServerTime(): Promise<Date> {
|
||||
if (this.globalConfig.database.type === 'postgresdb') {
|
||||
const [{ now }] = (await this.dataSource.query('SELECT CURRENT_TIMESTAMP(3) AS now')) as [
|
||||
{ now: Date },
|
||||
];
|
||||
const [{ now }] = await this.dataSource.query<[{ now: Date }]>(
|
||||
'SELECT CURRENT_TIMESTAMP(3) AS now',
|
||||
);
|
||||
return new Date(now.getTime());
|
||||
}
|
||||
|
||||
// SQLite: use ISO-friendly format directly to avoid JS-side string manipulation
|
||||
const [{ now }] = (await this.dataSource.query(
|
||||
const [{ now }] = await this.dataSource.query<[{ now: string }]>(
|
||||
"SELECT STRFTIME('%Y-%m-%dT%H:%M:%fZ', 'NOW') AS now",
|
||||
)) as [{ now: string }];
|
||||
);
|
||||
const date = new Date(now);
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
throw new UnexpectedError(`Invalid DB server time: ${now}`);
|
||||
|
||||
@@ -704,8 +704,8 @@ describe('WaitTracker', () => {
|
||||
expect(waitTracker.has(raceExecId)).toBe(true);
|
||||
|
||||
// Make workflowRunner.run() hang so we can observe the guard
|
||||
let resolveRun!: () => void;
|
||||
const runPromise = new Promise<void>((resolve) => {
|
||||
let resolveRun!: (value: string) => void;
|
||||
const runPromise = new Promise<string>((resolve) => {
|
||||
resolveRun = resolve;
|
||||
});
|
||||
workflowRunner.run.mockReturnValueOnce(runPromise);
|
||||
@@ -732,7 +732,7 @@ describe('WaitTracker', () => {
|
||||
expect(newTimerCalls).toHaveLength(0);
|
||||
|
||||
// Clean up
|
||||
resolveRun();
|
||||
resolveRun('exec-id');
|
||||
await startPromise;
|
||||
|
||||
// Now the guard should be released
|
||||
|
||||
Reference in New Issue
Block a user