-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from jbrunton/invitation-tests
test: add invitation tests
- Loading branch information
Showing
2 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,10 +49,10 @@ test("users can join rooms", async ({ | |
await user2RoomPage.join(); | ||
|
||
await expect( | ||
user1Page.getByText("User 2 joined the room. Welcome!") | ||
user1Page.getByText("Test User 2 joined the room. Welcome!") | ||
).toBeVisible(); | ||
await expect( | ||
user2Page.getByText("User 2 joined the room. Welcome!") | ||
user2Page.getByText("Test User 2 joined the room. Welcome!") | ||
).toBeVisible(); | ||
}); | ||
|
||
|
@@ -67,3 +67,81 @@ test("owners can rename rooms", async ({ page, menu, roomPage }) => { | |
await expect(roomPage.getMessage("Room renamed to My Room")).toBeVisible(); | ||
await expect(page.getByRole("heading", { name: "My Room" })).toBeVisible(); | ||
}); | ||
|
||
test("users can request to join rooms when join policy = 'request'", async ({ | ||
page: user1Page, | ||
roomPage: user1RoomPage, | ||
menu: user1Menu, | ||
browser, | ||
}) => { | ||
await user1Page.goto("/"); | ||
|
||
await user1Menu.open(); | ||
await user1Menu.createRoom(); | ||
await user1RoomPage.setJoinPolicy("request"); | ||
|
||
const user2Context = await browser.newContext({ | ||
storageState: user2AuthFile, | ||
}); | ||
const user2Page = await user2Context.newPage(); | ||
|
||
await user2Page.goto(user1Page.url()); | ||
|
||
const user2RoomPage = new RoomPage(user2Page); | ||
await user2RoomPage.requestToJoin(); | ||
|
||
await expect( | ||
user1Page.getByText( | ||
"Test User 2 ([email protected]) requested approval to join the room" | ||
) | ||
).toBeVisible(); | ||
|
||
await user1RoomPage.sendMessage("/approve request [email protected]"); | ||
|
||
await expect( | ||
user1Page.getByText("Test User 1 approved Test User 2 to join the room") | ||
).toBeVisible(); | ||
await user2Page.reload(); | ||
await expect( | ||
user2Page.getByText("Test User 1 approved Test User 2 to join the room") | ||
).toBeVisible(); | ||
}); | ||
|
||
test("users can send invites to rooms when join policy = 'invite'", async ({ | ||
page: user1Page, | ||
roomPage: user1RoomPage, | ||
menu: user1Menu, | ||
browser, | ||
}) => { | ||
await user1Page.goto("/"); | ||
|
||
await user1Menu.open(); | ||
await user1Menu.createRoom(); | ||
await user1RoomPage.setJoinPolicy("invite"); | ||
|
||
const user2Context = await browser.newContext({ | ||
storageState: user2AuthFile, | ||
}); | ||
const user2Page = await user2Context.newPage(); | ||
|
||
await user2Page.goto(user1Page.url()); | ||
|
||
const user2RoomPage = new RoomPage(user2Page); | ||
await expect(user2Page.getByText("You need an invite to join")).toBeVisible(); | ||
|
||
await user1RoomPage.sendMessage("/invite [email protected]"); | ||
|
||
await expect( | ||
user1Page.getByText("Test User 1 invited Test User 2 to join the room") | ||
).toBeVisible(); | ||
|
||
await user2Page.reload(); | ||
await user2RoomPage.join(); | ||
|
||
await expect( | ||
user1Page.getByText("Test User 2 joined the room") | ||
).toBeVisible(); | ||
await expect( | ||
user2Page.getByText("Test User 2 joined the room") | ||
).toBeVisible(); | ||
}); |