Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

[DO-1583][minor] Sorting shared parts #55

Merged
merged 20 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
3c659d6
fix: renamed the wrongly named filter columns and added the sending o…
JoelDietz Nov 17, 2023
87ddc2e
Merge branch 'dev' into fix/DO-1294_brokenMyPartsEntrys
JoelDietz Nov 17, 2023
e2c4820
fixed the naming of the sort option sent in the status selection.
JoelDietz Nov 17, 2023
605841d
fix: fixed the Site ID (catenaxSiteId) and partId reweird to manufact…
JoelDietz Nov 20, 2023
c716213
Revert "fix: fixed the Site ID (catenaxSiteId) and partId reweird to …
JoelDietz Nov 20, 2023
c14d9a6
fixed the partID for myParts and shared Parts
JoelDietz Nov 20, 2023
aa27636
Fix: catenaXSideId wrong mocking data, css class error that leads to …
JoelDietz Nov 21, 2023
e5f5468
chore added one missed test
JoelDietz Nov 21, 2023
1a69715
disabled third click sort and changed sorting arrow to be resetted if…
JoelDietz Nov 20, 2023
df08dae
Revert "fixed the partID for myParts and shared Parts"
JoelDietz Nov 21, 2023
32e6133
feature: changed the display of the multi sort and the tool tip
JoelDietz Nov 21, 2023
585e95c
merged dev in and fixed the arising problems.
JoelDietz Nov 22, 2023
feffc58
fix: alerts received not sorted correctly in the beginning. Also fixe…
JoelDietz Nov 22, 2023
4ea6f01
Merge branch 'dev' into feature/DO-1583_sortingSharedParts
JoelDietz Nov 22, 2023
1a70963
fix: dashboard table takes the height of the my parts table.
JoelDietz Nov 22, 2023
01a1c06
fix: tests and duplication
JoelDietz Nov 22, 2023
f1c1841
fix: test
JoelDietz Nov 22, 2023
9c98763
fix: test
JoelDietz Nov 22, 2023
01f001b
fix: duplication
JoelDietz Nov 22, 2023
b53097e
fix: more test things
JoelDietz Nov 23, 2023
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 @@ -25,7 +25,6 @@ import { renderComponent } from '@tests/test-render.utils';

import { AlertsComponent } from './alerts.component';


