Pizza e2e test
/// <reference types="Cypress" /> | |
import { isThisTypeNode } from 'typescript'; | |
context('Actions', () => { | |
beforeEach(() => { | |
cy.visit('/'); | |
}); | |
it('should fill form to order pizza', () => { | |
// Fill the name | |
cy.get('[data-cy="name"]') | |
.type('John Snow') | |
.should('have.value', 'John Snow'); | |
// Fill the email | |
cy.get('[data-cy="email"]') | |
.type('John.Snow@got.com') | |
.should('have.value', 'John.Snow@got.com'); | |
// Fill the confirm email | |
cy.get('[data-cy="confirmEmail"]') | |
.type('John.Snow@got.com') | |
.should('have.value', 'John.Snow@got.com'); | |
// Fill the address | |
cy.get('[data-cy="address"]') | |
.type('The North') | |
.should('have.value', 'The North'); | |
// Fill the postcode | |
cy.get('[data-cy="postcode"]') | |
.type('N6-7KGDS') | |
.should('have.value', 'N6-7KGDS'); | |
// Fill the phone | |
cy.get('[data-cy="phone"]') | |
.type('01234567890') | |
.should('have.value', '01234567890'); | |
// Select thje Pizza size 'Large' | |
cy.get('[data-cy="size"]') | |
.find('input[type="radio"]') | |
.first() | |
.check({ force: true }) | |
.should('be.checked'); | |
// Check 'anchovy' | |
cy.get('[data-cy="topping"]') | |
.find('input[type="checkbox"]') | |
.check('anchovy', { force: true }); | |
// Check 'bacon' | |
cy.get('[data-cy="topping"]') | |
.find('input[type="checkbox"]') | |
.check('bacon', { force: true }); | |
// Should have 2 toppings selected | |
cy.get('[data-cy="selectedTopping"]').should('have.length', 2); | |
// Verify first topping is Anchovy | |
cy.get('[data-cy="selectedTopping"]') | |
.first() | |
.invoke('text') | |
.should('be.equal', 'Anchovy'); | |
// Verify second topping is Bacon | |
cy.get('[data-cy="selectedTopping"]') | |
.last() | |
.invoke('text') | |
.should('be.equal', 'Bacon'); | |
cy.get('[data-cy="selectedTopping"]') | |
.first() | |
.scrollIntoView(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment