Avoid using .render() in forward dialog test (#7961)

Signed-off-by: Robin Townsend <robin@robin.town>
pull/21833/head
Robin 2022-03-03 07:54:20 -05:00 committed by GitHub
parent ebc2267e52
commit d883309dcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 8 deletions

View File

@ -53,6 +53,7 @@ describe("ForwardDialog", () => {
// Wait one tick for our profile data to load so the state update happens within act // Wait one tick for our profile data to load so the state update happens within act
await new Promise(resolve => setImmediate(resolve)); await new Promise(resolve => setImmediate(resolve));
}); });
wrapper.update();
return wrapper; return wrapper;
}; };
@ -97,31 +98,42 @@ describe("ForwardDialog", () => {
cancelSend = reject; cancelSend = reject;
})); }));
const firstButton = wrapper.find("AccessibleButton.mx_ForwardList_sendButton").first(); let firstButton;
expect(firstButton.render().is(".mx_ForwardList_canSend")).toBe(true); let secondButton;
const update = () => {
wrapper.update();
firstButton = wrapper.find("AccessibleButton.mx_ForwardList_sendButton").first();
secondButton = wrapper.find("AccessibleButton.mx_ForwardList_sendButton").at(1);
};
update();
expect(firstButton.is(".mx_ForwardList_canSend")).toBe(true);
act(() => { firstButton.simulate("click"); }); act(() => { firstButton.simulate("click"); });
expect(firstButton.render().is(".mx_ForwardList_sending")).toBe(true); update();
expect(firstButton.is(".mx_ForwardList_sending")).toBe(true);
await act(async () => { await act(async () => {
cancelSend(); cancelSend();
// Wait one tick for the button to realize the send failed // Wait one tick for the button to realize the send failed
await new Promise(resolve => setImmediate(resolve)); await new Promise(resolve => setImmediate(resolve));
}); });
expect(firstButton.render().is(".mx_ForwardList_sendFailed")).toBe(true); update();
expect(firstButton.is(".mx_ForwardList_sendFailed")).toBe(true);
const secondButton = wrapper.find("AccessibleButton.mx_ForwardList_sendButton").at(1); expect(secondButton.is(".mx_ForwardList_canSend")).toBe(true);
expect(secondButton.render().is(".mx_ForwardList_canSend")).toBe(true);
act(() => { secondButton.simulate("click"); }); act(() => { secondButton.simulate("click"); });
expect(secondButton.render().is(".mx_ForwardList_sending")).toBe(true); update();
expect(secondButton.is(".mx_ForwardList_sending")).toBe(true);
await act(async () => { await act(async () => {
finishSend(); finishSend();
// Wait one tick for the button to realize the send succeeded // Wait one tick for the button to realize the send succeeded
await new Promise(resolve => setImmediate(resolve)); await new Promise(resolve => setImmediate(resolve));
}); });
expect(secondButton.render().is(".mx_ForwardList_sent")).toBe(true); update();
expect(secondButton.is(".mx_ForwardList_sent")).toBe(true);
}); });
it("can render replies", async () => { it("can render replies", async () => {