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

feat: SJIP-1059 fix request body #216

Merged
merged 1 commit into from
Oct 29, 2024
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 14 additions & 26 deletions src/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,18 @@ describe('Express app (without Arranger)', () => {
});

const requestBody = {
genes:
'CYB5R1,TBCA,TOMM5,NRXN2,ENSG00000163462.18,ENSG00000211592,ENSG000002137410,FUT7,AL139424,ENSG00000204882.4',
genes: [
'CYB5R1',
'TBCA',
'TOMM5',
'NRXN2',
'ENSG00000163462.18',
'ENSG00000211592',
'ENSG000002137410',
'FUT7',
'AL139424',
'ENSG00000204882.4',
],
};

it('should return 403 if no Authorization header', () =>
Expand Down Expand Up @@ -826,18 +836,7 @@ describe('Express app (without Arranger)', () => {
.send(requestBody)
.expect(200, matchedGenes);
expect((checkGenesExist as jest.Mock).mock.calls.length).toEqual(1);
expect((checkGenesExist as jest.Mock).mock.calls[0][0]).toEqual([
'CYB5R1',
'TBCA',
'TOMM5',
'NRXN2',
'ENSG00000163462.18',
'ENSG00000211592',
'ENSG000002137410',
'FUT7',
'AL139424',
'ENSG00000204882.4',
]);
expect((checkGenesExist as jest.Mock).mock.calls[0][0]).toEqual(requestBody.genes);
});

it('should return 500 if Authorization header contains valid token but an error occurs', async () => {
Expand All @@ -855,18 +854,7 @@ describe('Express app (without Arranger)', () => {
.send(requestBody)
.expect(500, { error: 'Internal Server Error' });
expect((checkGenesExist as jest.Mock).mock.calls.length).toEqual(1);
expect((checkGenesExist as jest.Mock).mock.calls[0][0]).toEqual([
'CYB5R1',
'TBCA',
'TOMM5',
'NRXN2',
'ENSG00000163462.18',
'ENSG00000211592',
'ENSG000002137410',
'FUT7',
'AL139424',
'ENSG00000204882.4',
]);
expect((checkGenesExist as jest.Mock).mock.calls[0][0]).toEqual(requestBody.genes);
});
});
});
4 changes: 2 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ export default (keycloak: Keycloak, getProject: (projectId: string) => ArrangerP
});

app.postAsync('/transcriptomics/checkGenesExist', keycloak.protect(), async (req, res) => {
const genes: string = req.body.genes;
const genes: string[] = req.body.genes;

const data = await checkGenesExist(genes.split(','));
const data = await checkGenesExist(genes);

res.json(data);
});
Expand Down
Loading