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.
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { buildApp } from '../../src/app/build-app.js';
|
||||
import { buildApp } from "../../src/app/build-app.js";
|
||||
|
||||
test('returns public search results with pagination metadata', async (testContext) => {
|
||||
test("returns public search results with pagination metadata", async (testContext) => {
|
||||
const app = buildApp({
|
||||
searchService: {
|
||||
async searchPublic(filters) {
|
||||
assert.equal(filters.page, 2);
|
||||
assert.equal(filters.limit, 5);
|
||||
assert.equal(filters.includeSold, true);
|
||||
assert.equal(filters.sort, 'price_low');
|
||||
assert.equal(filters.conditionId, 'condition-1');
|
||||
assert.equal(filters.sort, "price_low");
|
||||
assert.equal(filters.conditionId, "condition-1");
|
||||
return {
|
||||
items: [{ id: 'listing-1', status: 'CLOSED' }],
|
||||
items: [{ id: "listing-1", status: "CLOSED" }],
|
||||
pagination: { page: 2, limit: 5, total: 6, totalPages: 2 },
|
||||
};
|
||||
},
|
||||
@@ -22,8 +22,8 @@ test('returns public search results with pagination metadata', async (testContex
|
||||
testContext.after(() => app.close());
|
||||
|
||||
const response = await app.inject({
|
||||
method: 'GET',
|
||||
url: '/api/v1/public/search?query=charizard&page=2&limit=5&includeSold=true&sort=price_low&conditionId=condition-1',
|
||||
method: "GET",
|
||||
url: "/api/v1/public/search?query=charizard&page=2&limit=5&includeSold=true&sort=price_low&conditionId=condition-1",
|
||||
});
|
||||
|
||||
assert.equal(response.statusCode, 200);
|
||||
@@ -33,44 +33,71 @@ test('returns public search results with pagination metadata', async (testContex
|
||||
total: 6,
|
||||
totalPages: 2,
|
||||
});
|
||||
assert.equal(response.json().data.items[0].id, 'listing-1');
|
||||
assert.equal(response.json().data.items[0].id, "listing-1");
|
||||
});
|
||||
|
||||
test('rejects malformed numeric search filters', async (testContext) => {
|
||||
const app = buildApp({ searchService: { async searchPublic() { throw new Error('should not run'); } } });
|
||||
test("rejects malformed numeric search filters", async (testContext) => {
|
||||
const app = buildApp({
|
||||
searchService: {
|
||||
async searchPublic() {
|
||||
throw new Error("should not run");
|
||||
},
|
||||
},
|
||||
});
|
||||
testContext.after(() => app.close());
|
||||
|
||||
const response = await app.inject({
|
||||
method: 'GET',
|
||||
url: '/api/v1/public/search?minPriceMinor=12.5',
|
||||
method: "GET",
|
||||
url: "/api/v1/public/search?minPriceMinor=12.5",
|
||||
});
|
||||
|
||||
assert.equal(response.statusCode, 400);
|
||||
assert.equal(response.json().error.code, 'INVALID_SEARCH_FILTER');
|
||||
assert.equal(response.json().error.code, "INVALID_SEARCH_FILTER");
|
||||
});
|
||||
|
||||
test('returns active public category options', async (testContext) => {
|
||||
test("returns active public category options", async (testContext) => {
|
||||
const app = buildApp({
|
||||
catalogLookupRepository: {
|
||||
async listCategories() { return [{ id: 'category-1', name: 'Trading Cards' }]; },
|
||||
async listCategories() {
|
||||
return [{ id: "category-1", name: "Trading Cards" }];
|
||||
},
|
||||
},
|
||||
});
|
||||
testContext.after(() => app.close());
|
||||
|
||||
const response = await app.inject({ method: 'GET', url: '/api/v1/public/lookups/categories' });
|
||||
const response = await app.inject({
|
||||
method: "GET",
|
||||
url: "/api/v1/public/lookups/categories",
|
||||
});
|
||||
assert.equal(response.statusCode, 200);
|
||||
assert.deepEqual(response.json().data, [{ id: 'category-1', name: 'Trading Cards' }]);
|
||||
assert.deepEqual(response.json().data, [
|
||||
{ id: "category-1", name: "Trading Cards" },
|
||||
]);
|
||||
});
|
||||
|
||||
test('returns public condition options without category internals', async (testContext) => {
|
||||
test("returns public condition options without category internals", async (testContext) => {
|
||||
const app = buildApp({
|
||||
catalogLookupRepository: {
|
||||
async listConditions() { return [{ id: 'condition-1', name: 'Near Mint', code: 'NM', categoryId: 'private-category' }]; },
|
||||
async listConditions() {
|
||||
return [
|
||||
{
|
||||
id: "condition-1",
|
||||
name: "Near Mint",
|
||||
code: "NM",
|
||||
categoryId: "private-category",
|
||||
},
|
||||
];
|
||||
},
|
||||
},
|
||||
});
|
||||
testContext.after(() => app.close());
|
||||
|
||||
const response = await app.inject({ method: 'GET', url: '/api/v1/public/lookups/conditions' });
|
||||
const response = await app.inject({
|
||||
method: "GET",
|
||||
url: "/api/v1/public/lookups/conditions",
|
||||
});
|
||||
assert.equal(response.statusCode, 200);
|
||||
assert.deepEqual(response.json().data, [{ id: 'condition-1', name: 'Near Mint', code: 'NM' }]);
|
||||
});
|
||||
assert.deepEqual(response.json().data, [
|
||||
{ id: "condition-1", name: "Near Mint", code: "NM" },
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user