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

regression: fix retention flaky test (#32649)

parent 768cad6d
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ export enum TIMEUNIT { ...@@ -4,7 +4,7 @@ export enum TIMEUNIT {
minutes = 'minutes', minutes = 'minutes',
} }
const isValidTimespan = (timespan: number): boolean => { export const isValidTimespan = (timespan: number): boolean => {
if (Number.isNaN(timespan)) { if (Number.isNaN(timespan)) {
return false; return false;
} }
...@@ -22,7 +22,7 @@ const isValidTimespan = (timespan: number): boolean => { ...@@ -22,7 +22,7 @@ const isValidTimespan = (timespan: number): boolean => {
export const timeUnitToMs = (unit: TIMEUNIT, timespan: number) => { export const timeUnitToMs = (unit: TIMEUNIT, timespan: number) => {
if (!isValidTimespan(timespan)) { if (!isValidTimespan(timespan)) {
throw new Error('timeUnitToMs - invalid timespan'); throw new Error(`timeUnitToMs - invalid timespan:${timespan}`);
} }
switch (unit) { switch (unit) {
...@@ -42,7 +42,7 @@ export const timeUnitToMs = (unit: TIMEUNIT, timespan: number) => { ...@@ -42,7 +42,7 @@ export const timeUnitToMs = (unit: TIMEUNIT, timespan: number) => {
export const msToTimeUnit = (unit: TIMEUNIT, timespan: number) => { export const msToTimeUnit = (unit: TIMEUNIT, timespan: number) => {
if (!isValidTimespan(timespan)) { if (!isValidTimespan(timespan)) {
throw new Error('msToTimeUnit - invalid timespan'); throw new Error(`msToTimeUnit - invalid timespan:${timespan}`);
} }
switch (unit) { switch (unit) {
......
import type { IRoom, IRoomWithRetentionPolicy } from '@rocket.chat/core-typings'; import type { IRoom, IRoomWithRetentionPolicy } from '@rocket.chat/core-typings';
import { useSetting } from '@rocket.chat/ui-contexts'; import { useSetting } from '@rocket.chat/ui-contexts';
import { TIMEUNIT, timeUnitToMs } from '../../../lib/convertTimeUnit'; import { TIMEUNIT, isValidTimespan, timeUnitToMs } from '../../../lib/convertTimeUnit';
const hasRetentionPolicy = (room: IRoom & { retention?: any }): room is IRoomWithRetentionPolicy => const hasRetentionPolicy = (room: IRoom & { retention?: any }): room is IRoomWithRetentionPolicy =>
'retention' in room && room.retention !== undefined; 'retention' in room && room.retention !== undefined && 'overrideGlobal' in room.retention && isValidTimespan(room.retention.maxAge);
type RetentionPolicySettings = { type RetentionPolicySettings = {
enabled: boolean; enabled: boolean;
......
...@@ -31,6 +31,10 @@ test.describe.serial('retention-policy', () => { ...@@ -31,6 +31,10 @@ test.describe.serial('retention-policy', () => {
}); });
test.describe('retention policy disabled', () => { test.describe('retention policy disabled', () => {
test.beforeAll(async ({ api }) => {
await setSettingValueById(api, 'RetentionPolicy_Enabled', false);
});
test('should not show prune banner in channel', async () => { test('should not show prune banner in channel', async () => {
await poHomeChannel.sidenav.openChat(targetChannel); await poHomeChannel.sidenav.openChat(targetChannel);
......
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