summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2020-10-11 15:14:11 -0100
committerGitHub <noreply@github.com>2020-10-11 15:14:11 -0100
commit2748b0e46a371616e51c74f7704081832ba1917b (patch)
tree4b44dc72958d7384a9316e91dcad492333e7b33b
parent5de193fc22dcc3c5577f84b01af2e4f2bbd6e562 (diff)
parent5512f1e404c40d57e1db1f2b795871c62c3069b0 (diff)
Merge pull request #1053 from nextcloud/cypress-fixes
cypress fixes
-rw-r--r--cypress/integration/0.setup.spec.js10
-rw-r--r--cypress/integration/post.spec.js30
-rw-r--r--cypress/support/commands.js7
3 files changed, 32 insertions, 15 deletions
diff --git a/cypress/integration/0.setup.spec.js b/cypress/integration/0.setup.spec.js
index 4c60f8bb..7c05bebb 100644
--- a/cypress/integration/0.setup.spec.js
+++ b/cypress/integration/0.setup.spec.js
@@ -1,7 +1,13 @@
-describe('Social app setup', function() {
+let userId = 'janedoe' + Date.now();
+describe('Social app setup', function() {
before(function() {
- cy.login('admin', 'admin')
+ cy.nextcloudCreateUser(userId, 'p4ssw0rd')
+ cy.login(userId, 'p4ssw0rd')
+ })
+
+ beforeEach(() => {
+ Cypress.Cookies.preserveOnce('nc_username', 'nc_token', 'nc_session_id', 'oc_sessionPassphrase');
})
it('See the welcome message', function() {
diff --git a/cypress/integration/post.spec.js b/cypress/integration/post.spec.js
index 1de7688f..5257b91f 100644
--- a/cypress/integration/post.spec.js
+++ b/cypress/integration/post.spec.js
@@ -20,15 +20,16 @@
*
*/
+let userId = 'janedoe' + Date.now();
+
describe('Create posts', function() {
before(function() {
- cy.visit('/apps/social/')
- cy.logout()
- cy.login('admin', 'admin')
- cy.nextcloudCreateUser('janedoe', 'p4ssw0rd')
- cy.logout()
- cy.login('janedoe', 'p4ssw0rd', '/apps/social/')
+ // ensure that the admin account is initialized for social
+ cy.login('admin', 'admin', '/apps/social/')
+
+ cy.nextcloudCreateUser(userId, 'p4ssw0rd')
+ cy.login(userId, 'p4ssw0rd', '/apps/social/')
cy.get('.app-content').should('be.visible')
})
@@ -36,7 +37,12 @@ describe('Create posts', function() {
cy.screenshot()
})
+ beforeEach(() => {
+ Cypress.Cookies.preserveOnce('nc_username', 'nc_token', 'nc_session_id', 'oc_sessionPassphrase');
+ })
+
it('Write a post to followers', function() {
+ cy.visit('/apps/social/')
cy.server()
cy.route('POST', '/index.php/apps/social/api/v1/post').as('postMessage')
cy.get('.new-post input[type=submit]')
@@ -51,6 +57,7 @@ describe('Create posts', function() {
})
it('Write a post to followers with shift enter', function() {
+ cy.visit('/apps/social/')
cy.server()
cy.route('POST', '/index.php/apps/social/api/v1/post').as('postMessage')
cy.get('.new-post').find('[contenteditable]').type('Hello world 2{shift}{enter}')
@@ -59,8 +66,10 @@ describe('Create posts', function() {
})
it('Write a post to @admin', function() {
+ cy.visit('/apps/social/')
cy.server()
cy.route('POST', '/index.php/apps/social/api/v1/post').as('postMessage')
+ cy.route('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')
@@ -68,10 +77,14 @@ describe('Create posts', function() {
cy.get('.new-post input[type=submit]')
.click()
cy.wait('@postMessage')
- cy.get('.social__timeline div.timeline-entry:first-child').should('contain', 'admin@localhost')
+ 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.visit('/apps/social/')
+ cy.server()
+ cy.route('POST', '/index.php/apps/social/api/v1/post').as('postMessage')
+ cy.route('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 input[type=submit]').should('not.be.disabled')
@@ -86,7 +99,8 @@ describe('Create posts', function() {
cy.get('.new-post input[type=submit]')
.click()
- cy.get('.social__timeline div.timeline-entry:first-child').should('contain', 'Hello there').should('contain', 'admin@localhost')
+ cy.wait('@postMessage')
+ cy.get('.social__timeline div.timeline-entry:first-child').should('contain', 'Hello world').should('contain', '@admin')
})
diff --git a/cypress/support/commands.js b/cypress/support/commands.js
index 283f3a19..7b65139a 100644
--- a/cypress/support/commands.js
+++ b/cypress/support/commands.js
@@ -29,10 +29,7 @@ const url = Cypress.config('baseUrl').replace(/\/index.php\/?$/g, '')
Cypress.env('baseUrl', url)
Cypress.Commands.add('login', (user, password, route = '/apps/files') => {
- cy.clearCookies()
- Cypress.Cookies.defaults({
- preserve: /^(oc|nc)/,
- })
+ cy.clearCookies();
cy.visit(route)
cy.get('input[name=user]').type(user)
cy.get('input[name=password]').type(password)
@@ -53,7 +50,7 @@ Cypress.Commands.add('logout', () => {
})
Cypress.Commands.add('nextcloudCreateUser', (user, password) => {
- cy.clearCookies()
+ cy.clearCookies();
cy.request({
method: 'POST',
url: `${Cypress.env('baseUrl')}/ocs/v1.php/cloud/users?format=json`,