forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
channel_display_mode_spec.js
124 lines (93 loc) · 5.16 KB
/
channel_display_mode_spec.js
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. 1. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
describe('Account Settings > Display > Channel Display Mode', () => {
before(() => {
cy.apiLogin('user-1');
// # Set default preference of a user on channel and message display
cy.apiSaveChannelDisplayModePreference('centered');
cy.apiSaveMessageDisplayPreference();
// Post a message to a channel
cy.visit('/');
cy.postMessage('Test for channel display mode {enter}');
});
beforeEach(() => {
cy.viewport(1500, 660);
});
it('should render in min setting view', () => {
// # Go to Account Settings with "user-1"
cy.toAccountSettingsModal('user-1');
// * Check that the Display tab is loaded
cy.get('#displayButton').should('be.visible');
// # Click the Display tab
cy.get('#displayButton').click();
// * Check that it changed into the Display section
cy.get('#displaySettingsTitle').should('be.visible').should('contain', 'Display Settings');
// # Scroll up to bring Channel Display setting in viewable area.
cy.get('#channel_display_modeTitle').scrollIntoView();
// * Check the min setting view if each element is present and contains expected text values
cy.get('#channel_display_modeTitle').should('be.visible').should('contain', 'Channel Display');
cy.get('#channel_display_modeDesc').should('be.visible').should('contain', 'Fixed width');
cy.get('#channel_display_modeEdit').should('be.visible').should('contain', 'Edit');
cy.get('#accountSettingsHeader > .close').should('be.visible');
});
it('should render in max setting view', () => {
// # Click "Edit" to the right of "Channel Display"
cy.get('#channel_display_modeEdit').click();
// # Scroll a bit to show the "Save" button
cy.get('.section-max').scrollIntoView();
// * Check that it changed into the Channel Display section
// * Check the max setting view if each element is present and contains expected text values
cy.get('#channel_display_modeFormatA').should('be.visible');
cy.get('#channel_display_modeFormatB').should('be.visible');
cy.get('#saveSetting').should('be.visible').should('contain', 'Save');
cy.get('#cancelSetting').should('be.visible').should('contain', 'Cancel');
cy.get('#accountSettingsHeader > .close').should('be.visible');
});
it('change channel display mode setting to "Full width"', () => {
// # Click the radio button for "Full width"
cy.get('#channel_display_modeFormatA').click();
// # Click "Save"
cy.get('#saveSetting').click();
// * Check that it changed into min setting view
// * Check if element is present and contains expected text values
cy.get('#channel_display_modeDesc').should('be.visible').should('contain', 'Full width');
// # Click "x" button to close Account Settings modal
cy.get('#accountSettingsHeader > .close').click();
// # Go to channel which has any posts
cy.get('#sidebarItem_town-square').click();
// * Validate if the post content in center channel is full width
// by checking the exact class name.
cy.get('#postContent').first().invoke('attr', 'class').should('contain', 'post__content').should('not.contain', 'center');
});
it('AS13225 Channel display mode setting to "Fixed width, centered"', () => {
// # Return to Account Settings modal
cy.toAccountSettingsModal('user-1', true);
// * Check that the Sidebar tab is loaded
cy.get('#displayButton').should('be.visible');
// # Click the display tab
cy.get('#displayButton').click();
// # Click "Edit" to the right of "Channel Display"
cy.get('#channel_display_modeEdit').click();
// # Scroll a bit to show the "Save" button
cy.get('.section-max').scrollIntoView();
// # Click the radio button for "Fixed width, centered"
cy.get('#channel_display_modeFormatB').click();
// # Click "Save"
cy.get('#saveSetting').click();
// * Check that it changed into min setting view
// * Check if element is present and contains expected text values
cy.get('#channel_display_modeDesc').should('be.visible').should('contain', 'Fixed width');
// # Click "x" button to close Account Settings modal
cy.get('#accountSettingsHeader > .close').click();
// # Go to channel which has any posts
cy.get('#sidebarItem_town-square').click();
// * Validate if the post content in center channel is fixed and centered
// by checking the exact class name.
cy.get('#postContent').first().invoke('attr', 'class').should('contain', 'post__content center');
});
});