From 8646e351f95e67e76beb64999a50f1b0d64c4dcc Mon Sep 17 00:00:00 2001 From: Artem Savchenko Date: Fri, 14 Nov 2025 13:43:50 +0700 Subject: [PATCH] Fix QMS login tests Signed-off-by: Artem Savchenko --- .../src/components/Form.svelte | 3 +- .../src/components/LoginPasswordForm.svelte | 33 +++++++++++-------- qms-tests/sanity/tests/model/login-page.ts | 4 +++ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/plugins/login-resources/src/components/Form.svelte b/plugins/login-resources/src/components/Form.svelte index eff31c5e73b..3ba6096c023 100644 --- a/plugins/login-resources/src/components/Form.svelte +++ b/plugins/login-resources/src/components/Form.svelte @@ -45,9 +45,10 @@ export let withProviders: boolean = false export let subtitle: string | undefined = undefined export let signUpDisabled = false + export let isLoading: boolean = false const validate = makeSequential(async function validateAsync (language: string): Promise { - if (ignoreInitialValidation) return true + if (ignoreInitialValidation || isLoading) return true for (const field of fields) { const v = object[field.name] diff --git a/plugins/login-resources/src/components/LoginPasswordForm.svelte b/plugins/login-resources/src/components/LoginPasswordForm.svelte index 8237fc86bc4..34fa12a7257 100644 --- a/plugins/login-resources/src/components/LoginPasswordForm.svelte +++ b/plugins/login-resources/src/components/LoginPasswordForm.svelte @@ -48,24 +48,30 @@ } let status = OK + let isLoading = false const action = { i18n: login.string.LogIn, func: async () => { - status = new Status(Severity.INFO, login.status.ConnectingToServer, {}) - const [loginStatus, result] = await doLogin(object.username, object.password) - status = loginStatus + isLoading = true + try { + status = new Status(Severity.INFO, login.status.ConnectingToServer, {}) + const [loginStatus, result] = await doLogin(object.username, object.password) + status = loginStatus - if (onLogin !== undefined) { - void onLogin(result, status) - } else { - await doLoginNavigate( - result, - (st) => { - status = st - }, - navigateUrl - ) + if (onLogin !== undefined) { + void onLogin(result, status) + } else { + await doLoginNavigate( + result, + (st) => { + status = st + }, + navigateUrl + ) + } + } finally { + isLoading = false } } } @@ -79,6 +85,7 @@ {object} {action} {signUpDisabled} + {isLoading} bottomActions={[recoveryAction]} ignoreInitialValidation withProviders diff --git a/qms-tests/sanity/tests/model/login-page.ts b/qms-tests/sanity/tests/model/login-page.ts index 153ec480356..7445202a3df 100644 --- a/qms-tests/sanity/tests/model/login-page.ts +++ b/qms-tests/sanity/tests/model/login-page.ts @@ -26,6 +26,10 @@ export class LoginPage { async login (email: string, password: string): Promise { await this.inputEmail.fill(email) await this.inputPassword.fill(password) + + // Wait for form validation to complete + await this.page.waitForTimeout(1000) + expect(await this.buttonLogin.isEnabled()).toBe(true) await this.buttonLogin.click() }