refactor(api): regroupe test/ par sous-domaine, miroir de src/lib/
18 fichiers à plat -> recipe-matching/ (ingredient-matcher, recipe-
translation, tech-step-matcher — miroir de lib/recipe-matching/),
recipe-sources/ (json-ld-recipe, recipe-source, recipe-source-sync,
the-meal-db — miroir de lib/recipe-sources/), sources/ (sources,
sources-index — module + registration src/sources/index.ts).
Les tests par domaine API sans regroupement naturel (auth, health,
house, logger.service, planning, preferences, profile, recipe,
reference) restent à la racine de test/, un fichier par domaine — même
logique que jwt.ts/safe-profile.ts restés à la racine de lib/.
Chemins relatifs corrigés (../src/ -> ../../src/, ../test-support/ ->
../../test-support/ dans les fichiers déplacés qui appellent
resetDatabase). .mocharc.json ("test/**/*.test.ts") couvre déjà les
sous-dossiers, aucun changement de config nécessaire.
Vérifié : biome check, 303 tests API.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
4db8e1369f
commit
82c09331dc
9 changed files with 35 additions and 35 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
import { INGREDIENT_LABEL_SYNONYMS_EN } from "@batch-cooking/shared";
|
import { INGREDIENT_LABEL_SYNONYMS_EN } from "@batch-cooking/shared";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import { prisma } from "../src/db/prisma.js";
|
import { prisma } from "../../src/db/prisma.js";
|
||||||
import {
|
import {
|
||||||
extractQuantity,
|
extractQuantity,
|
||||||
type IngredientMatchEntry,
|
type IngredientMatchEntry,
|
||||||
|
|
@ -9,8 +9,8 @@ import {
|
||||||
matchIngredientName,
|
matchIngredientName,
|
||||||
matchUnit,
|
matchUnit,
|
||||||
type UnitMatchEntry,
|
type UnitMatchEntry,
|
||||||
} from "../src/lib/recipe-matching/ingredient-matcher.js";
|
} from "../../src/lib/recipe-matching/ingredient-matcher.js";
|
||||||
import { resetDatabase } from "../test-support/reset-db.js";
|
import { resetDatabase } from "../../test-support/reset-db.js";
|
||||||
|
|
||||||
describe("ingredient-matcher", () => {
|
describe("ingredient-matcher", () => {
|
||||||
describe("matchIngredientName", () => {
|
describe("matchIngredientName", () => {
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import { prisma } from "../src/db/prisma.js";
|
import { prisma } from "../../src/db/prisma.js";
|
||||||
import type {
|
import type {
|
||||||
IngredientMatchEntry,
|
IngredientMatchEntry,
|
||||||
UnitMatchEntry,
|
UnitMatchEntry,
|
||||||
} from "../src/lib/recipe-matching/ingredient-matcher.js";
|
} from "../../src/lib/recipe-matching/ingredient-matcher.js";
|
||||||
import {
|
import {
|
||||||
mergeDuplicateIngredients,
|
mergeDuplicateIngredients,
|
||||||
type TranslatedRecipeIngredient,
|
type TranslatedRecipeIngredient,
|
||||||
|
|
@ -11,13 +11,13 @@ import {
|
||||||
translateRecipeIngredients,
|
translateRecipeIngredients,
|
||||||
translateRecipeSteps,
|
translateRecipeSteps,
|
||||||
type UnitConversionEntry,
|
type UnitConversionEntry,
|
||||||
} from "../src/lib/recipe-matching/recipe-translation.js";
|
} from "../../src/lib/recipe-matching/recipe-translation.js";
|
||||||
import type { TechStepMappingRule } from "../src/lib/recipe-matching/tech-step-matcher.js";
|
import type { TechStepMappingRule } from "../../src/lib/recipe-matching/tech-step-matcher.js";
|
||||||
import type {
|
import type {
|
||||||
ParsedRecipe,
|
ParsedRecipe,
|
||||||
ParsedRecipeIngredient,
|
ParsedRecipeIngredient,
|
||||||
} from "../src/lib/recipe-sources/recipe-source-adapter.js";
|
} from "../../src/lib/recipe-sources/recipe-source-adapter.js";
|
||||||
import { resetDatabase } from "../test-support/reset-db.js";
|
import { resetDatabase } from "../../test-support/reset-db.js";
|
||||||
|
|
||||||
/** A minimal fixture `ParsedRecipe` — only `steps` (built from `descriptions`) matters for most tests here, the rest is filler to prove it survives translation untouched. */
|
/** A minimal fixture `ParsedRecipe` — only `steps` (built from `descriptions`) matters for most tests here, the rest is filler to prove it survives translation untouched. */
|
||||||
function buildParsedRecipe(descriptions: string[]): ParsedRecipe {
|
function buildParsedRecipe(descriptions: string[]): ParsedRecipe {
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import { prisma } from "../src/db/prisma.js";
|
import { prisma } from "../../src/db/prisma.js";
|
||||||
import {
|
import {
|
||||||
loadTechStepMappingRules,
|
loadTechStepMappingRules,
|
||||||
matchTechStepSpans,
|
matchTechStepSpans,
|
||||||
matchTechSteps,
|
matchTechSteps,
|
||||||
normalizeText,
|
normalizeText,
|
||||||
type TechStepMappingRule,
|
type TechStepMappingRule,
|
||||||
} from "../src/lib/recipe-matching/tech-step-matcher.js";
|
} from "../../src/lib/recipe-matching/tech-step-matcher.js";
|
||||||
import { resetDatabase } from "../test-support/reset-db.js";
|
import { resetDatabase } from "../../test-support/reset-db.js";
|
||||||
|
|
||||||
describe("tech-step-matcher", () => {
|
describe("tech-step-matcher", () => {
|
||||||
describe("normalizeText", () => {
|
describe("normalizeText", () => {
|
||||||
|
|
@ -2,8 +2,8 @@ import { expect } from "chai";
|
||||||
import {
|
import {
|
||||||
RecipeSourceFetchError,
|
RecipeSourceFetchError,
|
||||||
RecipeSourceParseError,
|
RecipeSourceParseError,
|
||||||
} from "../src/lib/recipe-sources/recipe-source-errors.js";
|
} from "../../src/lib/recipe-sources/recipe-source-errors.js";
|
||||||
import { jsonLdRecipeAdapter } from "../src/sources/json-ld-recipe.js";
|
import { jsonLdRecipeAdapter } from "../../src/sources/json-ld-recipe.js";
|
||||||
|
|
||||||
/** Stubs `globalThis.fetch` to return `html` as the response body — same reasoning/pattern as `the-meal-db.test.ts`'s `stubFetch`, just returning text instead of JSON. */
|
/** Stubs `globalThis.fetch` to return `html` as the response body — same reasoning/pattern as `the-meal-db.test.ts`'s `stubFetch`, just returning text instead of JSON. */
|
||||||
function stubFetchHtml(html: string, status = 200) {
|
function stubFetchHtml(html: string, status = 200) {
|
||||||
|
|
@ -2,15 +2,15 @@ import type { SignupInput } from "@batch-cooking/shared";
|
||||||
import { faker } from "@faker-js/faker";
|
import { faker } from "@faker-js/faker";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import request from "supertest";
|
import request from "supertest";
|
||||||
import { createApp } from "../src/app.js";
|
import { createApp } from "../../src/app.js";
|
||||||
import { prisma } from "../src/db/prisma.js";
|
import { prisma } from "../../src/db/prisma.js";
|
||||||
import { findImportedRecipeIds, syncRecipeSources } from "../src/db/recipe-source-sync.js";
|
import { findImportedRecipeIds, syncRecipeSources } from "../../src/db/recipe-source-sync.js";
|
||||||
import type { RecipeSourceAdapter } from "../src/lib/recipe-sources/recipe-source-adapter.js";
|
import type { RecipeSourceAdapter } from "../../src/lib/recipe-sources/recipe-source-adapter.js";
|
||||||
import {
|
import {
|
||||||
clearRecipeSources,
|
clearRecipeSources,
|
||||||
registerRecipeSource,
|
registerRecipeSource,
|
||||||
} from "../src/lib/recipe-sources/recipe-source-registry.js";
|
} from "../../src/lib/recipe-sources/recipe-source-registry.js";
|
||||||
import { resetDatabase } from "../test-support/reset-db.js";
|
import { resetDatabase } from "../../test-support/reset-db.js";
|
||||||
|
|
||||||
/** See `recipe.test.ts` — generated rather than hardcoded, no test fixture looks like a real person's data. */
|
/** See `recipe.test.ts` — generated rather than hardcoded, no test fixture looks like a real person's data. */
|
||||||
function buildSignupPayload(): SignupInput {
|
function buildSignupPayload(): SignupInput {
|
||||||
|
|
@ -5,19 +5,19 @@ import type {
|
||||||
RecipeSourceListItem,
|
RecipeSourceListItem,
|
||||||
RecipeSourceListParams,
|
RecipeSourceListParams,
|
||||||
RecipeSourceListResult,
|
RecipeSourceListResult,
|
||||||
} from "../src/lib/recipe-sources/recipe-source-adapter.js";
|
} from "../../src/lib/recipe-sources/recipe-source-adapter.js";
|
||||||
import { markAlreadyImported } from "../src/lib/recipe-sources/recipe-source-adapter.js";
|
import { markAlreadyImported } from "../../src/lib/recipe-sources/recipe-source-adapter.js";
|
||||||
import {
|
import {
|
||||||
RecipeSourceError,
|
RecipeSourceError,
|
||||||
RecipeSourceFetchError,
|
RecipeSourceFetchError,
|
||||||
RecipeSourceParseError,
|
RecipeSourceParseError,
|
||||||
} from "../src/lib/recipe-sources/recipe-source-errors.js";
|
} from "../../src/lib/recipe-sources/recipe-source-errors.js";
|
||||||
import {
|
import {
|
||||||
clearRecipeSources,
|
clearRecipeSources,
|
||||||
getRecipeSource,
|
getRecipeSource,
|
||||||
listRecipeSources,
|
listRecipeSources,
|
||||||
registerRecipeSource,
|
registerRecipeSource,
|
||||||
} from "../src/lib/recipe-sources/recipe-source-registry.js";
|
} from "../../src/lib/recipe-sources/recipe-source-registry.js";
|
||||||
|
|
||||||
interface FakeRawRecipe {
|
interface FakeRawRecipe {
|
||||||
externalId: string;
|
externalId: string;
|
||||||
|
|
@ -2,8 +2,8 @@ import { expect } from "chai";
|
||||||
import {
|
import {
|
||||||
RecipeSourceFetchError,
|
RecipeSourceFetchError,
|
||||||
RecipeSourceParseError,
|
RecipeSourceParseError,
|
||||||
} from "../src/lib/recipe-sources/recipe-source-errors.js";
|
} from "../../src/lib/recipe-sources/recipe-source-errors.js";
|
||||||
import { type TheMealDbMeal, theMealDbAdapter } from "../src/sources/the-meal-db.js";
|
import { type TheMealDbMeal, theMealDbAdapter } from "../../src/sources/the-meal-db.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stubs `globalThis.fetch` for one test — no HTTP-mocking library exists
|
* Stubs `globalThis.fetch` for one test — no HTTP-mocking library exists
|
||||||
|
|
@ -3,8 +3,8 @@ import {
|
||||||
clearRecipeSources,
|
clearRecipeSources,
|
||||||
getRecipeSource,
|
getRecipeSource,
|
||||||
listRecipeSources,
|
listRecipeSources,
|
||||||
} from "../src/lib/recipe-sources/recipe-source-registry.js";
|
} from "../../src/lib/recipe-sources/recipe-source-registry.js";
|
||||||
import { registerAllRecipeSources } from "../src/sources/index.js";
|
import { registerAllRecipeSources } from "../../src/sources/index.js";
|
||||||
|
|
||||||
// Not exercised by any other test file — `registerAllRecipeSources` is
|
// Not exercised by any other test file — `registerAllRecipeSources` is
|
||||||
// deliberately never imported by `app.ts` (see its own doc comment), so
|
// deliberately never imported by `app.ts` (see its own doc comment), so
|
||||||
|
|
@ -3,21 +3,21 @@ import { ErrorCode } from "@batch-cooking/shared";
|
||||||
import { faker } from "@faker-js/faker";
|
import { faker } from "@faker-js/faker";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import request from "supertest";
|
import request from "supertest";
|
||||||
import { createApp } from "../src/app.js";
|
import { createApp } from "../../src/app.js";
|
||||||
import { prisma } from "../src/db/prisma.js";
|
import { prisma } from "../../src/db/prisma.js";
|
||||||
import { syncRecipeSources } from "../src/db/recipe-source-sync.js";
|
import { syncRecipeSources } from "../../src/db/recipe-source-sync.js";
|
||||||
import type {
|
import type {
|
||||||
ParsedRecipe,
|
ParsedRecipe,
|
||||||
RecipeSourceAdapter,
|
RecipeSourceAdapter,
|
||||||
RecipeSourceListParams,
|
RecipeSourceListParams,
|
||||||
RecipeSourceListResult,
|
RecipeSourceListResult,
|
||||||
} from "../src/lib/recipe-sources/recipe-source-adapter.js";
|
} from "../../src/lib/recipe-sources/recipe-source-adapter.js";
|
||||||
import { RecipeSourceFetchError } from "../src/lib/recipe-sources/recipe-source-errors.js";
|
import { RecipeSourceFetchError } from "../../src/lib/recipe-sources/recipe-source-errors.js";
|
||||||
import {
|
import {
|
||||||
clearRecipeSources,
|
clearRecipeSources,
|
||||||
registerRecipeSource,
|
registerRecipeSource,
|
||||||
} from "../src/lib/recipe-sources/recipe-source-registry.js";
|
} from "../../src/lib/recipe-sources/recipe-source-registry.js";
|
||||||
import { resetDatabase } from "../test-support/reset-db.js";
|
import { resetDatabase } from "../../test-support/reset-db.js";
|
||||||
|
|
||||||
/** See `recipe.test.ts` — generated rather than hardcoded, no test fixture looks like a real person's data. */
|
/** See `recipe.test.ts` — generated rather than hardcoded, no test fixture looks like a real person's data. */
|
||||||
function buildSignupPayload(): SignupInput {
|
function buildSignupPayload(): SignupInput {
|
||||||
Loading…
Reference in a new issue