From 84de5bc135dbd571198f995b54b0f692e3229e1f Mon Sep 17 00:00:00 2001 From: Douglas Fabris Date: Tue, 19 Sep 2023 19:21:49 -0300 Subject: [PATCH] chore: Assertion accuracy on registration test (#30440) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- apps/meteor/tests/e2e/page-objects/auth.ts | 8 -------- apps/meteor/tests/e2e/page-objects/utils.ts | 4 ++++ apps/meteor/tests/e2e/register.spec.ts | 14 ++++++++------ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/apps/meteor/tests/e2e/page-objects/auth.ts b/apps/meteor/tests/e2e/page-objects/auth.ts index 26537f183113..b03e45ee22b7 100644 --- a/apps/meteor/tests/e2e/page-objects/auth.ts +++ b/apps/meteor/tests/e2e/page-objects/auth.ts @@ -19,10 +19,6 @@ export class Registration { return this.page.locator('role=link[name="Create an account"]'); } - get main(): Locator { - return this.page.locator('role=main'); - } - get backToLogin(): Locator { return this.page.locator('role=link[name="Back to Login"]'); } @@ -63,10 +59,6 @@ export class Registration { return this.page.locator('[name=passwordConfirmation]'); } - // get textErrorPasswordConfirm(): Locator { - // return this.page.locator('[name=confirm-pass]~.input-error'); - // } - get forgotPasswordEmailCallout(): Locator { return this.page.locator('role=status'); } diff --git a/apps/meteor/tests/e2e/page-objects/utils.ts b/apps/meteor/tests/e2e/page-objects/utils.ts index d71eaf55daab..066c5eac153f 100644 --- a/apps/meteor/tests/e2e/page-objects/utils.ts +++ b/apps/meteor/tests/e2e/page-objects/utils.ts @@ -7,6 +7,10 @@ export class Utils { this.page = page; } + get mainContent(): Locator { + return this.page.locator('main.main-content'); + } + get toastBar(): Locator { return this.page.locator('.rcx-toastbar'); } diff --git a/apps/meteor/tests/e2e/register.spec.ts b/apps/meteor/tests/e2e/register.spec.ts index 6d62ace5e7d3..1709b8414e6b 100644 --- a/apps/meteor/tests/e2e/register.spec.ts +++ b/apps/meteor/tests/e2e/register.spec.ts @@ -1,14 +1,16 @@ import { faker } from '@faker-js/faker'; -import { Registration } from './page-objects'; +import { Utils, Registration } from './page-objects'; import { test, expect } from './utils/test'; -test.describe.serial('register', () => { +test.describe.parallel('register', () => { let poRegistration: Registration; + let poUtils: Utils; test.describe('Registration default flow', async () => { test.beforeEach(async ({ page }) => { poRegistration = new Registration(page); + poUtils = new Utils(page); }); test('Successfully Registration flow', async ({ page }) => { await test.step('expect trigger a validation error if no data is provided on register', async () => { @@ -37,7 +39,7 @@ test.describe.serial('register', () => { await test.step('expect successfully register a new user', async () => { await poRegistration.inputPasswordConfirm.fill('any_password'); await poRegistration.btnRegister.click(); - await expect(poRegistration.main).toBeHidden(); + await expect(poUtils.mainContent).toBeVisible(); }); }); @@ -70,7 +72,7 @@ test.describe.serial('register', () => { await poRegistration.inputPassword.fill('any_password'); await poRegistration.btnRegister.click(); - await expect(poRegistration.main).toBeHidden(); + await expect(poUtils.mainContent).toBeVisible(); }); }); }); @@ -137,6 +139,7 @@ test.describe.serial('register', () => { test.describe('Registration for secret password', async () => { test.beforeEach(async ({ api, page }) => { poRegistration = new Registration(page); + poUtils = new Utils(page); const result = await api.post('/settings/Accounts_RegistrationForm', { value: 'Secret URL' }); await api.post('/settings/Accounts_RegistrationForm_SecretURL', { value: 'secret' }); await expect(result.ok()).toBeTruthy(); @@ -173,8 +176,7 @@ test.describe.serial('register', () => { await poRegistration.inputPassword.fill('any_password'); await poRegistration.inputPasswordConfirm.fill('any_password'); await poRegistration.btnRegister.click(); - await page.waitForSelector('role=main'); - await expect(poRegistration.main).toBeVisible(); + await expect(poUtils.mainContent).toBeVisible(); }); });