Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 1 addition & 2 deletions .docker/init.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
SELECT 'CREATE DATABASE involvemint'
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'involvemint')\gexec

SELECT 'CREATE DATABASE involvemint-e2e'
SELECT 'CREATE DATABASE "involvemint-e2e"'
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'involvemint-e2e')\gexec

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,6 @@ gcp-service-key-prod.json
gcp-api-key-prod.json

reports/*
!reports/readme.md
!reports/readme.md

firebase-debug.log
20 changes: 14 additions & 6 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@
}
]
},
"local": {
"fileReplacements":[
{
"replace": "libs/shared/domain/src/lib/environments/environment.ts",
"with": "libs/shared/domain/src/lib/environments/environment.local.ts"
}
]
},
"local": {
"fileReplacements":[
{
Expand Down Expand Up @@ -814,22 +822,22 @@
}
}
},
"server-orcha": {
"root": "libs/server/orcha",
"sourceRoot": "libs/server/orcha/src",
"server-api": {
"root": "libs/server/api",
"sourceRoot": "libs/server/api/src",
"projectType": "library",
"architect": {
"lint": {
"builder": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": ["libs/server/orcha/**/*.ts"]
"lintFilePatterns": ["libs/server/api/**/*.ts"]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"outputs": ["coverage/libs/server/orcha"],
"outputs": ["coverage/libs/server/api"],
"options": {
"jestConfig": "libs/server/orcha/jest.config.js",
"jestConfig": "libs/server/api/jest.config.js",
"passWithNoTests": true
}
}
Expand Down
6 changes: 3 additions & 3 deletions apps/api-e2e/src/core/app-test.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ServerOrchaModule } from '@involvemint/server/orcha';
import { ServerAPIModule } from '@involvemint/server/api';
import { Module } from '@nestjs/common';
import { ScheduleModule } from '@nestjs/schedule';
import { TypeOrmModule } from '@nestjs/typeorm';
Expand All @@ -14,7 +14,7 @@ patchTypeORMRepositoryWithBaseRepository();

