Skip to content

Commit f490548

Browse files
committed
Coderabbit suggestions
1 parent 21a720f commit f490548

5 files changed

Lines changed: 20 additions & 9 deletions

File tree

tests/e2e/utils/contextManager.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ export class ContextManager {
77
constructor(private browser: Browser) {}
88

99
async createContext(name: string): Promise<App> {
10+
const existing = this.contexts.get(name)
11+
if (existing) await existing.page.context().close()
12+
1013
const context = await this.browser.newContext()
1114
const page = await context.newPage()
1215
const app = new App(page)

tests/e2e/utils/firebaseUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export async function verifyEmail(email: string, password: string) {
5353
await sendVerificationEmail(loginInfo.data.idToken)
5454
const oobResponse = await axios.get(`${config.FIREBASE_URL.FIREBASE_EMULATOR_API}`)
5555
const oobCode = await getOobCode(oobResponse.data.oobCodes, email)
56-
console.log(oobCode)
56+
if (!oobCode) throw new Error(`No verification OOB code found for email: ${email}`)
5757

5858
const response = await axios.post(
5959
`${config.FIREBASE_URL.BASE}${config.FIREBASE_URL.CONFIRM_EMAIL_VERIFICATION}`,

tests/e2e/web/pages/messagesPage.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ export class MessagesPage {
4747
const results = await this.newMessageSearchResults
4848
.getByTestId('search-results-username')
4949
.all()
50-
51-
for (let i = 0; i < results.length; i++) {
52-
const usernameResults = await results[i].textContent()
53-
if (usernameResults?.toLowerCase() === username[i].toLowerCase()) await results[i].click()
54-
break
50+
const targetUser = username[i].toLowerCase()
51+
for (let j = 0; j < results.length; j++) {
52+
const usernameResults = (await results[j].textContent())?.toLowerCase()
53+
if (usernameResults === targetUser) {
54+
await results[j].click()
55+
break
56+
}
5557
}
5658
}
5759

@@ -64,10 +66,12 @@ export class MessagesPage {
6466
await this.messageInput.fill(message)
6567
await expect(this.messageSubmit).toBeVisible()
6668
await this.messageSubmit.click()
69+
await this.verifyMessage(message)
6770
}
6871

6972
async findMessageConversation(displayName: string) {
7073
await expect(this.messagesTable).toBeVisible()
74+
await this.page.waitForTimeout(1000)
7175
const doMessagesExist = (await this.messagesRow.count()) > 0
7276
if (doMessagesExist) {
7377
const messages = await this.messagesRow.getByTestId('messages-username').all()
@@ -84,6 +88,7 @@ export class MessagesPage {
8488

8589
async verifyMessage(messageContent: string) {
8690
await expect(this.conversation).toBeVisible()
91+
await this.page.waitForTimeout(1000)
8792
const messageCount = (await this.conversationMessage.count()) > 0
8893
if (messageCount) {
8994
const messages = await this.conversationMessage.all()

tests/e2e/web/pages/peoplePage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ export class PeoplePage {
456456
async getProfileInfo() {
457457
await expect(this.profileGrid).toBeVisible()
458458
const totalResults = await this.profileResults.count()
459+
if (totalResults === 0) throw Error('No profiles found')
459460
const chosenProfileNumber = Math.floor(Math.random() * totalResults)
460461
const chosenProfile = await this.profileResults.nth(chosenProfileNumber)
461462
const profileName = await chosenProfile.getByTestId('people-profile-name').textContent()
@@ -506,6 +507,7 @@ export class PeoplePage {
506507
await expect(this.messageInput).toBeVisible()
507508
await this.messageInput.fill(message)
508509
await this.page.getByTestId('conversation-message-submit').click()
510+
return
509511
}
510512
}
511513
}

tests/e2e/web/specs/signIn.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ test.describe('when given valid input', () => {
3030
await app.people.setDisplayFilter({cardSize: 'Large'})
3131
const filterdProfiles = await app.people.profileCountLocator.textContent()
3232

33-
if (!totalProfiles || !filterdProfiles) return
34-
await expect(parseInt(totalProfiles)).not.toEqual(parseInt(filterdProfiles))
33+
await expect(totalProfiles).not.toBeNull()
34+
await expect(filterdProfiles).not.toBeNull()
35+
await expect(Number(totalProfiles)).not.toEqual(Number(filterdProfiles))
3536

3637
const results = await app.people.getProfileInfo()
3738
if (!results) return
@@ -66,7 +67,7 @@ test.describe('when given valid input', () => {
6667
await app.home.clickPeopleLink()
6768

6869
const totalProfiles = await app.people.profileCountLocator.textContent()
69-
await app.people.setGenderTypeFilter(['Women', 'female'])
70+
await app.people.setGenderTypeFilter(['Woman', 'female'])
7071
await app.people.setDisplayFilter({cardSize: 'Large'})
7172
if (!totalProfiles) return
7273
await app.people.verifyProfileCount(totalProfiles)

0 commit comments

Comments
 (0)