Skip to content

Commit

Permalink
refactor: specs
Browse files Browse the repository at this point in the history
  • Loading branch information
collettemathieu committed Sep 13, 2024
1 parent ae413f2 commit 05cb5b1
Show file tree
Hide file tree
Showing 44 changed files with 770 additions and 122 deletions.
52 changes: 52 additions & 0 deletions .detective/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"scopes": [
"libs/pathway-design/server/pathway/business/src/lib/entities",
"libs/pathway-design/server/pathway/business/src/lib/events",
"libs/pathway-design/server/pathway/business/src/lib/factories",
"libs/pathway-design/server/pathway/business/src/lib/ports",
"libs/pathway-design/server/pathway/business/src/lib/value-objects",
"libs/pathway-design/server/pathway/infrastructure/src/lib/persistence/common",
"libs/pathway-design/server/pathway/infrastructure/src/lib/persistence/initialize/in-memory",
"libs/pathway-design/server/pathway/interface-adapters/src/lib/initialize/controller",
"libs/pathway-design/server/pathway/interface-adapters/src/lib/initialize/dtos",
"libs/pathway-design/server/pathway/presenters/src/lib/toJson",
"apps/pathway-design/server/src/app",
"libs/pathway-design/server/pathway/application/src/lib/initialize/command",
"libs/pathway-design/server/pathway/application/src/lib/initialize/usecase",
"libs/pathway-design/server/pathway/application/src/lib/initialize/service"
],
"groups": [
"apps/pathway-design/server/src",
"apps/pathway-design/server",
"apps/pathway-design",
"apps",
"libs/pathway-design/server/pathway/application/src/lib/initialize",
"libs/pathway-design/server/pathway/application/src/lib",
"libs/pathway-design/server/pathway/application/src",
"libs/pathway-design/server/pathway/application",
"libs/pathway-design/server/pathway/business/src/lib",
"libs/pathway-design/server/pathway/business/src",
"libs/pathway-design/server/pathway/business",
"libs/pathway-design/server/pathway/infrastructure/src/lib/persistence/initialize",
"libs/pathway-design/server/pathway/infrastructure/src/lib/persistence",
"libs/pathway-design/server/pathway/infrastructure/src/lib",
"libs/pathway-design/server/pathway/infrastructure/src",
"libs/pathway-design/server/pathway/infrastructure",
"libs/pathway-design/server/pathway/interface-adapters/src/lib/initialize",
"libs/pathway-design/server/pathway/interface-adapters/src/lib",
"libs/pathway-design/server/pathway/interface-adapters/src",
"libs/pathway-design/server/pathway/interface-adapters",
"libs/pathway-design/server/pathway/presenters/src/lib",
"libs/pathway-design/server/pathway/presenters/src",
"libs/pathway-design/server/pathway/presenters",
"libs/pathway-design/server/pathway",
"libs/pathway-design/server",
"libs/pathway-design",
"libs"
],
"entries": [],
"teams": {
"example-team-a": ["John Doe", "Jane Doe"],
"example-team-b": ["Max Muster", "Susi Sorglos"]
}
}
1 change: 1 addition & 0 deletions .detective/hash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3601514f0819bed357d1b14c042a0d872079a336
483 changes: 483 additions & 0 deletions .detective/log

Large diffs are not rendered by default.

