From eb05f371877cb97d634fc9a127d283597931a365 Mon Sep 17 00:00:00 2001 From: Gary Luu Date: Fri, 8 Feb 2019 15:05:33 -0500 Subject: [PATCH] Feature/organization fixes (#541) * Don't null the description, change URL * Fix ng test * Add cypress test --- cypress/integration/group3/organizations.ts | 1 + .../state/register-organization.service.spec.ts | 4 ++-- .../organizations/state/register-organization.service.ts | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cypress/integration/group3/organizations.ts b/cypress/integration/group3/organizations.ts index f64d1513f4..b060f3042f 100644 --- a/cypress/integration/group3/organizations.ts +++ b/cypress/integration/group3/organizations.ts @@ -73,6 +73,7 @@ describe('Dockstore Organizations', () => { typeInInput('Location', 'UCSC Basement'); typeInInput('Contact Email Address', 'asdf@asdf.com'); cy.get('#createOrUpdateOrganizationButton').should('be.visible').should('not.be.disabled').click(); + cy.url().should('eq', Cypress.config().baseUrl + '/organizations/Potatoe'); }); it('have new fields reflected', () => { diff --git a/src/app/organizations/state/register-organization.service.spec.ts b/src/app/organizations/state/register-organization.service.spec.ts index a3b7292487..86c60cbe4d 100644 --- a/src/app/organizations/state/register-organization.service.spec.ts +++ b/src/app/organizations/state/register-organization.service.spec.ts @@ -50,7 +50,7 @@ describe('RegisterOrganizationService', () => { it('should handle error when updating an organization', () => { organisationsServiceSpy.updateOrganisation.and.returnValue(throwError('test 404 error')); - registerOrganizationService.updateOrganization(exampleFormState, 1); + registerOrganizationService.updateOrganization(exampleFormState, 1, 'potato'); // Expected createOrganisation call to be called (even though it will fail) expect(organisationsServiceSpy.updateOrganisation.calls.count()).toBe(1, 'spy method was called once'); @@ -62,7 +62,7 @@ describe('RegisterOrganizationService', () => { organisationsServiceSpy.updateOrganisation.and.returnValue(observableOf(null)); matDialogSpy.closeAll.and.returnValue(null); - registerOrganizationService.updateOrganization(exampleFormState, 1); + registerOrganizationService.updateOrganization(exampleFormState, 1, 'potato'); // Expected createOrganisation call to be called (and it will succeed) expect(organisationsServiceSpy.updateOrganisation.calls.count()).toBe(1, 'spy method was called once'); diff --git a/src/app/organizations/state/register-organization.service.ts b/src/app/organizations/state/register-organization.service.ts index b9b5ece826..413c54276f 100644 --- a/src/app/organizations/state/register-organization.service.ts +++ b/src/app/organizations/state/register-organization.service.ts @@ -64,7 +64,7 @@ export class RegisterOrganizationService { if (data.mode === TagEditorMode.Add) { this.createOrganization(form.value); } else { - this.updateOrganization(form.value, data.organization.id); + this.updateOrganization(form.value, data.organization.id, data.organization.description); } } @@ -165,7 +165,8 @@ export class RegisterOrganizationService { * @returns {void} * @memberof RegisterOrganizationService */ - updateOrganization(organizationFormState: FormsState['registerOrganization'], organizationId: number): void { + updateOrganization(organizationFormState: FormsState['registerOrganization'], organizationId: number, + organizationDescription: string): void { if (!organizationFormState) { console.error('Something has gone terribly wrong with the form manager'); return; @@ -177,6 +178,7 @@ export class RegisterOrganizationService { location: organizationFormState.location, email: organizationFormState.contactEmail, status: Organisation.StatusEnum.PENDING, + description: organizationDescription, users: [] }; this.alertService.start('Updating organization'); @@ -184,6 +186,8 @@ export class RegisterOrganizationService { this.matDialog.closeAll(); if (organization) { this.alertService.detailedSuccess(); + // Watch out if this function is executed on Dockstore UI where it's not /organizations/{organizationId} + this.router.navigate(['/organizations', editedOrganization.name]); this.organizationService.updateOrganizationFromID(organizationId); } else { console.error('No idea how it would successfully return no organization');