calc: fixed bogus cell view cursor overlay

On switching tab not clear other view messages saved for replay.
Added cypress unit tests for checking the cell view cursor bounds.

Signed-off-by: Marco Cecchetti <marco.cecchetti@collabora.com>
Change-Id: I788828783a86038bb9d7f26648925b0e03bd560a
pull/8619/head
Marco Cecchetti 2024-03-22 21:21:30 +01:00 committed by Marco Cecchetti
parent 3685faad68
commit acefa3f357
4 changed files with 83 additions and 9 deletions

View File

@ -30,7 +30,7 @@ L.Map.include({
if (docLayer.isCalc())
docLayer._sheetSwitch.save(part /* toPart */);
docLayer._clearMsgReplayStore();
docLayer._clearMsgReplayStore(true /* notOtherMsg*/);
docLayer._prevSelectedPart = docLayer._selectedPart;
docLayer._selectedParts = [];
if (part === 'prev') {

View File

@ -2873,6 +2873,7 @@ L.CanvasTileLayer = L.Layer.extend({
if (!cellViewCursorMarker) {
var backgroundColor = L.LOUtil.rgbToHex(this._map.getViewColor(viewId));
cellViewCursorMarker = new CCellCursor(this._cellViewCursors[viewId].corePixelBounds, {
name: 'cell-view-cursor-' + viewId,
viewId: viewId,
fill: false,
color: backgroundColor,
@ -5261,12 +5262,12 @@ L.CanvasTileLayer = L.Layer.extend({
this._printTwipsMessagesForReplay.save(msgType, textMsg, viewId);
},
_clearMsgReplayStore: function () {
_clearMsgReplayStore: function (notOtherMsg) {
if (!this._printTwipsMessagesForReplay) {
return;
}
this._printTwipsMessagesForReplay.clear();
this._printTwipsMessagesForReplay.clear(notOtherMsg);
},
_replayPrintTwipsMsgs: function (differentSheet) {
@ -7494,16 +7495,18 @@ L.MessageStore = L.Class.extend({
this._othersMessages = othersMessages;
},
clear: function () {
clear: function (notOtherMsg) {
var msgs = this._ownMessages;
Object.keys(msgs).forEach(function (msgType) {
msgs[msgType] = '';
});
msgs = this._othersMessages;
Object.keys(msgs).forEach(function (msgType) {
msgs[msgType] = [];
});
if (!notOtherMsg) {
msgs = this._othersMessages;
Object.keys(msgs).forEach(function (msgType) {
msgs[msgType] = [];
});
}
},
save: function (msgType, textMsg, viewId) {

View File

@ -1,4 +1,4 @@
/* global describe it cy beforeEach require afterEach */
/* global describe it cy beforeEach require afterEach expect */
var helper = require('../../common/helper');
@ -63,3 +63,74 @@ describe.skip(['tagmultiuser'], 'Multiuser sheet operations', function() {
});
});
describe(['tagmultiuser'], 'Check overlays after tab switching/operations', function() {
const origTestFileName = 'cell_cursor_overlay.ods';
let testFileName;
beforeEach(function() {
testFileName = helper.beforeAll(origTestFileName, 'calc', undefined, true);
});
afterEach(function() {
helper.afterAll(testFileName, this.currentTest.state);
});
it('Check cell cursor overlay bounds after switching tab', function () {
cy.cSetActiveFrame('#iframe1');
cy.cGet('#spreadsheet-tab1').click();
cy.cGet('input#addressInput').should('have.prop', 'value', 'A14');
let cellA14Bounds = new helper.Bounds();
helper.getOverlayItemBounds('#test-div-overlay-cell-cursor-border-0', cellA14Bounds);
cy.cSetActiveFrame('#iframe2');
// Check that cell cursor have the same bounds in both views
cy.cGet('#spreadsheet-tab1').click();
cy.cGet('input#addressInput').should('have.prop', 'value', 'A14');
helper.overlayItemHasBounds('#test-div-overlay-cell-cursor-border-0', cellA14Bounds);
});
it('Check cell view cursor overlay bounds after switching tab', function () {
cy.cSetActiveFrame('#iframe1');
cy.cGet('#spreadsheet-tab1').click();
let cellA14Bounds = new helper.Bounds();
helper.getOverlayItemBounds('#test-div-overlay-cell-cursor-border-0', cellA14Bounds);
cy.cSetActiveFrame('#iframe2');
cy.cGet('#spreadsheet-tab1').click();
// check that cell cursor and cell view cursor from first view have the same bounds
// since we don't know if view 0 has been loaded in frame1 or in frame2 we look for an element
// starting with 'test-div-overlay-cell-view-cursor' and ending with 'border-0'.
cy.cframe()
.find('[id^="test-div-overlay-cell-view-cursor"][id$="border-0"]')
.then(elements => {
expect(elements.length).to.be.equals(1);
const id = elements[0].id;
// cy.log('id: ' + id);
helper.overlayItemHasBounds('#' + id, cellA14Bounds);
});
});
it('Check cell view cursor overlay bounds after inserting a new tab', function () {
cy.cSetActiveFrame('#iframe1');
cy.cGet('input#addressInput').should('have.prop', 'value', 'D8');
cy.cSetActiveFrame('#iframe2');
helper.typeIntoInputField('input#addressInput', 'F6');
cy.cGet('input#addressInput').should('have.prop', 'value', 'F6');
cy.cSetActiveFrame('#iframe1');
cy.cGet('#tb_spreadsheet-toolbar_item_insertsheet').click();
// check that there is no cell view cursor;
// in fact in the other view the new sheet has never been selected
// since we don't know if view 0 has been loaded in frame1 or in frame2 we test for both.
cy.cGet('#test-div-overlay-cell-view-cursor-0-border-0').should('not.exist');
cy.cGet('#test-div-overlay-cell-view-cursor-1-border-0').should('not.exist');
});
});