diff --git a/tests/e2e/utils/contextManager.ts b/tests/e2e/utils/contextManager.ts index 33f9dbec..83cdb439 100644 --- a/tests/e2e/utils/contextManager.ts +++ b/tests/e2e/utils/contextManager.ts @@ -7,6 +7,9 @@ export class ContextManager { constructor(private browser: Browser) {} async createContext(name: string): Promise { + const existing = this.contexts.get(name) + if (existing) await existing.page.context().close() + const context = await this.browser.newContext() const page = await context.newPage() const app = new App(page) diff --git a/tests/e2e/utils/firebaseUtils.ts b/tests/e2e/utils/firebaseUtils.ts index 0fedeb7c..f90d2ca0 100644 --- a/tests/e2e/utils/firebaseUtils.ts +++ b/tests/e2e/utils/firebaseUtils.ts @@ -53,7 +53,7 @@ export async function verifyEmail(email: string, password: string) { await sendVerificationEmail(loginInfo.data.idToken) const oobResponse = await axios.get(`${config.FIREBASE_URL.FIREBASE_EMULATOR_API}`) const oobCode = await getOobCode(oobResponse.data.oobCodes, email) - console.log(oobCode) + if (!oobCode) throw new Error(`No verification OOB code found for email: ${email}`) const response = await axios.post( `${config.FIREBASE_URL.BASE}${config.FIREBASE_URL.CONFIRM_EMAIL_VERIFICATION}`, diff --git a/tests/e2e/web/pages/messagesPage.ts b/tests/e2e/web/pages/messagesPage.ts index de0120a4..5a80b4b0 100644 --- a/tests/e2e/web/pages/messagesPage.ts +++ b/tests/e2e/web/pages/messagesPage.ts @@ -47,11 +47,13 @@ export class MessagesPage { const results = await this.newMessageSearchResults .getByTestId('search-results-username') .all() - - for (let i = 0; i < results.length; i++) { - const usernameResults = await results[i].textContent() - if (usernameResults?.toLowerCase() === username[i].toLowerCase()) await results[i].click() - break + const targetUser = username[i].toLowerCase() + for (let j = 0; j < results.length; j++) { + const usernameResults = (await results[j].textContent())?.toLowerCase() + if (usernameResults === targetUser) { + await results[j].click() + break + } } } @@ -64,10 +66,12 @@ export class MessagesPage { await this.messageInput.fill(message) await expect(this.messageSubmit).toBeVisible() await this.messageSubmit.click() + await this.verifyMessage(message) } async findMessageConversation(displayName: string) { await expect(this.messagesTable).toBeVisible() + await this.page.waitForTimeout(1000) const doMessagesExist = (await this.messagesRow.count()) > 0 if (doMessagesExist) { const messages = await this.messagesRow.getByTestId('messages-username').all() @@ -84,6 +88,7 @@ export class MessagesPage { async verifyMessage(messageContent: string) { await expect(this.conversation).toBeVisible() + await this.page.waitForTimeout(1000) const messageCount = (await this.conversationMessage.count()) > 0 if (messageCount) { const messages = await this.conversationMessage.all() diff --git a/tests/e2e/web/pages/peoplePage.ts b/tests/e2e/web/pages/peoplePage.ts index e724e368..67eece02 100644 --- a/tests/e2e/web/pages/peoplePage.ts +++ b/tests/e2e/web/pages/peoplePage.ts @@ -456,6 +456,7 @@ export class PeoplePage { async getProfileInfo() { await expect(this.profileGrid).toBeVisible() const totalResults = await this.profileResults.count() + if (totalResults === 0) throw Error('No profiles found') const chosenProfileNumber = Math.floor(Math.random() * totalResults) const chosenProfile = await this.profileResults.nth(chosenProfileNumber) const profileName = await chosenProfile.getByTestId('people-profile-name').textContent() @@ -506,6 +507,7 @@ export class PeoplePage { await expect(this.messageInput).toBeVisible() await this.messageInput.fill(message) await this.page.getByTestId('conversation-message-submit').click() + return } } } diff --git a/tests/e2e/web/specs/signIn.spec.ts b/tests/e2e/web/specs/signIn.spec.ts index 4b554ba7..2cd8d467 100644 --- a/tests/e2e/web/specs/signIn.spec.ts +++ b/tests/e2e/web/specs/signIn.spec.ts @@ -30,8 +30,9 @@ test.describe('when given valid input', () => { await app.people.setDisplayFilter({cardSize: 'Large'}) const filterdProfiles = await app.people.profileCountLocator.textContent() - if (!totalProfiles || !filterdProfiles) return - await expect(parseInt(totalProfiles)).not.toEqual(parseInt(filterdProfiles)) + await expect(totalProfiles).not.toBeNull() + await expect(filterdProfiles).not.toBeNull() + await expect(Number(totalProfiles)).not.toEqual(Number(filterdProfiles)) const results = await app.people.getProfileInfo() if (!results) return @@ -66,7 +67,7 @@ test.describe('when given valid input', () => { await app.home.clickPeopleLink() const totalProfiles = await app.people.profileCountLocator.textContent() - await app.people.setGenderTypeFilter(['Women', 'female']) + await app.people.setGenderTypeFilter(['Woman', 'female']) await app.people.setDisplayFilter({cardSize: 'Large'}) if (!totalProfiles) return await app.people.verifyProfileCount(totalProfiles)