Skip to content
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
2 changes: 1 addition & 1 deletion modules/ui/src/app/mocks/profile.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export const RENAME_PROFILE_MOCK = {
export const COPY_PROFILE_MOCK: Profile = {
name: 'Copy of Primary profile',
status: ProfileStatus.VALID,
created: '2024-05-23 12:38:26',
created: '2025-05-23 12:38:26',
questions: [
{
question: 'What is the email of the device owner(s)?',
Expand Down
7 changes: 4 additions & 3 deletions modules/ui/src/app/services/test-run.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { AppState } from '../store/state';
import { Certificate } from '../model/certificate';
import { certificate } from '../mocks/certificate.mock';
import {
COPY_PROFILE_MOCK,
NEW_PROFILE_MOCK,
PROFILE_FORM,
PROFILE_MOCK,
Expand Down Expand Up @@ -521,9 +522,9 @@ describe('TestRunService', () => {
req.flush(true);
});

it('fetchProfiles should return profiles', () => {
it('fetchProfiles should return sorted list of profiles', () => {
service.fetchProfiles().subscribe(res => {
expect(res).toEqual([PROFILE_MOCK]);
expect(res).toEqual([COPY_PROFILE_MOCK, PROFILE_MOCK]);
});

const req = httpTestingController.expectOne(
Expand All @@ -532,7 +533,7 @@ describe('TestRunService', () => {

expect(req.request.method).toBe('GET');

req.flush([PROFILE_MOCK]);
req.flush([PROFILE_MOCK, COPY_PROFILE_MOCK]);
});

it('deleteProfile should delete profile', () => {
Expand Down
11 changes: 10 additions & 1 deletion modules/ui/src/app/services/test-run.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,16 @@ export class TestRunService {
}

fetchProfiles(): Observable<Profile[]> {
return this.http.get<Profile[]>(`${API_URL}/profiles`);
return this.http
.get<Required<Profile>[]>(`${API_URL}/profiles`)
.pipe(
map(items =>
items.sort(
(a, b) =>
new Date(b.created).getTime() - new Date(a.created).getTime()
)
)
);
}

deleteProfile(name: string): Observable<boolean> {
Expand Down
Loading