|
1 | 1 | import { writeFile, mkdir } from "node:fs/promises"; |
2 | 2 |
|
3 | 3 | import { buildCustomType, buildSlice, captureOutput, it } from "./it"; |
4 | | -import { deleteCustomType, deleteSlice, insertCustomType, insertSlice } from "./prismic"; |
| 4 | +import { |
| 5 | + deleteCustomType, |
| 6 | + deleteSlice, |
| 7 | + getCustomTypes, |
| 8 | + getSlices, |
| 9 | + insertCustomType, |
| 10 | + insertSlice, |
| 11 | +} from "./prismic"; |
5 | 12 |
|
6 | 13 | it("supports --help", async ({ expect, prismic }) => { |
7 | 14 | const { stdout, exitCode } = await prismic("sync", ["--help"]); |
@@ -82,6 +89,10 @@ it("adds new slice to existing library on re-sync", async ({ |
82 | 89 | // Insert a second slice remotely |
83 | 90 | const sliceB = buildSlice(); |
84 | 91 | await insertSlice(sliceB, { repo, token, host }); |
| 92 | + await expect.poll( |
| 93 | + async () => (await getSlices({ repo, token, host })).map((s) => s.id), |
| 94 | + { timeout: 5_000 }, |
| 95 | + ).toContain(sliceB.id); |
85 | 96 |
|
86 | 97 | // Second sync — should add slice B without breaking slice A |
87 | 98 | const second = await prismic("sync", ["--repo", repo]); |
@@ -114,6 +125,10 @@ it("removes deleted slice and updates index on re-sync", async ({ |
114 | 125 |
|
115 | 126 | // Delete slice B from remote |
116 | 127 | await deleteSlice(sliceB.id, { repo, token, host }); |
| 128 | + await expect.poll( |
| 129 | + async () => (await getSlices({ repo, token, host })).map((s) => s.id), |
| 130 | + { timeout: 5_000 }, |
| 131 | + ).not.toContain(sliceB.id); |
117 | 132 |
|
118 | 133 | // Second sync — should remove slice B and update the index |
119 | 134 | const second = await prismic("sync", ["--repo", repo]); |
@@ -199,6 +214,10 @@ it("removes route when page type is deleted", async ({ |
199 | 214 | await expect(project).toHaveRoute({ type: customType.id }); |
200 | 215 |
|
201 | 216 | await deleteCustomType(customType.id, { repo, token, host }); |
| 217 | + await expect.poll( |
| 218 | + async () => (await getCustomTypes({ repo, token, host })).map((ct) => ct.id), |
| 219 | + { timeout: 5_000 }, |
| 220 | + ).not.toContain(customType.id); |
202 | 221 |
|
203 | 222 | // Second sync — removes the route |
204 | 223 | const second = await prismic("sync", ["--repo", repo]); |
|
0 commit comments