Skip to content

Commit

Permalink
Merge pull request #1546 from prismicio/dani/table-mock
Browse files Browse the repository at this point in the history
Upgrade prismic mock
  • Loading branch information
dani-mp authored Jan 29, 2025
2 parents 779cb5e + dea27e4 commit 5c64faf
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 173 deletions.
2 changes: 1 addition & 1 deletion packages/adapter-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"pascal-case": "^3.1.2"
},
"devDependencies": {
"@prismicio/mock": "0.2.0",
"@prismicio/mock": "0.7.0-alpha.3",
"@size-limit/preset-small-lib": "8.2.4",
"@types/common-tags": "1.8.1",
"@types/react": "18.0.28",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"pascal-case": "^3.1.2"
},
"devDependencies": {
"@prismicio/mock": "0.2.0",
"@prismicio/mock": "0.7.0-alpha.3",
"@size-limit/preset-small-lib": "8.2.4",
"@types/common-tags": "1.8.1",
"@typescript-eslint/eslint-plugin": "5.55.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-nuxt2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"pascal-case": "^3.1.2"
},
"devDependencies": {
"@prismicio/mock": "0.2.0",
"@prismicio/mock": "0.7.0-alpha.3",
"@size-limit/preset-small-lib": "8.2.4",
"@typescript-eslint/eslint-plugin": "5.55.0",
"@typescript-eslint/parser": "5.55.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-sveltekit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"prettier-plugin-svelte": "^3.0.3"
},
"devDependencies": {
"@prismicio/mock": "0.2.0",
"@prismicio/mock": "0.7.0-alpha.3",
"@size-limit/preset-small-lib": "8.2.4",
"@sveltejs/kit": "2.0.0",
"@sveltejs/package": "2.2.1",
Expand Down
4 changes: 1 addition & 3 deletions packages/init/test/SliceMachineInitProcess-run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ const prepareEnvironment = async (
variations: [ctx.mockPrismic.model.sharedSliceVariation()],
});
const customTypeModel = ctx.mockPrismic.model.customType();
// TODO: update @prismicio/mock so that custom-type includes the "format" property
const customTypeModelWithFormat = { ...customTypeModel, format: "custom" };

const sliceLibraryReadHookHandler = vi.fn(({ libraryID }) => {
if (libraryID === "./slices") {
Expand Down Expand Up @@ -116,7 +114,7 @@ const prepareEnvironment = async (
return res(ctx.status(404));
},
async onCustomTypeInsert(req, res, ctx) {
expect(await req.json()).toStrictEqual(customTypeModelWithFormat);
expect(await req.json()).toStrictEqual(customTypeModel);

return res(ctx.status(201));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ const mockAdapter = async (
variations: [ctx.mockPrismic.model.sharedSliceVariation()],
});
const customTypeModel = ctx.mockPrismic.model.customType();
// TODO: maybe update @prismic/mock with the new custom-type format
const customTypeModelWithFormat = { ...customTypeModel, format: "custom" };

const sliceLibraryReadHookHandler = vi.fn(({ libraryID }) => {
if (options?.throwsOn?.includes("slice-library:read")) {
Expand Down Expand Up @@ -131,7 +129,7 @@ const mockAdapter = async (
adapter,
models: {
sharedSliceModel,
customTypeModel: customTypeModelWithFormat,
customTypeModel,
},
spiedHookHandlers: {
sliceLibraryReadHookHandler,
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
},
"devDependencies": {
"@amplitude/experiment-node-server": "1.8.1",
"@prismicio/mock": "0.2.0",
"@prismicio/mock": "0.7.0-alpha.3",
"@size-limit/preset-small-lib": "8.2.4",
"@types/express": "4.17.17",
"@types/semver": "7.3.13",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ it("calls plugins' `custom-type:delete` hook", async (ctx) => {

const res = await manager.customTypes.deleteCustomType({ id: model.id });

expectHookHandlerToHaveBeenCalledWithData(hookHandler, {
// TODO: update prismic/mock
model: { ...model, format: "custom" },
});
expectHookHandlerToHaveBeenCalledWithData(hookHandler, { model });
expect(res).toStrictEqual({
errors: [],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ it("pushes a Custom Type using the Custom Types API", async (ctx) => {

await manager.user.login(createPrismicAuthLoginResponse());
await manager.customTypes.pushCustomType({ id: model.id });
// TODO: update prismicio/mock library
expect(sentModel).toStrictEqual({ ...model, format: "custom" });
expect(sentModel).toStrictEqual(model);
});

it("pushes a Custom Type using the Custom Types API using the currently set environment", async (ctx) => {
Expand Down Expand Up @@ -93,8 +92,8 @@ it("pushes a Custom Type using the Custom Types API using the currently set envi

await manager.user.login(createPrismicAuthLoginResponse());
await manager.customTypes.pushCustomType({ id: model.id });
// TODO: update prismicio/mock library
expect(sentModel).toStrictEqual({ ...model, format: "custom" });

expect(sentModel).toStrictEqual(model);
});

it("uses the update endpoint if the Custom Type already exists", async (ctx) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ it("returns the adapter's `custom-type:read` return value", async (ctx) => {
const res = await manager.customTypes.readCustomType({ id: model.id });

expect(res).toStrictEqual({
// TODO: update prismic/mock
model: { ...model, format: "custom" },
model,
errors: [],
});
expectHookHandlerToHaveBeenCalledWithData(hookHandler, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ it("pushes changes using the push API", async (ctx) => {
{
id: customTypeModel.id,
type: ChangeTypes.CUSTOM_TYPE_UPDATE,
// TODO: update prismicio/mock librarys
payload: { ...customTypeModel, format: "custom" },
payload: customTypeModel,
},
],
confirmDeleteDocuments: false,
Expand Down Expand Up @@ -167,8 +166,7 @@ it("pushes changes using the push API to the selected environment when an enviro
{
id: customTypeModel.id,
type: ChangeTypes.CUSTOM_TYPE_UPDATE,
// TODO: update prismicio/mock librarys
payload: { ...customTypeModel, format: "custom" },
payload: customTypeModel,
},
],
confirmDeleteDocuments: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ it("removes deleted slice from custom types referencing it", async (ctx) => {
expect(deleteSliceHook).toHaveBeenCalledOnce();
expect(updateCustomTypeHook).toHaveBeenCalledOnce();
expectHookHandlerToHaveBeenCalledWithData(updateCustomTypeHook, {
// TODO: update prismicio/mock libray
model: { ...mockCustomTypeWithoutSlice, format: "custom" },
model: mockCustomTypeWithoutSlice,
});
expect(res).toStrictEqual({
errors: [],
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"prismic-ts-codegen": "^0.1.23"
},
"devDependencies": {
"@prismicio/mock": "0.3.7",
"@prismicio/mock": "0.7.0-alpha.3",
"@prismicio/types-internal": "3.4.0-alpha.11",
"@size-limit/preset-small-lib": "8.2.4",
"@types/common-tags": "1.8.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/slice-machine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@prismicio/editor-fields": "0.4.61",
"@prismicio/editor-support": "0.4.61",
"@prismicio/editor-ui": "0.4.61",
"@prismicio/mock": "0.3.3",
"@prismicio/mock": "0.7.0-alpha.3",
"@prismicio/mocks": "2.8.0",
"@prismicio/simulator": "0.1.4",
"@prismicio/types-internal": "3.4.0-alpha.11",
Expand Down
Loading

0 comments on commit 5c64faf

Please sign in to comment.