Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mat 6819 multi populations work sheet #8

Merged
merged 10 commits into from
Apr 12, 2024
8 changes: 4 additions & 4 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": "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
14 changes: 13 additions & 1 deletion src/auth/auth.guard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ describe('AuthGuard', () => {
}),
});

jest.mock('@okta/jwt-verifier', () => {
return jest.fn().mockImplementation(() => ({
verifyAccessToken: () => ({
oktaToken: {
claims: {
sub: 'a_user',
},
},
}),
}));
});

jest
.spyOn(mockExecutionContext.switchToHttp(), 'getRequest')
.mockImplementation(() => {
Expand All @@ -48,7 +60,7 @@ describe('AuthGuard', () => {
body: undefined,
headers: {
authorization:
'Bearer eyJraWQiOiJNNG9CMW9DSmthdC0tYTNENFFXUFA3RWZCbUl3NG9BV05KYWJxdEJhUnM4IiwiYWxnIjoiUlMyNTYifQ.eyJ2ZXIiOjEsImp0aSI6IkFULlBlN3hEc000MksyTnhHSW5vSWV1UEVEVmgxY3YydDVqQ1FKZmU1Sm9ZbkUiLCJpc3MiOiJodHRwczovL2Rldi0xODA5MjU3OC5va3RhLmNvbS9vYXV0aDIvZGVmYXVsdCIsImF1ZCI6ImFwaTovL2RlZmF1bHQiLCJpYXQiOjE3MTI4NjMyNzcsImV4cCI6MTcxMjg2Njg3NywiY2lkIjoiMG9hMmZxdGF6OTVmcUpxY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RKiNB58yg-AcNoF0ZYoro0lOr9up-ev0j32SQvBnhMXRZOARoOy4ALcT_GovwluH2v_sjXhNtjn26GV5UZU1EaWXsdMWfwg_-6eAmlQ9dLkIZerIYsu7Ut8pfwirgbpME4mMKqiJBXEkRWHUkAh5PEnJO4DvaKj6Tis5ERprNLuUKR5M4bWMhBjAMt74fTu5iLiANOi0uqropZscP72HVNEQhkyqM84hvgAvZvzlVYKUTUBuoWQF21eRSOUpYSE0yvDRW5JS5r0NCXUEZwuNfavuvl3gDUae31hcbtOo7kznQ2Q_-GkfVThA',
},
} as unknown as Request;
});
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
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ 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({
origin: [
'http://localhost:9000',
Expand Down
67 changes: 67 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,13 +44,52 @@ 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,
},
],
},
],
},
{
testCaseId: 'testCaseId2',
populations: [
{
name: 'initialPopulation',
expected: 2,
actual: 2,
pass: true,
},
],
notes: '',
Expand Down Expand Up @@ -233,5 +274,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
Loading