Skip to content

Commit

Permalink
Turn back on tests for snapshotting (#779)
Browse files Browse the repository at this point in the history
* Turn tests back on

* Fixing tests

* Change refresh logic

* Handle browsing away properly
add some types
lint

* Better message for snapshots too

* remove unused

* It should have none to start

* Rename test and make positive test for button

* Snapshot/snapshot and requested/create
Fix test
Use proper type for booleans
  • Loading branch information
david4096 authored Sep 9, 2019
1 parent 1fb29da commit 09a0640
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 69 deletions.
38 changes: 20 additions & 18 deletions cypress/integration/group2/myworkflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,26 @@ describe('Dockstore my workflows', () => {
cy.get('[data-cy=save-version').click();
cy.get('[data-cy=save-version').should('not.be.visible');
});
// TODO turn back on
// it('Should be able to snapshot', () => {
// cy.visit('/my-workflows/github.com/A/l');
// cy.url().should('eq', Cypress.config().baseUrl + '/my-workflows/github.com/A/l');
// goToTab('Versions');
// cy.get('[data-cy=dockstore-snapshot-locked]').should('have.length', 0);
//
// cy.get('[data-cy=dockstore-snapshot-unlocked]')
// .its('length')
// .should('be.gt', 0);
//
// cy.get('[data-cy=dockstore-snapshot]')
// .first()
// .click();
//
// cy.wait(250);
// cy.get('[data-cy=dockstore-snapshot-locked').should('have.length', 1);
// });

it('Should be able to snapshot', () => {
cy.visit('/my-workflows/github.com/A/l');
cy.url().should('eq', Cypress.config().baseUrl + '/my-workflows/github.com/A/l');
goToTab('Versions');
cy.get('[data-cy=dockstore-snapshot-locked]').should('have.length', 0);

cy.get('[data-cy=dockstore-snapshot-unlocked]')
.its('length')
.should('be.gt', 0);

cy.get('[data-cy=dockstore-snapshot]')
.first()
.click();

cy.get('[data-cy=confirm-dialog-button]').click();

cy.wait(250);
cy.get('[data-cy=dockstore-snapshot-locked').should('have.length', 1);
});
});

