Skip to content

Commit

Permalink
chore: add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
dougfabris committed May 23, 2024
1 parent 616544a commit 05579ec
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ export class HomeFlextabRoom {
}

get checkboxPruneMessages(): Locator {
return this.page.locator('label', { has: this.page.getByRole('checkbox', { name: 'Automatically prune old messages' }) });
return this.page.getByRole('dialog').locator('label', { has: this.page.getByRole('checkbox', { name: 'Automatically prune old messages' }) });
}

get checkboxOverrideGlobalRetention(): Locator {
return this.page.locator('label', { has: this.page.getByRole('checkbox', { name: 'Override global retention policy' }) });
return this.page.getByRole('dialog').locator('label', { has: this.page.getByRole('checkbox', { name: 'Override global retention policy' }) });
}

get checkboxIgnoreThreads(): Locator {
return this.page.getByRole('dialog').locator('label', { has: this.page.getByRole('checkbox', { name: 'Do not prune Threads' }) });
}
}
14 changes: 13 additions & 1 deletion apps/meteor/tests/e2e/retention-policy.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Users } from './fixtures/userStates';
import { HomeChannel } from './page-objects';
import { createTargetChannel, createTargetPrivateChannel, setSettingValueById } from './utils';
import { createTargetChannel, createTargetPrivateChannel, getSettingValueById, setSettingValueById } from './utils';
import { test, expect } from './utils/test';

test.use({ storageState: Users.admin.state });
Expand Down Expand Up @@ -102,7 +102,10 @@ test.describe.serial('retention-policy', () => {
});

test.describe('retention policy override', () => {
let ignoreThreadsSetting: boolean;

test.beforeAll(async ({ api }) => {
ignoreThreadsSetting = await getSettingValueById(api, 'RetentionPolicy_DoNotPruneThreads') as boolean;
expect((await setSettingValueById(api, 'RetentionPolicy_MaxAge_Channels', 15)).status()).toBe(200);
});

Expand Down Expand Up @@ -133,6 +136,15 @@ test.describe.serial('retention-policy', () => {
await expect(poHomeChannel.tabs.room.getMaxAgeLabel('15')).toBeVisible();
await expect(poHomeChannel.tabs.room.inputRetentionMaxAge).toHaveValue('365');
});

test('should ignore threads be checked accordingly with the global default value', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnRoomInfo.click();
await poHomeChannel.tabs.room.btnEdit.click();
await poHomeChannel.tabs.room.pruneAccordion.click();

await expect(poHomeChannel.tabs.room.checkboxIgnoreThreads).toBeChecked({ checked: ignoreThreadsSetting });
});
});
});
});
1 change: 1 addition & 0 deletions apps/meteor/tests/e2e/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './create-target-channel';
export * from './setSettingValueById';
export * from './getSettingValueById';

0 comments on commit 05579ec

Please sign in to comment.