Skip to content

Commit 1319dc0

Browse files
committed
chore: changes after review
1 parent d54eda3 commit 1319dc0

File tree

10 files changed

+18
-34
lines changed

10 files changed

+18
-34
lines changed

packages/cli/src/__tests__/commands/generate-arazzo.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import { generate } from '@redocly/respect-core';
33
import { vi, describe, it, expect, beforeEach } from 'vitest';
44
import { Config } from '@redocly/openapi-core';
55

6-
// Mock the generate function
76
vi.mock('@redocly/respect-core', async () => {
8-
const actual = await vi.importActual('@redocly/respect-core');
7+
const actual = await vi.importActual<typeof import('@redocly/respect-core')>(
8+
'@redocly/respect-core'
9+
);
910
return {
1011
...actual,
1112
generate: vi.fn(),
1213
};
1314
});
1415

15-
// Mock node:fs
1616
vi.mock('node:fs', async () => {
1717
return {
1818
writeFileSync: vi.fn(),
@@ -21,7 +21,6 @@ vi.mock('node:fs', async () => {
2121
};
2222
});
2323

24-
// Mock @redocly/openapi-core
2524
vi.mock('@redocly/openapi-core', async () => {
2625
const actual = await vi.importActual('@redocly/openapi-core');
2726
return {

packages/cli/src/__tests__/commands/respect/respect.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ vi.mock('node:fs', async () => {
1818

1919
// Mock the run function
2020
vi.mock('@redocly/respect-core', async () => {
21-
const actual = await vi.importActual('@redocly/respect-core');
21+
const actual = await vi.importActual<typeof import('@redocly/respect-core')>(
22+
'@redocly/respect-core'
23+
);
2224
return {
2325
...actual,
2426
run: vi.fn(),

packages/cli/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,6 @@ yargs(hideBin(process.argv))
672672
},
673673
}),
674674
(argv) => {
675-
process.env.REDOCLY_CLI_COMMAND = 'eject';
676675
commandWrapper(handleEject)(argv as Arguments<EjectArgv>);
677676
}
678677
)

packages/respect-core/src/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
export { generate } from './generate.js';
2-
export { run } from './run.js';
3-
export type { GenerateArazzoOptions } from './generate.js';
4-
export type { RespectOptions } from './run.js';
1+
export { generate, type GenerateArazzoOptions } from './generate.js';
2+
export { run, type RespectOptions } from './run.js';
53
export * from './types.js';
64
export { maskSecrets } from './modules/logger-output/mask-secrets.js';
75
export { calculateTotals } from './modules/logger-output/calculate-tests-passed.js';

packages/respect-core/src/modules/__tests__/config-parser/resolve-reusable-component-item.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('resolveReusableComponentItem', () => {
1010
options: {
1111
logger,
1212
},
13-
} as unknown as TestContext)
13+
} as Partial<TestContext> as TestContext)
1414
).toEqual({
1515
in: 'query',
1616
name: 'test',
@@ -31,7 +31,7 @@ describe('resolveReusableComponentItem', () => {
3131
options: {
3232
logger,
3333
},
34-
} as unknown as TestContext
34+
} as Partial<TestContext> as TestContext
3535
)
3636
).toEqual({
3737
name: 'SuccessActio',
@@ -47,7 +47,7 @@ describe('resolveReusableComponentItem', () => {
4747
options: {
4848
logger,
4949
},
50-
} as unknown as TestContext)
50+
} as Partial<TestContext> as TestContext)
5151
).toThrow(
5252
'Invalid reference: available components are $components.parameters, $components.failureActions, or $components.successActions'
5353
);

packages/respect-core/src/modules/__tests__/flow-runner/call-api-and-analyze-results.test.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,8 @@ import {
66
} from '../../flow-runner/index.js';
77
import { ApiFetcher } from '../../../utils/api-fetcher.js';
88

9-
const originalFetch = global.fetch;
10-
11-
beforeAll(() => {
12-
// Reset fetch mock before each test
13-
global.fetch = vi.fn();
14-
});
15-
16-
afterAll(() => {
17-
// Restore original fetch after each test
18-
global.fetch = originalFetch;
19-
});
20-
219
describe('callAPIAndAnalyzeResults', () => {
10+
const mockFetch = vi.fn();
2211
const apiClient = new ApiFetcher({});
2312
const ctx = {
2413
apiClient,
@@ -333,7 +322,7 @@ describe('callAPIAndAnalyzeResults', () => {
333322
maxSteps: 2000,
334323
maxFetchTimeout: 40_000,
335324
executionTimeout: 3_600_000,
336-
fetch,
325+
fetch: mockFetch,
337326
},
338327
'x-serverUrl': 'https://catfact.ninja/',
339328
info: {
@@ -364,7 +353,7 @@ describe('callAPIAndAnalyzeResults', () => {
364353
headers: new Headers(),
365354
};
366355

367-
vi.mocked(global.fetch).mockResolvedValue(mockResponse as any);
356+
vi.mocked(mockFetch).mockResolvedValue(mockResponse as any);
368357

369358
const result = await callAPIAndAnalyzeResults({
370359
ctx,

packages/respect-core/src/modules/__tests__/flow-runner/run-step.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ vi.mock('../../flow-runner/call-api-and-analyze-results.js', () => ({
2424
callAPIAndAnalyzeResults: vi.fn(),
2525
}));
2626

27-
// Add this mock for the direct import path used by helpers.ts
2827
vi.mock('../../logger-output/display-checks.js', () => ({
2928
displayChecks: vi.fn(),
3029
}));
@@ -3812,7 +3811,6 @@ describe('runStep', () => {
38123811
});
38133812

38143813
it('should report global timeout error and end execution', async () => {
3815-
// Mock Timer only for this test
38163814
const mockTimer = {
38173815
isTimedOut: vi.fn().mockReturnValue(true),
38183816
};

packages/respect-core/src/modules/__tests__/flow-runner/runner/run-test-file.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import { type Step, type TestContext } from '../../../../types.js';
1111
import { runTestFile, runStep } from '../../../flow-runner/index.js';
1212

1313
vi.mock('@redocly/openapi-core', async () => {
14-
const originalModule = await vi.importActual('@redocly/openapi-core');
14+
const originalModule = await vi.importActual<typeof import('@redocly/openapi-core')>(
15+
'@redocly/openapi-core'
16+
);
1517

1618
return {
1719
...originalModule, // Preserve other exports
@@ -79,7 +81,6 @@ describe('runTestFile', () => {
7981
});
8082
vi.mocked(lint).mockResolvedValue([]);
8183

82-
// Set up default mock for bundle to return proper structure
8384
vi.mocked(bundle).mockResolvedValue({
8485
bundle: {
8586
parsed: {

packages/respect-core/src/modules/context-parser/parse-request-body.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ const getRequestBodyMultipartFormData = async (
6767

6868
const getRequestBodyOctetStream = async (payload: RequestBody['payload'], ctx: TestContext) => {
6969
if (typeof payload === 'string' && payload.startsWith('$file(') && payload.endsWith(')')) {
70-
// fixme, remove this
7170
const filePath = path.resolve(
7271
path.dirname(ctx.options.workflowPath),
7372
stripFileDecorator(payload)
@@ -115,7 +114,6 @@ export async function parseRequestBody(
115114
return {
116115
...stepRequestBody,
117116
payload: formData,
118-
// contentType: `multipart/form-data; boundary=${formData.getBoundary()}`,
119117
};
120118
} else if (
121119
contentType === 'application/octet-stream' ||

packages/respect-core/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export interface WorkflowExecutionResult {
255255
type: 'workflow';
256256
workflowId: string;
257257
stepId?: string; // for child workflows
258-
sourceDescriptionName?: string; // maybe drop for now
258+
sourceDescriptionName?: string;
259259

260260
startTime: number;
261261
endTime: number;

0 commit comments

Comments
 (0)