Skip to content

Commit

Permalink
Solve issue when switching from on custom screen to another
Browse files Browse the repository at this point in the history
Signed-off-by: freddidierRTE <[email protected]>
  • Loading branch information
freddidierRTE authored and vlo-rte committed Feb 18, 2025
1 parent 14e3e79 commit 622d943
Show file tree
Hide file tree
Showing 9 changed files with 289 additions and 246 deletions.
16 changes: 8 additions & 8 deletions config/docker/externalJs/CustomScreenExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@
{
id: 'button1',
label: 'Accept proposals',
getUserResponses: (cards, responsesData) => {
getUserResponses: (selectedCards, userInputs) => {
const responseCards = [];

cards.forEach((card) => {
selectedCards.forEach((card) => {

const userInputs = responsesData.get(card.id);
const comment = userInputs?.comment ?? '';
const userInput = userInputs.get(card.id);
const comment = userInput?.comment ?? '';
const responseData = { "choice1": "on", "choice2": "on", "choice3": "on", "comment": comment }
responseCards.push({ data: responseData });
});
Expand All @@ -151,12 +151,12 @@
{
id: 'button2',
label: 'Refuse proposals',
getUserResponses: (cards, responsesData) => {
getUserResponses: (selectedCards, userInputs) => {
const responseCards = [];
let hasAlwaysComment = true;
cards.forEach((card) => {
const userInputs = responsesData.get(card.id);
const comment = userInputs?.comment ?? '';
selectedCards.forEach((card) => {
const userInput = userInputs.get(card.id);
const comment = userInput?.comment ?? '';
if (comment === '') {
hasAlwaysComment = false;
}
Expand Down
31 changes: 15 additions & 16 deletions config/docker/ui-config/ui-menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,17 @@
"label": "entry.custom"
},
{

"customMenuId": "uid_test_1",
"url": "https://opfab.github.io/",
"label": "entry.entry1",
"linkType": "BOTH",
"showOnlyForGroups": ["Maintainer", "Planner"]
"customScreenId": "testId2",
"label": "entry.custom2"
},
{
"customMenuId": "uid_test_2",
"url": "https://www.wikipedia.org/",
"label": "entry.entry2",
"url": "https://opfab.github.io/",
"label": "entry.doc",
"linkType": "BOTH",
"showOnlyForGroups": ["Dispatcher"]
"showOnlyForGroups": ["Maintainer", "Planner"]
},
{
"customMenuId": "uid_test_3",
Expand Down Expand Up @@ -146,11 +145,11 @@
},
"entry": {
"single": "Single menu entry",
"entry1": "First menu entry",
"entry2": "Second menu entry",
"doc": "Opfab documentation",
"entry3": "External application",
"admin": "Admin menu entry",
"custom": "Custom screen"
"custom": "Custom screen",
"custom2": "Custom screen 2"
}
}
},
Expand All @@ -164,11 +163,11 @@
},
"entry": {
"single": "Unique élément",
"entry1": "Premier élément",
"entry2": "Deuxième élément",
"doc": "Documentation Opfab",
"entry3": "Application externe",
"admin": "Menu admin élément",
"custom": "Écran personnalisé"
"custom": "Écran personnalisé",
"custom2": "Écran personnalisé 2"

}
}
Expand All @@ -183,11 +182,11 @@
},
"entry": {
"single": "Enkel menu-item",
"entry1": "Eerste menu-item",
"entry2": "Tweede menu-item",
"doc": "Opfab documentatie",
"entry3": "TExterne applicatie",
"admin": "Admin menu-item",
"custom": "Aangepast scherm"
"custom": "Aangepast scherm",
"custom2": "Aangepast scherm 2"
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/docs/asciidoc/reference_doc/ui_customization.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,13 @@ const customScreenExample = {
{
id: 'button1',
label: 'Accept proposals',
getUserResponses: (cards, responsesData) => {
getUserResponses: (cards, userInputs) => {
const responseCards = [];
cards.forEach((card) => {
const userInputs = responsesData.get(card.id);
const comment = userInputs?.comment ?? '';
const userInput = responsesData.get(card.id);
const comment = userInput?.comment ?? '';
const responseData = { "choice1": "on", "choice2": "on", "choice3": "on", "comment": comment }
responseCards.push({ data: responseData });
});
Expand All @@ -477,12 +477,12 @@ const customScreenExample = {
{
id: 'button2',
label: 'Refuse proposals',
getUserResponses: (cards, responsesData) => {
getUserResponses: (cards, userInputs) => {
const responseCards = [];
let hasAlwaysComment = true;
cards.forEach((card) => {
const userInputs = responsesData.get(card.id);
const comment = userInputs?.comment ?? '';
const userInput = responsesData.get(card.id);
const comment = userInput?.comment ?? '';
if (comment === '') {
hasAlwaysComment = false;
}
Expand Down
61 changes: 28 additions & 33 deletions src/test/cypress/cypress/integration/BusinessMenu.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022-2024, RTE (http://www.rte-france.com)
/* Copyright (c) 2022-2025, 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
Expand All @@ -7,44 +7,42 @@
* This file is part of the OperatorFabric project.
*/

import {OpfabGeneralCommands} from '../support/opfabGeneralCommands';
import {FeedCommands} from '../support/feedCommands';
import {ScriptCommands} from '../support/scriptCommands';
import { OpfabGeneralCommands } from '../support/opfabGeneralCommands';
import { FeedCommands } from '../support/feedCommands';
import { ScriptCommands } from '../support/scriptCommands';

describe('Business menu', () => {
const opfab = new OpfabGeneralCommands();
const feed = new FeedCommands();
const script = new ScriptCommands();

before('Set up configuration', function () {
before('Set up configuration', function() {
script.loadTestConf();
script.deleteAllCards();
script.sendCard('defaultProcess/chart.json');
});

it('Test business menu links in night mode ',
{
retries: {
runMode: 2, // to avoid flaky test
openMode: 1
}
},() => {
opfab.loginWithUser('operator1_fr');

feed.openFirstCard();
clickLinkInsideCard();
opfab.checkUrlDisplayedIs('https://en.wikipedia.org/w/index.php?search=chart&fulltext=1&opfab_theme=NIGHT');

openBusinessDropdownMenu();
clickOnDropdownMenu('uid_test_1');
opfab.checkUrlDisplayedIs('https://opfab.github.io/?opfab_theme=NIGHT');
openBusinessDropdownMenu();
clickOnDropdownMenu('uid_test_2');
opfab.checkUrlDisplayedIs('https://www.wikipedia.org/?opfab_theme=NIGHT');

openBusinessSingleMenu();
opfab.checkUrlDisplayedIs('https://en.wikipedia.org/w/index.php?opfab_theme=NIGHT');
});
it('Test business menu links in night mode ',
{
retries: {
runMode: 2, // to avoid flaky test
openMode: 1
}
}, () => {
opfab.loginWithUser('operator1_fr');

feed.openFirstCard();
clickLinkInsideCard();
opfab.checkUrlDisplayedIs('https://en.wikipedia.org/w/index.php?search=chart&fulltext=1&opfab_theme=NIGHT');

openBusinessDropdownMenu();
clickOnDropdownMenu('uid_test_2');
opfab.checkUrlDisplayedIs('https://opfab.github.io/?opfab_theme=NIGHT');
openBusinessDropdownMenu();

openBusinessSingleMenu();
opfab.checkUrlDisplayedIs('https://en.wikipedia.org/w/index.php?opfab_theme=NIGHT');
});

it(
'Test business menu links in day mode ',
Expand All @@ -62,12 +60,9 @@ describe('Business menu', () => {
clickLinkInsideCard();
opfab.checkUrlDisplayedIs('https://en.wikipedia.org/w/index.php?search=chart&fulltext=1&opfab_theme=DAY');

openBusinessDropdownMenu();
clickOnDropdownMenu('uid_test_1');
opfab.checkUrlDisplayedIs('https://opfab.github.io/?opfab_theme=DAY');
openBusinessDropdownMenu();
clickOnDropdownMenu('uid_test_2');
opfab.checkUrlDisplayedIs('https://www.wikipedia.org/?opfab_theme=DAY');
opfab.checkUrlDisplayedIs('https://opfab.github.io/?opfab_theme=DAY');

openBusinessSingleMenu();
opfab.checkUrlDisplayedIs('https://en.wikipedia.org/w/index.php?opfab_theme=DAY');
Expand All @@ -83,7 +78,7 @@ describe('Business menu', () => {
}

function clickOnDropdownMenu(menuId) {
cy.get('#opfab-navbar-menu-dropdown-'+ menuId).click({force:true});
cy.get('#opfab-navbar-menu-dropdown-' + menuId).click({ force: true });
}


Expand Down
41 changes: 18 additions & 23 deletions src/test/cypress/cypress/integration/Translation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
* This file is part of the OperatorFabric project.
*/

import {OpfabGeneralCommands} from '../support/opfabGeneralCommands';
import {ScriptCommands} from '../support/scriptCommands';
import {SettingsCommands} from '../support/settingsCommands';
import { OpfabGeneralCommands } from '../support/opfabGeneralCommands';
import { ScriptCommands } from '../support/scriptCommands';
import { SettingsCommands } from '../support/settingsCommands';

describe('Test translations', function () {
describe('Test translations', function() {
const ENGLISH = 'en';
const FRENCH = 'fr';
const DUTCH = 'nl';
Expand Down Expand Up @@ -63,8 +63,7 @@ describe('Test translations', function () {
loggingTitle,
singleMenuTitle,
secondMenuTitle,
firstEntryTitle,
secondEntryTitle
opfabDocTitle,
) {
cy.get('#opfab-navbar-menu-feed').should('have.text', feedTitle);
cy.get('#opfab-navbar-menu-archives').should('have.text', archivesTitle);
Expand All @@ -75,8 +74,7 @@ describe('Test translations', function () {

// Test dropdown menus titles
cy.get('#opfab-navbar-menu-menu2').trigger('mouseenter');
cy.get('#opfab-navbar-menu-dropdown-uid_test_1').should('have.text', firstEntryTitle);
cy.get('#opfab-navbar-menu-dropdown-uid_test_2').should('have.text', secondEntryTitle);
cy.get('#opfab-navbar-menu-dropdown-uid_test_2').should('have.text', opfabDocTitle);
}

function checkRightMenuStaticEntries(
Expand Down Expand Up @@ -237,12 +235,12 @@ describe('Test translations', function () {
cy.contains('#opfab-feed-card-not-found', cardNotFoundText);
}

before('Set up configuration and cards', function () {
before('Set up configuration and cards', function() {
script.deleteAllSettings();
script.loadTestConf();
});

it('Check translations for menu titles', function () {
it('Check translations for menu titles', function() {
opfab.loginWithUser('operator1_fr');

changeLanguage(ENGLISH);
Expand All @@ -253,8 +251,7 @@ describe('Test translations', function () {
'Logging',
'Single menu entry',
'Second menu',
'First menu entry',
'Second menu entry'
'Opfab documentation'
);

changeLanguage(FRENCH);
Expand All @@ -265,8 +262,7 @@ describe('Test translations', function () {
'Logging',
'Unique élément',
'Deuxième menu',
'Premier élément',
'Deuxième élément'
'Documentation Opfab'
);

changeLanguage(DUTCH);
Expand All @@ -277,12 +273,11 @@ describe('Test translations', function () {
'Logboek',
'Enkel menu-item',
'Tweede menu',
'Eerste menu-item',
'Tweede menu-item'
'Opfab documentatie'
);
});

it('Check translations for user dropdown menu', function () {
it('Check translations for user dropdown menu', function() {
opfab.loginWithUser('operator1_fr');

changeLanguage(ENGLISH);
Expand Down Expand Up @@ -322,7 +317,7 @@ describe('Test translations', function () {
checkDayAndNightTitles('Dag modus', 'Nacht modus');
});

it('Check archives screen translations', function () {
it('Check archives screen translations', function() {
opfab.loginWithUser('operator1_fr');

changeLanguage(ENGLISH);
Expand Down Expand Up @@ -373,7 +368,7 @@ describe('Test translations', function () {
);
});

it('Check Monitoring screen translations', function () {
it('Check Monitoring screen translations', function() {
opfab.loginWithUser('operator1_fr');

changeLanguage(ENGLISH);
Expand Down Expand Up @@ -416,7 +411,7 @@ describe('Test translations', function () {
checkMonitoringResultTexts('Kaarten met reactie van mijn entiteit ');
});

it('Check Business period translations', function () {
it('Check Business period translations', function() {
const currentDate = new Date(2020, 11, 31, 23, 46); // Date must be in the past to avoid session close with token expiration
opfab.loginWithClock(currentDate);

Expand Down Expand Up @@ -453,7 +448,7 @@ describe('Test translations', function () {
cy.get('.opfab-business-period').should('have.text', 'Bedrijfsperiode : 21:30 31/12/2020 -- 09:00 01/01/2021 ');
});

it('Check Feed filter translations', function () {
it('Check Feed filter translations', function() {
opfab.loginWithUser('operator1_fr');

changeLanguage(ENGLISH);
Expand All @@ -465,7 +460,7 @@ describe('Test translations', function () {
checkDateFilterTexts('Receipt date', 'START', 'END', 'Apply filters to timeline ');

// Deselect 'not acknowledged' checkbox on Acknowledgement filter to show the "Reset" link
cy.get('#opfab-feed-filter-ack-notack').click({force: true});
cy.get('#opfab-feed-filter-ack-notack').click({ force: true });
checkResetText('Reset filters');

changeLanguage(FRENCH);
Expand All @@ -485,7 +480,7 @@ describe('Test translations', function () {
checkResetText('Filters opnieuw instellen');
});

it('Check translation for non-existent card', function () {
it('Check translation for non-existent card', function() {
opfab.loginWithUser('operator1_fr');

changeLanguage(ENGLISH);
Expand Down
Loading

0 comments on commit 622d943

Please sign in to comment.