Binary file modified bun.lockb
Binary file not shown.
22 changes: 22 additions & 0 deletions libs/common/tools/server/http-exceptions/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"jsc": {
"target": "es2022",
"parser": {
"syntax": "typescript",
"decorators": true,
"dynamicImport": true
},
"transform": {
"decoratorMetadata": true,
"legacyDecorator": true
},
"keepClassNames": true,
"externalHelpers": true,
"loose": true
},
"module": {
"type": "es6"
},
"sourceMaps": true,
"exclude": [".*\\.spec.tsx?$", ".*\\.step.ts$", ".*\\.test.tsx?$", ".*.js$"]
}
17 changes: 17 additions & 0 deletions libs/common/tools/server/http-exceptions/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "../../../../../node_modules/@biomejs/biome/configuration_schema.json",
"extends": ["../../../../../biome.json"],
"linter": {
"rules": {
"nursery": {
"noRestrictedImports": {
"options": {
"paths": {}
},
"level": "error"
}
}
}
},
"overrides": [{}]
}
15 changes: 15 additions & 0 deletions libs/common/tools/server/http-exceptions/cucumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
default: {
paths: [
'libs/common/tools/server/http-exceptions/src/lib/**/*.feature',
],
requireModule: ['ts-node/register', 'tsconfig-paths/register'],
require: [
'libs/common/tools/server/http-exceptions/src/lib/**/*.step.ts',
],
format: [
'json:dist/reports/libs/common/tools/server/http-exceptions/test-feature/index.json',
'html:dist/reports/libs/common/tools/server/http-exceptions/test-feature/index.html',
],
},
};
9 changes: 9 additions & 0 deletions libs/common/tools/server/http-exceptions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@bewoak/common-tools-server-http-exceptions",
"version": "0.0.1",
"dependencies": {
"@swc/helpers": "~0.5.11"
},
"main": "./src/index.js",
"typings": "./src/index.d.ts"
}
50 changes: 50 additions & 0 deletions libs/common/tools/server/http-exceptions/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "common-tools-server-http-exceptions",
"$schema": "../../../../../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/common/tools/server/http-exceptions/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:swc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/common/tools/server/http-exceptions",
"main": "libs/common/tools/server/http-exceptions/src/index.ts",
"tsConfig": "libs/common/tools/server/http-exceptions/tsconfig.lib.json",
"assets": []
}
},
"nx-release-publish": {
"options": {
"packageRoot": "dist/{projectRoot}"
}
},
"lint": {
"executor": "nx:run-commands",
"options": {
"command": "bun run biome check --write {projectRoot} --config-path={projectRoot}/biome.json"
}
},
"test": {
"executor": "nx:run-commands",
"options": {
"command": "bun test --coverage --coverage-dir=dist/reports/{projectRoot}/coverage --coverage-reporter=lcov {projectRoot}"
}
},
"test-feature": {
"executor": "nx:run-commands",
"options": {
"command": "TS_NODE_PROJECT='{projectRoot}/tsconfig.spec.json' bun run cucumber-js --config={projectRoot}/cucumber.js"
}
}
},
"tags": ["type:common:tools:server:http-exceptions"],
"release": {
"version": {
"generatorOptions": {
"packageRoot": "dist/{projectRoot}",
"currentVersionResolver": "git-tag"
}
}
}
}
1 change: 1 addition & 0 deletions libs/common/tools/server/http-exceptions/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { CTSEBadRequestException } from './lib/exceptions';
13 changes: 13 additions & 0 deletions libs/common/tools/server/http-exceptions/src/lib/exceptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { HttpStatus } from './types';

export class CTSEBadRequestException extends Error {
public readonly statusCode: number;

constructor(message: string) {
super(message);
this.name = 'BadRequestException';
this.statusCode = HttpStatus.BAD_REQUEST;
this.message = message;
Error.captureStackTrace(this, this.constructor);
}
}
Original file line number Diff line number Diff line change
@@ -1,62 +1,50 @@
export class BadRequestException extends Error {
public readonly statusCode: number;

constructor(message: string) {
super(message);
this.name = 'BadRequestException';
this.statusCode = HttpStatus.BAD_REQUEST;
this.message = message;
Error.captureStackTrace(this, this.constructor);
}
}

