regression: fix retention flaky test (#32649)

pull/32652/head
Guilherme Gazzo 2 years ago committed by GitHub
parent 768cad6de5
commit 6274c439ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      apps/meteor/client/lib/convertTimeUnit.ts
  2. 4
      apps/meteor/client/views/room/hooks/useRetentionPolicy.ts
  3. 4
      apps/meteor/tests/e2e/retention-policy.spec.ts

@ -4,7 +4,7 @@ export enum TIMEUNIT {
minutes = 'minutes',
}
const isValidTimespan = (timespan: number): boolean => {
export const isValidTimespan = (timespan: number): boolean => {
if (Number.isNaN(timespan)) {
return false;
}
@ -22,7 +22,7 @@ const isValidTimespan = (timespan: number): boolean => {
export const timeUnitToMs = (unit: TIMEUNIT, timespan: number) => {
if (!isValidTimespan(timespan)) {
throw new Error('timeUnitToMs - invalid timespan');
throw new Error(`timeUnitToMs - invalid timespan:${timespan}`);
}
switch (unit) {
@ -42,7 +42,7 @@ export const timeUnitToMs = (unit: TIMEUNIT, timespan: number) => {
export const msToTimeUnit = (unit: TIMEUNIT, timespan: number) => {
if (!isValidTimespan(timespan)) {
throw new Error('msToTimeUnit - invalid timespan');
throw new Error(`msToTimeUnit - invalid timespan:${timespan}`);
}
switch (unit) {

@ -1,10 +1,10 @@
import type { IRoom, IRoomWithRetentionPolicy } from '@rocket.chat/core-typings';
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 =>
'retention' in room && room.retention !== undefined;
'retention' in room && room.retention !== undefined && 'overrideGlobal' in room.retention && isValidTimespan(room.retention.maxAge);
type RetentionPolicySettings = {
enabled: boolean;

@ -31,6 +31,10 @@ test.describe.serial('retention-policy', () => {
});
test.describe('retention policy disabled', () => {
test.beforeAll(async ({ api }) => {
await setSettingValueById(api, 'RetentionPolicy_Enabled', false);
});
test('should not show prune banner in channel', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);

Loading…
Cancel
Save