Skip to content

Commit e9b714d

Browse files
committed
- Remove legends from mockReportData json
- Update pathwayAnalysis unit tests
1 parent feeeedf commit e9b714d

3 files changed

Lines changed: 19 additions & 20 deletions

File tree

app/routes/report/summary/pathwayAnalysis.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ router.route('/')
7979
return res.json(req.pathwayAnalysis.view('public'));
8080
} catch (error) {
8181
logger.error(`Unable to update pathway analysis ${error}`);
82-
return res.status().json({error: {message: 'Unable to update pathway analysis'}});
82+
return res.status(HTTP_STATUS.INTERNAL_SERVER_ERROR).json({error: {message: 'Unable to update pathway analysis'}});
8383
}
8484
})
8585
.delete(async (req, res) => {

test/routes/report/summary/pathwayAnalysis.test.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ beforeAll(async () => {
3232

3333
describe('/reports/{report}/summary/pathway-analysis', () => {
3434
let report;
35+
let legend;
3536

3637
beforeAll(async () => {
3738
// Get genomic template
@@ -41,6 +42,13 @@ describe('/reports/{report}/summary/pathway-analysis', () => {
4142
templateId: template.id,
4243
patientId: 'TESTPATIENT1234',
4344
});
45+
// Create legend for pathway analysis tests
46+
legend = await db.models.legend.create({
47+
filename: 'pathway_legend_v1.png',
48+
name: 'v1',
49+
data: 'v1Data',
50+
default: true,
51+
});
4452
});
4553

4654
describe('GET', () => {
@@ -89,13 +97,13 @@ describe('/reports/{report}/summary/pathway-analysis', () => {
8997
.auth(username, password)
9098
.type('json')
9199
.attach('pathway', 'test/testData/images/pathwayAnalysisData.svg')
92-
.field('legendId', 1)
100+
.field('legendId', legend.id)
93101
.expect(HTTP_STATUS.OK);
94102

95103
checkPathwayAnalysis(res.body);
96104

97105
expect(res.body.pathway).not.toBeNull();
98-
expect(res.body.legendId).toBe(1);
106+
expect(res.body.legendId).toBe(legend.id);
99107
});
100108

101109
test('/ - 400 Bad request - Invalid legend fk', async () => {
@@ -113,7 +121,7 @@ describe('/reports/{report}/summary/pathway-analysis', () => {
113121
.auth(username, password)
114122
.type('json')
115123
.attach('pathway', 'test/testData/images/golden.jpg')
116-
.field('legendId', 1)
124+
.field('legendId', legend.id)
117125
.expect(HTTP_STATUS.BAD_REQUEST);
118126
});
119127

@@ -173,13 +181,13 @@ describe('/reports/{report}/summary/pathway-analysis', () => {
173181
.auth(username, password)
174182
.type('json')
175183
.attach('pathway', 'test/testData/images/pathwayAnalysisData.svg')
176-
.field('legendId', 1)
184+
.field('legendId', legend.id)
177185
.expect(HTTP_STATUS.CREATED);
178186

179187
checkPathwayAnalysis(res.body);
180188

181189
expect(res.body.pathway).not.toBeNull();
182-
expect(res.body.legendId).toBe(1);
190+
expect(res.body.legendId).toBe(legend.id);
183191

184192
// Remove pathway analysis
185193
await db.models.pathwayAnalysis.destroy({where: {ident: res.body.ident}});
@@ -201,7 +209,7 @@ describe('/reports/{report}/summary/pathway-analysis', () => {
201209
.auth(username, password)
202210
.type('json')
203211
.attach('pathway', 'test/testData/images/golden.jpg')
204-
.field('legendId', 1)
212+
.field('legendId', legend.id)
205213
.expect(HTTP_STATUS.BAD_REQUEST);
206214
});
207215

@@ -216,7 +224,7 @@ describe('/reports/{report}/summary/pathway-analysis', () => {
216224
.auth(username, password)
217225
.type('json')
218226
.attach('pathway', 'test/testData/images/pathwayAnalysisData.svg')
219-
.field('legendId', 1)
227+
.field('legendId', legend.id)
220228
.expect(HTTP_STATUS.CONFLICT);
221229

222230
// Remove pathway analysis
@@ -226,6 +234,7 @@ describe('/reports/{report}/summary/pathway-analysis', () => {
226234

227235
// Delete report
228236
afterAll(async () => {
237+
await db.models.legend.destroy({where: {id: legend.id}, force: true});
229238
await db.models.report.destroy({where: {id: report.id}, force: true});
230239
});
231240
});

test/testData/mockReportData.json

Lines changed: 2 additions & 12 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)