Skip to content

Commit

Permalink
chore: e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
dougfabris committed May 31, 2024
1 parent 613bcee commit 889621e
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions apps/meteor/tests/e2e/retention-policy.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import { faker } from '@faker-js/faker';

import { createAuxContext } from './fixtures/createAuxContext';
import { Users } from './fixtures/userStates';
import { HomeChannel } from './page-objects';
import { createTargetChannel, createTargetPrivateChannel, createTargetTeam, setSettingValueById } from './utils';
import { createTargetPrivateChannel, createTargetTeam, setSettingValueById } from './utils';
import { test, expect } from './utils/test';

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

test.describe.serial('retention-policy', () => {
let poHomeChannel: HomeChannel;
let targetChannel: string;
const targetChannel = faker.string.uuid();
let targetTeam: string;
let targetGroup: string;

test.beforeAll(async ({ api }) => {
targetChannel = await createTargetChannel(api);
const response = await api.post('/channels.create', { name: targetChannel, members: ['user1'] });
const { channel } = await response.json();
await api.post('/channels.addOwner', { roomId: channel._id, userId: Users.user1.data._id });

targetGroup = await createTargetPrivateChannel(api);
targetTeam = await createTargetTeam(api);
})
Expand Down Expand Up @@ -48,7 +54,7 @@ test.describe.serial('retention-policy', () => {
test.describe('retention policy enabled', () => {
test.beforeAll(async ({ api }) => {
await setSettingValueById(api, 'RetentionPolicy_Enabled', true);
})
});
test.afterAll(async ({ api }) => {
await setSettingValueById(api, 'RetentionPolicy_Enabled', false);
await setSettingValueById(api, 'RetentionPolicy_AppliesToChannels', false);
Expand Down Expand Up @@ -79,6 +85,17 @@ test.describe.serial('retention-policy', () => {
await expect(poHomeChannel.tabs.room.pruneAccordion).toBeVisible();
});

test('should not show prune section in edit channel for users without permission', async ({ browser }) => {
const { page } = await createAuxContext(browser, Users.user1);
const auxContext = { page, poHomeChannel: new HomeChannel(page) };
await auxContext.poHomeChannel.sidenav.openChat(targetChannel);
await auxContext.poHomeChannel.tabs.btnRoomInfo.click();
await auxContext.poHomeChannel.tabs.room.btnEdit.click();

await expect(poHomeChannel.tabs.room.pruneAccordion).not.toBeVisible();
await auxContext.page.close();
})

test.describe('retention policy applies enabled by default', () => {
test.beforeAll(async ({ api }) => {
await setSettingValueById(api, 'RetentionPolicy_AppliesToChannels', true);
Expand Down

0 comments on commit 889621e

Please sign in to comment.