describe('AlertsComponent', () => {
const renderAlerts = async () => {
return await renderComponent(AlertsComponent, {
Expand All @@ -51,14 +50,18 @@ describe('AlertsComponent', () => {
const { fixture } = await renderAlerts();
const alertsComponent = fixture.componentInstance;

let setTableFunctionSpy = spyOn<any>(alertsComponent, "setTableSortingList").and.callThrough();
let setTableFunctionSpy = spyOn<any>(alertsComponent, 'setTableSortingList').and.callThrough();
let statusColumnHeader = await screen.findByText('table.column.status');
await waitFor(() => { fireEvent.click(statusColumnHeader); }, { timeout: 3000 });

await waitFor(
() => {
fireEvent.click(statusColumnHeader);
},
{ timeout: 3000 },
);

expect(setTableFunctionSpy).toHaveBeenCalledWith(['status', 'asc'], "received");
expect(setTableFunctionSpy).toHaveBeenCalledWith(['status', 'asc'], 'received');

expect(alertsComponent['alertReceivedSortList']).toEqual([["status", "asc"]]);
expect(alertsComponent['alertReceivedSortList']).toEqual([['status', 'asc']]);
});

it('should sort queued and requested alerts after column status', async () => {
Expand All @@ -67,83 +70,61 @@ describe('AlertsComponent', () => {

fireEvent.click(await waitFor(() => screen.getByText('commonAlert.tabs.queuedAndRequested')));

let setTableFunctionSpy = spyOn<any>(alertsComponent, "setTableSortingList").and.callThrough();
let setTableFunctionSpy = spyOn<any>(alertsComponent, 'setTableSortingList').and.callThrough();
let statusColumnHeader = await screen.findByText('table.column.status');
await waitFor(() => { fireEvent.click(statusColumnHeader); }, { timeout: 3000 });

await waitFor(
() => {
fireEvent.click(statusColumnHeader);
},
{ timeout: 3000 },
);

expect(setTableFunctionSpy).toHaveBeenCalledWith(['status', 'asc'], "queued-and-requested");
expect(setTableFunctionSpy).toHaveBeenCalledWith(['status', 'asc'], 'queued-and-requested');

expect(alertsComponent['alertQueuedAndRequestedSortList']).toEqual([["status", "asc"]]);
expect(alertsComponent['alertQueuedAndRequestedSortList']).toEqual([['status', 'asc']]);
});


it('should multisort after column description and status', async () => {
const { fixture } = await renderAlerts();
const alertsComponent = fixture.componentInstance;

let setTableFunctionSpy = spyOn<any>(alertsComponent, "setTableSortingList").and.callThrough();
let setTableFunctionSpy = spyOn<any>(alertsComponent, 'setTableSortingList').and.callThrough();
let descriptionColumnHeader = await screen.findByText('table.column.description');
await waitFor(() => { fireEvent.click(descriptionColumnHeader); }, { timeout: 3000 });
let statusHeader = await screen.findByText('table.column.status')
await waitFor(
() => {
fireEvent.click(descriptionColumnHeader);
},
{ timeout: 3000 },
);
let statusHeader = await screen.findByText('table.column.status');

await waitFor(() => {
fireEvent.keyDown(statusHeader, {
ctrlKey: true,
charCode: 17
})
})
charCode: 17,
});
});
expect(alertsComponent['ctrlKeyState']).toBeTruthy();
await waitFor(() => {
fireEvent.click(statusHeader)
fireEvent.click(statusHeader);
});

await waitFor(() => {
fireEvent.keyUp(statusHeader, {
ctrlKey: true,
charCode: 17
})
})

await waitFor(() => { fireEvent.click(statusHeader) });


expect(setTableFunctionSpy).toHaveBeenCalledWith(['description', 'asc'], "received");
expect(setTableFunctionSpy).toHaveBeenCalledWith(['status', 'asc'], "received");
expect(alertsComponent['alertReceivedSortList']).toEqual([["description", "asc"], ["status", "desc"]]);
});

it('should reset sorting after third click', async () => {
const { fixture } = await renderAlerts();
const alertsComponent = fixture.componentInstance;

let descriptionColumnHeader = await screen.findByText('table.column.description');
await waitFor(() => { fireEvent.click(descriptionColumnHeader); }, { timeout: 3000 });
let statusColumnHeader = await screen.findByText('table.column.status')

await waitFor(() => {
fireEvent.keyDown(statusColumnHeader, {
ctrlKey: true,
charCode: 17
})
})

await waitFor(() => {
fireEvent.click(statusColumnHeader)
charCode: 17,
});
});

await waitFor(() => {
fireEvent.keyUp(statusColumnHeader, {
ctrlKey: true,
charCode: 17
})
})

await waitFor(() => { fireEvent.click(statusColumnHeader) });

await waitFor(() => { fireEvent.click(statusColumnHeader) });
fireEvent.click(statusHeader);
});

expect(alertsComponent['alertReceivedSortList']).toEqual([]);
expect(setTableFunctionSpy).toHaveBeenCalledWith(['description', 'asc'], 'received');
expect(setTableFunctionSpy).toHaveBeenCalledWith(['status', 'asc'], 'received');
expect(alertsComponent['alertReceivedSortList']).toEqual([
['description', 'asc'],
['status', 'desc'],
]);
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class DashboardFacade {
private readonly partsService: PartsService,
private readonly investigationsService: InvestigationsService,
private readonly alertsService: AlertsService,
) { }
) {}

