From f00c742ebcc7ee6d675506d448aef18bbc1ea1f5 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Fri, 5 May 2023 11:56:35 +0100 Subject: [PATCH] Wait for login screen to appear in loading-test (#25276) --- test/app-tests/loading-test.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/app-tests/loading-test.tsx b/test/app-tests/loading-test.tsx index abd6c3243b..dd4a3e70d5 100644 --- a/test/app-tests/loading-test.tsx +++ b/test/app-tests/loading-test.tsx @@ -611,10 +611,6 @@ describe("loading:", function () { httpBackend.when("GET", "/login").respond(200, { flows: [{ type: "m.login.password" }] }); httpBackend.flush(undefined); // We already would have tried the GET /login request - // Give the component some time to finish processing the login flows before - // continuing. - await sleep(100); - httpBackend .when("POST", "/login") .check(function (req) { @@ -628,6 +624,11 @@ describe("loading:", function () { device_id: "DEVICE_ID", access_token: "access_token", }); + + // Give the component some time to finish processing the login flows before continuing. + await waitFor(() => matrixChat?.container.querySelector("#mx_LoginForm_username")); + + // Enter login details fireEvent.change(matrixChat.container.querySelector("#mx_LoginForm_username")!, { target: { value: "user" } }); fireEvent.change(matrixChat.container.querySelector("#mx_LoginForm_password")!, { target: { value: "pass" } }); fireEvent.click(screen.getByText("Sign in", { selector: ".mx_Login_submit" }));