Skip to content

Commit 227f274

Browse files
tylerpinaclaude
andcommitted
test: add verify scripts for fragment getMany and get
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7670986 commit 227f274

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { version } from '../../package.json'
2+
;(globalThis as any).__VERSION__ = version
3+
4+
import { createClient } from '../../lib/index'
5+
6+
const accessToken = process.env.CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN
7+
if (!accessToken) {
8+
throw new Error('CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN is required')
9+
}
10+
11+
const spaceId = process.env.SPACE_ID
12+
const environmentId = process.env.ENVIRONMENT_ID ?? 'exo'
13+
14+
if (!spaceId) {
15+
throw new Error('SPACE_ID environment variable is required')
16+
}
17+
18+
const client = createClient(
19+
{ accessToken },
20+
{ type: 'plain', defaults: { spaceId, environmentId } },
21+
)
22+
23+
;(async () => {
24+
console.log(`Fetching fragments from space ${spaceId} (env: ${environmentId})...\n`)
25+
26+
try {
27+
const fragments = await client.fragment.getMany({ query: {} })
28+
console.log('Success! Response:\n')
29+
console.log(JSON.stringify(fragments, null, 2))
30+
} catch (error) {
31+
console.error('Request failed:\n')
32+
console.error(error)
33+
process.exit(1)
34+
}
35+
})()
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { version } from '../../package.json'
2+
;(globalThis as any).__VERSION__ = version
3+
4+
import { createClient } from '../../lib/index'
5+
6+
const accessToken = process.env.CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN
7+
if (!accessToken) {
8+
throw new Error('CONTENTFUL_INTEGRATION_TEST_CMA_TOKEN is required')
9+
}
10+
11+
const spaceId = process.env.SPACE_ID
12+
const environmentId = process.env.ENVIRONMENT_ID ?? 'exo'
13+
const fragmentId = process.env.FRAGMENT_ID
14+
15+
if (!spaceId || !fragmentId) {
16+
throw new Error('SPACE_ID and FRAGMENT_ID environment variables are required')
17+
}
18+
19+
const client = createClient(
20+
{ accessToken },
21+
{ type: 'plain', defaults: { spaceId, environmentId } },
22+
)
23+
24+
;(async () => {
25+
console.log(`Fetching fragment ${fragmentId} from space ${spaceId} (env: ${environmentId})...\n`)
26+
27+
try {
28+
const fragment = await client.fragment.get({ fragmentId })
29+
console.log('Success! Response:\n')
30+
console.log(JSON.stringify(fragment, null, 2))
31+
} catch (error) {
32+
console.error('Request failed:\n')
33+
console.error(error)
34+
process.exit(1)
35+
}
36+
})()

0 commit comments

Comments
 (0)