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 { expect } from "chai";
|
||||
import { prisma } from "../src/db/prisma.js";
|
||||
import { prisma } from "../../src/db/prisma.js";
|
||||
import {
|
||||
extractQuantity,
|
||||
type IngredientMatchEntry,
|
||||
|
|
@ -9,8 +9,8 @@ import {
|
|||
matchIngredientName,
|
||||
matchUnit,
|
||||
type UnitMatchEntry,
|
||||
} from "../src/lib/recipe-matching/ingredient-matcher.js";
|
||||
import { resetDatabase } from "../test-support/reset-db.js";
|
||||
} from "../../src/lib/recipe-matching/ingredient-matcher.js";
|
||||
import { resetDatabase } from "../../test-support/reset-db.js";
|
||||
|
||||
describe("ingredient-matcher", () => {
|
||||
describe("matchIngredientName", () => {
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
import { expect } from "chai";
|
||||
import { prisma } from "../src/db/prisma.js";
|
||||
import { prisma } from "../../src/db/prisma.js";
|
||||
import type {
|
||||
IngredientMatchEntry,
|
||||
UnitMatchEntry,
|
||||
} from "../src/lib/recipe-matching/ingredient-matcher.js";
|
||||
} from "../../src/lib/recipe-matching/ingredient-matcher.js";
|
||||
import {
|
||||
mergeDuplicateIngredients,
|
||||
type TranslatedRecipeIngredient,
|
||||
|
|
@ -11,13 +11,13 @@ import {
|
|||
translateRecipeIngredients,
|
||||
translateRecipeSteps,
|
||||
type UnitConversionEntry,
|
||||
} from "../src/lib/recipe-matching/recipe-translation.js";
|
||||
import type { TechStepMappingRule } from "../src/lib/recipe-matching/tech-step-matcher.js";
|
||||
} from "../../src/lib/recipe-matching/recipe-translation.js";
|
||||
import type { TechStepMappingRule } from "../../src/lib/recipe-matching/tech-step-matcher.js";
|
||||
import type {
|
||||
ParsedRecipe,
|
||||
ParsedRecipeIngredient,
|
||||
} from "../src/lib/recipe-sources/recipe-source-adapter.js";
|
||||
import { resetDatabase } from "../test-support/reset-db.js";
|
||||
} from "../../src/lib/recipe-sources/recipe-source-adapter.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. */
|
||||
function buildParsedRecipe(descriptions: string[]): ParsedRecipe {
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
import { expect } from "chai";
|
||||
import { prisma } from "../src/db/prisma.js";
|
||||
import { prisma } from "../../src/db/prisma.js";
|
||||
import {
|
||||
loadTechStepMappingRules,
|
||||
matchTechStepSpans,
|
||||
matchTechSteps,
|
||||
normalizeText,
|
||||
type TechStepMappingRule,
|
||||
} from "../src/lib/recipe-matching/tech-step-matcher.js";
|
||||
import { resetDatabase } from "../test-support/reset-db.js";
|
||||
} from "../../src/lib/recipe-matching/tech-step-matcher.js";
|
||||
import { resetDatabase } from "../../test-support/reset-db.js";
|
||||
|
||||
describe("tech-step-matcher", () => {
|
||||
describe("normalizeText", () => {
|
||||
|
|
@ -2,8 +2,8 @@ import { expect } from "chai";
|
|||
import {
|
||||
RecipeSourceFetchError,
|
||||
RecipeSourceParseError,
|
||||
} from "../src/lib/recipe-sources/recipe-source-errors.js";
|
||||
import { jsonLdRecipeAdapter } from "../src/sources/json-ld-recipe.js";
|
||||
} from "../../src/lib/recipe-sources/recipe-source-errors.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. */
|
||||
function stubFetchHtml(html: string, status = 200) {
|
||||
|
|
@ -2,15 +2,15 @@ import type { SignupInput } from "@batch-cooking/shared";
|
|||
import { faker } from "@faker-js/faker";
|
||||
import { expect } from "chai";
|
||||
import request from "supertest";
|
||||
import { createApp } from "../src/app.js";
|
||||
import { prisma } from "../src/db/prisma.js";
|
||||
import { findImportedRecipeIds, syncRecipeSources } from "../src/db/recipe-source-sync.js";
|
||||
import type { RecipeSourceAdapter } from "../src/lib/recipe-sources/recipe-source-adapter.js";
|
||||
import { createApp } from "../../src/app.js";
|
||||
import { prisma } from "../../src/db/prisma.js";
|
||||
import { findImportedRecipeIds, syncRecipeSources } from "../../src/db/recipe-source-sync.js";
|
||||
import type { RecipeSourceAdapter } from "../../src/lib/recipe-sources/recipe-source-adapter.js";
|
||||
import {
|
||||
clearRecipeSources,
|
||||
registerRecipeSource,
|
||||
} from "../src/lib/recipe-sources/recipe-source-registry.js";
|
||||
import { resetDatabase } from "../test-support/reset-db.js";
|
||||
} from "../../src/lib/recipe-sources/recipe-source-registry.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. */
|
||||
function buildSignupPayload(): SignupInput {
|
||||
|
|
@ -5,19 +5,19 @@ import type {
|
|||
RecipeSourceListItem,
|
||||
RecipeSourceListParams,
|
||||
RecipeSourceListResult,
|
||||
} from "../src/lib/recipe-sources/recipe-source-adapter.js";
|
||||
import { markAlreadyImported } 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 {
|
||||
RecipeSourceError,
|
||||
RecipeSourceFetchError,
|
||||
RecipeSourceParseError,
|
||||
} from "../src/lib/recipe-sources/recipe-source-errors.js";
|
||||
} from "../../src/lib/recipe-sources/recipe-source-errors.js";
|
||||
import {
|
||||
clearRecipeSources,
|
||||
getRecipeSource,
|
||||
listRecipeSources,
|
||||
registerRecipeSource,
|
||||
} from "../src/lib/recipe-sources/recipe-source-registry.js";
|
||||
} from "../../src/lib/recipe-sources/recipe-source-registry.js";
|
||||
|
||||
interface FakeRawRecipe {
|
||||
externalId: string;
|
||||
|
|
@ -2,8 +2,8 @@ import { expect } from "chai";
|
|||
import {
|
||||
RecipeSourceFetchError,
|
||||
RecipeSourceParseError,
|
||||
} from "../src/lib/recipe-sources/recipe-source-errors.js";
|
||||
import { type TheMealDbMeal, theMealDbAdapter } from "../src/sources/the-meal-db.js";
|
||||
} from "../../src/lib/recipe-sources/recipe-source-errors.js";
|
||||
import { type TheMealDbMeal, theMealDbAdapter } from "../../src/sources/the-meal-db.js";
|
||||
|
||||
/**
|
||||
* Stubs `globalThis.fetch` for one test — no HTTP-mocking library exists
|
||||
|
|
@ -3,8 +3,8 @@ import {
|
|||
clearRecipeSources,
|
||||
getRecipeSource,
|
||||
listRecipeSources,
|
||||
} from "../src/lib/recipe-sources/recipe-source-registry.js";
|
||||
import { registerAllRecipeSources } from "../src/sources/index.js";
|
||||
} from "../../src/lib/recipe-sources/recipe-source-registry.js";
|
||||
import { registerAllRecipeSources } from "../../src/sources/index.js";
|
||||
|
||||
// Not exercised by any other test file — `registerAllRecipeSources` is
|
||||
// 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 { expect } from "chai";
|
||||
import request from "supertest";
|
||||
import { createApp } from "../src/app.js";
|
||||
import { prisma } from "../src/db/prisma.js";
|
||||
import { syncRecipeSources } from "../src/db/recipe-source-sync.js";
|
||||
import { createApp } from "../../src/app.js";
|
||||
import { prisma } from "../../src/db/prisma.js";
|
||||
import { syncRecipeSources } from "../../src/db/recipe-source-sync.js";
|
||||
import type {
|
||||
ParsedRecipe,
|
||||
RecipeSourceAdapter,
|
||||
RecipeSourceListParams,
|
||||
RecipeSourceListResult,
|
||||
} from "../src/lib/recipe-sources/recipe-source-adapter.js";
|
||||
import { RecipeSourceFetchError } from "../src/lib/recipe-sources/recipe-source-errors.js";
|
||||
} from "../../src/lib/recipe-sources/recipe-source-adapter.js";
|
||||
import { RecipeSourceFetchError } from "../../src/lib/recipe-sources/recipe-source-errors.js";
|
||||
import {
|
||||
clearRecipeSources,
|
||||
registerRecipeSource,
|
||||
} from "../src/lib/recipe-sources/recipe-source-registry.js";
|
||||
import { resetDatabase } from "../test-support/reset-db.js";
|
||||
} from "../../src/lib/recipe-sources/recipe-source-registry.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. */
|
||||
function buildSignupPayload(): SignupInput {
|
||||
Loading…
Reference in a new issue