From 75bcb6fbd8f005afa17e554d8349f39ae36a5292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6kay=20=C5=9Eat=C4=B1r?= Date: Mon, 7 Oct 2024 11:43:10 +0300 Subject: [PATCH] Various improvements. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid JS error in app.calc.isRTL when the part is newly added and non-existing in the list. Parse hash to int when adding a comment marker is being added. Fix Cypress issues that was related to latest changes on Hide/Show sheets. Remove debugging code from KitHelper.hpp. Modify parseDocSize function in helpers.hpp to use JSON instead of text. Signed-off-by: Gökay Şatır Change-Id: I65cc6ef433452da297616f56da8f0d651a23dec6 --- browser/src/canvas/sections/CommentSection.ts | 2 +- browser/src/docstatefunctions.js | 4 +++- .../desktop/calc/sheet_operation_spec.js | 2 +- .../mobile/calc/sheet_operation_spec.js | 2 +- kit/KitHelper.hpp | 2 -- test/UnitRenderingOptions.cpp | 12 ++++-------- test/helpers.hpp | 19 ++++++++++--------- 7 files changed, 20 insertions(+), 23 deletions(-) diff --git a/browser/src/canvas/sections/CommentSection.ts b/browser/src/canvas/sections/CommentSection.ts index 22c097a48a7c..b7baacbd920a 100644 --- a/browser/src/canvas/sections/CommentSection.ts +++ b/browser/src/canvas/sections/CommentSection.ts @@ -693,7 +693,7 @@ export class Comment extends CanvasSectionObject { }), draggable: true }); - if (app.impress.partList[this.sectionProperties.docLayer._selectedPart].hash === this.sectionProperties.data.parthash || app.file.fileBasedView) + if (app.impress.partList[this.sectionProperties.docLayer._selectedPart].hash === parseInt(this.sectionProperties.data.parthash) || app.file.fileBasedView) this.map.addLayer(this.sectionProperties.annotationMarker); } if (this.sectionProperties.data.rectangle != null) { diff --git a/browser/src/docstatefunctions.js b/browser/src/docstatefunctions.js index c7c257264083..f45cf402482e 100644 --- a/browser/src/docstatefunctions.js +++ b/browser/src/docstatefunctions.js @@ -139,7 +139,9 @@ app.calc.isRTL = function () { const part = app.map._docLayer._lastStatusJSON.parts[app.map._docLayer._selectedPart]; - return part.rtllayout !== 0; + + if (part) return part.rtllayout !== 0; + else return false; }; app.setServerAuditFromCore = function (entries) { diff --git a/cypress_test/integration_tests/desktop/calc/sheet_operation_spec.js b/cypress_test/integration_tests/desktop/calc/sheet_operation_spec.js index 54f0b2e9d8dc..229fe557c455 100644 --- a/cypress_test/integration_tests/desktop/calc/sheet_operation_spec.js +++ b/cypress_test/integration_tests/desktop/calc/sheet_operation_spec.js @@ -76,7 +76,7 @@ describe(['tagdesktop', 'tagnextcloud', 'tagproxy'], 'Sheet Operations.', functi //show sheet calcHelper.selectOptionFromContextMenu('Show Sheet'); cy.cGet('#show-sheets-modal').should('exist'); - cy.cGet('#hidden-part-checkbox-1').check(); + cy.cGet('#hidden-part-checkbox-Sheet2').check(); cy.cGet('#show-sheets-modal-response').click(); calcHelper.assertNumberofSheets(2); }); diff --git a/cypress_test/integration_tests/mobile/calc/sheet_operation_spec.js b/cypress_test/integration_tests/mobile/calc/sheet_operation_spec.js index c2eeaedcd73d..6752d368257e 100644 --- a/cypress_test/integration_tests/mobile/calc/sheet_operation_spec.js +++ b/cypress_test/integration_tests/mobile/calc/sheet_operation_spec.js @@ -91,7 +91,7 @@ describe(['tagmobile', 'tagnextcloud', 'tagproxy'], 'Sheet Operation', function calcHelper.selectOptionMobileWizard('Show Sheet'); cy.cGet('#mobile-wizard-content-modal-dialog-show-sheets-modal').should('exist'); - cy.cGet('#hidden-part-checkbox-1').check(); + cy.cGet('#hidden-part-checkbox-Sheet2').check(); cy.cGet('#show-sheets-modal-response').click(); calcHelper.assertNumberofSheets(2); diff --git a/kit/KitHelper.hpp b/kit/KitHelper.hpp index f5c8f4b3eb51..1cd72d151e6a 100644 --- a/kit/KitHelper.hpp +++ b/kit/KitHelper.hpp @@ -60,8 +60,6 @@ namespace LOKitHelper resultingString.pop_back(); resultingString += "}"; - std::cout << "Resulting string: " << resultingString << std::endl; - return resultingString; } diff --git a/test/UnitRenderingOptions.cpp b/test/UnitRenderingOptions.cpp index 5b89932b4951..08aab491c268 100644 --- a/test/UnitRenderingOptions.cpp +++ b/test/UnitRenderingOptions.cpp @@ -55,15 +55,11 @@ void UnitRenderingOptions::invokeWSDTest() helpers::sendTextFrame(socket, "status", testname); const auto status = helpers::assertResponseString(socket, "status:", testname); - // Expected format is something like 'status: type=text parts=2 current=0 width=12808 height=1142'. + Poco::JSON::Parser parser; + Poco::Dynamic::Var statusJsonVar = parser.parse(status.substr(7)); + const Poco::SharedPtr& statusJsonObject = statusJsonVar.extract(); - StringVector tokens(StringVector::tokenize(status, ' ')); - LOK_ASSERT_EQUAL(static_cast(8), tokens.size()); - - const std::string token = tokens[5]; - const std::string prefix = "height="; - LOK_ASSERT_EQUAL(static_cast(0), token.find(prefix)); - const int height = std::stoi(token.substr(prefix.size())); + const int height = std::stoi(statusJsonObject->get("height").toString()); // HideWhitespace was ignored, this was 32532, should be around 16706. LOK_ASSERT(height < 20000); } diff --git a/test/helpers.hpp b/test/helpers.hpp index 4fcfae720a88..48e3aed81d82 100644 --- a/test/helpers.hpp +++ b/test/helpers.hpp @@ -702,15 +702,16 @@ void parseDocSize(const std::string& message, const std::string& type, int& part, int& parts, int& width, int& height, int& viewid, const std::string& testname) { - StringVector tokens(StringVector::tokenize(message, ' ')); - - // Expected format is something like 'type= parts= current= width= height='. - const std::string text = tokens[0].substr(std::string("type=").size()); - parts = std::stoi(tokens[1].substr(std::string("parts=").size())); - part = std::stoi(tokens[2].substr(std::string("current=").size())); - width = std::stoi(tokens[3].substr(std::string("width=").size())); - height = std::stoi(tokens[4].substr(std::string("height=").size())); - viewid = std::stoi(tokens[5].substr(std::string("viewid=").size())); + Poco::JSON::Parser parser; + Poco::Dynamic::Var statusJsonVar = parser.parse(message); + const Poco::SharedPtr& statusJsonObject = statusJsonVar.extract(); + + const std::string text = statusJsonObject->get("type").toString(); + parts = std::stoi(statusJsonObject->get("partscount").toString()); + part = std::stoi(statusJsonObject->get("selectedpart").toString()); + width = std::stoi(statusJsonObject->get("width").toString()); + height = std::stoi(statusJsonObject->get("height").toString()); + viewid = std::stoi(statusJsonObject->get("viewid").toString()); LOK_ASSERT_EQUAL(type, text); LOK_ASSERT(parts > 0); LOK_ASSERT(part >= 0);