Files
pokemon-inventory/apps/api/tests/http/provider-mapping-routes.test.js
fragginwagon b8f089a5d9 feat: reconcile application vertical slices
Backfill the completed acquisitions, sales, dashboard, pricing, search, public detail, worker, migration, contracts, validation, tests, and implementation-status changes into one verified application slice.
2026-09-09 22:12:53 -04:00

41 lines
1.1 KiB
JavaScript

import assert from "node:assert/strict";
import test from "node:test";
import { buildApp } from "../../src/app/build-app.js";
test("protects provider mapping writes and scopes mappings to the seller", async (testContext) => {
let received;
const app = buildApp({
authenticateAdmin: async () => ({ sellerId: "seller-1" }),
authorizeUnsafeRequest: async () => {},
providerMappingService: {
async create(input) {
received = input;
return { id: "mapping-1", ...input, status: "ACTIVE" };
},
async list() {
return [];
},
async disable() {
return { id: "mapping-1", status: "DISABLED" };
},
},
});
testContext.after(() => app.close());
const response = await app.inject({
method: "POST",
url: "/api/v1/admin/products/product-1/provider-mappings",
headers: { "x-csrf-token": "csrf" },
payload: {
providerId: "fixture",
mappingType: "PRODUCT",
externalIdentifier: "ext-1",
},
});
assert.equal(response.statusCode, 201);
assert.equal(received.sellerId, "seller-1");
assert.equal(response.json().data.providerId, "fixture");
});