Skip to content

Commit

Permalink
wip: e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKellerer committed Jun 4, 2024
1 parent d840a48 commit 9977a35
Show file tree
Hide file tree
Showing 56 changed files with 33,314 additions and 37 deletions.
13 changes: 13 additions & 0 deletions .idea/runConfigurations/LapisOpen.xml

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

13 changes: 13 additions & 0 deletions .idea/runConfigurations/LapisProtected.xml

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

11 changes: 0 additions & 11 deletions .idea/runConfigurations/lapis_open.xml

This file was deleted.

11 changes: 0 additions & 11 deletions .idea/runConfigurations/lapis_protected.xml

This file was deleted.

1 change: 1 addition & 0 deletions lapis-e2e/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules/

**/output/
**/logs/
**/temp/
3 changes: 2 additions & 1 deletion lapis-e2e/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/test/lapisClient
/test/lapisClientProtected
/test/lapisClientProtected
test/lapisClientMultiSegmented
9 changes: 9 additions & 0 deletions lapis-e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@
"description": "End to end tests for LAPIS backed by SILO",
"scripts": {
"test": "mocha --exit",

"generateLapisClient": "npm run runOpenApiGenerator && npm run copyGeneratedFiles && npm run cleanUpGeneratedFiles",
"runOpenApiGenerator": "openapi-generator-cli generate -i ../lapis/lapis-openapi.json -g typescript-fetch -o generated-sources",
"copyGeneratedFiles": "mkdir -p test/lapisClient && cp generated-sources/index.ts generated-sources/runtime.ts test/lapisClient && cp -r generated-sources/apis generated-sources/models test/lapisClient",

"generateLapisClientProtected": "npm run runOpenApiGeneratorProtected && npm run copyGeneratedFilesProtected && npm run cleanUpGeneratedFilesProtected",
"runOpenApiGeneratorProtected": "openapi-generator-cli generate -i ../lapis/lapis-openapi-protected.json -g typescript-fetch -o generated-sources-protected",
"copyGeneratedFilesProtected": "mkdir -p test/lapisClientProtected && cp generated-sources-protected/index.ts generated-sources-protected/runtime.ts test/lapisClientProtected && cp -r generated-sources-protected/apis generated-sources-protected/models test/lapisClientProtected",

"generateLapisClientMultiSegmented": "npm run runOpenApiGeneratorMultiSegmented && npm run copyGeneratedFilesMultiSegmented && npm run cleanUpGeneratedFilesProtected",
"runOpenApiGeneratorMultiSegmented": "openapi-generator-cli generate -i ../lapis/lapis-openapi-multi-segmented.json -g typescript-fetch -o generated-sources-multi-segmented",
"copyGeneratedFilesMultiSegmented": "mkdir -p test/lapisClientMultiSegmented && cp generated-sources-multi-segmented/index.ts generated-sources-multi-segmented/runtime.ts test/lapisClientMultiSegmented && cp -r generated-sources-multi-segmented/apis generated-sources-multi-segmented/models test/lapisClientMultiSegmented",

"cleanUpGeneratedFiles": "rm -rf generated-sources",
"cleanUpGeneratedFilesProtected": "rm -rf generated-sources-protected",
"cleanUpGeneratedFilesMultiSegmented": "rm -rf generated-sources-multi-segmented",

"check-format": "prettier --check .",
"format": "prettier --write ."
},
Expand Down
11 changes: 11 additions & 0 deletions lapis-e2e/test/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import {
Middleware,
SingleSegmentedSequenceControllerApi,
} from './lapisClient';
import { LapisControllerApi as LapisControllerApiMultiSegmented } from './lapisClientMultiSegmented';
import { expect } from 'chai';

import {
LapisControllerApi as LapisControllerApiProtected,
Configuration as ConfigurationProtected,
} from './lapisClientProtected';
import {MultiSegmentedSequenceControllerApi} from "./lapisClientMultiSegmented";

