Migrate to React 18 createRoot API (#28256)
* Migrate to React 18 createRoot API Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Discard changes to src/components/views/settings/devices/DeviceDetails.tsx * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Attempt to stabilise test Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * legacyRoot? Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Improve coverage Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update snapshots Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Improve coverage Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
48fd330dd9
commit
ca33d9165a
44 changed files with 719 additions and 731 deletions
|
@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
|
|||
*/
|
||||
|
||||
import React from "react";
|
||||
import { fireEvent, render, RenderResult, waitFor } from "jest-matrix-react";
|
||||
import { act, fireEvent, render, RenderResult, waitForElementToBeRemoved, waitFor } from "jest-matrix-react";
|
||||
import {
|
||||
MatrixEvent,
|
||||
Relations,
|
||||
|
@ -226,7 +226,7 @@ describe("MPollBody", () => {
|
|||
clickOption(renderResult, "pizza");
|
||||
|
||||
// When a new vote from me comes in
|
||||
await room.processPollEvents([responseEvent("@me:example.com", "wings", 101)]);
|
||||
await act(() => room.processPollEvents([responseEvent("@me:example.com", "wings", 101)]));
|
||||
|
||||
// Then the new vote is counted, not the old one
|
||||
expect(votesCount(renderResult, "pizza")).toBe("0 votes");
|
||||
|
@ -255,7 +255,7 @@ describe("MPollBody", () => {
|
|||
clickOption(renderResult, "pizza");
|
||||
|
||||
// When a new vote from someone else comes in
|
||||
await room.processPollEvents([responseEvent("@xx:example.com", "wings", 101)]);
|
||||
await act(() => room.processPollEvents([responseEvent("@xx:example.com", "wings", 101)]));
|
||||
|
||||
// Then my vote is still for pizza
|
||||
// NOTE: the new event does not affect the counts for other people -
|
||||
|
@ -596,11 +596,13 @@ describe("MPollBody", () => {
|
|||
];
|
||||
const renderResult = await newMPollBody(votes, ends);
|
||||
|
||||
expect(endedVotesCount(renderResult, "pizza")).toBe("2 votes");
|
||||
expect(endedVotesCount(renderResult, "poutine")).toBe("0 votes");
|
||||
expect(endedVotesCount(renderResult, "italian")).toBe("0 votes");
|
||||
expect(endedVotesCount(renderResult, "wings")).toBe('<div class="mx_PollOption_winnerIcon"></div>3 votes');
|
||||
expect(renderResult.getByTestId("totalVotes").innerHTML).toBe("Final result based on 5 votes");
|
||||
await waitFor(() => {
|
||||
expect(endedVotesCount(renderResult, "pizza")).toBe("2 votes");
|
||||
expect(endedVotesCount(renderResult, "poutine")).toBe("0 votes");
|
||||
expect(endedVotesCount(renderResult, "italian")).toBe("0 votes");
|
||||
expect(endedVotesCount(renderResult, "wings")).toBe('<div class="mx_PollOption_winnerIcon"></div>3 votes');
|
||||
expect(renderResult.getByTestId("totalVotes").innerHTML).toBe("Final result based on 5 votes");
|
||||
});
|
||||
});
|
||||
|
||||
it("ignores votes that arrived after the first end poll event", async () => {
|
||||
|
@ -890,12 +892,14 @@ async function newMPollBody(
|
|||
room_id: "#myroom:example.com",
|
||||
content: newPollStart(answers, undefined, disclosed),
|
||||
});
|
||||
const result = newMPollBodyFromEvent(mxEvent, relationEvents, endEvents);
|
||||
// flush promises from loading relations
|
||||
const prom = newMPollBodyFromEvent(mxEvent, relationEvents, endEvents);
|
||||
if (waitForResponsesLoad) {
|
||||
await flushPromises();
|
||||
const result = await prom;
|
||||
if (result.queryByTestId("spinner")) {
|
||||
await waitForElementToBeRemoved(() => result.getByTestId("spinner"));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return prom;
|
||||
}
|
||||
|
||||
function getMPollBodyPropsFromEvent(mxEvent: MatrixEvent): IBodyProps {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue