-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Such tests make use of the refactored login commands, which means that only the first tests needs to log in via the GUI, while others benefit from the session to be restored from the cache. In this test suite, I've also create a custom command to cleanup all existing models on the beforeEach hook so that tests always start in a fresh state.
- Loading branch information
Showing
2 changed files
with
57 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
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,56 @@ | ||
describe('Models', () => { | ||
beforeEach(() => { | ||
cy.intercept('get', '/models?userId=*').as('getUserModels') | ||
cy.login() | ||
cy.visit('/#!/main') | ||
cy.cleanUpUserModels() | ||
cy.contains('a', 'Nova Modelagem').click() | ||
cy.get('create-model-modal').should('be.visible') | ||
}) | ||
|
||
it('opens and closes the "New Model" modal', () => { | ||
cy.contains('button', 'Cancelar').click() | ||
cy.get('create-model-modal').should('not.exist') | ||
}) | ||
|
||
it('alerts when clicking SAVE without filling the title', () => { | ||
cy.contains('button', 'Salvar').click() | ||
cy.get('#name').should('have.class', 'error') | ||
}) | ||
|
||
context('Model creation', () => { | ||
const modelTitle = 'User' | ||
|
||
beforeEach(() => cy.get('#name').type(modelTitle)) | ||
|
||
it('creates a conceptual model', () => { | ||
cy.contains('button', 'Salvar').click() | ||
|
||
cy.contains('h2', `Modelo conceitual de: ${modelTitle}`) | ||
.should('be.visible') | ||
}) | ||
|
||
it('creates a logical model', () => { | ||
cy.get('.modelselect').click() | ||
cy.contains('li span', 'Lógico').click() | ||
cy.contains('button', 'Salvar').click() | ||
|
||
cy.contains('h2', `Modelo lógico de: ${modelTitle}`) | ||
.should('be.visible') | ||
}) | ||
}) | ||
}) | ||
|
||
Cypress.Commands.add('cleanUpUserModels', () => { | ||
cy.wait('@getUserModels').then(userModels => { | ||
cy.request('GET', userModels.response.url).then(userModelsResponse => { | ||
userModelsResponse.body.forEach(model => { | ||
cy.request( | ||
'DELETE', | ||
`${Cypress.config('apiUrl')}/models/:modelId?modelId=${model._id}` | ||
) | ||
}) | ||
}) | ||
}) | ||
cy.reload() | ||
}) |