Skip to content

Commit

Permalink
Implement Date Navigation Links in Process Monitoring Screen (#6241)
Browse files Browse the repository at this point in the history
Signed-off-by: vlo-rte <valerie.longa@rte-france.com>
  • Loading branch information
vlo-rte authored and freddidierRTE committed Apr 22, 2024
1 parent 02c5f1d commit a78868b
Show file tree
Hide file tree
Showing 8 changed files with 593 additions and 73 deletions.
65 changes: 65 additions & 0 deletions src/test/cypress/cypress/integration/MonitoringProcessus.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* Copyright (c) 2024, RTE (http://www.rte-france.com)
* See AUTHORS.txt
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* SPDX-License-Identifier: MPL-2.0
* This file is part of the OperatorFabric project.
*/

import {OpfabGeneralCommands} from "../support/opfabGeneralCommands"
import {ScriptCommands} from "../support/scriptCommands";

describe('Monitoring processus screen tests', function () {

const opfab = new OpfabGeneralCommands();
const script = new ScriptCommands();

before('Set up configuration', function () {
script.deleteAllCards();
script.loadTestConf();
script.send6TestCards();
});


it('Check navigation between dates', function () {
const currentDate = new Date(2024, 3, 16, 11, 35);
opfab.loginWithUser('operator2_fr');
cy.clock(currentDate);

opfab.navigateToMonitoringProcessus();
cy.waitDefaultTime();

checkDatePickerValue('#opfab-active-from', '2024-01-01T00:00');
checkDatePickerValue('#opfab-active-to', '2025-01-01T00:00');

navigateBackward();
checkDatePickerValue('#opfab-active-from', '2023-01-01T00:00');
checkDatePickerValue('#opfab-active-to', '2024-01-01T00:00');

navigateForward();
navigateForward();
checkDatePickerValue('#opfab-active-from', '2025-01-01T00:00');
checkDatePickerValue('#opfab-active-to', '2026-01-01T00:00');

clickMonthPeriod();
checkDatePickerValue('#opfab-active-from', '2024-04-01T00:00');
checkDatePickerValue('#opfab-active-to', '2024-05-01T00:00');
});

function checkDatePickerValue(inputId, value) {
cy.get(inputId).should('have.value', value);
}

function navigateBackward() {
cy.get('#opfab-processmonitoring-left-arrow').click();
}

function navigateForward() {
cy.get('#opfab-processmonitoring-right-arrow').click();
}

function clickMonthPeriod() {
cy.get('#opfab-processmonitoring-period-month').click();
}
});
5 changes: 5 additions & 0 deletions src/test/cypress/cypress/support/opfabGeneralCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ export class OpfabGeneralCommands extends OpfabCommands {
cy.get('of-dashboard').should('exist');
}

navigateToMonitoringProcessus = function () {
cy.get('#opfab-navbar-menu-processmonitoring').click();
cy.get('of-processmonitoring').should('exist');
}

navigateToRealTimeUsers = function () {
cy.get('#opfab-navbar-drop-user-menu').click();
cy.get('#opfab-navbar-right-menu-realtimeusers').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,4 +445,144 @@ describe('Process Monitoring view ', () => {
expect(mustViewAllCardsFeatureBeDisplayed).toBeTrue();
});
});

describe('get dates after period click if the current day/time is 2024-04-29 15:32 (summer time)', () => {
it('should return 2024-01-01T00:00 and 2025-01-01T00:00 if the user clicks on the year button', async () => {
jasmine.clock().mockDate(new Date(2024, 3, 29, 15, 32));
const processMonitoringView: ProcessMonitoringView = new ProcessMonitoringView();
const dates = processMonitoringView.getDatesAfterPeriodClick('year');
expect(dates).toEqual({activeFrom: '2024-01-01T00:00', activeTo: '2025-01-01T00:00'});
});

it('should return 2024-04-01T00:00 and 2024-05-01T00:00 if the user clicks on the month button', async () => {
jasmine.clock().mockDate(new Date(2024, 3, 29, 15, 32));
const processMonitoringView: ProcessMonitoringView = new ProcessMonitoringView();
const dates = processMonitoringView.getDatesAfterPeriodClick('month');
expect(dates).toEqual({activeFrom: '2024-04-01T00:00', activeTo: '2024-05-01T00:00'});
});

it('should return 2024-04-28T00:00 and 2024-05-05T00:00 if the user clicks on the week button', async () => {
jasmine.clock().mockDate(new Date(2024, 3, 29, 15, 32));
const processMonitoringView: ProcessMonitoringView = new ProcessMonitoringView();
const dates = processMonitoringView.getDatesAfterPeriodClick('week');
expect(dates).toEqual({activeFrom: '2024-04-28T00:00', activeTo: '2024-05-05T00:00'});
});
});

describe('get dates after period click if the current day/time is 2023-12-31 9:18 (winter time)', () => {
it('should return 2023-01-01T00:00 and 2024-01-01T00:00 if the user clicks on the year button', async () => {
jasmine.clock().mockDate(new Date(2023, 11, 31, 9, 18));
const processMonitoringView: ProcessMonitoringView = new ProcessMonitoringView();
const dates = processMonitoringView.getDatesAfterPeriodClick('year');
expect(dates).toEqual({activeFrom: '2023-01-01T00:00', activeTo: '2024-01-01T00:00'});
});

it('should return 2023-12-01T00:00 and 2024-01-01T00:00 if the user clicks on the month button', async () => {
jasmine.clock().mockDate(new Date(2023, 11, 31, 9, 18));
const processMonitoringView: ProcessMonitoringView = new ProcessMonitoringView();
const dates = processMonitoringView.getDatesAfterPeriodClick('month');
expect(dates).toEqual({activeFrom: '2023-12-01T00:00', activeTo: '2024-01-01T00:00'});
});

it('should return 2023-12-31T00:00 and 2024-01-07T00:00 if the user clicks on the week button', async () => {
jasmine.clock().mockDate(new Date(2023, 11, 31, 9, 18));
const processMonitoringView: ProcessMonitoringView = new ProcessMonitoringView();
const dates = processMonitoringView.getDatesAfterPeriodClick('week');
expect(dates).toEqual({activeFrom: '2023-12-31T00:00', activeTo: '2024-01-07T00:00'});
});
});

describe('get dates if the user navigates between dates after period click', () => {
it('should return 2023-01-01T00:00 and 2024-01-01T00:00 if the user clicks on the year button then navigates backward', async () => {
const processMonitoringView: ProcessMonitoringView = new ProcessMonitoringView();
const dates = processMonitoringView.getDatesWhenMoving(
'2024-01-01T00:00',
'2025-01-01T00:00',
false,
'year'
);
expect(dates).toEqual({activeFrom: '2023-01-01T00:00', activeTo: '2024-01-01T00:00'});
});

it('should return 2025-01-01T00:00 and 2026-01-01T00:00 if the user clicks on the year button then navigates forward', async () => {
const processMonitoringView: ProcessMonitoringView = new ProcessMonitoringView();
const dates = processMonitoringView.getDatesWhenMoving(
'2024-01-01T00:00',
'2025-01-01T00:00',
true,
'year'
);
expect(dates).toEqual({activeFrom: '2025-01-01T00:00', activeTo: '2026-01-01T00:00'});
});

it('should return 2024-03-01T00:00 and 2024-04-01T00:00 if the user clicks on the month button then navigates backward', async () => {
const processMonitoringView: ProcessMonitoringView = new ProcessMonitoringView();
const dates = processMonitoringView.getDatesWhenMoving(
'2024-04-01T00:00',
'2024-05-01T00:00',
false,
'month'
);
expect(dates).toEqual({activeFrom: '2024-03-01T00:00', activeTo: '2024-04-01T00:00'});
});

it('should return 2024-05-01T00:00 and 2024-06-01T00:00 if the user clicks on the year button then navigates forward', async () => {
const processMonitoringView: ProcessMonitoringView = new ProcessMonitoringView();
const dates = processMonitoringView.getDatesWhenMoving(
'2024-04-01T00:00',
'2024-05-01T00:00',
true,
'month'
);
expect(dates).toEqual({activeFrom: '2024-05-01T00:00', activeTo: '2024-06-01T00:00'});
});

it('should return 2024-04-21T00:00 and 2024-04-28T00:00 if the user clicks on the week button then navigates backward', async () => {
const processMonitoringView: ProcessMonitoringView = new ProcessMonitoringView();
const dates = processMonitoringView.getDatesWhenMoving(
'2024-04-28T00:00',
'2024-05-05T00:00',
false,
'week'
);
expect(dates).toEqual({activeFrom: '2024-04-21T00:00', activeTo: '2024-04-28T00:00'});
});

it('should return 2024-05-05T00:00 and 2024-05-12T00:00 if the user clicks on the week button then navigates forward', async () => {
const processMonitoringView: ProcessMonitoringView = new ProcessMonitoringView();
const dates = processMonitoringView.getDatesWhenMoving(
'2024-04-28T00:00',
'2024-05-05T00:00',
true,
'week'
);
expect(dates).toEqual({activeFrom: '2024-05-05T00:00', activeTo: '2024-05-12T00:00'});
});
});

describe('get dates if the user navigates between dates after setting dates manually', () => {
it('should return 2024-04-28T00:00 and 2024-05-02T00:00 if the user navigates backward', async () => {
const processMonitoringView: ProcessMonitoringView = new ProcessMonitoringView();
const dates = processMonitoringView.getDatesWhenMoving('2024-05-02T00:00', '2024-05-06T00:00', false, '');
expect(dates).toEqual({activeFrom: '2024-04-28T00:00', activeTo: '2024-05-02T00:00'});
});

it('should return 2024-05-06T00:00 and 2024-05-10T00:00 if the user navigates forward', async () => {
const processMonitoringView: ProcessMonitoringView = new ProcessMonitoringView();
const dates = processMonitoringView.getDatesWhenMoving('2024-05-02T00:00', '2024-05-06T00:00', true, '');
expect(dates).toEqual({activeFrom: '2024-05-06T00:00', activeTo: '2024-05-10T00:00'});
});

it('should return 2024-04-11T00:00 and 2024-05-01T00:00 if the user navigates backward', async () => {
const processMonitoringView: ProcessMonitoringView = new ProcessMonitoringView();
const dates = processMonitoringView.getDatesWhenMoving('2024-05-01T00:00', '2024-05-21T00:00', false, '');
expect(dates).toEqual({activeFrom: '2024-04-11T00:00', activeTo: '2024-05-01T00:00'});
});

it('should return 2024-05-06T00:00 and 2024-05-10T00:00 if the user navigates forward', async () => {
const processMonitoringView: ProcessMonitoringView = new ProcessMonitoringView();
const dates = processMonitoringView.getDatesWhenMoving('2024-05-01T00:00', '2024-05-21T00:00', true, '');
expect(dates).toEqual({activeFrom: '2024-05-21T00:00', activeTo: '2024-06-10T00:00'});
});
});
});

0 comments on commit a78868b

Please sign in to comment.