Skip to content

Commit

Permalink
test: team-management
Browse files Browse the repository at this point in the history
  • Loading branch information
juliajforesti committed Dec 11, 2024
1 parent f61dae1 commit 1ade865
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions apps/meteor/tests/e2e/team-management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { faker } from '@faker-js/faker';

import { Users } from './fixtures/userStates';
import { HomeTeam } from './page-objects';
import { createTargetChannel, deleteTeam, deleteChannel, createTargetTeam } from './utils';
import { createTargetChannel, deleteTeam, deleteChannel } from './utils';
import { expect, test } from './utils/test';

test.use({ storageState: Users.admin.state });

test.describe.serial('teams-management', () => {
let poHomeTeam: HomeTeam;
let targetChannel: string;
let targetTeam: string;
const targetTeam = faker.string.uuid();
const targetTeamName = faker.string.uuid();
const targetTeamNonPrivate = faker.string.uuid();
const targetTeamReadOnly = faker.string.uuid();
Expand All @@ -19,7 +19,6 @@ test.describe.serial('teams-management', () => {

test.beforeAll(async ({ api }) => {
targetChannel = await createTargetChannel(api);
targetTeam = await createTargetTeam(api);
});

test.afterAll(async ({ api }) => {
Expand Down Expand Up @@ -50,11 +49,11 @@ test.describe.serial('teams-management', () => {

test('should create targetTeam private', async ({ page }) => {
await poHomeTeam.sidebar.openCreateNewByLabel('Team');
await poHomeTeam.createRoomModal.inputTeamName.fill(targetTeamName);
await poHomeTeam.createRoomModal.inputTeamName.fill(targetTeam);
await poHomeTeam.addMember('user1');
await poHomeTeam.createRoomModal.btnCreate.click();

await expect(page).toHaveURL(`/group/${targetTeamName}`);
await expect(page).toHaveURL(`/group/${targetTeam}`);
});

test('should create targetTeamNonPrivate non private', async ({ page }) => {
Expand All @@ -80,7 +79,7 @@ test.describe.serial('teams-management', () => {

test('should throw validation error if team name already exists', async () => {
await poHomeTeam.sidebar.openCreateNewByLabel('Team');
await poHomeTeam.createRoomModal.inputTeamName.fill(targetTeamName);
await poHomeTeam.createRoomModal.inputTeamName.fill(targetTeam);
await poHomeTeam.createRoomModal.btnCreate.click();

await expect(poHomeTeam.inputTeamName).toHaveAttribute('aria-invalid', 'true');
Expand Down Expand Up @@ -137,7 +136,7 @@ test.describe.serial('teams-management', () => {
await expect(poHomeTeam.tabs.channels.btnCreateNew).not.toBeVisible();
});

test.skip('should allow creating a channel in a team if user has the create-team-channel permission, but not the create-team-group permission', async ({
test('should allow creating a channel in a team if user has the create-team-channel permission, but not the create-team-group permission', async ({
api,
}) => {
expect(
Expand All @@ -163,7 +162,7 @@ test.describe.serial('teams-management', () => {
await expect(poHomeTeam.tabs.channels.channelsList).toContainText(targetChannelNameInTeam);
});

test.skip('should allow creating a group in a team if user has the create-team-group permission, but not the create-team-channel permission', async ({
test('should allow creating a group in a team if user has the create-team-group permission, but not the create-team-channel permission', async ({
api,
}) => {
expect(
Expand Down Expand Up @@ -222,7 +221,7 @@ test.describe.serial('teams-management', () => {

await poHomeTeam.sidebar.openChat(targetTeam);
await poHomeTeam.tabs.btnChannels.click();
await poHomeTeam.tabs.channels.openChannelOptionMoreActions(targetChannel);
await poHomeTeam.tabs.channels.openChannelOptionMoreActions(targetGroupNameInTeam);
await expect(page.getByRole('menu', { exact: true }).getByRole('menuitem', { name: 'Remove from team' })).not.toBeVisible();
});

Expand All @@ -231,7 +230,7 @@ test.describe.serial('teams-management', () => {

await poHomeTeam.sidebar.openChat(targetTeam);
await poHomeTeam.tabs.btnChannels.click();
await poHomeTeam.tabs.channels.openChannelOptionMoreActions(targetChannel);
await poHomeTeam.tabs.channels.openChannelOptionMoreActions(targetGroupNameInTeam);
await expect(page.getByRole('menu', { exact: true }).getByRole('menuitem', { name: 'Remove from team' })).toBeVisible();
await page.getByRole('menu', { exact: true }).getByRole('menuitem', { name: 'Remove from team' }).click();
await poHomeTeam.tabs.channels.confirmRemoveChannel();
Expand All @@ -258,13 +257,13 @@ test.describe.serial('teams-management', () => {
await poHomeTeam.sidebar.openChat(targetTeam);
await poHomeTeam.tabs.btnChannels.click();
await poHomeTeam.tabs.channels.btnAddExisting.click();
await poHomeTeam.tabs.channels.inputChannels.fill(targetChannel);
await page.locator(`.rcx-option__content:has-text("${targetChannel}")`).click();
await poHomeTeam.tabs.channels.inputChannels.fill(targetGroupNameInTeam);
await page.locator(`.rcx-option__content:has-text("${targetGroupNameInTeam}")`).click();
await poHomeTeam.tabs.channels.btnAdd.click();
await expect(poHomeTeam.tabs.channels.channelsList).toContainText(targetChannel);
await expect(poHomeTeam.tabs.channels.channelsList).toContainText(targetGroupNameInTeam);

// try to delete group in team
await poHomeTeam.tabs.channels.openChannelOptionMoreActions(targetChannel);
await poHomeTeam.tabs.channels.openChannelOptionMoreActions(targetGroupNameInTeam);
await expect(page.getByRole('menu', { exact: true }).getByRole('menuitem', { name: 'Delete' })).not.toBeVisible();
});

Expand All @@ -274,16 +273,16 @@ test.describe.serial('teams-management', () => {
}) => {
expect((await api.post('/permissions.update', { permissions: [{ _id: 'delete-team-group', roles: ['owner'] }] })).status()).toBe(200);

await poHomeTeam.sidebar.openChat(targetTeam);
await poHomeTeam.sidebar.openChat(targetTeamName);
await poHomeTeam.tabs.btnChannels.click();
await poHomeTeam.tabs.channels.openChannelOptionMoreActions(targetChannel);
await poHomeTeam.tabs.channels.openChannelOptionMoreActions(targetGroupNameInTeam);
await expect(page.getByRole('menu', { exact: true }).getByRole('menuitem', { name: 'Delete' })).toBeVisible();
await page.getByRole('menu', { exact: true }).getByRole('menuitem', { name: 'Delete' }).click();
await poHomeTeam.tabs.channels.confirmDeleteRoom();

await poHomeTeam.sidebar.openChat(targetTeam);
await poHomeTeam.tabs.btnChannels.click();
await expect(poHomeTeam.tabs.channels.channelsList).not.toContainText(targetChannel);
await expect(poHomeTeam.tabs.channels.channelsList).not.toContainText(targetGroupNameInTeam);
});

test('should not allow removing a targetChannel from targetTeam if user does not have the remove-team-channel permission', async ({
Expand All @@ -296,7 +295,7 @@ test.describe.serial('teams-management', () => {

await poHomeTeam.sidebar.openChat(targetTeam);
await poHomeTeam.tabs.btnChannels.click();
await poHomeTeam.tabs.channels.openChannelOptionMoreActions(targetChannel);
await poHomeTeam.tabs.channels.openChannelOptionMoreActions(targetChannelNameInTeam);
await expect(page.getByRole('menu', { exact: true }).getByRole('menuitem', { name: 'Remove from team' })).not.toBeVisible();
});

Expand All @@ -305,12 +304,12 @@ test.describe.serial('teams-management', () => {

await poHomeTeam.sidebar.openChat(targetTeam);
await poHomeTeam.tabs.btnChannels.click();
await poHomeTeam.tabs.channels.openChannelOptionMoreActions(targetChannel);
await poHomeTeam.tabs.channels.openChannelOptionMoreActions(targetChannelNameInTeam);
await expect(page.getByRole('menu', { exact: true }).getByRole('menuitem', { name: 'Remove from team' })).toBeVisible();
await page.getByRole('menu', { exact: true }).getByRole('menuitem', { name: 'Remove from team' }).click();
await poHomeTeam.tabs.channels.confirmRemoveChannel();

await expect(poHomeTeam.tabs.channels.channelsList).not.toContainText(targetChannel);
await expect(poHomeTeam.tabs.channels.channelsList).not.toContainText(targetChannelNameInTeam);
});

test('should not allow deleting a targetChannel from targetTeam if the channel owner does not have the delete-team-channel permission', async ({
Expand All @@ -332,13 +331,13 @@ test.describe.serial('teams-management', () => {
await poHomeTeam.sidebar.openChat(targetTeam);
await poHomeTeam.tabs.btnChannels.click();
await poHomeTeam.tabs.channels.btnAddExisting.click();
await poHomeTeam.tabs.channels.inputChannels.fill(targetChannel);
await page.locator(`.rcx-option__content:has-text("${targetChannel}")`).click();
await poHomeTeam.tabs.channels.inputChannels.fill(targetChannelNameInTeam);
await page.locator(`.rcx-option__content:has-text("${targetChannelNameInTeam}")`).click();
await poHomeTeam.tabs.channels.btnAdd.click();
await expect(poHomeTeam.tabs.channels.channelsList).toContainText(targetChannel);
await expect(poHomeTeam.tabs.channels.channelsList).toContainText(targetChannelNameInTeam);

// try to delete channel in team
await poHomeTeam.tabs.channels.openChannelOptionMoreActions(targetChannel);
await poHomeTeam.tabs.channels.openChannelOptionMoreActions(targetChannelNameInTeam);
await expect(page.getByRole('menu', { exact: true }).getByRole('menuitem', { name: 'Delete' })).not.toBeVisible();
});

Expand All @@ -350,14 +349,14 @@ test.describe.serial('teams-management', () => {

await poHomeTeam.sidebar.openChat(targetTeam);
await poHomeTeam.tabs.btnChannels.click();
await poHomeTeam.tabs.channels.openChannelOptionMoreActions(targetChannel);
await poHomeTeam.tabs.channels.openChannelOptionMoreActions(targetChannelNameInTeam);
await expect(page.getByRole('menu', { exact: true }).getByRole('menuitem', { name: 'Delete' })).toBeVisible();
await page.getByRole('menu', { exact: true }).getByRole('menuitem', { name: 'Delete' }).click();
await poHomeTeam.tabs.channels.confirmDeleteRoom();

await poHomeTeam.sidebar.openChat(targetTeam);
await poHomeTeam.tabs.btnChannels.click();
await expect(poHomeTeam.tabs.channels.channelsList).not.toContainText(targetChannel);
await expect(poHomeTeam.tabs.channels.channelsList).not.toContainText(targetChannelNameInTeam);
});

test('should remove targetChannel from targetTeam', async ({ page, api }) => {
Expand Down

0 comments on commit 1ade865

Please sign in to comment.