export const basePath = 'http://localhost:8090';
export const basePathProtected = 'http://localhost:8092';
export const basePathMultiSegmented = 'http://localhost:8094';

const middleware: Middleware = {
onError: errorContext => {
Expand Down Expand Up @@ -40,11 +43,19 @@ export const lapisClient = new LapisControllerApi(new Configuration({ basePath }
export const lapisClientProtected = new LapisControllerApiProtected(
new ConfigurationProtected({ basePath: basePathProtected })
).withMiddleware(middleware);
export const lapisClientMultiSegmented = new LapisControllerApiMultiSegmented(
new Configuration({ basePath: basePathMultiSegmented })
).withMiddleware(middleware);


export const lapisSingleSegmentedSequenceController = new SingleSegmentedSequenceControllerApi(
new Configuration({ basePath })
).withMiddleware(middleware);

export const lapisMultiSegmentedSequenceController = new MultiSegmentedSequenceControllerApi(
new Configuration({ basePath: basePathMultiSegmented })
).withMiddleware(middleware);

export function sequenceData(serverResponse: string) {
const lines = serverResponse.split('\n').filter(line => line.length > 0);
const primaryKeys = lines.filter(line => line.startsWith('>'));
Expand Down
22 changes: 21 additions & 1 deletion lapis-e2e/test/nucleotideInsertions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { basePath, lapisClient } from './common';
import {basePath, lapisClient, lapisClientMultiSegmented} from './common';

describe('The /nucleotideInsertions endpoint', () => {
let someInsertion = 'ins_25701:CCC';
Expand All @@ -18,6 +18,26 @@ describe('The /nucleotideInsertions endpoint', () => {
expect(specificInsertion?.sequenceName).to.be.undefined;
});

it('should return nucleotide insertions for multi segmented sequences', async () => {
const result = await lapisClientMultiSegmented.postNucleotideInsertions1(
{
insertionsRequest: { country: 'Switzerland' },
}
);

expect(result.data).to.have.length(2);

const insertionsFirstSegment = result.data.find(
mutationData => mutationData.insertion === 'ins_L:123:AB'
);
expect(insertionsFirstSegment?.count).to.equal(1);

const insertionsSecondSegment = result.data.find(
mutationData => mutationData.insertion === 'ins_M:234:BC'
);
expect(insertionsSecondSegment?.count).to.equal(1);
})

it('should order by specified fields', async () => {
const ascendingOrderedResult = await lapisClient.postNucleotideInsertions1({
insertionsRequest: {
Expand Down
21 changes: 20 additions & 1 deletion lapis-e2e/test/nucleotideMutations.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { basePath, lapisClient } from './common';
import {basePath, lapisClient, lapisClientMultiSegmented} from './common';

describe('The /nucleotideMutations endpoint', () => {
let mutationWithLessThan10PercentProportion = 'C19220T';
Expand Down Expand Up @@ -29,6 +29,25 @@ describe('The /nucleotideMutations endpoint', () => {
expect(commonMutationProportion?.position).to.be.equal(28280);
});

it('should return mutations proportions for multi segmented', async () => {
const result = await lapisClientMultiSegmented.postNucleotideMutations1({
sequenceFiltersWithMinProportion: { country: 'Switzerland', minProportion: 0.0 },
});
})

expect(result.data).to.have.length(2);

const mutationProportionOnFirstSegment = result.data.find(
mutationData => mutationData.mutation === 'L:T1A'
);
expect(mutationProportionOnFirstSegment?.count).to.equal(1);

const mutationProportionOnSecondSegment = result.data.find(
mutationData => mutationData.mutation === 'M:T1A'
);
expect(mutationProportionOnSecondSegment?.count).to.equal(1);
})

it('should return mutation proportions for Switzerland with minProportion 0.5', async () => {
const result = await lapisClient.postNucleotideMutations1({
sequenceFiltersWithMinProportion: {
Expand Down
Loading

0 comments on commit 9977a35

Please sign in to comment.