From cf07a6b9ccdae3c586a09815e322309fdfe763d7 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 11 Dec 2024 13:53:59 +0000 Subject: [PATCH 1/2] Update test snapshot as the date formatting appears to have gained a comma, and somehow got through the merge tests on the dependency bump. --- .../views/rooms/__snapshots__/ReadReceiptGroup-test.tsx.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit-tests/components/views/rooms/__snapshots__/ReadReceiptGroup-test.tsx.snap b/test/unit-tests/components/views/rooms/__snapshots__/ReadReceiptGroup-test.tsx.snap index b0ba944a66a..b69466cc641 100644 --- a/test/unit-tests/components/views/rooms/__snapshots__/ReadReceiptGroup-test.tsx.snap +++ b/test/unit-tests/components/views/rooms/__snapshots__/ReadReceiptGroup-test.tsx.snap @@ -84,7 +84,7 @@ exports[`ReadReceiptGroup should render 1`] = `

- Wed, 15 May, 0:00 + Wed, May 15, 00:00

From 6a17bf17b962fbe6393ed329c46c0c51284b9636 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 11 Dec 2024 14:00:42 +0000 Subject: [PATCH 2/2] Actually this was the problem --- .../components/views/rooms/ReadReceiptGroup-test.tsx | 8 ++++++++ .../rooms/__snapshots__/ReadReceiptGroup-test.tsx.snap | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/test/unit-tests/components/views/rooms/ReadReceiptGroup-test.tsx b/test/unit-tests/components/views/rooms/ReadReceiptGroup-test.tsx index ff89aa69422..13500f9b1f9 100644 --- a/test/unit-tests/components/views/rooms/ReadReceiptGroup-test.tsx +++ b/test/unit-tests/components/views/rooms/ReadReceiptGroup-test.tsx @@ -10,6 +10,7 @@ import React, { ComponentProps } from "react"; import { render, screen, waitFor } from "jest-matrix-react"; import { RoomMember } from "matrix-js-sdk/src/matrix"; import userEvent from "@testing-library/user-event"; +import { mocked } from "jest-mock"; import { determineAvatarPosition, @@ -20,6 +21,9 @@ import * as languageHandler from "../../../../../src/languageHandler"; import { stubClient } from "../../../../test-utils"; import dispatcher from "../../../../../src/dispatcher/dispatcher"; import { Action } from "../../../../../src/dispatcher/actions"; +import { formatDate } from "../../../../../src/DateUtils"; + +jest.mock("../../../../../src/DateUtils"); describe("ReadReceiptGroup", () => { describe("TooltipText", () => { @@ -87,6 +91,10 @@ describe("ReadReceiptGroup", () => { describe("", () => { stubClient(); + // We pick a fixed time but this can still vary depending on the locale + // the tests are run in. We are not testing date formatting here, so stub it out. + mocked(formatDate).mockReturnValue("==MOCK FORMATTED DATE=="); + const ROOM_ID = "roomId"; const USER_ID = "@alice:example.org"; diff --git a/test/unit-tests/components/views/rooms/__snapshots__/ReadReceiptGroup-test.tsx.snap b/test/unit-tests/components/views/rooms/__snapshots__/ReadReceiptGroup-test.tsx.snap index b69466cc641..60e8f844af7 100644 --- a/test/unit-tests/components/views/rooms/__snapshots__/ReadReceiptGroup-test.tsx.snap +++ b/test/unit-tests/components/views/rooms/__snapshots__/ReadReceiptGroup-test.tsx.snap @@ -84,7 +84,7 @@ exports[`ReadReceiptGroup should render 1`] = `

- Wed, May 15, 00:00 + ==MOCK FORMATTED DATE==