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,16 +1,16 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import {
|
||||
buildSearchFilters,
|
||||
createSearchQuery,
|
||||
normalizeSearchQuery,
|
||||
} from '../../src/modules/search/domain/search-query.js';
|
||||
} from "../../src/modules/search/domain/search-query.js";
|
||||
|
||||
test('normalizes a public search query and keeps filter values within bounds', () => {
|
||||
test("normalizes a public search query and keeps filter values within bounds", () => {
|
||||
const query = createSearchQuery({
|
||||
query: ' Charizard ex ',
|
||||
category: 'Cards',
|
||||
query: " Charizard ex ",
|
||||
category: "Cards",
|
||||
minPriceMinor: 1000,
|
||||
maxPriceMinor: 5000,
|
||||
page: 1,
|
||||
@@ -18,8 +18,8 @@ test('normalizes a public search query and keeps filter values within bounds', (
|
||||
includeSold: false,
|
||||
});
|
||||
|
||||
assert.equal(query.text, 'charizard ex');
|
||||
assert.equal(query.category, 'Cards');
|
||||
assert.equal(query.text, "charizard ex");
|
||||
assert.equal(query.category, "Cards");
|
||||
assert.equal(query.minPriceMinor, 1000);
|
||||
assert.equal(query.maxPriceMinor, 5000);
|
||||
assert.equal(query.page, 1);
|
||||
@@ -27,25 +27,45 @@ test('normalizes a public search query and keeps filter values within bounds', (
|
||||
assert.equal(query.includeSold, false);
|
||||
});
|
||||
|
||||
test('rejects invalid pagination and price boundaries', () => {
|
||||
assert.throws(() => createSearchQuery({ query: 'abc', page: 0, limit: 20 }), /page must be >= 1/);
|
||||
assert.throws(() => createSearchQuery({ query: 'abc', minPriceMinor: 5000, maxPriceMinor: 1000 }), /minPriceMinor must be <= maxPriceMinor/);
|
||||
assert.throws(() => createSearchQuery({ query: 'abc', limit: 0 }), /limit must be between 1 and 100/);
|
||||
test("rejects invalid pagination and price boundaries", () => {
|
||||
assert.throws(
|
||||
() => createSearchQuery({ query: "abc", page: 0, limit: 20 }),
|
||||
/page must be >= 1/,
|
||||
);
|
||||
assert.throws(
|
||||
() =>
|
||||
createSearchQuery({
|
||||
query: "abc",
|
||||
minPriceMinor: 5000,
|
||||
maxPriceMinor: 1000,
|
||||
}),
|
||||
/minPriceMinor must be <= maxPriceMinor/,
|
||||
);
|
||||
assert.throws(
|
||||
() => createSearchQuery({ query: "abc", limit: 0 }),
|
||||
/limit must be between 1 and 100/,
|
||||
);
|
||||
});
|
||||
|
||||
test('builds a public query filter set that hides sold items by default', () => {
|
||||
test("builds a public query filter set that hides sold items by default", () => {
|
||||
const filters = buildSearchFilters({ includeSold: false });
|
||||
|
||||
assert.equal(filters.status, 'AVAILABLE');
|
||||
assert.equal(filters.status, "AVAILABLE");
|
||||
assert.equal(filters.includeSold, false);
|
||||
assert.deepEqual(filters.sort, ['recently_added']);
|
||||
assert.deepEqual(filters.sort, ["recently_added"]);
|
||||
});
|
||||
|
||||
test('accepts only the supported public search sort values', () => {
|
||||
assert.equal(createSearchQuery({ sort: 'price_low' }).sort, 'price_low');
|
||||
assert.throws(() => createSearchQuery({ sort: 'random' }), /sort must be recent/);
|
||||
test("accepts only the supported public search sort values", () => {
|
||||
assert.equal(createSearchQuery({ sort: "price_low" }).sort, "price_low");
|
||||
assert.throws(
|
||||
() => createSearchQuery({ sort: "random" }),
|
||||
/sort must be recent/,
|
||||
);
|
||||
});
|
||||
|
||||
test('normalizes whitespace and punctuation in free-text search terms', () => {
|
||||
assert.equal(normalizeSearchQuery(' Pikachu #199 / holo '), 'pikachu 199 holo');
|
||||
test("normalizes whitespace and punctuation in free-text search terms", () => {
|
||||
assert.equal(
|
||||
normalizeSearchQuery(" Pikachu #199 / holo "),
|
||||
"pikachu 199 holo",
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user