This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
nickname.js
107 lines (85 loc) · 4.62 KB
/
nickname.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
// 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 > Sidebar > General', () => {
before(() => {
// # Go to Account Settings with "user-1"
cy.toAccountSettingsModal('user-1');
});
it('Nickname should render in before clicking edit', () => {
// # Check that the General tab is loaded and click it
cy.get('#generalButton').should('be.visible');
cy.get('#generalButton').click();
// * Check if element is present before nickname is set and contains expected text values
cy.get('#generalSettingsTitle').should('be.visible').should('contain', 'General Settings');
cy.get('#nicknameTitle').should('be.visible').should('contain', 'Nickname');
cy.get('#nicknameDesc').should('be.visible').should('contain', "Click 'Edit' to add a nickname");
cy.get('#nicknameEdit').should('be.visible').should('contain', 'Edit');
cy.get('#accountSettingsHeader > .close').should('be.visible');
});
it('Nickname should render after clicking edit', () => {
// # Click "Edit" to the right of "Nickname"
cy.get('#nicknameEdit').click();
// * Check elements after clicking 'Edit'
cy.get('#generalSettingsTitle').should('be.visible').should('contain', 'General Settings');
cy.get('#settingTitle').should('be.visible').should('contain', 'Nickname');
cy.get('#nickname').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('No nickname is present', () => {
// # Clear the nickname text field contents
cy.get('#nickname').clear();
cy.get('#saveSetting').click();
cy.get('#nicknameDesc').should('be.visible').should('contain', "Click 'Edit' to add a nickname");
// # Open manage/view members
cy.toAccountSettingsModal('user-1');
cy.get('#accountSettingsHeader > .close').click();
cy.get('#sidebarHeaderDropdownButton').click();
cy.get('#viewMembers').should('be.visible');
cy.get('#viewMembers').click();
// # Search for username and check that no nickname is present
cy.get('.modal-title').should('be.visible');
cy.get('#searchUsersInput').should('be.visible').type('Victor Welch');
cy.get('.more-modal__details > .more-modal__name').should('be.visible').should('contain', '@user-1 - Victor Welch');
});
it('AS13279 Account Settings > Add Nickname', () => {
// # Go to Account Settings view
cy.toAccountSettingsModal('user-1');
// # Click the General tab
cy.get('#generalButton').should('be.visible');
cy.get('#generalButton').click();
// # Add the nickname to textfield contents
cy.get('#nicknameEdit').click();
cy.get('#nickname').clear();
cy.get('#nickname').type('victor_nick');
cy.get('#saveSetting').click();
// * Check if element is present and contains expected text values
cy.get('#nicknameDesc').should('be.visible').should('contain', 'victor_nick');
// # Open manage memebers
cy.toAccountSettingsModal('user-1');
cy.get('#accountSettingsHeader > .close').click();
cy.get('#sidebarHeaderDropdownButton').click();
cy.get('#viewMembers').should('be.visible');
cy.get('#viewMembers').click();
// # Search for username and check that expected nickname is present
cy.get('.modal-title').should('be.visible');
cy.get('#searchUsersInput').should('be.visible').type('Victor Welch');
cy.get('.more-modal__details > .more-modal__name').should('be.visible').should('contain', '@user-1 - Victor Welch (victor_nick)');
});
it('Clear the nickname', () => {
// # Clear the set nickname
cy.toAccountSettingsModal('user-1');
cy.get('#generalButton').should('be.visible');
cy.get('#generalButton').click();
cy.get('#nicknameEdit').click();
cy.get('#nickname').clear();
cy.get('#saveSetting').click();
cy.get('#nicknameDesc').should('be.visible').should('contain', "Click 'Edit' to add a nickname");
});
});