Skip to content

Commit 43acc70

Browse files
committed
test(theme): add test for Ctrl+C calling onClose and add changeset
1 parent 95c9967 commit 43acc70

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/theme': patch
3+
---
4+
5+
Fix analytics not being sent when exiting `theme dev` via Ctrl+C. The process now waits for the post-run analytics hook to complete before terminating.

packages/theme/src/cli/services/dev.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,4 +232,17 @@ describe('createKeypressHandler', () => {
232232
expect(openURL).toHaveBeenCalledTimes(1)
233233
expect(openURL).toHaveBeenCalledWith(urls.local)
234234
})
235+
236+
test('calls onClose when Ctrl+C is pressed', () => {
237+
// Given
238+
const onClose = vi.fn()
239+
const handler = createKeypressHandler(urls, ctx, onClose)
240+
241+
// When
242+
handler('', {ctrl: true, name: 'c'})
243+
244+
// Then
245+
expect(onClose).toHaveBeenCalledOnce()
246+
expect(openURL).not.toHaveBeenCalled()
247+
})
235248
})

0 commit comments

Comments
 (0)