Skip to content

Commit

Permalink
test: e2e test for username taken
Browse files Browse the repository at this point in the history
  • Loading branch information
Kacper-RF committed Dec 6, 2023
1 parent 7e870b6 commit d82a503
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
9 changes: 9 additions & 0 deletions packages/e2e-tests/src/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ export class RegisterUsernameModal {
return this.driver.wait(until.elementLocated(By.xpath("//h3[text()='Register a username']")))
}

get elementUsernameTaken() {
return this.driver.wait(until.elementLocated(By.xpath("//h6[text()='Username taken']")))
}

get error() {
return this.driver.wait(until.elementLocated(By.xpath("//p[text()='Username already taken.']")))
}
Expand All @@ -163,6 +167,11 @@ export class RegisterUsernameModal {
const submitButton = await this.driver.findElement(By.xpath('//button[text()="Register"]'))
await submitButton.click()
}

async submitUsernameTaken() {
const submitButton = await this.driver.findElement(By.xpath('//button[text()="Continue"]'))
await submitButton.click()
}
}
export class JoinCommunityModal {
private readonly driver: ThenableWebDriver
Expand Down
20 changes: 17 additions & 3 deletions packages/e2e-tests/src/tests/multipleClients.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,32 @@ describe('Multiple Clients', () => {
await joinCommunityModal.typeCommunityCode(invitationCode)
await joinCommunityModal.submit()
})
// ______________

it('Second user submits valid, not-duplicated username', async () => {
console.log('nereeew user - 5')
it('Second user submits non-valid, duplicated username', async () => {
console.log('duplicated user - 1')
const registerModal = new RegisterUsernameModal(users.user3.app.driver)
const isRegisterModal = await registerModal.element.isDisplayed()
expect(isRegisterModal).toBeTruthy()
await registerModal.clearInput()
await registerModal.typeUsername(users.user3.username)
await registerModal.typeUsername(users.user1.username)
await registerModal.submit()
console.time(`[${users.user3.app.name}] '${users.user1.username}' duplicated joining community time`)
})

it('Second user submits valid username', async () => {
console.log('duplicated user - 2')
const registerModal = new RegisterUsernameModal(users.user3.app.driver)
const isRegisterModal = await registerModal.elementUsernameTaken.isDisplayed()
expect(isRegisterModal).toBeTruthy()
await registerModal.clearInput()
await registerModal.typeUsername(users.user3.username)
await registerModal.submitUsernameTaken()
console.time(`[${users.user3.app.name}] '${users.user3.username}' joining community time`)
})

// ______________

it('Second user sees general channel', async () => {
console.log('new user - 7')
generalChannelUser3 = new Channel(users.user3.app.driver, 'general')
Expand Down

0 comments on commit d82a503

Please sign in to comment.