From f3e64681c2b304aeb0aa6d18ab4a6558a23bad7c Mon Sep 17 00:00:00 2001 From: Nathnael Date: Tue, 18 Aug 2026 11:47:18 +0000 Subject: [PATCH] test(e2e): wait for rehydration before retyping the TIN after a switch The switch clears the registration but not the tax number, so the company step reopens with the old TIN and RHF re-seeds the field when the profile refetch lands. A TIN typed before that arrived was silently replaced by the stored one and the lookup ran against the wrong number. The spec now waits for the rehydrated VAT value, then asserts the field holds what it typed before waiting on eTrade. --- .../cypress/e2e/flows/onboarding_switch_back.cy.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e/freight/cypress/e2e/flows/onboarding_switch_back.cy.ts b/e2e/freight/cypress/e2e/flows/onboarding_switch_back.cy.ts index 4f16898d0..e6c903e89 100644 --- a/e2e/freight/cypress/e2e/flows/onboarding_switch_back.cy.ts +++ b/e2e/freight/cypress/e2e/flows/onboarding_switch_back.cy.ts @@ -100,7 +100,18 @@ describe("onboarding — switching back to eTrade registration", { retries: 0 }, // The typed registration section is gone: this is an ordinary company now. cy.contains("Nothing on file at eTrade for this TIN").should("not.exist"); + // Wait for the profile to rehydrate before typing. The company still holds + // the TIN it typed under the flag (the switch clears the registration, not + // the tax number), and RHF re-seeds the field when the refetch lands — so a + // TIN typed into an empty-looking field is silently replaced by the stored + // one, and the lookup then runs against the wrong number. + cy.get('.mantine-Modal-content [aria-label="VAT Number"]') + .should("not.have.value", ""); fillAria('[aria-label^="TIN Number"]', etradeTin(stamp)); + cy.get('.mantine-Modal-content [aria-label^="TIN Number"]').should( + "have.value", + etradeTin(stamp), + ); cy.contains("Verified with eTrade", { timeout: 20000 }).should("be.visible"); cy.wait(500); wizardClick("Continue");