Skip to content

Commit d75bc18

Browse files
committed
Add tests for settings
Signed-off-by: Louis Chemineau <[email protected]>
1 parent 7747b22 commit d75bc18

10 files changed

Lines changed: 249 additions & 655 deletions

File tree

cypress.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
"projectId": "hx9gqy",
44
"viewportWidth": 1280,
55
"viewportHeight": 720
6-
}
6+
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/**
2+
* @copyright Copyright (c) 2021 Louis Chemineau <[email protected]>
3+
*
4+
* @author Louis Chemineau <[email protected]>
5+
*
6+
* @license GNU AGPL version 3 or any later version
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
/// <reference types="Cypress" />
24+
25+
import { randHash } from '../utils'
26+
const randUser = randHash()
27+
28+
describe('Check that user\'s settings survive a reload', () => {
29+
before(() => {
30+
cy.nextcloudCreateUser(randUser, 'password')
31+
cy.login(randUser, 'password')
32+
cy.visit('/settings/user/activity')
33+
cy.wait(1000)
34+
})
35+
36+
after(() => {
37+
cy.logout()
38+
})
39+
40+
it('Form survive a reload', () => {
41+
cy.get("#app-content input[type='checkbox']").uncheck({force: true}).should('not.be.checked')
42+
43+
cy.reload()
44+
45+
cy.get("#app-content input[type='checkbox']").uncheck({force: true}).should('not.be.checked')
46+
47+
cy.get("#file_changed_notification").check({force: true})
48+
cy.contains("A calendar was modified").click()
49+
cy.contains("Other activities").parentsUntil('table').contains("Push").click()
50+
cy.contains("Comments for files").click()
51+
cy.contains("Your password or email was modified").click()
52+
53+
cy.reload()
54+
55+
cy.get("#file_favorite_changed_email").should('not.be.checked')
56+
cy.get("#file_favorite_changed_notification").should('not.be.checked')
57+
cy.get("#file_changed_email").should('not.be.checked')
58+
cy.get("#file_changed_notification").should('be.checked')
59+
cy.get("#favorite_email").should('not.be.checked')
60+
cy.get("#favorite_notification").should('not.be.checked')
61+
cy.get("#shared_email").should('not.be.checked')
62+
cy.get("#shared_notification").should('not.be.checked')
63+
cy.get("#remote_share_email").should('not.be.checked')
64+
cy.get("#remote_share_notification").should('not.be.checked')
65+
cy.get("#public_links_email").should('not.be.checked')
66+
cy.get("#public_links_notification").should('not.be.checked')
67+
cy.get("#calendar_email").should('be.checked')
68+
cy.get("#calendar_notification").should('be.checked')
69+
cy.get("#calendar_event_email").should('not.be.checked')
70+
cy.get("#calendar_event_notification").should('not.be.checked')
71+
cy.get("#calendar_todo_email").should('not.be.checked')
72+
cy.get("#calendar_todo_notification").should('not.be.checked')
73+
cy.get("#contacts_email").should('not.be.checked')
74+
cy.get("#contacts_notification").should('not.be.checked')
75+
cy.get("#group_settings_email").should('not.be.checked')
76+
cy.get("#group_settings_notification").should('be.checked')
77+
cy.get("#personal_settings_email").should('not.be.checked')
78+
cy.get("#personal_settings_notification").should('not.be.checked')
79+
cy.get("#security_email").should('not.be.checked')
80+
cy.get("#security_notification").should('be.checked')
81+
cy.get("#comments_email").should('be.checked')
82+
cy.get("#comments_notification").should('be.checked')
83+
cy.get("#systemtags_email").should('not.be.checked')
84+
cy.get("#systemtags_notification").should('be.checked')
85+
})
86+
87+
it('Notification frequency survive a reload', () => {
88+
cy.get(".notification-frequency__select").select("Weekly")
89+
90+
cy.wait(200)
91+
cy.reload()
92+
93+
cy.get('.notification-frequency__select').find(':selected').contains('Weekly')
94+
cy.get(".notification-frequency__select").select("Hourly")
95+
96+
cy.wait(200)
97+
cy.reload()
98+
99+
cy.get('.notification-frequency__select').find(':selected').contains('Hourly')
100+
})
101+
102+
it('Activity summary survive a reload', () => {
103+
let input = cy.get("#app-content").contains("Send daily activity summary in the morning").parentsUntil('.settings-section.summary-form').children('input')
104+
105+
input.check({force: true})
106+
107+
cy.reload()
108+
input = cy.get("#app-content").contains("Send daily activity summary in the morning").parentsUntil('.settings-section.summary-form').children('input')
109+
110+
input.should('be.checked')
111+
112+
input.uncheck({force: true})
113+
114+
cy.reload()
115+
input = cy.get("#app-content").contains("Send daily activity summary in the morning").parentsUntil('.settings-section.summary-form').children('input')
116+
117+
input.should('not.be.checked')
118+
})
119+
})
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020
*
2121
*/
2222

