Skip to content

Commit c72113b

Browse files
committed
test(create): cover intent setup skip under --no-install
Add regression tests for #495: setupIntent must not run the intent install command when dependency installation is skipped, and the closing next steps must report the skip with follow-up commands instead of claiming the agent config was wired up.
1 parent c79a4f7 commit c72113b

2 files changed

Lines changed: 111 additions & 0 deletions

File tree

packages/create/tests/create-app.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,48 @@ describe('createApp', () => {
124124
})
125125
})
126126

127+
it('skips intent setup and reports the follow-up when dependency install is skipped', async () => {
128+
const { environment, output } = createMemoryEnvironment()
129+
let outro = ''
130+
environment.outro = (message: string) => {
131+
outro = message
132+
}
133+
await createApp(environment, {
134+
...simpleOptions,
135+
intent: true,
136+
install: false,
137+
})
138+
139+
expect(output.commands).not.toContainEqual({
140+
command: 'pnpm',
141+
args: ['dlx', '@tanstack/intent', 'install', '--map'],
142+
})
143+
expect(outro).not.toContain('was wired up by TanStack Intent')
144+
expect(outro).toContain('TanStack Intent was skipped')
145+
expect(outro).toContain('pnpm install')
146+
expect(outro).toContain('pnpm dlx @tanstack/intent install --map')
147+
})
148+
149+
it('sets up intent and reports the agent config when dependencies are installed', async () => {
150+
const { environment, output } = createMemoryEnvironment()
151+
let outro = ''
152+
environment.outro = (message: string) => {
153+
outro = message
154+
}
155+
await createApp(environment, {
156+
...simpleOptions,
157+
intent: true,
158+
install: true,
159+
})
160+
161+
expect(output.commands).toContainEqual({
162+
command: 'pnpm',
163+
args: ['dlx', '@tanstack/intent', 'install', '--map'],
164+
})
165+
expect(outro).toContain('was wired up by TanStack Intent')
166+
expect(outro).not.toContain('TanStack Intent was skipped')
167+
})
168+
127169
it('should create an app - with a add-on', async () => {
128170
const { environment, output } = createMemoryEnvironment()
129171
await createApp(environment, {
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { describe, expect, it } from 'vitest'
2+
3+
import { createMemoryEnvironment } from '../../src/environment.js'
4+
import { setupIntent } from '../../src/integrations/intent.js'
5+
6+
import type { Options } from '../../src/types.js'
7+
8+
describe('intent', () => {
9+
it('should skip if intent is not enabled', async () => {
10+
const { environment, output } = createMemoryEnvironment()
11+
environment.startRun()
12+
await setupIntent(environment, '/test', {
13+
packageManager: 'pnpm',
14+
intent: false,
15+
projectName: 'test',
16+
typescript: true,
17+
spinner: () => ({
18+
start: () => {},
19+
stop: () => {},
20+
}),
21+
} as unknown as Options)
22+
environment.finishRun()
23+
24+
expect(output.commands).toEqual([])
25+
})
26+
27+
it('should run the intent install command when dependencies are installed', async () => {
28+
const { environment, output } = createMemoryEnvironment()
29+
environment.startRun()
30+
await setupIntent(environment, '/test', {
31+
packageManager: 'pnpm',
32+
intent: true,
33+
install: true,
34+
projectName: 'test',
35+
typescript: true,
36+
spinner: () => ({
37+
start: () => {},
38+
stop: () => {},
39+
}),
40+
} as unknown as Options)
41+
environment.finishRun()
42+
43+
expect(output.commands).toEqual([
44+
{
45+
command: 'pnpm',
46+
args: ['dlx', '@tanstack/intent', 'install', '--map'],
47+
},
48+
])
49+
})
50+
51+
it('should skip the intent install command when dependency install is skipped', async () => {
52+
const { environment, output } = createMemoryEnvironment()
53+
environment.startRun()
54+
await setupIntent(environment, '/test', {
55+
packageManager: 'pnpm',
56+
intent: true,
57+
install: false,
58+
projectName: 'test',
59+
typescript: true,
60+
spinner: () => ({
61+
start: () => {},
62+
stop: () => {},
63+
}),
64+
} as unknown as Options)
65+
environment.finishRun()
66+
67+
expect(output.commands).toEqual([])
68+
})
69+
})

0 commit comments

Comments
 (0)