public get numberOfMyParts$(): Observable<View<number>> {
return this.dashboardState.numberOfMyParts$;
Expand Down Expand Up @@ -87,7 +87,6 @@ export class DashboardFacade {
this.dashboardState.setNumberOfOtherParts({ data: dashboardStats.otherParts });
this.dashboardState.setNumberOfInvestigations({ data: dashboardStats.investigations || 0 });
this.dashboardState.setNumberOfAlerts({ data: dashboardStats.alerts || 0 });

},
error: error => {
this.dashboardState.setNumberOfMyParts({ error });
Expand All @@ -113,7 +112,7 @@ export class DashboardFacade {

private setAlerts(): void {
this.alertSubscription?.unsubscribe();
this.alertSubscription = this.alertsService.getReceivedAlerts(0, 5, null).subscribe({
this.alertSubscription = this.alertsService.getReceivedAlerts(0, 5, []).subscribe({
next: data => this.dashboardState.setAlerts({ data }),
error: (error: Error) => this.dashboardState.setAlerts({ error }),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,93 +68,83 @@ describe('InvestigationsComponent', () => {

it('should sort received investigations after column status', async () => {
const { fixture } = await renderInvestigations();
const investigationComponent = fixture.componentInstance;
const investigationComponent = fixture.componentInstance;

let setTableFunctionSpy = spyOn<any>(investigationComponent, "setTableSortingList").and.callThrough();
let setTableFunctionSpy = spyOn<any>(investigationComponent, 'setTableSortingList').and.callThrough();
let statusColumnHeader = await screen.findByText('table.column.status');
await waitFor(() => {fireEvent.click(statusColumnHeader);}, {timeout: 3000});
await waitFor(
() => {
fireEvent.click(statusColumnHeader);
},
{ timeout: 3000 },
);

expect(setTableFunctionSpy).toHaveBeenCalledWith(['status', 'asc'], 'received');

expect(setTableFunctionSpy).toHaveBeenCalledWith(['status', 'asc'], "received" );

expect(investigationComponent['investigationReceivedSortList']).toEqual([["status", "asc"]]);
expect(investigationComponent['investigationReceivedSortList']).toEqual([['status', 'asc']]);
});

it('should sort queued and requested investigations after column status', async () => {
const { fixture } = await renderInvestigations();
const investigationComponent = fixture.componentInstance;
const investigationComponent = fixture.componentInstance;

fireEvent.click(await waitFor(() => screen.getByText('commonInvestigation.tabs.queuedAndRequested')));

let setTableFunctionSpy = spyOn<any>(investigationComponent, "setTableSortingList").and.callThrough();
let setTableFunctionSpy = spyOn<any>(investigationComponent, 'setTableSortingList').and.callThrough();
let statusColumnHeader = await screen.findByText('table.column.status');
await waitFor(() => {fireEvent.click(statusColumnHeader);}, {timeout: 3000});

await waitFor(
() => {
fireEvent.click(statusColumnHeader);
},
{ timeout: 3000 },
);

expect(setTableFunctionSpy).toHaveBeenCalledWith(['status', 'asc'], "queued-and-requested" );
expect(setTableFunctionSpy).toHaveBeenCalledWith(['status', 'asc'], 'queued-and-requested');

expect(investigationComponent['investigationQueuedAndRequestedSortList']).toEqual([["status", "asc"]]);
expect(investigationComponent['investigationQueuedAndRequestedSortList']).toEqual([['status', 'asc']]);
});


it('should multisort after column description and status', async () => {
const { fixture } = await renderInvestigations();
const investigationsComponent = fixture.componentInstance;
const investigationsComponent = fixture.componentInstance;

let setTableFunctionSpy = spyOn<any>(investigationsComponent, "setTableSortingList").and.callThrough();
let setTableFunctionSpy = spyOn<any>(investigationsComponent, 'setTableSortingList').and.callThrough();
let descriptionColumnHeader = await screen.findByText('table.column.description');
await waitFor(() => {fireEvent.click(descriptionColumnHeader);}, {timeout: 3000});
let statusHeader = await screen.findByText('table.column.status')
await waitFor(
() => {
fireEvent.click(descriptionColumnHeader);
},
{ timeout: 3000 },
);
let statusHeader = await screen.findByText('table.column.status');

await waitFor(() => {fireEvent.keyDown(statusHeader, {
ctrlKey: true,
charCode: 17
})})
await waitFor(() => {
fireEvent.keyDown(statusHeader, {
ctrlKey: true,
charCode: 17,
});
});
expect(investigationsComponent['ctrlKeyState']).toBeTruthy();
await waitFor(() => {
fireEvent.click(statusHeader)
fireEvent.click(statusHeader);
});

await waitFor(() => {fireEvent.keyUp(statusHeader, {
ctrlKey: true,
charCode: 17
})})

await waitFor(() => {fireEvent.click(statusHeader)});


expect(setTableFunctionSpy).toHaveBeenCalledWith(['description', 'asc'], "received" );
expect(setTableFunctionSpy).toHaveBeenCalledWith(['status', 'asc'], "received" );
expect(investigationsComponent['investigationReceivedSortList']).toEqual([["description", "asc"], ["status", "desc"]]);
});

it('should reset sorting after third click', async () => {
const { fixture } = await renderInvestigations();
const investigationsComponent = fixture.componentInstance;

let descriptionColumnHeader = await screen.findByText('table.column.description');
await waitFor(() => {fireEvent.click(descriptionColumnHeader);}, {timeout: 3000});
let statusColumnHeader = await screen.findByText('table.column.status')

await waitFor(() => {fireEvent.keyDown(statusColumnHeader, {
ctrlKey: true,
charCode: 17
})})

await waitFor(() => {
fireEvent.click(statusColumnHeader)
fireEvent.keyUp(statusHeader, {
ctrlKey: true,
charCode: 17,
});
});

await waitFor(() => {fireEvent.keyUp(statusColumnHeader, {
ctrlKey: true,
charCode: 17
})})

await waitFor(() => {fireEvent.click(statusColumnHeader)});

await waitFor(() => {fireEvent.click(statusColumnHeader)});
await waitFor(() => {
fireEvent.click(statusHeader);
});

expect(investigationsComponent['investigationReceivedSortList']).toEqual([]);
expect(setTableFunctionSpy).toHaveBeenCalledWith(['description', 'asc'], 'received');
expect(setTableFunctionSpy).toHaveBeenCalledWith(['status', 'asc'], 'received');
expect(investigationsComponent['investigationReceivedSortList']).toEqual([
['description', 'asc'],
['status', 'desc'],
]);
});

});
Loading
Loading