Skip to content

Commit

Permalink
Merge pull request #901 from nextcloud/tests/archive-favorite
Browse files Browse the repository at this point in the history
cypress testing for archive/favorite
  • Loading branch information
juliusknorr authored Mar 5, 2024
2 parents 5207241 + b47223d commit bcb7d1e
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 0 deletions.
49 changes: 49 additions & 0 deletions cypress/e2e/tables-archive.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
let localUser

describe('Archive tables/views', () => {

before(function() {
cy.createRandomUser().then(user => {
localUser = user
})
})

beforeEach(function() {
cy.login(localUser)
cy.visit('apps/tables')
})

it('can archive tables', () => {
cy.get('[data-cy="navigationTableItem"]').first().as('tutorialTable')

cy.get('@tutorialTable').should('contain.text', 'Tutorial')
cy.get('@tutorialTable').find('[aria-haspopup="menu"]').click({ force: true })

cy.intercept({ method: 'PUT', url: '**/apps/tables/table/*'}).as('archiveTableReq')
cy.contains('Archive table').click({ force: true })

cy.wait('@archiveTableReq').then(request => {
expect(request.response.statusCode).to.equal(200)
expect(request.response.body.archived).to.equal(true)
})

cy.get('@tutorialTable').parent().parent().should('contain.text', 'Archived tables')
})

it('can unarchive tables', () => {
cy.get('[data-cy="navigationTableItem"]').first().as('tutorialTable')

cy.get('@tutorialTable').should('contain.text', 'Tutorial')
cy.get('@tutorialTable').find('[aria-haspopup="menu"]').click({ force: true })

cy.intercept({ method: 'PUT', url: '**/apps/tables/table/*' }).as('unarchiveTableReq')
cy.contains('Unarchive table').click({ force: true })

cy.wait('@unarchiveTableReq').then(request => {
expect(request.response.statusCode).to.equal(200)
expect(request.response.body.archived).to.equal(false)
})

cy.get('@tutorialTable').parent().should('contain.text', 'Tables')
})
})
71 changes: 71 additions & 0 deletions cypress/e2e/tables-favorite.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
let localUser

describe('Favorite tables/views', () => {

before(function() {
cy.createRandomUser().then(user => {
localUser = user
})
})

beforeEach(function() {
cy.login(localUser)
cy.visit('apps/tables')
})

it('can favorite tables', () => {
cy.get('[data-cy="navigationTableItem"]').first().as('tutorialTable')

cy.get('@tutorialTable').should('contain.text', 'Tutorial')
cy.get('@tutorialTable').find('[aria-haspopup="menu"]').click({ force: true })

cy.intercept({ method: 'POST', url: '**/ocs/v2.php/apps/tables/api/2/favorites/*/*'}).as('favoriteTableReq')
cy.contains('Add to favorites').click({ force: true })
cy.wait('@favoriteTableReq').its('response.statusCode').should('equal', 200)

cy.get('@tutorialTable').parent().should('contain.text', 'Favorites')
})

it('can remove favorite table', () => {
cy.get('[data-cy="navigationTableItem"]').first().as('tutorialTable')

cy.get('@tutorialTable').should('contain.text', 'Tutorial')
cy.get('@tutorialTable').find('[aria-haspopup="menu"]').click({ force: true })

cy.intercept({ method: 'DELETE', url: '**/ocs/v2.php/apps/tables/api/2/favorites/*/*' }).as('unfavoriteTableReq')
cy.contains('Remove from favorites').click({ force: true })
cy.wait('@unfavoriteTableReq').its('response.statusCode').should('equal', 200)

cy.get('@tutorialTable').parent().should('contain.text', 'Tables')
})

it('can favorite views', () => {
cy.loadTable('Tutorial')
cy.createView('test')

cy.get('[data-cy="navigationViewItem"]').first().as('testView')

cy.get('@testView').parent().parent().should('contain.text', 'Tutorial')
cy.get('@testView').find('[aria-haspopup="menu"]').click({ force: true })

cy.intercept({ method: 'POST', url: '**/ocs/v2.php/apps/tables/api/2/favorites/*/*' }).as('favoriteViewReq')
cy.contains('Add to favorites').click({ force: true })
cy.wait('@favoriteViewReq').its('response.statusCode').should('equal', 200)

cy.get('@testView').parent().should('contain.text', 'Favorites')
})

it('can unfavorite views', () => {
cy.get('[data-cy="navigationViewItem"]').first().as('testView')

cy.get('@testView').parent().should('contain.text', 'Favorites')
cy.get('@testView').find('[aria-haspopup="menu"]').click({ force: true })

cy.intercept({ method: 'DELETE', url: '**/ocs/v2.php/apps/tables/api/2/favorites/*/*' }).as('unfavoriteViewReq')
cy.contains('Remove from favorites').click({ force: true })
cy.wait('@unfavoriteViewReq').its('response.statusCode').should('equal', 200)

cy.get('@testView').parent().parent().should('contain.text', 'Tutorial')
})

})

0 comments on commit bcb7d1e

Please sign in to comment.