Skip to content

Commit

Permalink
test(cli): add tests for denying telemetry consent
Browse files Browse the repository at this point in the history
  • Loading branch information
juice49 authored and bjoerge committed Dec 14, 2023
1 parent 280096f commit 60ff848
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions packages/@sanity/cli/test/telemetry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,65 @@ https://sanity.io/telemetry
`)
})
})

describeCliTest('CLI: `sanity telemetry disable`', () => {
testConcurrent('sanity telemetry disable: success', async () => {
const result = await runSanityCmdCommand('v3', ['telemetry', 'disable'], {
env: {
MOCK_TELEMETRY_CONSENT_MODE: 'success',
},
})

expect(result.stdout).toMatchInlineSnapshot(`
"Status: Disabled
You've opted out of telemetry data collection.
No data will be collected from your Sanity account.
Learn more here:
https://sanity.io/telemetry
"
`)
})

testConcurrent('sanity telemetry disable: success (already denied)', async () => {
const result = await runSanityCmdCommand('v3', ['telemetry', 'disable'], {
env: {
MOCK_CONSENT: 'denied',
},
})

expect(result.stdout).toMatchInlineSnapshot(`
"Status: Disabled
You've already opted out of telemetry data collection.
No data is collected from your Sanity account.
Learn more here:
https://sanity.io/telemetry
"
`)
})

testConcurrent(
'sanity telemetry disable: success (already denied using DO_NOT_TRACK)',
async () => {
const result = await runSanityCmdCommand('v3', ['telemetry', 'disable'], {
env: {
DO_NOT_TRACK: '1',
},
})

expect(result.stdout).toMatchInlineSnapshot(`
"Status: Disabled
You've already opted out of telemetry data collection.
No data is collected from your Sanity account.
Learn more here:
https://sanity.io/telemetry
"
`)
},
)
})

0 comments on commit 60ff848

Please sign in to comment.