File size: 1,805 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
describe('form reset', () => {
it('should be able to re-populate the form while reset', () => {
cy.visit('http://localhost:3000/reset');
cy.get('input[name="firstName"]').type('0 wrong');
cy.get('input[name="array.1"]').type('1 wrong');
cy.get('input[name="objectData.test"]').type('2 wrong');
cy.get('input[name="lastName"]').type('lastName');
cy.get('input[name="deepNest.level1.level2.data"]').type('whatever');
cy.get('button').click();
cy.get('input[name="firstName"]').should('have.value', 'bill');
cy.get('input[name="lastName"]').should('have.value', 'luo');
cy.get('input[name="array.1"]').should('have.value', 'test');
cy.get('input[name="objectData.test"]').should('have.value', 'data');
cy.get('input[name="deepNest.level1.level2.data"]').should(
'have.value',
'hey',
);
});
it('should be able to re-populate the form while reset keeping dirty values', () => {
cy.visit('http://localhost:3000/resetKeepDirty');
cy.get('input[name="firstName"]').should('have.value', '');
cy.get('input[name="users"]').should('have.value', 'users#0');
cy.get('input[name="objectData.test"]').should('have.value', '');
cy.get('input[name="lastName"]').should('have.value', '');
cy.get('input[name="deepNest.level1.level2.data"]').should(
'have.value',
'',
);
cy.get('button').click({ multiple: true });
cy.get('input[name="firstName"]').should('have.value', 'bill');
cy.get('input[name="lastName"]').should('have.value', 'luo');
cy.get('input[name="users"]').should('have.value', 'users#1');
cy.get('input[name="objectData.test"]').should('have.value', 'data');
cy.get('input[name="deepNest.level1.level2.data"]').should(
'have.value',
'hey',
);
});
});
|