Skip to content
Snippets Groups Projects
Unverified Commit b5866a19 authored by Guilherme Gazzo's avatar Guilherme Gazzo Committed by GitHub
Browse files

test: close pages properly (#32681)

parent dbc79b76
No related branches found
No related tags found
No related merge requests found
......@@ -17,16 +17,8 @@ test.describe.serial('admin-rooms', () => {
await page.goto('/admin/rooms');
});
test.beforeAll(async ({ browser, api }) => {
[channel, privateRoom] = await Promise.all([
createTargetChannel(api),
createTargetPrivateChannel(api),
browser.newPage({ storageState: Users.admin.state }).then(async (page) => {
await page.goto('/home');
await page.waitForSelector('[data-qa-id="home-header"]');
return page;
}),
]);
test.beforeAll(async ({ api }) => {
[channel, privateRoom] = await Promise.all([createTargetChannel(api), createTargetPrivateChannel(api)]);
});
test('should display the Rooms Table', async ({ page }) => {
......
......@@ -67,122 +67,6 @@ test.describe.serial('channel-management', () => {
await expect(poHomeChannel.getSystemMessageByText('added user1')).toBeVisible();
});
test('should ignore user1 messages', async ({ browser }) => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnTabMembers.click();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.ignoreUser('user1');
await poHomeChannel.tabs.members.openMoreActions();
await expect(poHomeChannel.tabs.members.getMenuItemAction('Unignore')).toBeVisible();
const user1Page = await browser.newPage({ storageState: Users.user1.state });
const user1Channel = new HomeChannel(user1Page);
await user1Page.goto(`/channel/${targetChannel}`);
await user1Channel.waitForChannel();
await user1Channel.content.sendMessage('message to check ignore');
await expect(poHomeChannel.content.lastUserMessageBody).toContainText('This message was ignored');
await user1Page.close();
});
test('should unignore single user1 message', async ({ browser }) => {
await poHomeChannel.sidenav.openChat(targetChannel);
const user1Page = await browser.newPage({ storageState: Users.user1.state });
const user1Channel = new HomeChannel(user1Page);
await user1Page.goto(`/channel/${targetChannel}`);
await user1Channel.waitForChannel();
await user1Channel.content.sendMessage('only message to be unignored');
await poHomeChannel.sidenav.openChat(targetChannel);
await expect(poHomeChannel.content.lastUserMessageBody).toContainText('This message was ignored');
await poHomeChannel.content.lastIgnoredUserMessage.click();
await expect(poHomeChannel.content.lastUserMessageBody).toContainText('only message to be unignored');
await user1Page.close();
});
test('should unignore user1 messages', async ({ browser }) => {
const user1Page = await browser.newPage({ storageState: Users.user1.state });
const user1Channel = new HomeChannel(user1Page);
await user1Page.goto(`/channel/${targetChannel}`);
await user1Channel.waitForChannel();
await user1Channel.content.sendMessage('message before being unignored');
await poHomeChannel.sidenav.openChat(targetChannel);
await expect(poHomeChannel.content.lastUserMessageBody).toContainText('This message was ignored');
await poHomeChannel.tabs.btnTabMembers.click();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.unignoreUser('user1');
await poHomeChannel.tabs.members.openMoreActions();
await expect(poHomeChannel.tabs.members.getMenuItemAction('Ignore')).toBeVisible();
await user1Channel.content.sendMessage('message after being unignored');
await expect(poHomeChannel.content.nthMessage(-2)).toContainText('message before being unignored');
await expect(poHomeChannel.content.lastUserMessageBody).toContainText('message after being unignored');
await user1Page.close();
});
test('should mute user1', async ({ browser }) => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnTabMembers.click();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.muteUser('user1');
await expect(poHomeChannel.getSystemMessageByText('muted user1')).toBeVisible();
const user1Page = await browser.newPage({ storageState: Users.user1.state });
const user1Channel = new HomeChannel(user1Page);
await user1Page.goto(`/channel/${targetChannel}`);
await user1Channel.waitForChannel();
await expect(user1Channel.readOnlyFooter).toBeVisible();
await user1Page.close();
});
test('should set user1 as moderator', async ({ browser }) => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnTabMembers.click();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.setUserAsModerator('user1');
await expect(poHomeChannel.getSystemMessageByText('set user1 as moderator')).toBeVisible();
const user1Page = await browser.newPage({ storageState: Users.user1.state });
const user1Channel = new HomeChannel(user1Page);
await user1Page.goto(`/channel/${targetChannel}`);
await user1Channel.waitForChannel();
await user1Channel.tabs.btnRoomInfo.click();
await expect(user1Channel.tabs.room.btnEdit).toBeVisible();
await user1Page.close();
});
test('should set user1 as owner', async ({ browser }) => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnTabMembers.click();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.setUserAsOwner('user1');
await expect(poHomeChannel.getSystemMessageByText('set user1 as owner')).toBeVisible();
const user1Page = await browser.newPage({ storageState: Users.user1.state });
const user1Channel = new HomeChannel(user1Page);
await user1Page.goto(`/channel/${targetChannel}`);
await user1Channel.waitForChannel();
await user1Channel.tabs.btnRoomInfo.click();
await expect(user1Channel.tabs.room.btnDelete).toBeVisible();
await user1Page.close();
});
test('should edit topic of targetChannel', async ({ page }) => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnRoomInfo.click();
......@@ -302,24 +186,143 @@ test.describe.serial('channel-management', () => {
await expect(poHomeChannel.tabs.notificationPreferences.getPreferenceByDevice('Email')).toContainText('Mentions');
});
let regularUserPage: Page;
test('should readOnlyChannel show join button', async ({ browser }) => {
const channelName = faker.string.uuid();
await poHomeChannel.sidenav.openNewByLabel('Channel');
await poHomeChannel.sidenav.inputChannelName.fill(channelName);
await poHomeChannel.sidenav.checkboxPrivateChannel.click();
await poHomeChannel.sidenav.checkboxReadOnly.click();
await poHomeChannel.sidenav.btnCreate.click();
regularUserPage = await browser.newPage({ storageState: Users.user2.state });
const channel = new HomeChannel(regularUserPage);
await regularUserPage.goto(`/channel/${channelName}`);
await channel.waitForChannel();
await expect(regularUserPage.locator('button >> text="Join"')).toBeVisible();
await regularUserPage.close();
test.describe.serial('cross user tests', () => {
let user1Page: Page;
test.beforeEach(async ({ browser }) => {
user1Page = await browser.newPage({ storageState: Users.user1.state });
});
test.afterEach(async () => {
await user1Page.close();
});
test('should mute user1', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnTabMembers.click();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.muteUser('user1');
await expect(poHomeChannel.getSystemMessageByText('muted user1')).toBeVisible();
const user1Channel = new HomeChannel(user1Page);
await user1Page.goto(`/channel/${targetChannel}`);
await user1Channel.waitForChannel();
await expect(user1Channel.readOnlyFooter).toBeVisible();
});
test('should unmuteUser user1', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnTabMembers.click();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.unmuteUser('user1');
await expect(poHomeChannel.getSystemMessageByText('unmuted user1')).toBeVisible();
const user1Channel = new HomeChannel(user1Page);
await user1Page.goto(`/channel/${targetChannel}`);
await user1Channel.waitForChannel();
await expect(user1Channel.composer).toBeVisible();
});
test('should set user1 as moderator', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnTabMembers.click();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.setUserAsModerator('user1');
await expect(poHomeChannel.getSystemMessageByText('set user1 as moderator')).toBeVisible();
const user1Channel = new HomeChannel(user1Page);
await user1Page.goto(`/channel/${targetChannel}`);
await user1Channel.waitForChannel();
await user1Channel.tabs.btnRoomInfo.click();
await expect(user1Channel.tabs.room.btnEdit).toBeVisible();
});
test('should set user1 as owner', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnTabMembers.click();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.setUserAsOwner('user1');
await expect(poHomeChannel.getSystemMessageByText('set user1 as owner')).toBeVisible();
const user1Channel = new HomeChannel(user1Page);
await user1Page.goto(`/channel/${targetChannel}`);
await user1Channel.waitForChannel();
await user1Channel.tabs.btnRoomInfo.click();
await expect(user1Channel.tabs.room.btnDelete).toBeVisible();
await user1Page.close();
});
test('should ignore user1 messages', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnTabMembers.click();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.ignoreUser('user1');
await poHomeChannel.tabs.members.openMoreActions();
await expect(poHomeChannel.tabs.members.getMenuItemAction('Unignore')).toBeVisible();
const user1Channel = new HomeChannel(user1Page);
await user1Page.goto(`/channel/${targetChannel}`);
await user1Channel.waitForChannel();
await user1Channel.content.sendMessage('message to check ignore');
await expect(poHomeChannel.content.lastUserMessageBody).toContainText('This message was ignored');
});
test('should unignore single user1 message', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
const user1Channel = new HomeChannel(user1Page);
await user1Page.goto(`/channel/${targetChannel}`);
await user1Channel.waitForChannel();
await user1Channel.content.sendMessage('only message to be unignored');
await poHomeChannel.sidenav.openChat(targetChannel);
await expect(poHomeChannel.content.lastUserMessageBody).toContainText('This message was ignored');
await poHomeChannel.content.lastIgnoredUserMessage.click();
await expect(poHomeChannel.content.lastUserMessageBody).toContainText('only message to be unignored');
});
test('should unignore user1 messages', async () => {
const user1Channel = new HomeChannel(user1Page);
await user1Page.goto(`/channel/${targetChannel}`);
await user1Channel.waitForChannel();
await user1Channel.content.sendMessage('message before being unignored');
await poHomeChannel.sidenav.openChat(targetChannel);
await expect(poHomeChannel.content.lastUserMessageBody).toContainText('This message was ignored');
await poHomeChannel.tabs.btnTabMembers.click();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.unignoreUser('user1');
await poHomeChannel.tabs.members.openMoreActions();
await expect(poHomeChannel.tabs.members.getMenuItemAction('Ignore')).toBeVisible();
await user1Channel.content.sendMessage('message after being unignored');
await expect(poHomeChannel.content.nthMessage(-2)).toContainText('message before being unignored');
await expect(poHomeChannel.content.lastUserMessageBody).toContainText('message after being unignored');
});
test('should readOnlyChannel show join button', async () => {
const channelName = faker.string.uuid();
await poHomeChannel.sidenav.openNewByLabel('Channel');
await poHomeChannel.sidenav.inputChannelName.fill(channelName);
await poHomeChannel.sidenav.checkboxPrivateChannel.click();
await poHomeChannel.sidenav.checkboxReadOnly.click();
await poHomeChannel.sidenav.btnCreate.click();
const channel = new HomeChannel(user1Page);
await user1Page.goto(`/channel/${channelName}`);
await channel.waitForChannel();
await expect(user1Page.locator('button >> text="Join"')).toBeVisible();
});
});
});
......@@ -46,6 +46,11 @@ export class HomeFlextabMembers {
await this.page.getByRole('dialog').getByRole('button').first().click();
}
async unmuteUser(username: string) {
await this.openMemberOptionMoreActions(username);
await this.getMenuItemAction('Unmute user').click();
}
async setUserAsModerator(username: string) {
await this.openMemberOptionMoreActions(username);
await this.getMenuItemAction('Set as moderator').click();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment