-
Notifications
You must be signed in to change notification settings - Fork 960
Expand file tree
/
Copy pathcommunityOpenMode.test.ts
More file actions
74 lines (66 loc) · 2.32 KB
/
Copy pathcommunityOpenMode.test.ts
File metadata and controls
74 lines (66 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import {describe, expect, it} from 'vitest';
import shouldOpenForumAsNavigationTab, {
USE_COMMUNITY_NAVIGATION_TAB
} from '@components/forumTab/communityOpenMode';
import isCommunityChat from '@appManagers/utils/communities/isCommunity';
import type {Chat} from '@layer';
describe('Community open mode', () => {
it('enables the Community navigation tab by default', () => {
expect(USE_COMMUNITY_NAVIGATION_TAB).toBe(true);
});
it('opens a Community as a navigation tab when the flag is enabled', () => {
expect(shouldOpenForumAsNavigationTab({
hasNavigationHistory: false,
isCommunity: true,
isNarrowScreen: false
})).toBe(true);
});
it('keeps the floating fallback when the flag is disabled on desktop', () => {
expect(shouldOpenForumAsNavigationTab({
hasNavigationHistory: false,
isCommunity: true,
isNarrowScreen: false,
useCommunityNavigationTab: false
})).toBe(false);
});
it('uses a navigation tab on narrow screens even with the flag disabled', () => {
expect(shouldOpenForumAsNavigationTab({
hasNavigationHistory: false,
isCommunity: true,
isNarrowScreen: true,
useCommunityNavigationTab: false
})).toBe(true);
});
it('does not change an ordinary forum without navigation history', () => {
expect(shouldOpenForumAsNavigationTab({
hasNavigationHistory: false,
isCommunity: false,
isNarrowScreen: true
})).toBe(false);
});
it('preserves the existing navigation stack behavior for any forum', () => {
expect(shouldOpenForumAsNavigationTab({
hasNavigationHistory: true,
isCommunity: false,
isNarrowScreen: false
})).toBe(true);
});
// A forum channel is a plain Chat.channel — classifying it as a Community
// sent every ordinary forum into a navigation tab instead of the floating one.
it('keeps a forum channel floating', () => {
const forum: Chat.channel = {
_: 'channel',
id: 1,
title: 'Forum',
pFlags: {broadcast: undefined, megagroup: true, forum: true},
photo: undefined,
date: 0
} as Chat.channel;
expect(isCommunityChat(forum)).toBe(false);
expect(shouldOpenForumAsNavigationTab({
hasNavigationHistory: false,
isCommunity: isCommunityChat(forum),
isNarrowScreen: false
})).toBe(false);
});
});