23+
/// <reference types="Cypress" />
24+
2325
import { randHash } from '../utils'
2426
const randUser = randHash()
2527

26-
describe('Open test.md in viewer', function() {
28+
describe('Check activity listing in the sidebar', function() {
2729
before(function() {
2830
cy.nextcloudCreateUser(randUser, 'password')
2931
cy.login(randUser, 'password')

cypress/support/commands.js

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
*/
2222

23-
import axios from '@nextcloud/axios'
23+
/// <reference types="Cypress" />
2424

2525
const url = Cypress.config('baseUrl').replace(/\/index.php\/?$/g, '')
2626
Cypress.env('baseUrl', url)
@@ -68,92 +68,3 @@ Cypress.Commands.add('nextcloudCreateUser', (user, password) => {
6868
cy.log(`Created user ${user}`, response.status)
6969
})
7070
})
71-
72-
Cypress.Commands.add('createFolder', dirName => {
73-
cy.get('#controls .actions > .button.new').click()
74-
cy.get('#controls .actions .newFileMenu a[data-action="folder"]').click()
75-
cy.get('#controls .actions .newFileMenu a[data-action="folder"] input[type="text"]').type(dirName)
76-
cy.get('#controls .actions .newFileMenu a[data-action="folder"] input.icon-confirm').click()
77-
cy.log('Created folder', dirName)
78-
cy.wait(500)
79-
})
80-
81-
Cypress.Commands.add('moveFile', (fileName, dirName) => {
82-
cy.get(`#fileList tr[data-file="${fileName}"] .icon-more`).click()
83-
cy.get(`#fileList tr[data-file="${fileName}"] .action-movecopy`).click()
84-
cy.get(`.oc-dialog tr[data-entryname="${dirName}"]`).click()
85-
cy.contains(`Move to ${dirName}`).click()
86-
cy.wait(500)
87-
})
88-
89-
Cypress.Commands.add('showSidebarForFile', fileName => {
90-
cy.hideSidebar('welcome.txt')
91-
cy.get('#fileList tr[data-file="welcome.txt"] .icon-more').click()
92-
cy.contains('Details').click()
93-
cy.get('#app-sidebar-vue').contains('Activity').click()
94-
})
95-
96-
Cypress.Commands.add('hideSidebar', fileName => {
97-
cy.get('body')
98-
.then(($body) => {
99-
if ($body.find('.app-sidebar__close').length !== 0) {
100-
cy.get('.app-sidebar__close').click()
101-
}
102-
})
103-
})
104-
105-
Cypress.Commands.add('showActivityTab', fileName => {
106-
cy.showSidebarForFile()
107-
cy.get('#app-sidebar-vue').contains('Activity').click()
108-
})
109-
110-
Cypress.Commands.add('addToFavorites', fileName => {
111-
cy.get(`#fileList tr[data-file="${fileName}"] .icon-more`).click()
112-
cy.contains('Add to favorites').click()
113-
})
114-
115-
Cypress.Commands.add('removeFromFavorites', fileName => {
116-
cy.get(`#fileList tr[data-file="${fileName}"] .icon-more`).click()
117-
cy.contains('Remove from favorites').click()
118-
})
119-
120-
Cypress.Commands.add('createPublicShare', fileName => {
121-
cy.get(`#fileList tr[data-file="${fileName}"] .icon-more`).click()
122-
cy.contains('Details').click()
123-
cy.get('#app-sidebar-vue').contains('Sharing').click()
124-
125-
cy.get('#app-sidebar-vue a#sharing').trigger('click')
126-
cy.get('#app-sidebar-vue button.new-share-link').trigger('click')
127-
cy.get('#app-sidebar-vue a.sharing-entry__copy')
128-
})
129-
130-
Cypress.Commands.add('renameFile', (fileName, newName) => {
131-
cy.get(`#fileList tr[data-file="${fileName}"] .icon-more`).click()
132-
cy.get(`#fileList tr[data-file="${fileName}"] .action-rename`).click()
133-
cy.get(`#fileList tr[data-file="${fileName}"] input.filename`).type(newName).parent().submit()
134-
cy.wait(500)
135-
})
136-
137-
Cypress.Commands.add('goToDir', (dirName) => {
138-
cy.get(`#fileList tr[data-file="${dirName}"]`).click()
139-
cy.wait(500)
140-
})
141-
142-
Cypress.Commands.add('addTag', (fileName, tag) => {
143-
cy.showSidebarForFile('welcome.txt')
144-
145-
cy.get('.app-sidebar-header__menu .action-item__menutoggle').click()
146-
cy.get('.action-button__icon.icon-tag').click()
147-
cy.get('.systemTagsInputField input').type('my_tag{enter}{esc}')
148-
149-
cy.wait(500)
150-
})
151-
152-
Cypress.Commands.add('addComment', (fileName, comment) => {
153-
cy.showSidebarForFile('welcome.txt')
154-
cy.get('#app-sidebar-vue').contains('Comments').click()
155-
cy.get('.comment__editor .rich-contenteditable__input').type(comment)
156-
cy.get('input.comment__submit').click()
157-
158-
cy.wait(500)
159-
})

cypress/support/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,5 @@
1313
// https://on.cypress.io/configuration
1414
// ***********************************************************
1515

16-
// Import commands.js using ES2015 syntax:
1716
import './commands'
18-
19-
// Alternatively you can use CommonJS syntax:
20-
// require('./commands')
17+
import './sidebar'

cypress/support/sidebar.js

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/**
2+
* @copyright Copyright (c) 2021 Louis Chemineau <[email protected]>
3+
*
4+
* @author Louis Chemineau <[email protected]>
5+
*
6+
* @license GNU AGPL version 3 or any later version
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
/// <reference types="Cypress" />
24+
25+
Cypress.Commands.add('createFolder', dirName => {
26+
cy.get('#controls .actions > .button.new').click()
27+
cy.get('#controls .actions .newFileMenu a[data-action="folder"]').click()
28+
cy.get('#controls .actions .newFileMenu a[data-action="folder"] input[type="text"]').type(dirName)
29+
cy.get('#controls .actions .newFileMenu a[data-action="folder"] input.icon-confirm').click()
30+
cy.log('Created folder', dirName)
31+
cy.wait(500)
32+
})
33+
34+
Cypress.Commands.add('moveFile', (fileName, dirName) => {
35+
cy.get(`#fileList tr[data-file="${fileName}"] .icon-more`).click()
36+
cy.get(`#fileList tr[data-file="${fileName}"] .action-movecopy`).click()
37+
cy.get(`.oc-dialog tr[data-entryname="${dirName}"]`).click()
38+
cy.contains(`Move to ${dirName}`).click()
39+
cy.wait(500)
40+
})
41+
42+
Cypress.Commands.add('showSidebarForFile', fileName => {
43+
cy.hideSidebar('welcome.txt')
44+
cy.get('#fileList tr[data-file="welcome.txt"] .icon-more').click()
45+
cy.contains('Details').click()
46+
cy.get('#app-sidebar-vue').contains('Activity').click()
47+
})
48+
49+
Cypress.Commands.add('hideSidebar', fileName => {
50+
cy.get('body')
51+
.then(($body) => {
52+
if ($body.find('.app-sidebar__close').length !== 0) {
53+
cy.get('.app-sidebar__close').click()
54+
}
55+
})
56+
})
57+
58+
Cypress.Commands.add('showActivityTab', fileName => {
59+
cy.showSidebarForFile()
60+
cy.get('#app-sidebar-vue').contains('Activity').click()
61+
})
62+
63+
Cypress.Commands.add('addToFavorites', fileName => {
64+
cy.get(`#fileList tr[data-file="${fileName}"] .icon-more`).click()
65+
cy.contains('Add to favorites').click()
66+
})
67+
68+
Cypress.Commands.add('removeFromFavorites', fileName => {
69+
cy.get(`#fileList tr[data-file="${fileName}"] .icon-more`).click()
70+
cy.contains('Remove from favorites').click()
71+
})
72+
73+
Cypress.Commands.add('createPublicShare', fileName => {
74+
cy.get(`#fileList tr[data-file="${fileName}"] .icon-more`).click()
75+
cy.contains('Details').click()
76+
cy.get('#app-sidebar-vue').contains('Sharing').click()
77+
78+
cy.get('#app-sidebar-vue a#sharing').trigger('click')
79+
cy.get('#app-sidebar-vue button.new-share-link').trigger('click')
80+
cy.get('#app-sidebar-vue a.sharing-entry__copy')
81+
})
82+
83+
Cypress.Commands.add('renameFile', (fileName, newName) => {
84+
cy.get(`#fileList tr[data-file="${fileName}"] .icon-more`).click()
85+
cy.get(`#fileList tr[data-file="${fileName}"] .action-rename`).click()
86+
cy.get(`#fileList tr[data-file="${fileName}"] input.filename`).type(newName).parent().submit()
87+
cy.wait(500)
88+
})
89+
90+
Cypress.Commands.add('goToDir', (dirName) => {
91+
cy.get(`#fileList tr[data-file="${dirName}"]`).click()
92+
cy.wait(500)
93+
})
94+
95+
Cypress.Commands.add('addTag', (fileName, tag) => {
96+
cy.showSidebarForFile('welcome.txt')
97+
98+
cy.get('.app-sidebar-header__menu .action-item__menutoggle').click()
99+
cy.get('.action-button__icon.icon-tag').click()
100+
cy.get('.systemTagsInputField input').type('my_tag{enter}{esc}')
101+
102+
cy.wait(500)
103+
})
104+
105+
Cypress.Commands.add('addComment', (fileName, comment) => {
106+
cy.showSidebarForFile('welcome.txt')
107+
cy.get('#app-sidebar-vue').contains('Comments').click()
108+
cy.get('.comment__editor .rich-contenteditable__input').type(comment)
109+
cy.get('input.comment__submit').click()
110+
111+
cy.wait(500)
112+
})

0 commit comments

Comments
 (0)