Skip to content

Commit

Permalink
cypress: make mobile toolbar tests more reliable
Browse files Browse the repository at this point in the history
- wait for enabled state
- then click internal button

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I7663deb668de2e98b007fbace60386a4a7157058
  • Loading branch information
eszkadev committed Apr 1, 2024
1 parent 31fd035 commit 3888489
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
6 changes: 5 additions & 1 deletion cypress_test/integration_tests/common/mobile_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ function openInsertionWizard() {
cy.log('>> openInsertionWizard - start');

cy.cGet('#toolbar-up #insertion_mobile_wizard')
.should('not.have.class', 'disabled')
.should('not.have.class', 'disabled');

cy.cGet('#toolbar-up #insertion_mobile_wizard button')
.click();

cy.cGet('#mobile-wizard-content')
Expand All @@ -179,6 +181,8 @@ function openCommentWizard() {

cy.cGet('#toolbar-up #comment_wizard')
.should('not.have.class', 'disabled')

cy.cGet('#toolbar-up #comment_wizard button')
.click();

//cy.cGet('#toolbar-up #comment_wizard')
Expand Down
36 changes: 19 additions & 17 deletions cypress_test/integration_tests/mobile/writer/toolbar_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe(['tagmobile', 'tagnextcloud', 'tagproxy'], 'Toolbar tests', function()

it('State of mobile wizard toolbar item.', function() {
// Mobile wizard toolbar button is disabled by default
cy.cGet('#toolbar-up #mobile_wizard').should('have.class', 'disabled');
cy.cGet('#toolbar-up #mobile_wizard').should('have.attr', 'disabled');
// Click on edit button
mobileHelper.enableEditingMobile();
// Button should be enabled now
Expand All @@ -26,63 +26,64 @@ describe(['tagmobile', 'tagnextcloud', 'tagproxy'], 'Toolbar tests', function()

it('State of insertion mobile wizard toolbar item.', function() {
// Insertion mobile wizard toolbar button is disabled by default
cy.cGet('#toolbar-up #insertion_mobile_wizard').should('have.class', 'disabled');
cy.cGet('#toolbar-up #insertion_mobile_wizard').should('have.attr', 'disabled');
// Click on edit button
mobileHelper.enableEditingMobile();
// Button should be enabled now
cy.cGet('#toolbar-up #insertion_mobile_wizard').should('not.have.class', 'disabled');
cy.cGet('#toolbar-up #insertion_mobile_wizard').should('not.have.attr', 'disabled');
});

it('State of comment wizard toolbar item.', function() {
// Insertion mobile wizard toolbar button is disabled by default
cy.cGet('#toolbar-up #comment_wizard').should('not.have.class', 'disabled');
cy.cGet('#toolbar-up #comment_wizard').should('not.have.attr', 'disabled');
// Click on edit button
mobileHelper.enableEditingMobile();
// Button should be enabled now
cy.cGet('#toolbar-up #comment_wizard').should('not.have.class', 'disabled');
cy.cGet('#toolbar-up #comment_wizard').should('not.have.attr', 'disabled');
});

it('State of undo toolbar item.', function() {
// Insertion mobile wizard toolbar button is disabled by default
cy.cGet('#toolbar-up #undo').should('have.class', 'disabled');
cy.cGet('#toolbar-up #undo').should('have.attr', 'disabled');
// Click on edit button
mobileHelper.enableEditingMobile();
// Button should be still disabled
cy.cGet('#toolbar-up #undo').should('have.class', 'disabled');
cy.cGet('#toolbar-up #undo').should('have.attr', 'disabled');
// Type something in the document
helper.typeIntoDocument('x');
// Button should become enabled
cy.cGet('#toolbar-up #undo').should('not.have.class', 'disabled');
cy.cGet('#toolbar-up #undo').should('not.have.attr', 'disabled');
});

it('State of redo toolbar item.', function() {
// Insertion mobile wizard toolbar button is disabled by default
cy.cGet('#toolbar-up #redo').should('have.class', 'disabled');
cy.cGet('#toolbar-up #redo').should('have.attr', 'disabled');
// Click on edit button
mobileHelper.enableEditingMobile();
// Button should be still disabled
cy.cGet('#toolbar-up #redo').should('have.class', 'disabled');
cy.cGet('#toolbar-up #redo').should('have.attr', 'disabled');
// Type something in the document
helper.typeIntoDocument('x');
// Button should be still disabled
cy.cGet('#toolbar-up #redo').should('have.class', 'disabled');
cy.cGet('#toolbar-up #redo').should('have.attr', 'disabled');
// Do an undo
cy.cGet('#toolbar-up #undo').should('not.have.class', 'disabled');
cy.cGet('#toolbar-up #undo').should('not.have.attr', 'disabled');
cy.cGet('#toolbar-up #undo').click();
// Button should become enabled
cy.cGet('#toolbar-up #redo').should('not.have.class', 'disabled');
cy.cGet('#toolbar-up #redo').should('not.have.attr', 'disabled');
});

it('Open and close mobile wizard by toolbar item.', function() {
// Click on edit button
mobileHelper.enableEditingMobile();
// Click on mobile wizard toolbar item
cy.cGet('#toolbar-up #mobile_wizard').should('not.have.class', 'disabled').click();
cy.cGet('#toolbar-up #mobile_wizard').should('not.have.attr', 'disabled');
cy.cGet('#toolbar-up #mobile_wizard button').click();
// Mobile wizard is opened and it has any content
cy.cGet('#mobile-wizard-content').should('not.be.empty');
// Toolbar button is checked
//cy.cGet('#toolbar-up #mobile_wizard').should('have.class', 'checked');
cy.cGet('#toolbar-up #mobile_wizard').click();
cy.cGet('#toolbar-up #mobile_wizard button').click();
// Mobile wizard is closed
cy.cGet('#mobile-wizard').should('not.be.visible');
//cy.cGet('#toolbar-up #mobile_wizard').should('not.have.class', 'checked');
Expand All @@ -100,12 +101,13 @@ describe(['tagmobile', 'tagnextcloud', 'tagproxy'], 'Toolbar tests', function()
// Click on edit button
mobileHelper.enableEditingMobile();
// Click on mobile wizard toolbar item
cy.cGet('#toolbar-up #comment_wizard').should('not.have.class', 'disabled').click();
cy.cGet('#toolbar-up #comment_wizard').should('not.have.attr', 'disabled');
cy.cGet('#toolbar-up #comment_wizard button').click();
// Mobile wizard is opened and it has any content
cy.cGet('#mobile-wizard-content').should('not.be.empty');
// Toolbar button is checked
//cy.cGet('#toolbar-up #comment_wizard').should('have.class', 'checked');
cy.cGet('#toolbar-up #comment_wizard').click();
cy.cGet('#toolbar-up #comment_wizard button').click();
// Mobile wizard is closed
cy.cGet('#mobile-wizard').should('not.be.visible');
//cy.cGet('#toolbar-up #comment_wizard').should('not.have.class', 'checked');
Expand Down

0 comments on commit 3888489

Please sign in to comment.