File: D:/HostingSpaces/SBogers10/shop.komma.nl/tests/Cypress/integration/site/confirmation_page.spec.js
/// <reference types="Cypress" />
import PagesInfo from "../../support/pagesInfo";
const pagesInfo = new PagesInfo();
import faker from 'faker';
describe('Confirmation page', function() {
// describe('Change details link', function() {
// it('Should send you to the details page', function() {
// cy.clearCookies();
// cy.request('GET', '/testapi/v1/cart/addToCart', {
// items: [
// {'productable_type' : 'product', 'id' : 2, 'quantity': 2}, //Hammer
// ]
// }).then(function(response) {
// cy.visit(pagesInfo.getByName('customer_details').locations.nl)
//
// const contactDetails = {
// firstName: faker.name.firstName(),
// lastNamePrefix: faker.random.arrayElement(['van de', 'de', 'aan', 'aan de', 'ten', 'over den']),
// lastName: faker.name.lastName(),
// email: faker.internet.email(),
// phone: faker.phone.phoneNumberFormat()
// }
//
// const invoiceDetails = {
// postalCode: faker.address.zipCode(),
// city: faker.address.city(),
// streetName: faker.address.streetName(),
// houseNumber: faker.address.streetAddress(),
// }
//
// cy.get('[data-test="first_name"]').type(contactDetails.firstName)
// cy.get('[data-test="last_name_prefix"]').type(contactDetails.lastNamePrefix)
// cy.get('[data-test="last_name"]').type(contactDetails.lastName)
// cy.get('[data-test="email"]').type(contactDetails.email)
// cy.get('[data-test="phone"]').type(contactDetails.phone)
// cy.get('[data-test="invoice_street"]').type(invoiceDetails.streetName)
// cy.get('[data-test="invoice_house_number"]').type(invoiceDetails.houseNumber)
// cy.get('[data-test="invoice_postal_code"]').type(invoiceDetails.postalCode)
// cy.get('[data-test="invoice_city"]').type(invoiceDetails.city)
//
// cy.get('[data-test="continue"]').click({force: true})
// cy.get('[data-test="change-details"]').click()
// cy.url().should('contain', pagesInfo.getByName('customer_details').locations.nl);
// })
// });
// });
describe('Data', function() {
it('Should show the entered data', function() {
cy.clearCookies();
cy.request('GET', '/testapi/v1/cart/addToCart', {
items: [
{'productable_type' : 'product', 'id' : 2, 'quantity': 2}, //Hammer
]
}).then(function(response) {
cy.visit('/'); //Needed because previous test already is on the same page, and therefore the page still may contain state.
cy.visit(pagesInfo.getByName('customer_details').locations.nl)
const contactDetails = {
firstName: faker.name.firstName(),
lastNamePrefix: faker.random.arrayElement(['van de', 'de', 'aan', 'aan de', 'ten', 'over den']),
lastName: faker.name.lastName(),
email: faker.internet.email(),
phone: faker.phone.phoneNumberFormat()
}
const invoiceDetails = {
postalCode: faker.address.zipCode(),
city: faker.address.city(),
streetName: faker.address.streetName(),
houseNumber: faker.address.streetAddress(),
}
cy.get('[data-test="first_name"]').type(contactDetails.firstName)
cy.get('[data-test="last_name_prefix"]').type(contactDetails.lastNamePrefix)
cy.get('[data-test="last_name"]').type(contactDetails.lastName)
cy.get('[data-test="email"]').type(contactDetails.email)
cy.get('[data-test="phone"]').type(contactDetails.phone)
cy.get('[data-test="invoice_street"]').type(invoiceDetails.streetName)
cy.get('[data-test="invoice_house_number"]').type(invoiceDetails.houseNumber)
cy.get('[data-test="invoice_postal_code"]').type(invoiceDetails.postalCode)
cy.get('[data-test="invoice_city"]').type(invoiceDetails.city)
cy. get('[data-test="continue"]').click({force: true})
// cy.get('[data-test="contact-details"]').contains(contactDetails.firstName).should('exist');
// cy.get('[data-test="contact-details"]').contains(contactDetails.lastNamePrefix).should('exist');
// cy.get('[data-test="contact-details"]').contains(contactDetails.lastName).should('exist');
cy.get('[data-test="contact-details"]').contains(contactDetails.email).should('exist');
cy.get('[data-test="contact-details"]').contains(contactDetails.phone).should('exist');
cy.get('[data-test="invoice-address"]').contains(invoiceDetails.streetName).should('exist');
cy.get('[data-test="invoice-address"]').contains(invoiceDetails.houseNumber).should('exist');
cy.get('[data-test="invoice-address"]').contains(invoiceDetails.postalCode).should('exist');
cy.get('[data-test="invoice-address"]').contains(invoiceDetails.city).should('exist');
cy.get('[data-test="shipping-address"]').contains(invoiceDetails.streetName).should('exist');
cy.get('[data-test="shipping-address"]').contains(invoiceDetails.houseNumber).should('exist');
cy.get('[data-test="shipping-address"]').contains(invoiceDetails.postalCode).should('exist')
cy.get('[data-test="shipping-address"]').contains(invoiceDetails.city).should('exist');
cy.request('GET', '/checkout/information').then(function(response) {
response.body.items.forEach(item => {
cy.get('[data-test="items"]').contains(item.productable.translation.name).should('exist')
cy.get('[data-test="items"]').contains(item.price_inc_formatted).should('exist')
})
});
})
});
});
//
// describe('"I agree to the therms" checkbox', function() {
// it('Should show an error when you do not check it and continue', function() {
// cy.clearCookies();
// cy.request('GET', '/testapi/v1/cart/addToCart', {
// items: [
// {'productable_type' : 'product', 'id' : 2, 'quantity': 2}, //Hammer
// ]
// }).then(function(response) {
// cy.visit('/'); //Needed because previous test already is on the same page, and therefore the page still may contain state.
// cy.visit(pagesInfo.getByName('customer_details').locations.nl)
//
// const contactDetails = {
// firstName: faker.name.firstName(),
// lastNamePrefix: faker.random.arrayElement(['van de', 'de', 'aan', 'aan de', 'ten', 'over den']),
// lastName: faker.name.lastName(),
// email: faker.internet.email(),
// phone: faker.phone.phoneNumberFormat()
// }
//
// const invoiceDetails = {
// postalCode: faker.address.zipCode(),
// city: faker.address.city(),
// streetName: faker.address.streetName(),
// houseNumber: faker.address.streetAddress(),
// }
//
// cy.get('[data-test="first_name"]').type(contactDetails.firstName)
// cy.get('[data-test="last_name_prefix"]').type(contactDetails.lastNamePrefix)
// cy.get('[data-test="last_name"]').type(contactDetails.lastName)
// cy.get('[data-test="email"]').type(contactDetails.email)
// cy.get('[data-test="phone"]').type(contactDetails.phone)
//
// cy.get('[data-test="invoice_street"]').type(invoiceDetails.streetName)
// cy.get('[data-test="invoice_house_number"]').type(invoiceDetails.houseNumber)
// cy.get('[data-test="invoice_postal_code"]').type(invoiceDetails.postalCode)
// cy.get('[data-test="invoice_city"]').type(invoiceDetails.city)
//
// cy.get('[data-test="continue"]').click({force: true})
//
// cy.get('[data-test="terms-and-conditions"]').should('not.be.checked');
// cy.get('[data-test="terms_and_conditions-error"]').should('not.be.visible');
// cy.get('[data-test="confirm-and-pay"]').click({force: true});
// cy.get('[data-test="terms_and_conditions-error"]').should('be.visible');
// })
// });
//
// it('Should show the Komma PSP when agreed to the therms', function() {
// cy.clearCookies();
// cy.request('GET', '/testapi/v1/cart/addToCart', {
// items: [
// {'productable_type' : 'product', 'id' : 2, 'quantity': 2}, //Hammer
// ]
// }).then(function(response) {
// cy.visit('/'); //Needed because previous test already is on the same page, and therefore the page still may contain state.
// cy.visit(pagesInfo.getByName('customer_details').locations.nl)
//
// const contactDetails = {
// firstName: faker.name.firstName(),
// lastNamePrefix: faker.random.arrayElement(['van de', 'de', 'aan', 'aan de', 'ten', 'over den']),
// lastName: faker.name.lastName(),
// email: faker.internet.email(),
// phone: faker.phone.phoneNumberFormat()
// }
//
// const invoiceDetails = {
// postalCode: faker.address.zipCode(),
// city: faker.address.city(),
// streetName: faker.address.streetName(),
// houseNumber: faker.address.streetAddress(),
// }
//
// cy.get('[data-test="first_name"]').type(contactDetails.firstName)
// cy.get('[data-test="last_name_prefix"]').type(contactDetails.lastNamePrefix)
// cy.get('[data-test="last_name"]').type(contactDetails.lastName)
// cy.get('[data-test="email"]').type(contactDetails.email)
// cy.get('[data-test="phone"]').type(contactDetails.phone)
//
// cy.get('[data-test="invoice_street"]').type(invoiceDetails.streetName)
// cy.get('[data-test="invoice_house_number"]').type(invoiceDetails.houseNumber)
// cy.get('[data-test="invoice_postal_code"]').type(invoiceDetails.postalCode)
// cy.get('[data-test="invoice_city"]').type(invoiceDetails.city)
//
// cy.get('[data-test="continue"]').click({force: true})
//
// cy.get('[data-test="terms-and-conditions"]').should('not.be.checked');
// cy.get('[data-test="terms-and-conditions"]').check();
// cy.get('[data-test="confirm-and-pay"]').click({force: true});
//
// cy.get('[data-test="komma-psp"]').should('exist')
// })
// });
// });
});