Skip to content

Commit

Permalink
Feature/add service test (#718)
Browse files Browse the repository at this point in the history
* Add service to test

* Use migration from jar instead

* Get the correct TRS files

* Use new services boolean query parameter

* Use latest webservice
  • Loading branch information
garyluu authored Aug 9, 2019
1 parent c4b7be0 commit 4a501e9
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 74 deletions.
52 changes: 25 additions & 27 deletions cypress/integration/immutableDatabaseTests/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ describe('Dockstore Home', () => {
});
});

// TODO: This is a fake service, need to use a more realistic one later
describe('services', () => {
it('Have no services in /services', () => {
it('Have one service in /services', () => {
cy.visit('/services');
cy.url().should('contain', 'services');
cy.get('[data-cy=header]').contains('h3', 'Available Services');
cy.contains('Search services');
cy.contains('garyluu/another-test-service');
});
it('Have fake service in /services/{id}', () => {
cy.visit('/services/github.com/A/l');
cy.url().should('contain', '/services/github.com/A/l');
cy.visit('/services/github.com/garyluu/another-test-service');
cy.url().should('contain', '/services/github.com/garyluu/another-test-service');
cy.get('[data-cy=header]').contains('h3', 'Available Services');
cy.contains('github.com/A/l:master');
cy.contains('github.com/garyluu/another-test-service:1.3');
checkTabs();
checkInfoTab();
// TRS only visibile in public page
Expand All @@ -56,24 +56,22 @@ describe('Dockstore Home', () => {
});
});

// TODO: These are fake services, need to use a more realistic ones later
// describe('my-services', () => {
// setTokenUserViewPort();
// it('Have no services in /services', () => {
// cy.visit('/my-services');
// cy.url().should('contain', 'my-services/github.com/A/l');
// cy.get('[data-cy=header]').contains('h3', 'My Services');
// cy.get('#workflow-path').contains('github.com/A/l:master');
// checkTabs();
// checkInfoTab();
// // TRS only visibile in public page
// cy.contains('TRS: ').should('not.be.visible');
// checkVersionsTab();
// // Hidden version not visible on public page
// cy.contains('td', 'test').should('be.visible');
// checkFilesTab();
// });
// });
describe('my-services', () => {
setTokenUserViewPort();
it('Have no services in /services', () => {
cy.visit('/my-services');
cy.url().should('contain', 'my-services/github.com/garyluu/another-test-service');
cy.get('[data-cy=header]').contains('h3', 'My Services');
// 1.3 version is selected because it's the newest version
cy.get('#workflow-path').contains('github.com/garyluu/another-test-service:1.3');
checkTabs();
checkInfoTab();
// TRS only visibile in public page
cy.contains('TRS: ').should('not.be.visible');
checkVersionsTab();
checkFilesTab();
});
});
function checkTabs() {
assertVisibleTab('Info');
assertVisibleTab('Versions');
Expand All @@ -100,16 +98,16 @@ describe('Dockstore Home', () => {
function checkVersionsTab() {
goToTab('Versions');
cy.contains('tr', 'Git Reference');
cy.contains('td', 'master');
cy.contains('td', '1.3');
cy.contains('tr', 'Date Modified');
cy.contains('td', 'Nov 28, 2016, 3:01:57 PM');
cy.contains('td', 'Jul 19, 2019, 1:13:48 PM');
cy.contains('tr', 'Valid');
cy.contains('tr', 'Verified Platforms');
cy.contains('button', 'View');
}
function checkFilesTab() {
goToTab('Files');
cy.contains('1st-workflow.cwl');
cy.contains('cwlVersion: v1.0');
cy.contains('README.md');
cy.contains('# another-test-serviceaaaa');
}
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "2.3.0",
"license": "Apache License 2.0",
"config": {
"webservice_version": "1.7.0-beta.1"
"webservice_version": "1.7.0-beta.3"
},
"scripts": {
"ng": "npx ng",
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-webservice-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ psql -h localhost -c "create user dockstore with password 'dockstore' createdb;"
psql -h localhost -c "ALTER USER dockstore WITH superuser;" -U postgres
psql -h localhost -c 'create database webservice_test with owner = dockstore;' -U postgres
psql -h localhost -f travisci/db_dump.sql webservice_test -U postgres
java -jar dockstore-webservice.jar db migrate -i 1.5.0,1.6.0,1.7.0 travisci/web.yml
java -jar dockstore-webservice.jar db migrate -i 1.5.0,1.6.0,1.7.0,add_service_1.7.0 travisci/web.yml

18 changes: 9 additions & 9 deletions src/app/entry/entry-file-tab/state/entry-file-tab.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Injectable } from '@angular/core';
import { transaction } from '@datorama/akita';
import { Base } from 'app/shared/base';
import { ga4ghWorkflowIdPrefix } from 'app/shared/constants';
import { ga4ghServiceIdPrefix, ga4ghWorkflowIdPrefix } from 'app/shared/constants';
import { DescriptorTypeCompatService } from 'app/shared/descriptor-type-compat.service';
import { EntryType } from 'app/shared/enum/entry-type';
import { FileService } from 'app/shared/file.service';
import { GA4GHFiles } from 'app/shared/ga4gh-files/ga4gh-files.model';
import { GA4GHFilesQuery } from 'app/shared/ga4gh-files/ga4gh-files.query';
import { GA4GHFilesService } from 'app/shared/ga4gh-files/ga4gh-files.service';
import { SessionQuery } from 'app/shared/session/session.query';
import { WorkflowQuery } from 'app/shared/state/workflow.query';
import { FileWrapper, GA4GHService, ToolDescriptor, ToolFile } from 'app/shared/swagger';
import { takeUntil } from 'rxjs/operators';
Expand All @@ -23,7 +25,8 @@ export class EntryFileTabService extends Base {
private ga4ghService: GA4GHService,
private ga4ghFilesService: GA4GHFilesService,
private descriptorTypeCompatService: DescriptorTypeCompatService,
private fileService: FileService
private fileService: FileService,
private sessionQuery: SessionQuery
) {
super();
}
Expand Down Expand Up @@ -200,16 +203,12 @@ export class EntryFileTabService extends Base {
const workflow = this.workflowQuery.getActive();
const version = this.workflowQuery.getSnapshot().version;
const path = toolFile.path;
const prefix = this.sessionQuery.getSnapshot().entryType === EntryType.Service ? ga4ghServiceIdPrefix : ga4ghWorkflowIdPrefix;
const fileType = workflow.descriptorType;
this.setFileContents(null);
this.setLoading(true);
this.ga4ghService
.toolsIdVersionsVersionIdTypeDescriptorRelativePathGet(
fileType,
ga4ghWorkflowIdPrefix + workflow.full_workflow_path,
version.name,
path
)
.toolsIdVersionsVersionIdTypeDescriptorRelativePathGet(fileType, prefix + workflow.full_workflow_path, version.name, path)
.subscribe(
(fileWrapper: FileWrapper) => {
this.handleFileWrapperChange(fileWrapper);
Expand Down Expand Up @@ -261,7 +260,8 @@ export class EntryFileTabService extends Base {
console.error('Worklow or version is not truthy');
return null;
}
const id = ga4ghWorkflowIdPrefix + entryPath;
const prefix = this.sessionQuery.getSnapshot().entryType === EntryType.Service ? ga4ghServiceIdPrefix : ga4ghWorkflowIdPrefix;
const id = prefix + entryPath;
const versionId = version.name;
const type = this.descriptorTypeCompatService.toolDescriptorTypeEnumToPlainTRS(toolDescriptorType);
const relativePath = this.entryFileTabQuery.getSnapshot().selectedFile.path;
Expand Down
13 changes: 8 additions & 5 deletions src/app/shared/entry-actions/workflow-actions.component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';
import { AlertQuery } from '../alert/state/alert.query';
import { ga4ghWorkflowIdPrefix } from '../constants';
import { ga4ghWorkflowIdPrefix, ga4ghServiceIdPrefix } from '../constants';
import { EntryType } from '../enum/entry-type';
import { RefreshService } from '../refresh.service';
import { BioWorkflow, Service, WorkflowVersion } from '../swagger';
import { EntryActionsComponent } from './entry-actions.component';
import { EntryActionsService } from './entry-actions.service';
import {Observable} from 'rxjs';
import {TokenQuery} from '../state/token.query';
import { Observable } from 'rxjs';
import { TokenQuery } from '../state/token.query';
import { SessionQuery } from '../session/session.query';

@Component({
selector: 'app-workflow-actions',
Expand All @@ -27,7 +28,8 @@ export class WorkflowActionsComponent extends EntryActionsComponent implements O
protected entryActionsService: EntryActionsService,
protected alertQuery: AlertQuery,
private tokenQuery: TokenQuery,
private refreshService: RefreshService
private refreshService: RefreshService,
private sessionQuery: SessionQuery
) {
super(alertQuery, entryActionsService);
this.zenodoAccountIsLinked$ = this.tokenQuery.hasZenodoToken$;
Expand Down Expand Up @@ -67,6 +69,7 @@ export class WorkflowActionsComponent extends EntryActionsComponent implements O
*/
refresh() {
const versionName = this.selectedVersion ? this.selectedVersion.name : null;
this.refreshService.refreshWorkflow(ga4ghWorkflowIdPrefix + this.workflow.full_workflow_path, versionName);
const prefix = this.sessionQuery.getSnapshot().entryType === EntryType.Service ? ga4ghServiceIdPrefix : ga4ghWorkflowIdPrefix;
this.refreshService.refreshWorkflow(prefix + this.workflow.full_workflow_path, versionName);
}
}
6 changes: 2 additions & 4 deletions src/app/workflow/info-tab/info-tab.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
import { HttpErrorResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { ga4ghPath, ga4ghWorkflowIdPrefix } from 'app/shared/constants';
import { ga4ghPath, ga4ghWorkflowIdPrefix, ga4ghServiceIdPrefix } from 'app/shared/constants';
import { Dockstore } from 'app/shared/dockstore.model';
import { EntryType } from 'app/shared/enum/entry-type';
import { BehaviorSubject } from 'rxjs';
Expand Down Expand Up @@ -193,9 +193,7 @@ export class InfoTabService {
* @memberof InfoTabService
*/
getTRSLink(path: string, versionName: string, descriptorType: string, descriptorPath: string, entryType: EntryType): string {
// const prefix: string = entryType === EntryType.BioWorkflow ? ga4ghWorkflowIdPrefix : ga4ghServiceIdPrefix;
// Currently they're both using the same prefix in the webservice
const prefix = ga4ghWorkflowIdPrefix;
const prefix: string = entryType === EntryType.BioWorkflow ? ga4ghWorkflowIdPrefix : ga4ghServiceIdPrefix;
return (
`${Dockstore.API_URI}${ga4ghPath}/tools/${encodeURIComponent(prefix + path)}` +
`/versions/${encodeURIComponent(versionName)}/plain-` +
Expand Down
49 changes: 28 additions & 21 deletions src/app/workflow/permissions/permissions.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { TokenQuery } from '../../shared/state/token.query';
import { Permission, Workflow, WorkflowsService } from '../../shared/swagger';

import RoleEnum = Permission.RoleEnum;
import { EntryType } from 'app/shared/enum/entry-type';
import { SessionQuery } from 'app/shared/session/session.query';
@Component({
selector: 'app-permissions',
templateUrl: './permissions.component.html',
Expand All @@ -29,7 +31,7 @@ export class PermissionsComponent implements OnInit {
public terraUrl = Dockstore.TERRA_IMPORT_URL.substr(0, Dockstore.TERRA_IMPORT_URL.indexOf('/#'));
private _workflow: Workflow;
protected ngUnsubscribe: Subject<{}> = new Subject();

public entryType: EntryType;
separatorKeysCodes = [ENTER, COMMA];
addOnBlur = true;

Expand All @@ -47,26 +49,29 @@ export class PermissionsComponent implements OnInit {
private snackBar: MatSnackBar,
private alertService: AlertService,
private tokenQuery: TokenQuery,
private refreshService: RefreshService
private sessionQuery: SessionQuery
) {}

ngOnInit() {
const entryType = this.sessionQuery.getSnapshot().entryType;
this.tokenQuery.tokens$.pipe(takeUntil(this.ngUnsubscribe)).subscribe(tokens => {
this.hasGoogleAccount = !!tokens.find(token => token.tokenSource === TokenSource.GOOGLE);
});
}

remove(entity: string, permission: RoleEnum) {
this.updating++;
this.workflowsService.removeWorkflowRole(this.workflow.full_workflow_path, entity, permission).subscribe(
(userPermissions: Permission[]) => {
this.updating--;
this.processResponse(userPermissions);
},
(e: HttpErrorResponse) => {
this.handleError(e, `Error removing user ${entity}.`);
}
);
this.workflowsService
.removeWorkflowRole(this.workflow.full_workflow_path, entity, permission, this.entryType === EntryType.Service)
.subscribe(
(userPermissions: Permission[]) => {
this.updating--;
this.processResponse(userPermissions);
},
(e: HttpErrorResponse) => {
this.handleError(e, `Error removing user ${entity}.`);
}
);
}

private add(event: MatChipInputEvent, permission: RoleEnum): void {
Expand All @@ -76,15 +81,17 @@ export class PermissionsComponent implements OnInit {
if ((value || '').trim()) {
this.updating++;
this.alertService.start('Updating permissions');
this.workflowsService.addWorkflowPermission(this.workflow.full_workflow_path, { email: value, role: permission }).subscribe(
(userPermissions: Permission[]) => {
this.updating--;
this.processResponse(userPermissions);
},
(e: HttpErrorResponse) => {
this.handleError(e, `Error adding user ${value}. Please make sure ${value} is registered with Terra`);
}
);
this.workflowsService
.addWorkflowPermission(this.workflow.full_workflow_path, { email: value, role: permission }, this.entryType === EntryType.Service)
.subscribe(
(userPermissions: Permission[]) => {
this.updating--;
this.processResponse(userPermissions);
},
(e: HttpErrorResponse) => {
this.handleError(e, `Error adding user ${value}. Please make sure ${value} is registered with Terra`);
}
);
}

// Reset the input value
Expand All @@ -109,7 +116,7 @@ export class PermissionsComponent implements OnInit {
this.owners = [];
if (this._workflow) {
this.hosted = this.workflow.mode === 'HOSTED';
this.workflowsService.getWorkflowPermissions(this._workflow.full_workflow_path).subscribe(
this.workflowsService.getWorkflowPermissions(this._workflow.full_workflow_path, this.entryType === EntryType.Service).subscribe(
(userPermissions: Permission[]) => {
this.canViewPermissions = true;
this.processResponse(userPermissions);
Expand Down
20 changes: 14 additions & 6 deletions src/app/workflow/workflow.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ import { Observable } from 'rxjs';
import { finalize, takeUntil } from 'rxjs/operators';
import { AlertQuery } from '../shared/alert/state/alert.query';
import { BioschemaService } from '../shared/bioschema.service';
import { ga4ghWorkflowIdPrefix, includesValidation, myBioWorkflowsURLSegment, myServicesURLSegment } from '../shared/constants';
import {
ga4ghServiceIdPrefix,
ga4ghWorkflowIdPrefix,
includesValidation,
myBioWorkflowsURLSegment,
myServicesURLSegment
} from '../shared/constants';
import { DateService } from '../shared/date.service';
import { DescriptorTypeCompatService } from '../shared/descriptor-type-compat.service';
import { DockstoreService } from '../shared/dockstore.service';
Expand Down Expand Up @@ -211,7 +217,7 @@ export class WorkflowComponent extends Entry implements AfterViewInit {
if (!this.isPublic()) {
this.showWorkflowActions = false;
this.workflowsService
.getWorkflowActions(this.workflow.full_workflow_path)
.getWorkflowActions(this.workflow.full_workflow_path, this.entryType === EntryType.Service)
.pipe(
finalize(() => {
this.showWorkflowActions = true;
Expand All @@ -227,7 +233,7 @@ export class WorkflowComponent extends Entry implements AfterViewInit {
// for users that are not on FireCloud
if (this.isOwner && this.isHosted() && this.workflow) {
this.workflowsService
.getWorkflowPermissions(this.workflow.full_workflow_path)
.getWorkflowPermissions(this.workflow.full_workflow_path, this.entryType === EntryType.Service)
.pipe(takeUntil(this.ngUnsubscribe))
.subscribe((userPermissions: Permission[]) => {
this.processPermissions(userPermissions);
Expand All @@ -246,7 +252,8 @@ export class WorkflowComponent extends Entry implements AfterViewInit {
this.selectedVersion = this.selectWorkflowVersion(this.workflow.workflowVersions, this.urlVersion, this.workflow.defaultVersion);
if (this.selectedVersion) {
this.workflowService.setWorkflowVersion(this.selectedVersion);
this.gA4GHFilesService.updateFiles(ga4ghWorkflowIdPrefix + this.workflow.full_workflow_path, this.selectedVersion.name, [
const prefix = this.entryType === EntryType.BioWorkflow ? ga4ghWorkflowIdPrefix : ga4ghServiceIdPrefix;
this.gA4GHFilesService.updateFiles(prefix + this.workflow.full_workflow_path, this.selectedVersion.name, [
this.descriptorTypeCompatService.stringToDescriptorType(this.workflow.descriptorType)
]);
}
Expand All @@ -268,7 +275,7 @@ export class WorkflowComponent extends Entry implements AfterViewInit {
if (url.includes('workflows') || url.includes('services')) {
// Only get published workflow if the URI is for a specific workflow (/containers/quay.io%2FA2%2Fb3)
// as opposed to just /tools or /docs etc.
this.workflowsService.getPublishedWorkflowByPath(this.title, includesValidation).subscribe(
this.workflowsService.getPublishedWorkflowByPath(this.title, includesValidation, this.entryType === EntryType.Service).subscribe(
workflow => {
this.workflowService.setWorkflow(workflow);
this.selectTab(this.validTabs.indexOf(this.currentTab));
Expand Down Expand Up @@ -362,7 +369,8 @@ export class WorkflowComponent extends Entry implements AfterViewInit {
onSelectedVersionChange(version: WorkflowVersion): void {
this.selectedVersion = version;
if (this.selectVersion) {
this.gA4GHFilesService.updateFiles(ga4ghWorkflowIdPrefix + this.workflow.full_workflow_path, this.selectedVersion.name, [
const prefix = this.entryType === EntryType.BioWorkflow ? ga4ghWorkflowIdPrefix : ga4ghServiceIdPrefix;
this.gA4GHFilesService.updateFiles(prefix + this.workflow.full_workflow_path, this.selectedVersion.name, [
this.descriptorTypeCompatService.stringToDescriptorType(this.workflow.descriptorType)
]);
}
Expand Down

0 comments on commit 4a501e9

Please sign in to comment.