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.
This commit is contained in:
Nathnael
2026-08-18 11:47:18 +00:00
parent f62054d4a4
commit f3e64681c2

View File

@@ -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");