export enum HttpStatus {
CONTINUE = 100,
SWITCHING_PROTOCOLS = 101,
PROCESSING = 102,
EARLYHINTS = 103,
OK = 200,
CREATED = 201,
ACCEPTED = 202,
NON_AUTHORITATIVE_INFORMATION = 203,
NO_CONTENT = 204,
RESET_CONTENT = 205,
PARTIAL_CONTENT = 206,
AMBIGUOUS = 300,
MOVED_PERMANENTLY = 301,
FOUND = 302,
SEE_OTHER = 303,
NOT_MODIFIED = 304,
TEMPORARY_REDIRECT = 307,
PERMANENT_REDIRECT = 308,
BAD_GATEWAY = 502,
BAD_REQUEST = 400,
UNAUTHORIZED = 401,
PAYMENT_REQUIRED = 402,
FORBIDDEN = 403,
NOT_FOUND = 404,
METHOD_NOT_ALLOWED = 405,
NOT_ACCEPTABLE = 406,
PROXY_AUTHENTICATION_REQUIRED = 407,
REQUEST_TIMEOUT = 408,
CONFLICT = 409,
GONE = 410,
LENGTH_REQUIRED = 411,
PRECONDITION_FAILED = 412,
PAYLOAD_TOO_LARGE = 413,
URI_TOO_LONG = 414,
UNSUPPORTED_MEDIA_TYPE = 415,
REQUESTED_RANGE_NOT_SATISFIABLE = 416,
CONTINUE = 100,
CREATED = 201,
EARLYHINTS = 103,
EXPECTATION_FAILED = 417,
I_AM_A_TEAPOT = 418,
MISDIRECTED = 421,
UNPROCESSABLE_ENTITY = 422,
FAILED_DEPENDENCY = 424,
PRECONDITION_REQUIRED = 428,
TOO_MANY_REQUESTS = 429,
FORBIDDEN = 403,
FOUND = 302,
GATEWAY_TIMEOUT = 504,
GONE = 410,
HTTP_VERSION_NOT_SUPPORTED = 505,
INTERNAL_SERVER_ERROR = 500,
I_AM_A_TEAPOT = 418,
LENGTH_REQUIRED = 411,
METHOD_NOT_ALLOWED = 405,
MISDIRECTED = 421,
MOVED_PERMANENTLY = 301,
NON_AUTHORITATIVE_INFORMATION = 203,
NOT_ACCEPTABLE = 406,
NOT_FOUND = 404,
NOT_IMPLEMENTED = 501,
BAD_GATEWAY = 502,
NOT_MODIFIED = 304,
NO_CONTENT = 204,
OK = 200,
PARTIAL_CONTENT = 206,
PAYLOAD_TOO_LARGE = 413,
PAYMENT_REQUIRED = 402,
PERMANENT_REDIRECT = 308,
PRECONDITION_FAILED = 412,
PRECONDITION_REQUIRED = 428,
PROCESSING = 102,
PROXY_AUTHENTICATION_REQUIRED = 407,
REQUESTED_RANGE_NOT_SATISFIABLE = 416,
REQUEST_TIMEOUT = 408,
RESET_CONTENT = 205,
SEE_OTHER = 303,
SERVICE_UNAVAILABLE = 503,
GATEWAY_TIMEOUT = 504,
HTTP_VERSION_NOT_SUPPORTED = 505,
SWITCHING_PROTOCOLS = 101,
TEMPORARY_REDIRECT = 307,
TOO_MANY_REQUESTS = 429,
UNAUTHORIZED = 401,
UNPROCESSABLE_ENTITY = 422,
UNSUPPORTED_MEDIA_TYPE = 415,
URI_TOO_LONG = 414,
}
14 changes: 14 additions & 0 deletions libs/common/tools/server/http-exceptions/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "../../../../../tsconfig.base.json",
"compilerOptions": {
"module": "es2022",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": []
}
9 changes: 9 additions & 0 deletions libs/common/tools/server/http-exceptions/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../../../dist/out-tsc",
"types": ["node"]
},
"include": ["src/**/*.ts"],
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.step.ts"]
}
8 changes: 8 additions & 0 deletions libs/common/tools/server/http-exceptions/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"esModuleInterop": true
},
"include": ["src/**/*.ts"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}
}
},
"tags": ["type:business:pathway-design:server"],
"tags": ["type:pathway-design:server:pathway:application"],
"release": {
"version": {
"generatorOptions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '@bewoak/pathway-design-server-pathway-business';
import type { DataTable } from '@cucumber/cucumber';
import { binding, given, then, when } from 'cucumber-tsflow';
import { PDSPBUChangeTitlePathwayUseCase } from './change-title-pathway.usecase';
import { PDSPBUChangeTitlePathwayUseCase } from '../usecase/change-title-pathway.usecase';

@binding()
export default class ControllerSteps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { strict as assert } from 'node:assert';
import type {
PDSPBEPathwayEntity,
PDSPBPInitializePathwayPersistencePort,
Expand All @@ -8,8 +7,9 @@ import type {
import type { DataTable } from '@cucumber/cucumber';
import type { EventPublisher } from '@nestjs/cqrs';
import { before, binding, then, when } from 'cucumber-tsflow';
import { strict as assert } from 'node:assert';
import sinon from 'sinon';
import { PDSPAIUInitializePathwayUsecase } from './initialize-pathway.usecase';
import { PDSPAIUInitializePathwayUsecase } from '../usecase/initialize-pathway.usecase';

class FakeInitializePathwayPersistence
implements PDSPBPInitializePathwayPersistencePort
Expand Down
10 changes: 1 addition & 9 deletions libs/pathway-design/server/pathway/application/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,5 @@
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
"include": []
}
2 changes: 1 addition & 1 deletion libs/pathway-design/server/pathway/business/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}
}
},
"tags": ["type:business:pathway-design:server"],
"tags": ["type:pathway-design:server:pathway:business"],
"release": {
"version": {
"generatorOptions": {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Feature: Manage Pathway Entity
Feature: Initialize a pathway

Scenario: I want to initialize a pathway with valid data
When I initialize a pathway with these data
Expand Down
Loading

0 comments on commit 05cb5b1

Please sign in to comment.