Skip to content

Commit

Permalink
cypress: add tests for comment operations (mobile).
Browse files Browse the repository at this point in the history
Change-Id: I9eb2dea1a600caba0bc11763838f574a1c69f0a5
  • Loading branch information
tzolnai committed Oct 13, 2020
1 parent ad471cc commit 81179ac
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 0 deletions.
Binary file added cypress_test/data/mobile/writer/annotation.odt
Binary file not shown.
16 changes: 16 additions & 0 deletions cypress_test/integration_tests/common/mobile_helper.js
Expand Up @@ -240,10 +240,26 @@ function selectHamburgerMenuItem(menuItems) {
cy.log('Selecting hamburger menu item - end.');
}

function selectAnnotationMenuItem(menuItem) {
cy.log('Selecting annotation menu item - start.');

cy.get('.loleaflet-annotation-menu')
.click({force: true});

cy.get('.context-menu-list')
.should('exist');

cy.contains('.context-menu-link', menuItem)
.click();

cy.log('Selecting annotation menu item - end.');
}

module.exports.enableEditingMobile = enableEditingMobile;
module.exports.longPressOnDocument = longPressOnDocument;
module.exports.openHamburgerMenu = openHamburgerMenu;
module.exports.selectHamburgerMenuItem = selectHamburgerMenuItem;
module.exports.selectAnnotationMenuItem = selectAnnotationMenuItem;
module.exports.closeHamburgerMenu = closeHamburgerMenu;
module.exports.openMobileWizard = openMobileWizard;
module.exports.closeMobileWizard = closeMobileWizard;
Expand Down
160 changes: 160 additions & 0 deletions cypress_test/integration_tests/mobile/writer/annotation_spec.js
@@ -0,0 +1,160 @@
/* global describe it cy beforeEach require afterEach */

var helper = require('../../common/helper');
var mobileHelper = require('../../common/mobile_helper');

describe('Annotation tests.', function() {
var testFileName = 'annotation.odt';

beforeEach(function() {
helper.beforeAll(testFileName, 'writer');

// Click on edit button
mobileHelper.enableEditingMobile();
});

afterEach(function() {
helper.afterAll(testFileName);
});

function insertComment() {
mobileHelper.openInsertionWizard();

cy.contains('.menu-entry-with-icon', 'Comment')
.click();

cy.get('.loleaflet-annotation-table')
.should('exist');

cy.get('.loleaflet-annotation-textarea')
.type('some text');

cy.get('.vex-dialog-button-primary')
.click();

cy.get('.loleaflet-annotation')
.should('exist');

cy.get('.loleaflet-annotation-content')
.should('have.text', 'some text');
}

it('Saving comment.', function() {
insertComment();

mobileHelper.selectHamburgerMenuItem(['File', 'Save']);

helper.beforeAll(testFileName, 'writer', true);

mobileHelper.enableEditingMobile();

cy.get('.loleaflet-annotation-content')
.should('have.text', 'some text');
});

it('Modifying comment.', function() {
insertComment();

mobileHelper.selectAnnotationMenuItem('Modify');

cy.get('.loleaflet-annotation-table')
.should('exist');

cy.get('.vex-dialog-form .loleaflet-annotation-textarea')
.should('have.text', 'some text');

cy.get('.vex-dialog-form .loleaflet-annotation-textarea')
.type('modified ');

cy.get('.vex-dialog-button-primary')
.click();

cy.get('.loleaflet-annotation')
.should('exist');

cy.get('.loleaflet-annotation-content')
.should('have.text', 'modified some text');
});

it('Reply to comment.', function() {
insertComment();

mobileHelper.selectAnnotationMenuItem('Reply');

cy.get('.loleaflet-annotation-table')
.should('exist');

cy.get('.vex-dialog-form .loleaflet-annotation-textarea')
.should('have.text', '');

cy.get('.vex-dialog-form .loleaflet-annotation-textarea')
.type('reply');

cy.get('.vex-dialog-button-primary')
.click();

cy.get('.loleaflet-annotation')
.should('exist');

cy.get('.loleaflet-annotation:nth-of-type(2) .loleaflet-annotation-content')
.should('have.text', 'some text');

cy.get('.loleaflet-annotation:nth-of-type(3) .loleaflet-annotation-content')
.should('have.text', 'reply');
});

it('Remove comment.', function() {
insertComment();

cy.get('.loleaflet-annotation-content')
.should('have.text', 'some text');

mobileHelper.selectAnnotationMenuItem('Remove');

cy.get('.loleaflet-annotation-content')
.should('have.text', '');
});

it('Try to insert empty comment.', function() {
mobileHelper.openInsertionWizard();

cy.contains('.menu-entry-with-icon', 'Comment')
.click();

cy.get('.loleaflet-annotation-table')
.should('exist');

cy.get('.loleaflet-annotation-textarea')
.should('have.text', '');

cy.get('.vex-dialog-button-primary')
.click();

cy.get('.vex-dialog-button-secondary')
.click();

cy.get('.loleaflet-annotation')
.should('not.exist');

cy.get('.loleaflet-annotation-content')
.should('not.exist');
});

it('Resolve comment.', function() {
// Show resolved comments
mobileHelper.selectHamburgerMenuItem(['View', 'Resolved Comments']);

insertComment();

cy.get('.loleaflet-annotation-content')
.should('have.text', 'some text');

mobileHelper.selectAnnotationMenuItem('Resolve');

cy.get('.loleaflet-annotation-content-resolved')
.should('exist');

cy.get('.loleaflet-annotation-content-resolved')
.should('have.text', 'Resolved');
});
});

0 comments on commit 81179ac

Please sign in to comment.