Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The risk profile draft is shown in the dropdown on the Download ZIP popup; 404 error on redirect #569

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ describe('DownloadReportZipComponent', () => {
tick();

expect(testrunServiceMock.downloadZip).toHaveBeenCalled();
expect(router.url).not.toBe(Routes.RiskAssessment);
openSpy.calls.reset();
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ export class DownloadReportZipComponent
}
if (profile === null) {
this.route.navigate([Routes.RiskAssessment]);
}

if (this.url != null) {
} else if (this.url != null) {
this.testrunService.downloadZip(this.getZipLink(this.url), profile);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';

import { DownloadZipModalComponent } from './download-zip-modal.component';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { PROFILE_MOCK, PROFILE_MOCK_2 } from '../../mocks/profile.mock';
import {
PROFILE_MOCK,
PROFILE_MOCK_2,
PROFILE_MOCK_3,
} from '../../mocks/profile.mock';
import { of } from 'rxjs';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { TestRunService } from '../../services/test-run.service';
Expand Down Expand Up @@ -41,7 +45,7 @@ describe('DownloadZipModalComponent', () => {
TestBed.overrideProvider(MAT_DIALOG_DATA, {
useValue: {
hasProfiles: true,
profiles: [PROFILE_MOCK_2, PROFILE_MOCK],
profiles: [PROFILE_MOCK_2, PROFILE_MOCK, PROFILE_MOCK_3],
},
});

Expand Down Expand Up @@ -106,7 +110,7 @@ describe('DownloadZipModalComponent', () => {
closeSpy.calls.reset();
});

it('should have sorted profiles', async () => {
it('should have filtered and sorted profiles', async () => {
expect(component.profiles).toEqual([PROFILE_MOCK, PROFILE_MOCK_2]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import {
MatDialogRef,
} from '@angular/material/dialog';
import { EscapableDialogComponent } from '../escapable-dialog/escapable-dialog.component';
import { Profile, RiskResultClassName } from '../../model/profile';
import {
Profile,
ProfileStatus,
RiskResultClassName,
} from '../../model/profile';
import { MatButtonModule } from '@angular/material/button';
import { CommonModule, NgForOf, NgIf } from '@angular/common';
import { MatFormField } from '@angular/material/form-field';
Expand Down Expand Up @@ -47,7 +51,9 @@ export class DownloadZipModalComponent extends EscapableDialogComponent {
) {
super(dialogRef);
if (data.hasProfiles) {
this.profiles = [...data.profiles] as Profile[];
this.profiles = data.profiles.filter(
profile => profile.status === ProfileStatus.VALID
);
this.profiles.sort((a, b) =>
a.name.toLowerCase().localeCompare(b.name.toLowerCase())
);
Expand Down
2 changes: 2 additions & 0 deletions modules/ui/src/app/mocks/profile.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ export const PROFILE_MOCK: Profile = {
};

export const PROFILE_MOCK_2: Profile = {
status: ProfileStatus.VALID,
name: 'Second profile name',
questions: [],
};

export const PROFILE_MOCK_3: Profile = {
status: ProfileStatus.DRAFT,
name: 'Third profile name',
questions: [],
};
Expand Down