Skip to content

Commit

Permalink
Feature/organization fixes (#541)
Browse files Browse the repository at this point in the history
* Don't null the description, change URL

* Fix ng test

* Add cypress test
  • Loading branch information
garyluu authored Feb 8, 2019
1 parent c4248f4 commit eb05f37
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions cypress/integration/group3/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand Down
8 changes: 6 additions & 2 deletions src/app/organizations/state/register-organization.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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;
Expand All @@ -177,13 +178,16 @@ export class RegisterOrganizationService {
location: organizationFormState.location,
email: organizationFormState.contactEmail,
status: Organisation.StatusEnum.PENDING,
description: organizationDescription,
users: []
};
this.alertService.start('Updating organization');
this.organisationsService.updateOrganisation(organizationId, editedOrganization).subscribe((organization: Organisation) => {
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');
Expand Down

0 comments on commit eb05f37

Please sign in to comment.