From c0f9193de39385db9fd4f4ec67b6d1364b0a8324 Mon Sep 17 00:00:00 2001 From: Michalina Date: Mon, 24 Jul 2023 08:53:02 +0200 Subject: [PATCH] Refactor code asserting asset's balance Previous implementation wasn't properly handling cases when the assertion was not met. In such cases it was silently ending the tests, without reporting any failures (the failure was visible only in the Playwright report, which wasn't opened by default). --- e2e-tests/utils/assets.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/e2e-tests/utils/assets.ts b/e2e-tests/utils/assets.ts index 43f0d71991..9779d57dfb 100644 --- a/e2e-tests/utils/assets.ts +++ b/e2e-tests/utils/assets.ts @@ -78,15 +78,13 @@ export default class AssetsHelper { * Assert the token name and make sure the balance equals (or gets updated * to) the correct value. */ - const activityLeftContainer = this.popup.locator(".left").filter({ + const activityLeftContainer = this.popup.getByTestId("left_wrap").filter({ has: this.popup.locator("span").filter({ hasText: assetSymbol }), }) - await expect(async () => { - const balance = await activityLeftContainer - .getByText(/^(\d|,)+(\.\d{2,4})*$/) - .textContent() - expect(balance).toMatch(expectedBalance) - }).toPass({ + const balance = await activityLeftContainer.getByText( + /^(\d|,)+(\.\d{2,4})*$/ + ) + await expect(balance.getByText(expectedBalance)).toHaveCount(1, { timeout: 120000, })