From 2a723cb8b3f0b1606df2b68cb79d1302d9666c50 Mon Sep 17 00:00:00 2001 From: Suguru Hirahara Date: Wed, 12 Apr 2023 01:07:05 +0900 Subject: [PATCH 1/3] Update tests to ensure file size unit has been fixed Signed-off-by: Suguru Hirahara --- cypress/e2e/right-panel/file-panel.spec.ts | 17 +++++++++++++ cypress/e2e/timeline/timeline.spec.ts | 28 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/cypress/e2e/right-panel/file-panel.spec.ts b/cypress/e2e/right-panel/file-panel.spec.ts index 619b40a7cf4..969623de2cf 100644 --- a/cypress/e2e/right-panel/file-panel.spec.ts +++ b/cypress/e2e/right-panel/file-panel.spec.ts @@ -211,6 +211,23 @@ describe("FilePanel", () => { }); }); + it("should render file size in kilobyte on a file tile", () => { + const size = "1.12 KB"; // actual file size in kilobyte (KB) + + // Upload a file + uploadFile("cypress/fixtures/matrix-org-client-versions.json"); + + cy.get(".mx_FilePanel .mx_EventTile").within(() => { + // Assert that the file size is displayed in kilobyte, not kibibyte (kB) + // See: https://github.com/vector-im/element-web/issues/24866 + cy.contains(".mx_MFileBody_info_filename", size).should("exist"); + cy.get(".mx_MFileBody_download").within(() => { + cy.contains("a", size).should("exist"); + cy.contains(".mx_MImageBody_size", size).should("exist"); + }); + }); + }); + it("should not add inline padding to a tile when it is selected with right click", () => { // Upload a file uploadFile("cypress/fixtures/1sec.ogg"); diff --git a/cypress/e2e/timeline/timeline.spec.ts b/cypress/e2e/timeline/timeline.spec.ts index fe7cefd1a41..d4a75a68305 100644 --- a/cypress/e2e/timeline/timeline.spec.ts +++ b/cypress/e2e/timeline/timeline.spec.ts @@ -679,6 +679,34 @@ describe("Timeline", () => { cy.get(".mx_EventTile[data-layout=irc] .mx_ViewSourceEvent_expanded").should("be.visible"); }); + it("should render file size in kilobyte on a file tile", () => { + cy.visit("/#/room/" + roomId); + cy.get(".mx_GenericEventListSummary_summary").within(() => { + cy.findByText(OLD_NAME + " created and configured the room.").should("exist"); + }); + + // Upload a file from the message composer + cy.get(".mx_MessageComposer_actions input[type='file']").selectFile( + "cypress/fixtures/matrix-org-client-versions.json", + { force: true }, + ); + + cy.get(".mx_Dialog").within(() => { + // Click "Upload" button + cy.findByRole("button", { name: "Upload" }).click(); + }); + + // Wait until the file is sent + cy.get(".mx_RoomView_statusArea_expanded").should("not.exist"); + cy.get(".mx_EventTile.mx_EventTile_last .mx_EventTile_receiptSent").should("exist"); + + // Assert that the file size is displayed in kilobyte, not kibibyte (kB) + // See: https://github.com/vector-im/element-web/issues/24866 + cy.get(".mx_EventTile_last").within(() => { + cy.contains(".mx_MFileBody_info_filename", "1.12 KB").should("exist"); // actual file size in kilobyte + }); + }); + it("should highlight search result words regardless of formatting", () => { sendEvent(roomId); sendEvent(roomId, true); From 5b01b2eac4ed6aea52a35096ec2aaf74ac3a4b35 Mon Sep 17 00:00:00 2001 From: Suguru Hirahara Date: Wed, 12 Apr 2023 05:24:51 +0000 Subject: [PATCH 2/3] Update cypress/e2e/timeline/timeline.spec.ts Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- cypress/e2e/timeline/timeline.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/timeline/timeline.spec.ts b/cypress/e2e/timeline/timeline.spec.ts index d4a75a68305..c19155e3959 100644 --- a/cypress/e2e/timeline/timeline.spec.ts +++ b/cypress/e2e/timeline/timeline.spec.ts @@ -700,7 +700,7 @@ describe("Timeline", () => { cy.get(".mx_RoomView_statusArea_expanded").should("not.exist"); cy.get(".mx_EventTile.mx_EventTile_last .mx_EventTile_receiptSent").should("exist"); - // Assert that the file size is displayed in kilobyte, not kibibyte (kB) + // Assert that the file size is displayed in kibibytes (1024 bytes), not kilobytes (1000 bytes) // See: https://github.com/vector-im/element-web/issues/24866 cy.get(".mx_EventTile_last").within(() => { cy.contains(".mx_MFileBody_info_filename", "1.12 KB").should("exist"); // actual file size in kilobyte From 9b93311fd9c15c17787a814316206302946504f5 Mon Sep 17 00:00:00 2001 From: Suguru Hirahara Date: Wed, 12 Apr 2023 14:51:25 +0900 Subject: [PATCH 3/3] Edit comments mentioning kilobytes Signed-off-by: Suguru Hirahara --- cypress/e2e/right-panel/file-panel.spec.ts | 6 +++--- cypress/e2e/timeline/timeline.spec.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cypress/e2e/right-panel/file-panel.spec.ts b/cypress/e2e/right-panel/file-panel.spec.ts index 969623de2cf..5af62815856 100644 --- a/cypress/e2e/right-panel/file-panel.spec.ts +++ b/cypress/e2e/right-panel/file-panel.spec.ts @@ -211,14 +211,14 @@ describe("FilePanel", () => { }); }); - it("should render file size in kilobyte on a file tile", () => { - const size = "1.12 KB"; // actual file size in kilobyte (KB) + it("should render file size in kibibytes on a file tile", () => { + const size = "1.12 KB"; // actual file size in kibibytes (1024 bytes) // Upload a file uploadFile("cypress/fixtures/matrix-org-client-versions.json"); cy.get(".mx_FilePanel .mx_EventTile").within(() => { - // Assert that the file size is displayed in kilobyte, not kibibyte (kB) + // Assert that the file size is displayed in kibibytes, not kilobytes (1000 bytes) // See: https://github.com/vector-im/element-web/issues/24866 cy.contains(".mx_MFileBody_info_filename", size).should("exist"); cy.get(".mx_MFileBody_download").within(() => { diff --git a/cypress/e2e/timeline/timeline.spec.ts b/cypress/e2e/timeline/timeline.spec.ts index c19155e3959..06b289d1e2f 100644 --- a/cypress/e2e/timeline/timeline.spec.ts +++ b/cypress/e2e/timeline/timeline.spec.ts @@ -679,7 +679,7 @@ describe("Timeline", () => { cy.get(".mx_EventTile[data-layout=irc] .mx_ViewSourceEvent_expanded").should("be.visible"); }); - it("should render file size in kilobyte on a file tile", () => { + it("should render file size in kibibytes on a file tile", () => { cy.visit("/#/room/" + roomId); cy.get(".mx_GenericEventListSummary_summary").within(() => { cy.findByText(OLD_NAME + " created and configured the room.").should("exist"); @@ -703,7 +703,7 @@ describe("Timeline", () => { // Assert that the file size is displayed in kibibytes (1024 bytes), not kilobytes (1000 bytes) // See: https://github.com/vector-im/element-web/issues/24866 cy.get(".mx_EventTile_last").within(() => { - cy.contains(".mx_MFileBody_info_filename", "1.12 KB").should("exist"); // actual file size in kilobyte + cy.contains(".mx_MFileBody_info_filename", "1.12 KB").should("exist"); // actual file size in kibibytes }); });