describe('Look at an invalid workflow', () => {
Expand Down
7 changes: 4 additions & 3 deletions cypress/integration/immutableDatabaseTests/workflowDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,20 @@ describe('Dockstore Workflow Details', () => {
cy.url().should('eq', Cypress.config().baseUrl + '/workflows/github.com/A/l:master?tab=launch');
});

it('Change tab to versions and not see snapshot', () => {
it('Change tab to versions and not see snapshotted version', () => {
goToTab('Versions');
cy
.get('tbody>tr')
.should('have.length', 1); // 1 Version and no warning line
cy.url().should('eq', Cypress.config().baseUrl + '/workflows/github.com/A/l:master?tab=versions');
// Buttons to create snapshots are hidden on public
cy.get('[data-cy=dockstore-snapshot]').should('not.be.visible');
cy.get('[data-cy=dockstore-snapshot-locked]').should('have.length', 0);

cy.get('[data-cy=dockstore-snapshot-unlocked]')
.its('length')
.should('be.gt', 0);
cy.get('[data-cy=dockstore-snapshot]')
.should('not.be.visible');

});

describe('Change tab to files', () => {
Expand Down
29 changes: 0 additions & 29 deletions src/app/workflow/view/view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { Component, Input, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material';
import { EntryType } from 'app/shared/enum/entry-type';
import { BioWorkflow } from 'app/shared/swagger/model/bioWorkflow';
import { WorkflowVersion } from 'app/shared/swagger/model/workflowVersion';
import { Service } from 'app/shared/swagger/model/service';
import { Observable } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
Expand Down Expand Up @@ -97,34 +96,6 @@ export class ViewWorkflowComponent extends View implements OnInit {
});
}

/**
* Updates the workflow version and alerts the Dockstore User with success
* or failure.
*
* @private
* @memberof ViewWorkflowComponent
*/
private updateWorkflowToSnapshot(version): void {
// Clear sourcefiles to shrink version
version.sourceFiles = [];

this.workflowsService.updateWorkflowVersion(this.workflow.id, [version]).subscribe(
workflowVersions => {
this.alertService.detailedSuccess('Snapshot successfully created!');
const workflow = { ...this.workflowQuery.getActive() };
workflow.workflowVersions = workflowVersions;
this.workflowService.setWorkflow(workflow);
},
error => {
if (error) {
this.alertService.detailedError(error);
} else {
this.alertService.simpleError();
}
}
);
}

/**
* Handles the create DOI button being clicked
*
Expand Down
44 changes: 25 additions & 19 deletions src/app/workflow/view/view.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ import { Injectable } from '@angular/core';
import { HttpErrorResponse } from '@angular/common/http';
import { MatDialog } from '@angular/material';
import { BehaviorSubject, Observable, of as observableOf, Subject } from 'rxjs';
import { concatMap } from 'rxjs/operators';
import { AlertService } from '../../shared/alert/state/alert.service';
import { RefreshService } from '../../shared/refresh.service';
import { WorkflowQuery } from '../../shared/state/workflow.query';
import { WorkflowsService } from '../../shared/swagger/api/workflows.service';
import { SourceFile } from '../../shared/swagger/model/sourceFile';
import { WorkflowService } from '../../shared/state/workflow.service';
import { Workflow, WorkflowVersion } from '../../shared/swagger';
import { ConfirmationDialogService } from '../../confirmation-dialog/confirmation-dialog.service';
Expand All @@ -37,9 +35,7 @@ export class ViewService {
private confirmationDialogService: ConfirmationDialogService,
private workflowQuery: WorkflowQuery,
private workflowService: WorkflowService,
private workflowsService: WorkflowsService,
private refreshService: RefreshService,
private matDialog: MatDialog
private workflowsService: WorkflowsService
) {}

/**
Expand All @@ -52,13 +48,16 @@ export class ViewService {
private updateWorkflowToSnapshot(workflow: Workflow, version: WorkflowVersion, cb: Function): void {
const snapshot: WorkflowVersion = { ...version, frozen: true };
this.workflowsService.updateWorkflowVersion(workflow.id, [snapshot]).subscribe(
workflowVersions => {
(workflowVersions: Array<WorkflowVersion>) => {
this.alertService.detailedSuccess(`A snapshot was created for workflow
"${workflow.workflowName}" version "${version.name}"!`);
const selectedWorkflow = { ...this.workflowQuery.getActive() };
if (selectedWorkflow.id === workflow.id) {
this.workflowService.setWorkflow({ ...selectedWorkflow, workflowVersions: workflowVersions });
}
cb(workflowVersions);
const activeWorkflow = { ...this.workflowQuery.getActive() };
workflow.workflowVersions = workflowVersions;
this.workflowService.setWorkflow(activeWorkflow);
},
error => {
(error: HttpErrorResponse) => {
if (error) {
this.alertService.detailedError(error);
} else {
Expand Down Expand Up @@ -102,7 +101,8 @@ export class ViewService {
private showRequestDOIDialog(workflow: Workflow, version: WorkflowVersion): void {
const dialogData: ConfirmationDialogData = {
message: `A Digital Object Identifier (DOI) allows a version to be easily cited in publications and can't be
undone, though some metadata will remain editable. Are you sure you'd like to create a DOI for version
undone, though some metadata will remain editable. It can take some time to request a DOI.
Are you sure you'd like to create a DOI for version
<b>${version.name}</b>?`,
title: 'Issue DOI',
confirmationButtonText: 'Issue DOI',
Expand All @@ -114,8 +114,8 @@ export class ViewService {
this.workflowsService
.requestDOIForWorkflowVersion(workflow.id, version.id)
.subscribe(
versions => this.requestDOISuccess(version, versions),
errorResponse => this.alertService.detailedError(errorResponse)
(versions: Array<WorkflowVersion>) => this.requestDOISuccess({ ...workflow, workflowVersions: versions }, version),
(errorResponse: HttpErrorResponse) => this.alertService.detailedError(errorResponse)
);
} else {
this.alertService.detailedSuccess('You cancelled DOI issuance.');
Expand All @@ -129,10 +129,13 @@ export class ViewService {
* @private
* @memberof ViewService
*/
private requestDOISuccess(version: WorkflowVersion, workflowVersions: Array<WorkflowVersion>): void {
const newSelectedVersion = workflowVersions.find(v => v.id === version.id);
this.workflowService.setWorkflowVersion(newSelectedVersion);
this.alertService.simpleSuccess();
private requestDOISuccess(workflow: Workflow, version: WorkflowVersion): void {
const selectedWorkflow = { ...this.workflowQuery.getActive() };
if (selectedWorkflow.id === workflow.id) {
this.workflowService.setWorkflow(workflow);
}
this.alertService.detailedSuccess(`A Digital Object Identifier (DOI) was created for workflow
"${workflow.workflowName}" version "${version.name}"!`);
}

/**
Expand All @@ -153,9 +156,12 @@ export class ViewService {
confirmationButtonText: 'Snapshot Version',
cancelButtonText: 'Cancel'
};
this.confirmationDialogService.openDialog(dialogData, bootstrap4mediumModalSize).subscribe(confirmationResult => {
this.confirmationDialogService.openDialog(dialogData, bootstrap4mediumModalSize).subscribe((confirmationResult: boolean) => {
if (confirmationResult) {
this.updateWorkflowToSnapshot(workflow, version, () => this.alertService.detailedSuccess('Snapshot successfully created!'));
this.updateWorkflowToSnapshot(workflow, version, () => {
this.alertService.detailedSuccess(`A snapshot was created for workflow
"${workflow.workflowName}" version "${version.name}"!`);
});
} else {
this.alertService.detailedSuccess('You cancelled creating a snapshot.');
}
Expand Down

0 comments on commit 09a0640

Please sign in to comment.