Skip to content

Commit

Permalink
feat: implement change title
Browse files Browse the repository at this point in the history
  • Loading branch information
collettemathieu committed Oct 1, 2024
1 parent 7a093ab commit 3e4a5ed
Show file tree
Hide file tree
Showing 104 changed files with 1,174 additions and 507 deletions.
2 changes: 1 addition & 1 deletion .hooks/commit-msg
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# #!/bin/sh
#!/bin/sh
echo "Checking with commitlint...."
bun run commitlint --edit $1
4 changes: 2 additions & 2 deletions apps/pathway-design/server/cucumber.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
default: {
paths: ['apps/pathway-design/server/src/test/**/*.feature'],
paths: ['apps/pathway-design/server/src/**/*.feature'],
requireModule: ['ts-node/register', 'tsconfig-paths/register'],
require: ['apps/pathway-design/server/src/test/**/*.step.ts'],
require: ['apps/pathway-design/server/src/**/*.step.ts'],
format: [
'json:dist/reports/apps/pathway-design/server/test-feature/index.json',
'html:dist/reports/apps/pathway-design/server/test-feature/index.html',
Expand Down
19 changes: 11 additions & 8 deletions apps/pathway-design/server/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { Module } from '@nestjs/common';

import { PDSPIInitializePathwayPersistenceInfrastructureModule } from '@bewoak/pathway-design-server-pathway-infrastructure';
import { PDSPIAInitializePathwayInterfaceAdaptersModule } from '@bewoak/pathway-design-server-pathway-interface-adapters';
import { PDSPIPPathwayPersistenceInfrastructureModule } from '@bewoak/pathway-design-server-pathway-infrastructure';
import {
PDSPIAChangeTitlePathwayInterfaceAdaptersModule,
PDSPIAInitializePathwayInterfaceAdaptersModule,
} from '@bewoak/pathway-design-server-pathway-interface-adapters';
import { PDSPPPathwayPresentersModule } from '@bewoak/pathway-design-server-pathway-presenters';
import { CqrsModule } from '@nestjs/cqrs';

@Module({
imports: [
PDSPIAInitializePathwayInterfaceAdaptersModule.withPersistence(
PDSPIInitializePathwayPersistenceInfrastructureModule.use(
'inMemory'
)
)
.withPresenter(PDSPPPathwayPresentersModule.use('toJson'))
PDSPIAChangeTitlePathwayInterfaceAdaptersModule.withPresenter(PDSPPPathwayPresentersModule.use('toJson'))
.withPersistence(PDSPIPPathwayPersistenceInfrastructureModule.use('inMemory'))
.build(),
PDSPIAInitializePathwayInterfaceAdaptersModule.withPresenter(PDSPPPathwayPresentersModule.use('toJson'))
.withPersistence(PDSPIPPathwayPersistenceInfrastructureModule.use('inMemory'))
.build(),
CqrsModule.forRoot(),
CqrsModule.forRoot(),
],
controllers: [],
Expand Down
11 changes: 3 additions & 8 deletions apps/pathway-design/server/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ async function bootstrap() {
// Setting up Swagger document
const options = new DocumentBuilder()
.setTitle('Pathway design Application')
.setDescription(
'Application Programming Interface (API) of Pathway design Application'
)
.setDescription('Application Programming Interface (API) of Pathway design Application')
.setVersion('1.0')
.addBearerAuth(
{
description:
'Please enter token in following format: Bearer <JWT>',
description: 'Please enter token in following format: Bearer <JWT>',
name: 'Authorization',
bearerFormat: 'Bearer',
scheme: 'Bearer',
Expand All @@ -40,9 +37,7 @@ async function bootstrap() {
SwaggerModule.setup('api', app, document);

await app.listen(port);
Logger.log(
`🚀 Application is running on: http://localhost:${port}/${globalPrefix}`
);
Logger.log(`🚀 Application is running on: http://localhost:${port}/${globalPrefix}`);
}

bootstrap();
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Feature: Change the title of a pathway in a memory database with json presenter

Scenario: I want to change the title of a learning pathway
Given I am authenticated on the platform for change the title of the pathway in memory persistence and json presenter
Given I have a pathway recorded in memory with these data
| title | description | researchField |
| My Pathway | A test pathway | biology |
When I want to change the title of the pathway in memory to "My New Pathway"
Then I should receive from memory the new title of the pathway
| title |
| My New Pathway |

Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { strict as assert } from 'node:assert';
import type { Http2Server } from 'node:http2';
import { PDSPIPPathwayPersistenceInfrastructureModule } from '@bewoak/pathway-design-server-pathway-infrastructure';
import {
PDSPIAChangeTitlePathwayInterfaceAdaptersModule,
PDSPIAInitializePathwayInterfaceAdaptersModule,
} from '@bewoak/pathway-design-server-pathway-interface-adapters';
import { PDSPPPathwayPresentersModule } from '@bewoak/pathway-design-server-pathway-presenters';
import type { DataTable } from '@cucumber/cucumber';
import type { INestApplication } from '@nestjs/common';
import { CqrsModule } from '@nestjs/cqrs';
import { Test } from '@nestjs/testing';
import { binding, given, then, when } from 'cucumber-tsflow';
import request from 'supertest';

@binding()
class ControllerSteps {
private app: INestApplication;
private httpServer: Http2Server;
private response: request.Response;

@given('I am authenticated on the platform for change the title of the pathway in memory persistence and json presenter')
public async withInMemoryPeristenceAndJsonPresenter() {
const testingModule = await Test.createTestingModule({
imports: [
PDSPIAChangeTitlePathwayInterfaceAdaptersModule.withPresenter(PDSPPPathwayPresentersModule.use('toJson'))
.withPersistence(PDSPIPPathwayPersistenceInfrastructureModule.use('inMemory'))
.build(),
PDSPIAInitializePathwayInterfaceAdaptersModule.withPresenter(PDSPPPathwayPresentersModule.use('toJson'))
.withPersistence(PDSPIPPathwayPersistenceInfrastructureModule.use('inMemory'))
.build(),
CqrsModule.forRoot(),
],
}).compile();

this.app = testingModule.createNestApplication();
await this.app.init();
this.httpServer = this.app.getHttpServer();
}

@given('I have a pathway recorded in memory with these data')
public async givenIHaveAPathwayRecordedInMemroy(dataTable: DataTable) {
const firstRow = dataTable.hashes()[0];

this.response = await request(this.httpServer).post('/pathway/init').send({
title: firstRow.title,
description: firstRow.description,
researchField: firstRow.researchField,
});
}

@when('I want to change the title of the pathway in memory to {string}')
public async whenIChangeTheTitleOfThePathwayTo(title: string) {
this.response = await request(this.httpServer).patch(`/pathway/change-title/${this.response.body.id}`).send({
title,
});
}

@then('I should receive from memory the new title of the pathway')
public async thenIShouldReceiveTheNewTitleOfThePathway(dataTable: DataTable) {
const firstRow = dataTable.hashes()[0];

assert.strictEqual(this.response.body.title, firstRow.title);
}
}

export = ControllerSteps;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: Initialize Pathway in a memory database
Feature: Initialize Pathway in a memory database with json presenter

Scenario: I want to initialize a learning pathway
Given I am authenticated on the platform
Given I am authenticated on the platform for initialize a pathway in memory persistence and json presenter
When I want to initialize a pathway with these data
| title | description | researchField |
| My Pathway | A test pathway | biology |
Expand All @@ -10,13 +10,4 @@ Feature: Initialize Pathway in a memory database
| My Pathway | A test pathway | biology |
Then The pathway should be have a unique identifier

Scenario: I want to initialize another learning pathway with different data
Given I am authenticated on the platform
When I want to initialize a pathway with these data
| title | description | researchField |
| Arterial stiffness | Understand the role of the arterial stiffness | biomedical |
Then I should retrieve a pathway initialized with its data
| title | description | researchField |
| Arterial stiffness | Understand the role of the arterial stiffness | biomedical |
Then The pathway should be have a unique identifier

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { strict as assert } from 'node:assert';
import type { Http2Server } from 'node:http2';
import { PDSPIInitializePathwayPersistenceInfrastructureModule } from '@bewoak/pathway-design-server-pathway-infrastructure';
import { PDSPIPPathwayPersistenceInfrastructureModule } from '@bewoak/pathway-design-server-pathway-infrastructure';
import { PDSPIAInitializePathwayInterfaceAdaptersModule } from '@bewoak/pathway-design-server-pathway-interface-adapters';
import { PDSPPPathwayPresentersModule } from '@bewoak/pathway-design-server-pathway-presenters';
import type { DataTable } from '@cucumber/cucumber';
Expand All @@ -13,25 +13,22 @@ import request from 'supertest';
@binding()
class ControllerSteps {
private app: INestApplication;
private response: request.Response;
private httpServer: Http2Server;
private response: request.Response;

@given('I am authenticated on the platform')
public async givenAmIAuthenticatedOnThePlatform() {
const module = await Test.createTestingModule({
@given('I am authenticated on the platform for initialize a pathway in memory persistence and json presenter')
public async withInMemoryPeristenceAndJsonPresenter() {
const testingModule = await Test.createTestingModule({
imports: [
PDSPIAInitializePathwayInterfaceAdaptersModule.withPersistence(
PDSPIInitializePathwayPersistenceInfrastructureModule.use(
'inMemory'
)
)
.withPresenter(PDSPPPathwayPresentersModule.use('toJson'))
PDSPIAInitializePathwayInterfaceAdaptersModule.withPresenter(PDSPPPathwayPresentersModule.use('toJson'))
.withPersistence(PDSPIPPathwayPersistenceInfrastructureModule.use('inMemory'))
.build(),
CqrsModule.forRoot(),
],
exports: [],
}).compile();

this.app = module.createNestApplication();
this.app = testingModule.createNestApplication();
await this.app.init();
this.httpServer = this.app.getHttpServer();
}
Expand All @@ -40,28 +37,20 @@ class ControllerSteps {
public async whenIInitiateAPathway(dataTable: DataTable) {
const firstRow = dataTable.hashes()[0];

this.response = await request(this.httpServer)
.post('/pathway/init')
.send({
title: firstRow.title,
description: firstRow.description,
researchField: firstRow.researchField,
});
this.response = await request(this.httpServer).post('/pathway/init').send({
title: firstRow.title,
description: firstRow.description,
researchField: firstRow.researchField,
});
}

@then('I should retrieve a pathway initialized with its data')
public thenIShouldRetrieveAPathwayInitiated(dataTable: DataTable) {
const firstRow = dataTable.hashes()[0];

assert.strictEqual(this.response.body.title, firstRow.title);
assert.strictEqual(
this.response.body.description,
firstRow.description
);
assert.strictEqual(
this.response.body.researchField,
firstRow.researchField
);
assert.strictEqual(this.response.body.description, firstRow.description);
assert.strictEqual(this.response.body.researchField, firstRow.researchField);
}

@then('The pathway should be have a unique identifier')
Expand Down
3 changes: 1 addition & 2 deletions apps/pathway-design/server/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ module.exports = {
tsConfig: './tsconfig.app.json',
assets: ['./src/assets'],
optimization: process.env.BUN_ENV === 'production',
outputHashing:
process.env.BUN_ENV === 'production' ? 'all' : 'none',
outputHashing: process.env.BUN_ENV === 'production' ? 'all' : 'none',
transformers: [{ name: '@nestjs/swagger/plugin' }],
}),
],
Expand Down
22 changes: 3 additions & 19 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,15 @@
"attributePosition": "auto",
"enabled": true,
"formatWithErrors": false,
"ignore": [
"dist",
"coverage",
".nx",
".vscode",
"node_modules",
"tmp",
".angular"
],
"ignore": ["dist", "coverage", ".nx", ".vscode", "node_modules", "tmp", ".angular"],
"indentStyle": "space",
"indentWidth": 4,
"lineEnding": "lf",
"lineWidth": 80
"lineWidth": 130
},
"linter": {
"enabled": true,
"ignore": [
"dist",
"coverage",
".nx",
".vscode",
"node_modules",
"tmp",
".angular"
],
"ignore": ["dist", "coverage", ".nx", ".vscode", "node_modules", "tmp", ".angular"],
"rules": {
"recommended": true,
"suspicious": {
Expand Down
Binary file modified bun.lockb
Binary file not shown.
22 changes: 22 additions & 0 deletions libs/common/events/.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/events/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": [{}]
}
11 changes: 11 additions & 0 deletions libs/common/events/cucumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
default: {
paths: ['libs/common/events/src/lib/**/*.feature'],
requireModule: ['ts-node/register', 'tsconfig-paths/register'],
require: ['libs/common/events/src/lib/**/*.step.ts'],
format: [
'json:dist/reports/libs/common/events/test-feature/index.json',
'html:dist/reports/libs/common/events/test-feature/index.html',
],
},
};
9 changes: 9 additions & 0 deletions libs/common/events/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@bewoak/common-events",
"version": "0.0.1",
"dependencies": {
"@swc/helpers": "~0.5.11"
},
"main": "./src/index.js",
"typings": "./src/index.d.ts"
}
Loading

0 comments on commit 3e4a5ed

Please sign in to comment.