summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2023-06-28 13:54:31 +0200
committerLouis Chemineau <louis@chmn.me>2023-06-28 14:05:55 +0200
commitf8c0f24cf871667e36364839f876760780b5b52c (patch)
tree9a17fad30b06efaac23c7092869a7ba7abd923c2
parentfe646e929abcbceeb48b4daeb39de7127ffc3e0a (diff)
Fix e2e tests
Signed-off-by: Louis Chemineau <louis@chmn.me>
-rw-r--r--cypress/e2e/0.setup.cy.js30
-rw-r--r--cypress/e2e/post.cy.js105
-rw-r--r--cypress/e2e/post.cy.ts100
-rw-r--r--cypress/e2e/setup.cy.ts58
-rw-r--r--cypress/utils/index.ts (renamed from cypress/utils/index.js)8
5 files changed, 162 insertions, 139 deletions
diff --git a/cypress/e2e/0.setup.cy.js b/cypress/e2e/0.setup.cy.js
deleted file mode 100644
index e66c8e2b..00000000
--- a/cypress/e2e/0.setup.cy.js
+++ /dev/null
@@ -1,30 +0,0 @@
-const userId = 'janedoe' + Date.now()
-
-describe('Social app setup', function () {
- before(function () {
- cy.createRandomUser()
- .then((user) => {
- cy.login(user)
- cy.visit('/apps/social')
- })
- })
-
- it('See the welcome message', function () {
- cy.get('.social__welcome').should('contain', 'Nextcloud becomes part of the federated social networks!')
- cy.get('.social__welcome').find('.icon-close').click()
- cy.get('.social__welcome').should('not.exist')
- })
-
- it('See the home section in the sidebar', function () {
- cy.get('.app-navigation').contains('Home').click()
- cy.get('.app-social .empty-content').should('be.visible')
- })
-
- it('See the empty content illustration', function () {
- cy.reload()
- cy.get('.app-navigation').contains('Direct messages').click()
- cy.get('.app-social .empty-content').should('be.visible').contains('No direct messages found')
- cy.get('.app-navigation').contains('Profile').click()
- cy.get('.app-social .empty-content').should('be.visible').contains('You have not tooted yet')
- })
-})
diff --git a/cypress/e2e/post.cy.js b/cypress/e2e/post.cy.js
deleted file mode 100644
index 2ff6af92..00000000
--- a/cypress/e2e/post.cy.js
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
- *
- * @author Julius Härtl <jus@bitgrid.net>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-const userId = 'janedoe' + Date.now()
-
-describe('Create posts', function () {
-
- before(function () {
- // ensure that the admin account is initialized for social
- // cy.login('admin', 'admin', '/apps/social/')
-
- cy.createRandomUser()
- .then((user) => {
- cy.login(user)
- cy.visit('/apps/social')
- cy.get('.app-content').should('be.visible')
- })
- })
-
- it('See the empty content illustration', function () {
- cy.get('.social__welcome').find('.icon-close').click()
- cy.get('.app-social .empty-content').should('be.visible').contains('No posts found')
- cy.reload()
- })
-
- it('Write a post to followers', function () {
- cy.visit('/apps/social/')
- cy.intercept('POST', '/index.php/apps/social/api/v1/statuses').as('postMessage')
- cy.get('.new-post button[type=submit]')
- .should('be.disabled')
- cy.get('.new-post').find('[contenteditable]').type('Hello world')
- cy.get('.new-post button[type=submit]')
- .should('not.be.disabled')
- cy.get('.new-post button[type=submit]')
- .click()
- cy.wait('@postMessage')
- cy.get('.social__timeline div.timeline-entry:first-child').should('contain', 'Hello world')
- })
-
- it('No longer see the empty content illustration', function () {
- cy.get('.app-social .empty-content').should('not.exist')
- })
-
- it('Write a post to followers with shift enter', function () {
- cy.intercept('POST', '/index.php/apps/social/api/v1/statuses').as('postMessage')
- cy.get('.new-post').find('[contenteditable]').type('Hello world 2{shift}{enter}')
- cy.wait('@postMessage')
- cy.get('.social__timeline div.timeline-entry:first-child').should('contain', 'Hello world 2')
- })
-
- it('Write a post to @admin', function () {
- cy.intercept('POST', '/index.php/apps/social/api/v1/statuses').as('postMessage')
- cy.intercept('GET', '/index.php/apps/social/api/v1/global/accounts/search')
- cy.get('.new-post').find('[contenteditable]').type('@adm', { delay: 500 })
- cy.get('.tribute-container').should('be.visible')
- cy.get('.tribute-container ul li:first').contains('admin')
- cy.get('.new-post').find('[contenteditable]').type('{enter} Hello there', { delay: 100, force: true })
- cy.get('.new-post button[type=submit]')
- .click()
- cy.wait('@postMessage')
- cy.get('.social__timeline div.timeline-entry:first-child').should('contain', '@admin')
- })
-
- it('Opens the menu and shows that followers is selected by default', function () {
- cy.intercept('POST', '/index.php/apps/social/api/v1/statuses').as('postMessage')
- cy.intercept('GET', '/index.php/apps/social/api/v1/global/accounts/search')
- cy.get('.new-post').find('[contenteditable]').click({ force: true }).type('@adm{enter} Hello world', { delay: 500, force: true })
- cy.wait(500)
- cy.get('.new-post button[type=submit]').should('not.be.disabled')
- const visibilityButton = cy.get('.new-post .options > div > button')
- visibilityButton.should('have.class', 'icon-contacts-dark')
-
- visibilityButton.click()
- cy.get('.new-post-form .popovermenu').should('be.visible')
- cy.get('.new-post-form .popovermenu .active').contains('Followers')
- visibilityButton.click()
- cy.get('.new-post-form .popovermenu').should('not.be.visible')
-
- cy.get('.new-post button[type=submit]')
- .click()
- cy.wait('@postMessage')
- cy.get('.social__timeline div.timeline-entry:first-child').should('contain', 'Hello world').should('contain', '@admin')
-
- })
-
-})
diff --git a/cypress/e2e/post.cy.ts b/cypress/e2e/post.cy.ts
new file mode 100644
index 00000000..dfd32167
--- /dev/null
+++ b/cypress/e2e/post.cy.ts
@@ -0,0 +1,100 @@
+/**
+ * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
+ *
+ * @author Julius Härtl <jus@bitgrid.net>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+import { User } from "@nextcloud/cypress"
+import { randHash } from "../utils"
+
+const alice = new User(`alice_${randHash()}`)
+
+describe('Create posts', () => {
+ before(() => {
+ cy.createUser(alice)
+ cy.login(alice)
+ cy.visit('/apps/social')
+ cy.createRandomUser()
+ .then((user) => {
+ cy.login(user)
+ cy.visit('/apps/social')
+ })
+ })
+
+ it('See the empty content illustration', () => {
+ cy.get('.social__welcome').find('.icon-close').click()
+ cy.get('.app-social .empty-content').should('be.visible').contains('No posts found')
+ cy.reload()
+ })
+
+ it('Write a post to followers', () => {
+ cy.intercept({ times: 1, method: 'POST', url: '/index.php/apps/social/api/v1/statuses' }).as('postMessage')
+ cy.get('.new-post button[type=submit]').should('be.disabled')
+ cy.get('.new-post').find('[contenteditable]').type('Hello world')
+ cy.get('.new-post button[type=submit]').should('not.be.disabled')
+ cy.get('.new-post button[type=submit]').click()
+ cy.wait('@postMessage')
+ cy.get('.social__timeline .timeline-entry:first-child').should('contain', 'Hello world')
+ })
+
+ it('No longer see the empty content illustration', () => {
+ cy.get('.app-social .empty-content').should('not.exist')
+ })
+
+ it('Write a post to followers with ctrl+enter', () => {
+ cy.intercept({ times: 1, method: 'POST', url: '/index.php/apps/social/api/v1/statuses' }).as('postMessage')
+ cy.get('.new-post').find('[contenteditable]').type('Hello world 2{ctrl}{enter}')
+ cy.wait('@postMessage')
+ cy.get('.social__timeline .timeline-entry:first-child').should('contain', 'Hello world 2')
+ })
+
+ it('Write a post to @alice', () => {
+ cy.intercept({ times: 1, method: 'POST', url: '/index.php/apps/social/api/v1/statuses' }).as('postMessage')
+ cy.intercept({ times: 1, method: 'GET', url: '/index.php/apps/social/api/v1/global/accounts/search' })
+ cy.get('.new-post').find('[contenteditable]').type(`@${alice.userId}`, { delay: 500 })
+ cy.get('.tribute-container').should('be.visible')
+ cy.get('.tribute-container ul li:first').contains(alice.userId)
+ cy.get('.new-post').find('[contenteditable]').type('{enter} Hello there', { delay: 100, force: true })
+ cy.get('.new-post button[type=submit]').click()
+ cy.wait('@postMessage')
+ cy.get('.social__timeline .timeline-entry:first-child').should('contain', `@${alice.userId}`)
+ })
+
+ it('Opens the menu and shows that followers is selected by default', () => {
+ cy.intercept({ times: 1, method: 'POST', url: '/index.php/apps/social/api/v1/statuses' }).as('postMessage')
+ cy.intercept({ times: 1, method: 'GET', url: '/index.php/apps/social/api/v1/global/accounts/search' })
+ cy.get('.new-post').find('[contenteditable]').click({ force: true }).type(`@${alice.userId}{enter} Hello world`, { delay: 200, force: true })
+ cy.wait(500)
+ cy.get('.new-post button[type=submit]').should('not.be.disabled')
+ const visibilityButton = cy.get('.new-post .options > .action-item > div > button')
+ visibilityButton.find('.material-design-icon').should('have.class', 'account-multiple-icon')
+
+ visibilityButton.click()
+ cy.get('.v-popper__popper ').should('be.visible')
+ cy.get('.v-popper__popper .selected-visibility').contains('Visible to followers only')
+ visibilityButton.click()
+ cy.get('.v-popper__popper ').should('not.be.visible')
+
+ cy.get('.new-post button[type=submit]').click()
+ cy.wait('@postMessage')
+ cy.get('.social__timeline .timeline-entry:first-child').should('contain', 'Hello world').should('contain', `@${alice.userId}`)
+
+ })
+
+})
diff --git a/cypress/e2e/setup.cy.ts b/cypress/e2e/setup.cy.ts
new file mode 100644
index 00000000..4e14d4fe
--- /dev/null
+++ b/cypress/e2e/setup.cy.ts
@@ -0,0 +1,58 @@
+/**
+ * @copyright Copyright (c) 2023 Louis Chmn <louis@chmn.me>
+ *
+ * @author Louis Chmn <louis@chmn.me>
+ *
+ * @license AGPL-3.0-or-later
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+describe('Social app setup', () => {
+ before(() => {
+ cy.createRandomUser()
+ .then((user) => {
+ cy.login(user)
+ cy.visit('/apps/social')
+ })
+ })
+
+ it('See the welcome message', () => {
+ cy.get('.social__welcome').should('contain', 'Nextcloud becomes part of the federated social networks!')
+ cy.get('.social__welcome').find('.icon-close').click()
+ cy.get('.social__welcome').should('not.exist')
+ cy.reload()
+ })
+
+ it('See the home section in the sidebar', () => {
+ cy.get('.app-navigation').contains('Home').click()
+ cy.get('.app-social .empty-content').should('be.visible')
+ })
+
+ it('See the empty content illustration of Direct messages', () => {
+ cy.get('.app-navigation').contains('Direct messages').click()
+ cy.get('.app-social .empty-content').should('be.visible').contains('No direct messages found')
+ })
+
+ it('See the empty content illustration of Profile', () => {
+ cy.intercept({ times: 1, method: 'GET', url: '**/apps/social/api/v1/accounts/*/statuses?*' }).as('accountStatuses')
+
+ cy.get('.app-navigation').contains('Profile').click()
+ cy.wait("@accountStatuses")
+
+ cy.get('.app-social .empty-content__title').scrollIntoView()
+ cy.get('.app-social .empty-content').should('be.visible').contains('You have not tooted yet')
+ })
+})
diff --git a/cypress/utils/index.js b/cypress/utils/index.ts
index 901c9bd0..0abe3876 100644
--- a/cypress/utils/index.js
+++ b/cypress/utils/index.ts
@@ -20,7 +20,7 @@
*
*/
-const getSearchParams = url => {
+export function getSearchParams (url) {
return url
.split(/[?&]/)
.reduce((acc, cur) => {
@@ -30,6 +30,6 @@ const getSearchParams = url => {
}, {})
}
-const randHash = () => Math.random().toString(36).replace(/[^a-z]+/g, '').slice(0, 10)
-
-export default { getSearchParams, randHash }
+export function randHash() {
+ return Math.random().toString(36).replace(/[^a-z]+/g, '').slice(0, 10)
+}