@Module({
imports: [
ServerOrchaModule,
ServerAPIModule,
TypeOrmModule.forRoot({
type: 'postgres',
host: '127.0.0.1',
Expand All @@ -29,4 +29,4 @@ patchTypeORMRepositoryWithBaseRepository();
ScheduleModule.forRoot(),
],
})
export class AppTestModule {}
export class AppTestModule {}
116 changes: 82 additions & 34 deletions apps/api-e2e/src/specs/change-maker/change-maker-e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@

import { ChangeMakerRepository } from '@involvemint/server/core/domain-services';
import { ChangeMaker, IChangeMakerOrchestration, IUserOrchestration, User } from '@involvemint/shared/domain';
import { ChangeMaker, DTO_KEY, EditCmProfileDto, QUERY_KEY, TOKEN_KEY, User } from '@involvemint/shared/domain';
import { HttpStatus } from '@nestjs/common';
import { NestFastifyApplication } from '@nestjs/platform-fastify';
import { Test } from '@nestjs/testing';
import { createQuery, IParser } from '@orcha/common';
import { ITestOrchestration } from '@orcha/testing';
import supertest from 'supertest';
import { INestApplication } from '@nestjs/common';
import { createQuery, IParser } from '@involvemint/shared/domain';
import { AppTestModule } from '../../core/app-test.module';
import { DatabaseService } from '../../core/database.service';
import { createUserOrchestration } from '../user/user.orchestration';
import { createChangeMakerOrchestration } from './change-maker.orchestration';

describe('ChangeMaker Orchestration Integration Tests', () => {
let app: NestFastifyApplication;
describe('ChangeMaker Integration Tests', () => {
let app: INestApplication;
let db: DatabaseService;

let userOrcha: ITestOrchestration<IUserOrchestration>;
let cmOrcha: ITestOrchestration<IChangeMakerOrchestration>;

let cmRepo: ChangeMakerRepository;

const creds = { id: 'email@email.com', password: 'GoodPwd@341' };
let auth: { body: { token: string }; statusCode: HttpStatus };
let token: string;

const cmQuery = createQuery<ChangeMaker>()({ id: true, firstName: true, handle: { id: true } });
let cmProfile: IParser<ChangeMaker, typeof cmQuery>;
Expand All @@ -36,53 +32,105 @@ describe('ChangeMaker Orchestration Integration Tests', () => {
app = moduleRef.createNestApplication();
db = moduleRef.get(DatabaseService);

userOrcha = createUserOrchestration(app);
cmOrcha = createChangeMakerOrchestration(app);

cmRepo = moduleRef.get(ChangeMakerRepository);

await app.init();
});

beforeEach(async () => {
await db.clearDb();
auth = await userOrcha.signUp({ token: true }, '', creds);
const { body, statusCode } = await cmOrcha.createProfile(cmQuery, auth.body.token, {
handle: 'bobby',
firstName: 'fn',
lastName: 'ln',
phone: '(555) 555-5555',
const signUpResult = await supertest(app.getHttpServer())
.post('/user/signUp')
.send({
[QUERY_KEY]: { [TOKEN_KEY]: true },
[DTO_KEY]: creds,
});
token = signUpResult.body[TOKEN_KEY];
const profileCreationResult = await supertest(app.getHttpServer())
.post('/changeMaker/createProfile')
.set('token', token)
.set('Content-Type', 'application/json')
.set('Accept', 'application/json')
.send({
[QUERY_KEY]: cmQuery,
[DTO_KEY]: {
handle: 'bobby',
firstName: 'fn',
lastName: 'ln',
phone: '(555) 555-5555',
}
});
cmProfile = body;
expect(statusCode).toBe(HttpStatus.CREATED);

cmProfile = profileCreationResult.body as IParser<ChangeMaker, typeof cmQuery>;
expect(profileCreationResult.statusCode).toBe(HttpStatus.CREATED);
});

afterAll(async () => await app.close());

describe('createProfile', () => {
it('should create profile', async () => {
const res = await userOrcha.getUserData(userQuery, auth.body.token);
const getUserData = await supertest(app.getHttpServer())
.post('/user/getUserData')
.set(TOKEN_KEY, token)
.send({
[QUERY_KEY]: userQuery
});

const cmEntity = await cmRepo.findOneOrFail(cmProfile.id, cmQuery);
expect(res.body.changeMaker).toMatchObject(cmEntity);
expect(getUserData.body.changeMaker).toMatchObject(cmEntity);

});

it('should verify handle uniqueness', async () => {
const { error } = await cmOrcha.createProfile(cmQuery, auth.body.token, {
firstName: 'Bobby',
lastName: 'Smith',
handle: 'bobby',
phone: '(412) 232-2953',

const profileCreationResult = await supertest(app.getHttpServer())
.post('/changeMaker/createProfile')
.set('token', token)
.set('Content-Type', 'application/json')
.set('Accept', 'application/json')
.send({
[QUERY_KEY]: cmQuery,
[DTO_KEY]: {
firstName: 'Bobby',
lastName: 'Smith',
handle: 'bobby',
phone: '(412) 232-2953',
}
});
expect(error).toBe(`Handle @bobby already exists.`);

if(profileCreationResult.error !== false)
{
expect(JSON.parse(profileCreationResult.error.text).message).toBe(`Handle @bobby already exists.`);
}

});
});

describe('editProfile', () => {
it('should edit profile', async () => {
const firstName = 'Jessie';
await cmOrcha.editProfile(cmQuery, auth.body.token, { firstName });
const res = await userOrcha.getUserData(userQuery, auth.body.token);
expect(res.body.changeMaker?.firstName).toBe(firstName);

const editProfileArgument: EditCmProfileDto = {
firstName: 'Jessie'
}
await supertest(app.getHttpServer())
.post('/changeMaker/editProfile')
.set('token', token)
.set('Content-Type', 'application/json')
.set('Accept', 'application/json')
.send({
[QUERY_KEY]: cmQuery,
[DTO_KEY]: editProfileArgument
});

const getUserDataResponse = await supertest(app.getHttpServer())
.post('/user/getUserData')
.set(TOKEN_KEY, token)
.send({
[QUERY_KEY]: userQuery
});

expect(getUserDataResponse.body.changeMaker?.firstName).toBe(firstName);
});
});
});
22 changes: 0 additions & 22 deletions apps/api-e2e/src/specs/change-maker/change-maker.orchestration.ts

This file was deleted.

Loading