1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-09 16:06:21 +02:00

tests for new button

This commit is contained in:
Arnab Sen
2022-04-16 10:36:32 +05:30
parent f6cf7766f3
commit cb4d19d05c
10 changed files with 44 additions and 4 deletions

View File

@ -0,0 +1,35 @@
/// <reference types="cypress" />
describe('Testing interfaces', () => {
beforeEach(() => {
cy.init();
});
it('New button should create a new item if no unsaved changes present', () => {
cy.get('[data-testid=newButton]').click();
// since we haven't made any changed it should show the modal
cy.get('.modal__content').should('be.visible');
});
it('New button should ask for confirmation if unsaved changes present, when confirmed modal should pop-up', () => {
cy.get('#htmlCodeEl').type('Hello');
cy.get('[data-testid=newButton]').click();
cy.on('window:confirm', text => {
expect(text).to.contains('You have unsaved changes.');
});
cy.get('.modal__content').should('be.visible');
});
it('New button should ask for confirmation if unsaved changes present, when declined modal should not pop-up', () => {
cy.get('#htmlCodeEl').type('Hello');
cy.get('[data-testid=newButton]').click();
cy.on('window:confirm', text => {
expect(text).to.contains('You have unsaved changes.');
return false;
});
cy.get('.modal__content').should('not.exist');
});
});