-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cypress testing for archive/favorite
Signed-off-by: Elizabeth Danzberger <[email protected]>
- Loading branch information
Showing
2 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
}) | ||
|
||
}) |