Skip to content

Commit

Permalink
Feature/2386/config (#628)
Browse files Browse the repository at this point in the history
dockstore/dockstore#2386

All api calls go to /api  on same domain (host/port) as UI is served from endpoint -- see app.module.ts

In the APP_INITIALIZER, UI calls /api/metadata/config.json and sets dockstore.model.ts based on the response.

When running locally, use Angular proxy. Just use `npm run start`.

When running on Circle-CI, use nginx.

Also: 
In checkerWorkflowFromWorkflow.ts, it was checking
if a button was not visible, then if it was visible.
Removed that, as I think it was relying on a delay
for the button to appear.
  • Loading branch information
coverbeck authored May 20, 2019
1 parent e3501ab commit f3e0d5e
Show file tree
Hide file tree
Showing 19 changed files with 226 additions and 77 deletions.
14 changes: 10 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,20 @@ commands:
name: Install cypress dependencies
command: sudo apt install libgtk2.0-0 -yq
- run:
name: Install angular http server (replace with nginx)
command: bash -i -c 'npm i [email protected] [email protected] --no-save'
name: Install cypress
command: bash -i -c 'npm i [email protected] --no-save'
- run:
name: Prepare webservice
command: bash -i -c 'npm run webservice'
- run:
name: Serve
command: bash -i -c 'npx angular-http-server --path ./dist -p 4200'
name: Install nginx
command: sudo apt install -y nginx || true
- run:
name: Prepapre nginx config
command: sed "s%REPLACEME%`pwd`%" .circleci/nginx.conf.tmpl > .circleci/nginx.conf
- run:
name: Run nginx
command: sudo nginx -c `pwd`/.circleci/nginx.conf
background: true
- run:
name: Run webservice
Expand Down
26 changes: 26 additions & 0 deletions .circleci/nginx.conf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
events {
}

http {
include /etc/nginx/mime.types;
server {
listen 4200;

location = /swagger.json {
proxy_pass http://localhost:8080/swagger.json;
}

location /api/ {
rewrite ^ $request_uri;
rewrite ^/api/(.*) $1 break;
return 400;
proxy_pass http://localhost:8080/$uri;
}

location / {
root REPLACEME/dist;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
}
}
3 changes: 1 addition & 2 deletions cypress/integration/group1/checkerWorkflowFromWorkflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ describe('Checker workflow test from my-workflows', () => {
cy.fixture('refreshedChecker').then((json) => {
cy.route({
method: 'GET',
url: '/workflows/*/refresh',
url: '/api/workflows/*/refresh',
response: json
});
cy.get('#submitButton').click();
});

// Actions should be possible right after registering checker workflow
cy.get('#viewCheckerWorkflowButton').should('not.be.visible');
cy.get('#viewCheckerWorkflowButton').should('be.visible');
cy.get('#viewParentEntryButton').should('not.be.visible');
cy.get('#viewCheckerWorkflowButton').should('not.be.disabled').click();
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/group1/curator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Curator UI', () => {
cy.server();
const userObject = { id: 1, username: 'user_A', curator: true, isAdmin: false, name: 'user_A', setupComplete: false};
cy.route({
url: '/users/user',
url: '*/users/user',
method: 'GET',
status: 200,
response: userObject
Expand Down
22 changes: 11 additions & 11 deletions cypress/integration/group1/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Dropdown test', () => {
.server()
.route({
method: 'GET',
url: '/users/user',
url: '*/users/user',
response: { id: 4, username: 'user_curator', name: 'user_curator', curator: true, isAdmin: false }
});

Expand Down Expand Up @@ -92,7 +92,7 @@ describe('Dropdown test', () => {
.server()
.route({
method: 'GET',
url: '/organizations/all?type=pending',
url: '*/organizations/all?type=pending',
response: pendingOrganizations
});

Expand All @@ -106,7 +106,7 @@ describe('Dropdown test', () => {
.server()
.route({
method: 'GET',
url: '/users/user/memberships',
url: '*/users/user/memberships',
response: memberships
});
// Choose dropdown
Expand All @@ -122,7 +122,7 @@ describe('Dropdown test', () => {
.server()
.route({
method: 'POST',
url: '/organizations/1002/request',
url: '*/organizations/1002/request',
response: { id: 1002, name: 'OrgThree', status: 'PENDING' }
});

Expand All @@ -137,7 +137,7 @@ describe('Dropdown test', () => {
.server()
.route({
method: 'GET',
url: '/organizations/all?type=pending',
url: '*/organizations/all?type=pending',
response: pendingOrganizations
});

Expand All @@ -151,7 +151,7 @@ describe('Dropdown test', () => {
.server()
.route({
method: 'GET',
url: '/users/user/memberships',
url: '*/users/user/memberships',
response: memberships
});

Expand Down Expand Up @@ -180,7 +180,7 @@ describe('Dropdown test', () => {
.server()
.route({
method: 'GET',
url: '/organizations/all?type=pending',
url: '*/organizations/all?type=pending',
response: pendingOrganizations
});

Expand All @@ -189,7 +189,7 @@ describe('Dropdown test', () => {
.server()
.route({
method: 'POST',
url: '/organizations/1000/approve',
url: '*/organizations/1000/approve',
response: []
});

Expand All @@ -213,7 +213,7 @@ describe('Dropdown test', () => {
.server()
.route({
method: 'POST',
url: '/organizations/1000/invitation?accept=true',
url: '*/organizations/1000/invitation?accept=true',
response: []
});

Expand All @@ -226,7 +226,7 @@ describe('Dropdown test', () => {
.server()
.route({
method: 'GET',
url: '/users/user/memberships',
url: '*/users/user/memberships',
response: memberships
});

Expand Down Expand Up @@ -258,7 +258,7 @@ describe('Dropdown test', () => {
.server()
.route({
method: 'DELETE',
url: '/users/user',
url: '*/users/user',
response: 'true'
});
cy
Expand Down
6 changes: 3 additions & 3 deletions cypress/integration/group2/searchTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Dockstore tool/workflow search table', () => {
cy.server();
// Tools/worflows not starred in this response.
cy.route({
url: '/api/ga4gh/v2/extended/tools/entry/_search',
url: '*/api/ga4gh/v2/extended/tools/entry/_search',
method: 'POST',
status: 200,
response: {"took":18,"timed_out":false,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0},"hits":{"total":4,"max_score":1.0,"hits":[{"_index":"entry","_type":"tool","_id":"52","_score":1.0,"_source":{"tool_maintainer_email":"","aliases":{},"default_dockerfile_path":"/Dockerfile","is_published":true,"toolname":"cgpmap-cramOut","last_modified_date":null,"checker_id":null,"private_access":false,"descriptorType":["cwl"],"mode":"MANUAL_IMAGE_PATH","lastBuild":1518478819000,"lastUpdated":1518479742691,"path":"quay.io/garyluu/dockstore-cgpmap","defaultCWLTestParameterFile":"/examples/cgpmap/cramOut/fastq_gz_input.json","has_checker":false,"id":52,"last_modified":null,"email":null,"default_wdl_path":"/Dockstore.wdl","tool_path":"quay.io/garyluu/dockstore-cgpmap/cgpmap-cramOut","registry":"QUAY_IO","dbUpdateDate":null,"author":null,"registry_string":"quay.io","tags":[{"doiURL":null,"hidden":false,"workingDirectory":"cwls","versionEditor":null,"verifiedSource":null,"verified":false,"referenceType":"UNSET","commitID":null,"dockerfile_path":"/Dockerfile","doiStatus":"NOT_REQUESTED","reference":"3.0.0-rc8","valid":true,"wdl_path":"/Dockstore.wdl","automated":true,"size":138844180,"cwl_path":"/cwls/cgpmap-cramOut.cwl","name":"3.0.0-rc8","id":52,"image_id":"c387f22e65f066c42ccaf11392fdbd640aa2b7627eb40ac06a0dbaca2ca323cb","dirtyBit":false,"last_modified":1518479368000}],"dbCreateDate":null,"custom_docker_registry_path":"quay.io","default_cwl_path":"/cwls/cgpmap-cramOut.cwl","name":"dockstore-cgpmap","namespace":"garyluu","gitUrl":"[email protected]:garyluu/dockstore-cgpmap.git","defaultWDLTestParameterFile":"/test.wdl.json","defaultVersion":null}},{"_index":"entry","_type":"tool","_id":"5","_score":1.0,"_source":{"tool_maintainer_email":"","aliases":{},"default_dockerfile_path":"/Dockerfile","is_published":true,"toolname":null,"last_modified_date":null,"checker_id":null,"private_access":false,"descriptorType":["cwl"],"mode":"AUTO_DETECT_QUAY_TAGS_AUTOMATED_BUILDS","lastBuild":1465419996000,"lastUpdated":1480374043873,"path":"quay.io/A2/a","defaultCWLTestParameterFile":null,"has_checker":false,"id":5,"last_modified":null,"email":null,"default_wdl_path":"/Dockstore.wdl","tool_path":"quay.io/A2/a","registry":"QUAY_IO","dbUpdateDate":null,"author":null,"registry_string":"quay.io","tags":[{"doiURL":null,"hidden":false,"workingDirectory":"","versionEditor":null,"verifiedSource":null,"verified":false,"referenceType":"UNSET","commitID":null,"dockerfile_path":"/Dockerfile","doiStatus":"NOT_REQUESTED","reference":"master","valid":true,"wdl_path":"/Dockstore.wdl","automated":true,"size":44363874,"cwl_path":"/Dockstore.cwl","name":"latest","id":11,"image_id":"9227b87c1304b9ce746d06d0eb8144ec17a253f5b8e00a3922d86b538c8296c0","dirtyBit":false,"last_modified":1465420088000},{"doiURL":null,"hidden":false,"workingDirectory":"","versionEditor":null,"verifiedSource":null,"verified":false,"referenceType":"UNSET","commitID":null,"dockerfile_path":"/Dockerfile","doiStatus":"NOT_REQUESTED","reference":"master","valid":true,"wdl_path":"/Dockstore.wdl","automated":true,"size":44363874,"cwl_path":"/Dockstore.cwl","name":"master","id":10,"image_id":"9227b87c1304b9ce746d06d0eb8144ec17a253f5b8e00a3922d86b538c8296c0","dirtyBit":false,"last_modified":1465420088000}],"dbCreateDate":null,"custom_docker_registry_path":"quay.io","default_cwl_path":"/Dockstore.cwl","name":"a","namespace":"A2","gitUrl":"[email protected]:A2/a.git","defaultWDLTestParameterFile":null,"defaultVersion":null}},{"_index":"entry","_type":"tool","_id":"4","_score":1.0,"_source":{"tool_maintainer_email":"","aliases":{},"default_dockerfile_path":"/Dockerfile","is_published":true,"toolname":null,"last_modified_date":null,"checker_id":null,"private_access":false,"descriptorType":["wdl"],"mode":"AUTO_DETECT_QUAY_TAGS_AUTOMATED_BUILDS","lastBuild":1458081382000,"lastUpdated":1480374043873,"path":"quay.io/A2/b3","defaultCWLTestParameterFile":null,"has_checker":false,"id":4,"last_modified":null,"email":null,"default_wdl_path":"/Dockstore.wdl","tool_path":"quay.io/A2/b3","registry":"QUAY_IO","dbUpdateDate":null,"author":null,"registry_string":"quay.io","tags":[{"doiURL":null,"hidden":false,"workingDirectory":"","versionEditor":null,"verifiedSource":null,"verified":false,"referenceType":"UNSET","commitID":null,"dockerfile_path":"/Dockerfile","doiStatus":"NOT_REQUESTED","reference":"master","valid":true,"wdl_path":"/Dockstore.wdl","automated":true,"size":108722128,"cwl_path":"/Dockstore.cwl","name":"latest","id":9,"image_id":"f92aa8edcc265e4d5faabf7f89157008d52d514f8f6d7c1b833024f58f126e9d","dirtyBit":false,"last_modified":1458081725000},{"doiURL":null,"hidden":true,"workingDirectory":"","versionEditor":null,"verifiedSource":null,"verified":false,"referenceType":"UNSET","commitID":null,"dockerfile_path":"/Dockerfile","doiStatus":"NOT_REQUESTED","reference":"master","valid":true,"wdl_path":"/Dockstore.wdl","automated":true,"size":108722128,"cwl_path":"/Dockstore.cwl","name":"master","id":8,"image_id":"f92aa8edcc265e4d5faabf7f89157008d52d514f8f6d7c1b833024f58f126e9d","dirtyBit":false,"last_modified":1458081724000}],"dbCreateDate":null,"custom_docker_registry_path":"quay.io","default_cwl_path":"/Dockstore.cwl","name":"b3","namespace":"A2","gitUrl":"[email protected]:A2/b3.git","defaultWDLTestParameterFile":null,"defaultVersion":null}},{"_index":"entry","_type":"workflow","_id":"11","_score":1.0,"_source":{"aliases":{},"is_published":true,"last_modified_date":null,"is_checker":false,"checker_id":null,"repository":"l","source_control_provider":"GITHUB","descriptorType":"cwl","full_workflow_path":"github.com/A/l","mode":"FULL","lastUpdated":1480374057688,"path":"github.com/A/l","workflowVersions":[{"doiURL":null,"verifiedSource":null,"versionEditor":null,"verified":false,"referenceType":"UNSET","commitID":null,"id":13,"doiStatus":"NOT_REQUESTED"},{"doiURL":null,"verifiedSource":null,"versionEditor":null,"verified":false,"referenceType":"UNSET","commitID":null,"id":14,"doiStatus":"NOT_REQUESTED"}],"sourceControl":"github.com","has_checker":false,"id":11,"last_modified":null,"email":null,"dbUpdateDate":null,"author":null,"defaultTestParameterFilePath":null,"workflowName":null,"workflow_path":"/1st-workflow.cwl","dbCreateDate":null,"parent_id":null,"organization":"A","gitUrl":"[email protected]:A/l.git","defaultVersion":null}}]}}
Expand All @@ -44,7 +44,7 @@ describe('Dockstore tool/workflow search table', () => {
// First tool and workflow starred
cy.fixture('searchTableResponse').then((json) => {
cy.route({
url: '/api/ga4gh/v2/extended/tools/entry/_search',
url: '*/api/ga4gh/v2/extended/tools/entry/_search',
method: 'POST',
response: json
});
Expand Down Expand Up @@ -79,7 +79,7 @@ describe('search table items per page', () => {
cy.server();
cy.fixture('searchTableResponse').then((json) => {
cy.route({
url: '/api/ga4gh/v2/extended/tools/entry/_search',
url: '*/api/ga4gh/v2/extended/tools/entry/_search',
method: 'POST',
response: json
});
Expand Down
11 changes: 6 additions & 5 deletions cypress/integration/group3/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ describe('Dockstore Organizations', () => {
.server()
.route({
method: 'GET',
url: '/users/user/memberships',
url: '*/users/user/memberships',
response: memberships
});
});
Expand Down Expand Up @@ -226,6 +226,7 @@ describe('Dockstore Organizations', () => {
cy.get('#accept-remove-entry-from-org').click();
cy.contains('This collection has no associated entries');
cy.visit('/organizations/Potatoe');
cy.contains('Members').should('be.visible');
});
});

Expand Down Expand Up @@ -291,7 +292,7 @@ describe('Dockstore Organizations', () => {
it('organization alias', () => {
cy.server();
cy.route({
url: '/organizations/fakeAlias/aliases',
url: '*/organizations/fakeAlias/aliases',
method: 'GET',
status: 200,
response: { 'name': 'Potatoe' }
Expand All @@ -303,7 +304,7 @@ describe('Dockstore Organizations', () => {
it('collection alias', () => {
cy.server();
cy.route({
url: '/organizations/collections/fakeAlias/aliases',
url: '*/organizations/collections/fakeAlias/aliases',
method: 'GET',
status: 200,
response: { 'organizationName': 'Potatoe', 'name': 'veryFakeCollectionName' }
Expand All @@ -322,7 +323,7 @@ describe('Dockstore Organizations', () => {
it('organization alias incorrect', () => {
cy.server();
cy.route({
url: '/organizations/incorrectAlias/aliases',
url: '*/organizations/incorrectAlias/aliases',
method: 'GET',
status: 404,
response: {}
Expand All @@ -335,7 +336,7 @@ describe('Dockstore Organizations', () => {
it('collection alias incorrect', () => {
cy.server();
cy.route({
url: '/organizations/collections/incorrectAlias/aliases',
url: '*/organizations/collections/incorrectAlias/aliases',
method: 'GET',
status: 404,
response: {}
Expand Down
6 changes: 3 additions & 3 deletions cypress/integration/group3/sharedWorkflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,21 @@ describe('Shared with me workflow test from my-workflows', () => {
cy
.route({
method: 'GET',
url: '*workflows/200*',
url: '*/workflows/200*',
response: readerWorkflow
}).as('getReaderWorkflow');

cy
.route({
method: 'GET',
url: '*workflows/201*',
url: '*/workflows/201*',
response: writerWorkflow
}).as('getWriterWorkflow');

cy
.route({
method: 'GET',
url: '*workflows/202*',
url: '*/workflows/202*',
response: ownerWorkflow
}).as('getOwnerWorkflow');

Expand Down
12 changes: 6 additions & 6 deletions cypress/integration/group3/starErrorMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,28 @@ describe('Tool and workflow starring error messages', () => {

describe('Workflow starring error message', () => {
it('Workflow server error message', () => {
starringServerError('/workflows/github.com/A/l', '/workflows/11/star');
starringServerError('/workflows/github.com/A/l', '*/workflows/11/star');
})

it('Workflow cannot be starred if not already unstarred.', () => {
starringError('/workflows/github.com/A/l', 'workflow', '/workflows/11/star', 'github.com/A/l');
starringError('/workflows/github.com/A/l', 'workflow', '*/workflows/11/star', 'github.com/A/l');
});

it('Workflow cannot be unstarred if not already starred.', () => {
unstarringError('/workflows/github.com/A/l', 'workflow', '/workflows/11/unstar', 'github.com/A/l');
unstarringError('/workflows/github.com/A/l', 'workflow', '*/workflows/11/unstar', 'github.com/A/l');
});
});

describe('Tool starring error message', () =>{
it('Tool server error message', () => {
starringServerError('/containers/quay.io/A2/a:latest?tab=info', '/containers/5/star');
starringServerError('/containers/quay.io/A2/a:latest?tab=info', '*/containers/5/star');
})
it('Tool cannot be starred if not already unstarred.', () => {
starringError('/containers/quay.io/A2/a:latest?tab=info', 'tool', '/containers/5/star', 'quay.io/A2/a');
starringError('/containers/quay.io/A2/a:latest?tab=info', 'tool', '*/containers/5/star', 'quay.io/A2/a');
})

it('Tool cannot be unstarred if not already starred.', () => {
unstarringError('/containers/quay.io/A2/a:latest?tab=info', 'tool', '/containers/5/unstar', 'quay.io/A2/a');
unstarringError('/containers/quay.io/A2/a:latest?tab=info', 'tool', '*/containers/5/unstar', 'quay.io/A2/a');
});
})
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"scripts": {
"ng": "npx ng",
"start": "npx ng serve --progress=false",
"start": "npx ng serve --progress=false --proxy-config=proxy.conf.json",
"webservice": "./scripts/run-webservice-script.sh",
"prebuild": "ts-node git.version.ts && ./scripts/generate-openapi-script.sh",
"prebuild.prod": "npm run prebuild",
Expand Down
11 changes: 11 additions & 0 deletions proxy.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"/api": {
"target": "http://localhost:8080",
"pathRewrite": {
"^/api" : ""
}
},
"/swagger.json": {
"target": "http://localhost:8080"
}
}
2 changes: 1 addition & 1 deletion scripts/run-travis-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ npm run webservice
npm run build
npm run start &
./scripts/wait-for.sh
cypress run --record --config defaultCommandTimeout=10000 --spec ${TEST}
npx cypress run --record --config defaultCommandTimeout=10000 --spec ${TEST}
Loading

0 comments on commit f3e0d5e

Please sign in to comment.