mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 21:48:42 +08:00
test(angular): add support for multi-version testing (#25665)
This commit is contained in:
119
angular/test/base/e2e/src/modal.spec.ts
Normal file
119
angular/test/base/e2e/src/modal.spec.ts
Normal file
@ -0,0 +1,119 @@
|
||||
describe('Modals', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/modals');
|
||||
})
|
||||
|
||||
it('should open standalone modal and close', () => {
|
||||
cy.get('#action-button').click();
|
||||
|
||||
cy.get('ion-modal').should('exist').should('be.visible');
|
||||
|
||||
cy.get('app-modal-example h2').should('have.text', '123');
|
||||
cy.get('app-modal-example h3').should('have.text', '321');
|
||||
cy.get('#modalInstance').should('have.text', 'true');
|
||||
|
||||
cy.get('#onWillDismiss').should('have.text', 'false');
|
||||
cy.get('#onDidDismiss').should('have.text', 'false');
|
||||
|
||||
cy.get('#close-modal').click();
|
||||
|
||||
cy.get('ion-modal').should('not.exist');
|
||||
|
||||
cy.get('#onWillDismiss').should('have.text', 'true');
|
||||
cy.get('#onDidDismiss').should('have.text', 'true');
|
||||
});
|
||||
|
||||
it('should open nav modal and close', () => {
|
||||
cy.get('#action-button-2').click();
|
||||
|
||||
cy.get('ion-modal').should('exist').should('be.visible');
|
||||
|
||||
cy.get('ion-nav > *:last-child h2').should('have.text', '123');
|
||||
cy.get('ion-nav > *:last-child h3').should('have.text', '321');
|
||||
|
||||
cy.get('ion-nav > *:last-child .push-page').click();
|
||||
|
||||
cy.get('ion-nav > *:last-child h2').should('have.text', 'pushed!');
|
||||
cy.get('ion-nav > *:last-child h3').should('have.text', '');
|
||||
|
||||
cy.get('ion-nav > *:last-child .pop-page').click();
|
||||
|
||||
cy.get('ion-nav > *:last-child h2').should('have.text', '123');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Modals: Inline', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/modal-inline');
|
||||
});
|
||||
|
||||
it('should initially have no items', () => {
|
||||
cy.get('ion-list ion-item').should('not.exist');
|
||||
});
|
||||
|
||||
it('should have items after opening', () => {
|
||||
cy.get('#open-modal').click();
|
||||
|
||||
cy.get('ion-list ion-item:nth-child(1)').should('have.text', 'A');
|
||||
cy.get('ion-list ion-item:nth-child(2)').should('have.text', 'B');
|
||||
cy.get('ion-list ion-item:nth-child(3)').should('have.text', 'C');
|
||||
cy.get('ion-list ion-item:nth-child(4)').should('have.text', 'D');
|
||||
});
|
||||
|
||||
it('should have a div with .ion-page after opening', () => {
|
||||
cy.get('#open-modal').click();
|
||||
|
||||
cy.get('ion-modal').children('.ion-page').should('exist');
|
||||
});
|
||||
|
||||
it('should remove .ion-page when closing the modal', () => {
|
||||
cy.get('#open-modal').click();
|
||||
|
||||
cy.get('ion-modal').children('.ion-page').should('exist');
|
||||
cy.get('ion-modal').trigger('click', 20, 20);
|
||||
|
||||
cy.get('ion-modal').children('.ion-page').should('not.exist');
|
||||
});
|
||||
|
||||
describe('setting the current breakpoint', () => {
|
||||
|
||||
it('should emit ionBreakpointDidChange', () => {
|
||||
cy.get('#open-modal').click();
|
||||
|
||||
cy.get('ion-modal').then(modal => {
|
||||
(modal.get(0) as any).setCurrentBreakpoint(1);
|
||||
});
|
||||
|
||||
cy.get('#breakpointDidChange').should('have.text', '1');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('when in a modal', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
cy.visit('/modals');
|
||||
cy.get('#action-button').click();
|
||||
cy.get('#close-modal').click();
|
||||
cy.get('#action-button').click();
|
||||
});
|
||||
|
||||
it('should render ion-item item-has-value class when control value is set', () => {
|
||||
cy.get('[formControlName="select"]').invoke('attr', 'value', 0);
|
||||
cy.get('#inputWithFloatingLabel').should('have.class', 'item-has-value');
|
||||
});
|
||||
|
||||
it('should not render ion-item item-has-value class when control value is undefined', () => {
|
||||
cy.get('[formControlName="select"]').invoke('attr', 'value', undefined);
|
||||
cy.get('#inputWithFloatingLabel').should('not.have.class', 'item-has-value');
|
||||
});
|
||||
|
||||
it('should not render ion-item item-has-value class when control value is null', () => {
|
||||
cy.get('[formControlName="select"]').invoke('attr', 'value', null);
|
||||
cy.get('#inputWithFloatingLabel').should('not.have.class', 'item-has-value');
|
||||
});
|
||||
|
||||
});
|
Reference in New Issue
Block a user