Skip to content

Commit

Permalink
Cypress Test for Layout Options: Changed mouseenter to mouseover and …
Browse files Browse the repository at this point in the history
…added condition to openToolbarMenu command
  • Loading branch information
gracec20 committed Nov 6, 2024
1 parent e17d0b9 commit 6ff42d4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
12 changes: 6 additions & 6 deletions cypress/e2e/Layout/Editor/layout_editor_options.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('Layout Editor', function() {
cy.intercept('PUT', '/layout/publish/*').as('publishLayout');

// Open widgets toolbox
cy.openToolbarMenu(0);
cy.openToolbarMenu(0, false);
cy.get('[data-sub-type="ics-calendar"]').click();
cy.get('[data-template-id="daily_light"]').click();
cy.get('.viewer-object').click();
Expand Down Expand Up @@ -161,7 +161,7 @@ describe('Layout Editor', function() {
cy.log(`Layout Name: ${layoutName}`);

// Open global elements toolbox
cy.openToolbarMenu(1);
cy.openToolbarMenu(1, false);
cy.get('[data-template-id="text"]').click();
cy.get('.viewer-object').click();

Expand Down Expand Up @@ -232,7 +232,7 @@ describe('Layout Editor', function() {
// Verify that tooltips are present
cy.get('.navbar-nav .btn-menu-option[data-toggle="tooltip"]').each(($element) => {
// Trigger hover to show tooltip
cy.wrap($element).trigger('mouseenter');
cy.wrap($element).trigger('mouseover');

// Check that the tooltip is visible for each button
cy.get('.tooltip').should('be.visible'); // Expect tooltip to be present
Expand Down Expand Up @@ -261,7 +261,7 @@ describe('Layout Editor', function() {

// Verify that tooltips are gone
cy.get('.navbar-nav .btn-menu-option[data-toggle="tooltip"]').each(($element) => {
cy.wrap($element).trigger('mouseenter'); // Trigger hover to show tooltip
cy.wrap($element).trigger('mouseover'); // Trigger hover to show tooltip
cy.get('.tooltip').should('not.exist'); // Check if tooltip is gone for each button on the toolbox
});

Expand All @@ -286,7 +286,7 @@ describe('Layout Editor', function() {
});

// Add an element then attempt to delete
cy.openToolbarMenu(0);
cy.openToolbarMenu(0, false);
cy.get('[data-sub-type="clock"]').click();
cy.get('[data-sub-type="clock-analogue"]').click();
cy.get('.viewer-object').click();
Expand Down Expand Up @@ -319,7 +319,7 @@ describe('Layout Editor', function() {
cy.intercept('DELETE', '/region/*').as('deleteElement');

// Add an element then attempt to delete
cy.openToolbarMenu(0);
cy.openToolbarMenu(0, false);
cy.get('[data-sub-type="clock"]').click();
cy.get('[data-sub-type="clock-analogue"]').click();
cy.get('.viewer-object').click();
Expand Down
13 changes: 10 additions & 3 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -820,14 +820,20 @@ Cypress.Commands.add('displayStatusEquals', function(displayName, statusId) {
* Force open toolbar menu
* @param {number} menuIdx
*/
Cypress.Commands.add('openToolbarMenu', function(menuIdx) {
Cypress.Commands.add('openToolbarMenu', function(menuIdx, load) {
cy.intercept('GET', '/user/pref?preference=toolbar').as('toolbarPrefsLoad');
cy.intercept('GET', '/user/pref?preference=editor').as('editorPrefsLoad');
cy.intercept('POST', '/user/pref?preference=toolbar').as('toolbarPrefsLoad');

// Wait for the toolbar to reload when getting prefs at start
cy.wait('@toolbarPrefsLoad');
cy.wait('@editorPrefsLoad');
//cy.wait('@toolbarPrefsLoad');
//cy.wait('@editorPrefsLoad');

// Wait for the toolbar to reload when getting prefs at start, based on the load parameter
if (load) {
cy.wait('@toolbarPrefsLoad');
cy.wait('@editorPrefsLoad');
}

cy.get('.editor-toolbar').then(($toolbar) => {
if ($toolbar.find('#content-' + menuIdx + ' .close-submenu').length > 0) {
Expand All @@ -840,6 +846,7 @@ Cypress.Commands.add('openToolbarMenu', function(menuIdx) {
cy.log('Do nothing!');
}
});

});

/**
Expand Down

0 comments on commit 6ff42d4

Please sign in to comment.