diff options
author | Robin Appelman <robin@icewind.nl> | 2020-10-09 17:36:51 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2020-10-09 17:36:51 +0200 |
commit | 5512f1e404c40d57e1db1f2b795871c62c3069b0 (patch) | |
tree | 215def98e4bc1bb52ba255b5667061278f2594d3 /cypress/integration | |
parent | 304a2556d26a3259152e4dd36574bdd2f4eb093e (diff) |
make setup a bit more reliable
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'cypress/integration')
-rw-r--r-- | cypress/integration/0.setup.spec.js | 10 | ||||
-rw-r--r-- | cypress/integration/post.spec.js | 27 |
2 files changed, 28 insertions, 9 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 3b9f8ee8..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,6 +66,7 @@ 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') @@ -73,6 +81,10 @@ describe('Create posts', function() { }) 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') @@ -87,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') + cy.wait('@postMessage') + cy.get('.social__timeline div.timeline-entry:first-child').should('contain', 'Hello world').should('contain', '@admin') }) |