Skip to content

Commit

Permalink
Added commands for cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
gracec20 committed Nov 26, 2024
1 parent f6fcb1e commit 9fd5fa9
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable new-cap */
/* eslint-disable max-len */
/*
* Copyright (C) 2024 Xibo Signage Ltd
*
Expand Down Expand Up @@ -830,7 +832,7 @@ Cypress.Commands.add('openToolbarMenu', function(menuIdx, load = true) {
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 @@ -843,7 +845,6 @@ Cypress.Commands.add('openToolbarMenu', function(menuIdx, load = true) {
cy.log('Do nothing!');
}
});

});

/**
Expand All @@ -869,17 +870,40 @@ Cypress.Commands.add('openToolbarMenuForPlaylist', function(menuIdx) {
});
});

Cypress.Commands.add('toolbarSearch', (textToType) => {
cy.intercept('POST', '/user/pref').as('updatePreferences');

// Clear the search box first
cy.get('input#input-name')
.filter(':visible')
.should('have.length', 1)
.invoke('val')
.then((value) => {
if (value !== '') {
cy.get('input#input-name')
.filter(':visible')
.clear();
cy.wait('@updatePreferences');
}
});
// Type keyword to search
cy.get('input#input-name')
.filter(':visible')
.type(textToType);
cy.wait('@updatePreferences');
});

// Open Options Menu within the Layout Editor
Cypress.Commands.add('openOptionsMenu', () => {
cy.get('.navbar-submenu')
.should('be.visible')
.within(() => {
cy.get('#optionsContainerTop')
.should('be.visible')
.and('not.be.disabled')
.click({force: true})
.should('have.attr', 'aria-expanded', 'true');
});
.should('be.visible')
.within(() => {
cy.get('#optionsContainerTop')
.should('be.visible')
.and('not.be.disabled')
.click({force: true})
.should('have.attr', 'aria-expanded', 'true');
});
});

// Open Row Menu of the first item on the Layouts page
Expand Down

0 comments on commit 9fd5fa9

Please sign in to comment.