Writer: Cypress test integration.

Make cpyress tests for comments use ids instead of classes.

Increase the width of the comment section so comment menu is visible
while the sidebar is open.

Signed-off-by: Gökay Şatır <gokay.satir@collabora.com>
Change-Id: I17a81d15c440cd198eb02086be3d9fc65487d9f8
This commit is contained in:
Gökay Şatır 2021-06-10 12:04:05 +03:00 committed by Gökay ŞATIR
parent 9068c8d1ca
commit bc0a4c4341
4 changed files with 23 additions and 35 deletions

View file

@ -273,19 +273,14 @@ function deleteImage() {
function insertMultipleComment(numberOfComments) {
numberOfComments = numberOfComments || 1;
for (var n=0;n<numberOfComments;n++) {
cy.get('#menu-insert').click()
.get('#menu-insertcomment').click();
cy.get('.loleaflet-annotation-table')
.should('exist');
cy.get('#menu-insert').click().get('#menu-insertcomment').click();
// Fixme: when there are multiple comments, .modify-annotation class does not gives unique element that's why using style to identify them.
cy.get('.loleaflet-annotation-table').should('exist');
cy.get('.loleaflet-annotation-edit.modify-annotation[style=""]')
.type('some text' + n);
cy.get('#annotation-modify-textarea-new').type('some text' + n);
cy.get('.loleaflet-annotation-edit.modify-annotation[style=""] #annotation-save')
.click();
cy.get('#annotation-save-new').click();
}
}

View file

@ -19,8 +19,7 @@ describe('Annotation Tests', function() {
cy.get('.loleaflet-annotation-content-wrapper').should('exist');
cy.get('.loleaflet-annotation-content > div')
.should('contain','some text');
cy.get('#annotation-content-area-1').should('contain','some text0');
});
it('Modify',function() {
@ -28,24 +27,19 @@ describe('Annotation Tests', function() {
cy.get('.loleaflet-annotation-content-wrapper').should('exist');
cy.get('.loleaflet-annotation-content > div')
.should('contain','some text');
cy.get('#annotation-content-area-1').should('contain','some text0');
cy.get('.loleaflet-annotation-menu').click();
cy.get('#comment-annotation-menu-1').click();
cy.contains('.context-menu-item','Modify')
.click();
cy.contains('.context-menu-item','Modify').click();
cy.get('.loleaflet-annotation-edit.modify-annotation')
.type('some other text, ');
cy.get('#annotation-modify-textarea-1').type('some other text, ');
cy.get('.loleaflet-annotation-edit.modify-annotation #annotation-save')
.click();
cy.get('#annotation-save-1').click();
cy.get('.loleaflet-annotation-content-wrapper').should('exist');
cy.get('.loleaflet-annotation-content > div')
.should('contain','some other text, some text');
cy.get('#annotation-content-area-1').should('contain','some other text, some text0');
});
it('Reply',function() {
@ -53,22 +47,17 @@ describe('Annotation Tests', function() {
cy.get('.loleaflet-annotation-content-wrapper').should('exist');
cy.get('.loleaflet-annotation-content > div')
.should('contain','some text');
cy.get('#annotation-content-area-1').should('contain','some text');
cy.get('.loleaflet-annotation-menu').click();
cy.get('#comment-annotation-menu-1').click();
cy.contains('.context-menu-item','Reply')
.click();
cy.contains('.context-menu-item','Reply').click();
cy.get('.loleaflet-annotation-edit.reply-annotation')
.type('some reply text');
cy.get('#annotation-reply-textarea-1').type('some reply text');
cy.get('.loleaflet-annotation-edit.reply-annotation #annotation-reply')
.click();
cy.get('#annotation-reply-1').click();
cy.get('.loleaflet-annotation-content > div').eq(1)
.should('contain','some reply text');
cy.get('#annotation-content-area-2').should('contain','some reply text');
});
it('Remove',function() {

View file

@ -69,7 +69,7 @@ class CommentSection {
this.sectionProperties.marginY = 10 * app.dpiScale;
this.sectionProperties.offset = 5 * app.dpiScale;
this.sectionProperties.layoutTimer = null;
this.sectionProperties.width = Math.round(290 * app.dpiScale); // Configurable variable.
this.sectionProperties.width = Math.round(300 * app.dpiScale); // Configurable variable.
}
public onInitialize () {

View file

@ -112,11 +112,14 @@ class Comment {
}
this.sectionProperties.contentNode = L.DomUtil.create('div', 'loleaflet-annotation-content loleaflet-dont-break', this.sectionProperties.wrapper);
this.sectionProperties.contentNode.id = 'annotation-content-area-' + this.sectionProperties.data.id;
this.sectionProperties.nodeModify = L.DomUtil.create('div', 'loleaflet-annotation-edit' + ' modify-annotation', this.sectionProperties.wrapper);
this.sectionProperties.nodeModifyText = L.DomUtil.create('textarea', 'loleaflet-annotation-textarea', this.sectionProperties.nodeModify);
this.sectionProperties.nodeModifyText.id = 'annotation-modify-textarea-' + this.sectionProperties.data.id;
this.sectionProperties.contentText = L.DomUtil.create('div', '', this.sectionProperties.contentNode);
this.sectionProperties.nodeReply = L.DomUtil.create('div', 'loleaflet-annotation-edit' + ' reply-annotation', this.sectionProperties.wrapper);
this.sectionProperties.nodeReplyText = L.DomUtil.create('textarea', 'loleaflet-annotation-textarea', this.sectionProperties.nodeReply);
this.sectionProperties.nodeReplyText.id = 'annotation-reply-textarea-' + this.sectionProperties.data.id;
var button = L.DomUtil.create('div', '', this.sectionProperties.nodeModify);
L.DomEvent.on(this.sectionProperties.nodeModifyText, 'blur', this.onLostFocus, this);
@ -125,7 +128,7 @@ class Comment {
this.createButton(button, 'annotation-save-' + this.sectionProperties.data.id, _('Save'), this.onSaveComment);
button = L.DomUtil.create('div', '', this.sectionProperties.nodeReply);
this.createButton(button, 'annotation-cancel-reply-' + this.sectionProperties.data.id, _('Cancel'), this.onCancelClick);
this.createButton(button, 'annotation-reply', _('Reply'), this.onReplyClick);
this.createButton(button, 'annotation-reply-' + this.sectionProperties.data.id, _('Reply'), this.onReplyClick);
L.DomEvent.disableScrollPropagation(this.sectionProperties.container);
this.sectionProperties.container.style.visibility = 'hidden';
@ -201,6 +204,7 @@ class Comment {
private createMenu () {
var tdMenu = L.DomUtil.create('td', 'loleaflet-annotation-menubar', document.getElementById('author table row ' + this.sectionProperties.data.id));
this.sectionProperties.menu = L.DomUtil.create('div', this.sectionProperties.data.trackchange ? 'loleaflet-annotation-menu-redline' : 'loleaflet-annotation-menu', tdMenu);
this.sectionProperties.menu.id = 'comment-annotation-menu-' + this.sectionProperties.data.id;
this.sectionProperties.menu.onclick = this.menuOnMouseClick.bind(this);
var divMenuTooltipText = _('Open menu');
this.sectionProperties.menu.dataset.title = divMenuTooltipText;