Skip to content

Commit

Permalink
Merge pull request #4940 from HSLdevcom/DT-6229
Browse files Browse the repository at this point in the history
DT-6229 Service alerts should be shown before cancellations
  • Loading branch information
vesameskanen authored Jan 30, 2024
2 parents cf20ae2 + 067b6c6 commit f5cffbd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
10 changes: 8 additions & 2 deletions app/component/AlertList.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '../util/alertUtils';
import { AlertShape } from '../util/shapes';
import withBreakpoint from '../util/withBreakpoint';
import { AlertEntityType } from '../constants';
import { AlertEntityType, AlertSeverityLevelType } from '../constants';

const AlertList = ({
cancelations,
Expand Down Expand Up @@ -41,9 +41,15 @@ const AlertList = ({
);
}

// Cancelations should be between non-info alerts and info alerts
const alertsSorted = [
...validAlerts
.filter(alert => alert.alertSeverityLevel !== AlertSeverityLevelType.Info)
.sort(alertCompare),
...validCancelations.sort(alertCompare),
...validAlerts.sort(alertCompare),
...validAlerts.filter(
alert => alert.alertSeverityLevel === AlertSeverityLevelType.Info,
),
];

return (
Expand Down
10 changes: 5 additions & 5 deletions test/unit/component/AlertList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ describe('<AlertList />', () => {
expect(wrapper.find('.no-alerts-container')).to.have.lengthOf(1);
});

it('should order the cancelations and service alerts by route shortName', () => {
it('should order the cancelations and service alerts by route shortName and put alerts first', () => {
const props = {
currentTime: 1547464414,
cancelations: [
{
alertHeaderText: 'first',
alertHeaderText: 'third',
alertSeverityLevel: 'SEVERE',
effectiveStartDate: 1547464413,
entities: [
Expand All @@ -34,7 +34,7 @@ describe('<AlertList />', () => {
],
},
{
alertHeaderText: 'second',
alertHeaderText: 'fourth',
alertSeverityLevel: 'SEVERE',
effectiveStartDate: 1547464413,
entities: [
Expand All @@ -49,7 +49,7 @@ describe('<AlertList />', () => {
],
serviceAlerts: [
{
alertHeaderText: 'fourth',
alertHeaderText: 'second',
alertSeverityLevel: 'SEVERE',
effectiveStartDate: 1547464413,
entities: [
Expand All @@ -62,7 +62,7 @@ describe('<AlertList />', () => {
],
},
{
alertHeaderText: 'third',
alertHeaderText: 'first',
alertSeverityLevel: 'SEVERE',
effectiveStartDate: 1547464413,
entities: [
Expand Down

0 comments on commit f5cffbd

Please sign in to comment.