Skip to content

Commit 8cb2e44

Browse files
committed
feat: add test fixes
1 parent 9bb09f9 commit 8cb2e44

5 files changed

Lines changed: 76 additions & 0 deletions

File tree

test/integration/resolver.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@ vi.mock('node:fs/promises', async () => {
1515
return fs.promises;
1616
})
1717

18+
vi.mock('../../src/api/backend/index.js', async () => {
19+
const { fs } = await import('memfs');
20+
const path = await import('node:path');
21+
const os = await import('node:os');
22+
return {
23+
ApiClient: {
24+
searchPlugins: vi.fn(async () => ({
25+
default: { name: 'default', version: '1.0.0', downloadLink: 'https://fake/plugin.js' }
26+
})),
27+
downloadPlugin: vi.fn(async (filePath: string) => {
28+
const dir = path.default.dirname(filePath);
29+
fs.mkdirSync(dir, { recursive: true });
30+
fs.writeFileSync(filePath, 'export default {}');
31+
}),
32+
}
33+
}
34+
})
35+
1836
describe('Plugin resolver integration test', () => {
1937

2038
it('resolves the default plugin', async () => {

test/orchestrator/edit/edit.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ vi.mock(import('open'), async () => {
3535
}
3636
})
3737

38+
vi.mock('../../../src/utils/desktop-installer.js', () => ({
39+
getDesktopAppPath: vi.fn(async () => null),
40+
getDesktopDownloadUrl: vi.fn(() => null),
41+
installDesktopApp: vi.fn(async () => {}),
42+
}))
43+
3844
// The apply orchestrator directly calls plan so this will test both
3945
describe('Edit orchestrator tests', () => {
4046
beforeEach(() => {

test/orchestrator/import/import.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,24 @@ vi.mock('../../../src/plugins/plugin.js', async () => {
116116
return { Plugin: MockPlugin };
117117
})
118118

119+
vi.mock('../../../src/api/backend/index.js', async () => {
120+
const { fs } = await import('memfs');
121+
const path = await import('node:path');
122+
const os = await import('node:os');
123+
return {
124+
ApiClient: {
125+
searchPlugins: vi.fn(async () => ({
126+
default: { name: 'default', version: '1.0.0', downloadLink: 'https://fake/plugin.js' }
127+
})),
128+
downloadPlugin: vi.fn(async (filePath: string) => {
129+
const dir = path.default.dirname(filePath);
130+
fs.mkdirSync(dir, { recursive: true });
131+
fs.writeFileSync(filePath, 'export default {}');
132+
}),
133+
}
134+
}
135+
})
136+
119137
vi.mock('node:fs', async () => {
120138
const { fs } = await import('memfs');
121139
return fs

test/orchestrator/initialize/initialize.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,23 @@ vi.mock('../../../src/plugins/plugin.js', async () => {
4040
return { Plugin: MockPlugin };
4141
})
4242

43+
vi.mock('../../../src/api/backend/index.js', async () => {
44+
const { fs } = await import('memfs');
45+
const path = await import('node:path');
46+
return {
47+
ApiClient: {
48+
searchPlugins: vi.fn(async () => ({
49+
default: { name: 'default', version: '1.0.0', downloadLink: 'https://fake/plugin.js' }
50+
})),
51+
downloadPlugin: vi.fn(async (filePath: string) => {
52+
const dir = path.default.dirname(filePath);
53+
fs.mkdirSync(dir, { recursive: true });
54+
fs.writeFileSync(filePath, 'export default {}');
55+
}),
56+
}
57+
}
58+
})
59+
4360
describe('Parser integration tests', () => {
4461
it('Finds the correct files to initialize and initializes all files within a folder', async () => {
4562
const file1Contents =

test/orchestrator/refresh/refresh.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,23 @@ vi.mock('../../../src/plugins/plugin.js', async () => {
117117
return { Plugin: MockPlugin };
118118
})
119119

120+
vi.mock('../../../src/api/backend/index.js', async () => {
121+
const { fs } = await import('memfs');
122+
const path = await import('node:path');
123+
return {
124+
ApiClient: {
125+
searchPlugins: vi.fn(async () => ({
126+
default: { name: 'default', version: '1.0.0', downloadLink: 'https://fake/plugin.js' }
127+
})),
128+
downloadPlugin: vi.fn(async (filePath: string) => {
129+
const dir = path.default.dirname(filePath);
130+
fs.mkdirSync(dir, { recursive: true });
131+
fs.writeFileSync(filePath, 'export default {}');
132+
}),
133+
}
134+
}
135+
})
136+
120137
vi.mock('node:fs', async () => {
121138
const { fs } = await import('memfs');
122139
return fs

0 commit comments

Comments
 (0)