Skip to content

Commit 62580d5

Browse files
angeloashmoreclaude
andcommitted
fix: use test helpers instead of importing from src
Add getCustomTypes/getSlices helpers to test/prismic.ts and use those for polling instead of importing from src/clients/custom-types.ts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 62c3002 commit 62580d5

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

test/prismic.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,32 @@ export async function deleteRepository(
4747
}
4848
}
4949

50+
export async function getCustomTypes(config: RepoConfig): Promise<{ id: string }[]> {
51+
const host = config.host ?? DEFAULT_HOST;
52+
const url = new URL("customtypes", `https://customtypes.${host}/`);
53+
const res = await fetch(url, {
54+
headers: {
55+
Authorization: `Bearer ${config.token}`,
56+
repository: config.repo,
57+
},
58+
});
59+
if (!res.ok) throw new Error(`Failed to get custom types: ${res.status} ${await res.text()}`);
60+
return await res.json();
61+
}
62+
63+
export async function getSlices(config: RepoConfig): Promise<{ id: string }[]> {
64+
const host = config.host ?? DEFAULT_HOST;
65+
const url = new URL("slices", `https://customtypes.${host}/`);
66+
const res = await fetch(url, {
67+
headers: {
68+
Authorization: `Bearer ${config.token}`,
69+
repository: config.repo,
70+
},
71+
});
72+
if (!res.ok) throw new Error(`Failed to get slices: ${res.status} ${await res.text()}`);
73+
return await res.json();
74+
}
75+
5076
export async function insertCustomType(customType: object, config: RepoConfig): Promise<void> {
5177
const host = config.host ?? DEFAULT_HOST;
5278
const url = new URL("customtypes/insert", `https://customtypes.${host}/`);

test/sync.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import { writeFile, mkdir } from "node:fs/promises";
22

3-
import { getCustomTypes, getSlices } from "../src/clients/custom-types";
43
import { buildCustomType, buildSlice, captureOutput, it } from "./it";
5-
import { deleteCustomType, deleteSlice, insertCustomType, insertSlice } from "./prismic";
4+
import {
5+
deleteCustomType,
6+
deleteSlice,
7+
getCustomTypes,
8+
getSlices,
9+
insertCustomType,
10+
insertSlice,
11+
} from "./prismic";
612

713
it("supports --help", async ({ expect, prismic }) => {
814
const { stdout, exitCode } = await prismic("sync", ["--help"]);

0 commit comments

Comments
 (0)