
* Removed old macaw and material * Add trpc router that fetches shop address info * Config page layout with header and address * display default addres * Draft channels list * add v2 config model * Render address overrides * Render address overrides ui * connect address form * reset address form * implement removing conifg * connect dashboard sites * update webhook * Add ConfigV1 to ConfigV2 transformer * Cleanup v1 router, abstract v2 * Implement runtime migrations * Implement migration service in controllers * test for configuration service * test for app cofnig * draft test for router * refactor webhook * Unify Address schema to single one * Extractr data fetching from form
68 lines
1.5 KiB
TypeScript
68 lines
1.5 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { appConfigurationRouter } from "./app-configuration-router";
|
|
import { getMockAddress } from "../../fixtures/mock-address";
|
|
import { mockMetadataManager } from "./__mocks__/metadata-manager";
|
|
|
|
vi.mock("./metadata-manager");
|
|
|
|
vi.mock("../../saleor-app", () => {
|
|
const apl = {
|
|
async get() {
|
|
return {
|
|
appId: "app",
|
|
saleorApiUrl: "http://localhost:8000/graphql/",
|
|
token: "TOKEN",
|
|
domain: "localhost:8000",
|
|
};
|
|
},
|
|
async set() {},
|
|
async delete() {},
|
|
async getAll() {
|
|
return [];
|
|
},
|
|
async isReady() {
|
|
return {
|
|
ready: true,
|
|
};
|
|
},
|
|
async isConfigured() {
|
|
return {
|
|
configured: true,
|
|
};
|
|
},
|
|
};
|
|
|
|
return {
|
|
saleorApp: {
|
|
apl,
|
|
},
|
|
};
|
|
});
|
|
|
|
vi.mock("@saleor/app-sdk/verify-jwt", () => {
|
|
return {
|
|
verifyJWT: vi.fn().mockImplementation((async) => {}),
|
|
};
|
|
});
|
|
|
|
describe("appConfigurationRouter", function () {
|
|
describe("upsertChannelOverride", function () {
|
|
it("Calls metadata manager with proper value to save", async () => {
|
|
await appConfigurationRouter
|
|
.createCaller({
|
|
token: "TOKEN",
|
|
saleorApiUrl: "http://localhost:8000/graphql/",
|
|
appId: "app",
|
|
})
|
|
.upsertChannelOverride({
|
|
channelSlug: "test",
|
|
address: getMockAddress(),
|
|
});
|
|
|
|
expect(mockMetadataManager.set).toHaveBeenCalledWith({
|
|
key: "app-config-v2",
|
|
value: expect.any(String),
|
|
});
|
|
});
|
|
});
|
|
});
|