Skip to content

Commit

Permalink
MAT-6819 multiple populations
Browse files Browse the repository at this point in the history
  • Loading branch information
CeciliaLiu8 committed Apr 4, 2024
1 parent 397a9d5 commit 5793fbd
Show file tree
Hide file tree
Showing 7 changed files with 249 additions and 40 deletions.
17 changes: 6 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"test:e2e": "JWT_SECRET=ThisIsMySecret jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@madie/madie-models": "^1.3.49",
"@madie/madie-models": "^1.3.51",
"@nestjs/common": "^10.3.5",
"@nestjs/core": "^10.3.5",
"@nestjs/jwt": "^10.2.0",
Expand Down
1 change: 1 addition & 0 deletions src/controllers/export.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('exportController', () => {
groupNumber: '1',
testCaseExecutionResults: [
{
testCaseId: 'testCaseId',
populations: [],
notes: '',
last: 'testSeries1',
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/export.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Response, Request } from 'express';
import { ExportService } from '../services/export.service';
import { AuthGuard } from '../auth/auth.guard';
import { TestCaseExcelExportDto } from '@madie/madie-models';
import { log } from 'console';

@Controller('excel')
@UseGuards(AuthGuard)
Expand All @@ -18,6 +19,7 @@ export class ExportController {
async getExcelFile(@Req() req: Request, @Res() res: Response) {
const testCaseGroupDtos: TestCaseExcelExportDto[] =
req.body.testCaseExcelExportDtos;
log('request -> ' + JSON.stringify(testCaseGroupDtos));
const buffer = await this.exportService.generateXlsx(testCaseGroupDtos);
res.send(buffer);
}
Expand Down
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { NestFactory } from '@nestjs/core';
import { ExportModule } from './export.module';

export async function bootstrap() {
const app = await NestFactory.create(ExportModule);
const app = await NestFactory.create(ExportModule, {
logger: ['error', 'log'],
});
app.enableCors();
await app.listen(3000);
}
bootstrap();
65 changes: 65 additions & 0 deletions src/services/export.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ describe('ExcelService', () => {
groupNumber: '1',
testCaseExecutionResults: [
{
testCaseId: 'testCaseId1',
populations: [
{
name: 'initialPopulation',
expected: 1,
actual: 2,
pass: false,
},
],
notes: '',
Expand Down Expand Up @@ -42,6 +44,43 @@ describe('ExcelService', () => {
actual: 'FUNCTION',
},
],
stratifications: [
{
testCaseId: 'testCaseId1',
stratId: 'stratId1',
stratName: 'PopSet1 Stratification 1',
stratificationDtos: [
{
id: 'stratId1',
name: 'STRAT',
expected: 11,
actual: 0,
pass: false,
},
{
id: 'f0b3c08d-1164-48d8-bc71-aed87499099f',
name: 'initialPopulation',
expected: 11,
actual: 0,
pass: false,
},
{
id: 'f0b3c08d-1164-48d8-bc71-aed87499099f',
name: 'denominator',
expected: 11,
actual: 0,
pass: false,
},
{
id: 'f0b3c08d-1164-48d8-bc71-aed87499099f',
name: 'numerator',
expected: 11,
actual: 0,
pass: false,
},
],
},
],
},
],
};
Expand Down Expand Up @@ -180,5 +219,31 @@ describe('ExcelService', () => {
'1 - Population Criteria Section',
);
expect(populationCriteria1WorkSheet).not.toBe(null);

const strat1WorkSheet = workbook.getWorksheet(
'2 - PopSet1 Stratification 1',
);
expect(strat1WorkSheet).not.toBe(null);
expect(strat1WorkSheet.getRows.length).toBe(2);
expect(strat1WorkSheet.getCell(1, 1).value).toBe('Expected');
expect(strat1WorkSheet.getCell(1, 5).value).toBe('Actual');

expect(strat1WorkSheet.getCell(2, 1).value).toBe('STRAT');
expect(strat1WorkSheet.getCell(2, 2).value).toBe('initialPopulation');
expect(strat1WorkSheet.getCell(2, 3).value).toBe('denominator');
expect(strat1WorkSheet.getCell(2, 4).value).toBe('numerator');
expect(strat1WorkSheet.getCell(2, 5).value).toBe('STRAT');
expect(strat1WorkSheet.getCell(2, 6).value).toBe('initialPopulation');
expect(strat1WorkSheet.getCell(2, 7).value).toBe('denominator');
expect(strat1WorkSheet.getCell(2, 8).value).toBe('numerator');

expect(strat1WorkSheet.getCell(3, 1).value).toBe(11);
expect(strat1WorkSheet.getCell(3, 2).value).toBe(11);
expect(strat1WorkSheet.getCell(3, 3).value).toBe(11);
expect(strat1WorkSheet.getCell(3, 4).value).toBe(11);
expect(strat1WorkSheet.getCell(3, 5).value).toBe(0);
expect(strat1WorkSheet.getCell(3, 6).value).toBe(0);
expect(strat1WorkSheet.getCell(3, 7).value).toBe(0);
expect(strat1WorkSheet.getCell(3, 8).value).toBe(0);
});
});
Loading

0 comments on commit 5793fbd

Please sign in to comment.