Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ composer.lock
Icon?
ehthumbs.db
Thumbs.db
altapay-master.zip
altapay-master.zip
tests/integration-tests/node_modules
21 changes: 21 additions & 0 deletions tests/integration-tests/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { defineConfig } = require("cypress");

module.exports = defineConfig({
chromeWebSecurity: false,
videoCompression: false,
videoUploadOnPasses: false,
includeShadowDom: true,
retries: {
runMode: 2,
openMode: 2,
},
env: {
NODE_TLS_REJECT_UNAUTHORIZED: 0,
},

e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
80 changes: 80 additions & 0 deletions tests/integration-tests/cypress/e2e/commons/utils.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
class Order {
clrcookies() {
cy.clearCookies()
}
visit() {
cy.fixture('config').then((url) => {
cy.visit(url.shopURL)
})
}

addProduct() {
cy.get('.nav-item-a515ae260223466f8e37471d279e6406 > .main-navigation-link-text > span').click()
cy.get(':nth-child(1) > .card > .card-body > .product-info > .product-action > .buy-widget > .d-grid > .btn').click()
cy.get('.offcanvas-cart-actions > :nth-child(2) > .btn').click()
}

cc(CC_TERMINAL_NAME) {
cy.contains(CC_TERMINAL_NAME).click({ force: true })
cy.get('#confirmFormSubmit').click()

cy.origin('https://testgateway.altapaysecure.com', () => {
cy.get('#creditCardNumberInput').type('4222222222222222')
cy.get('#cvcInput').type('123')
cy.get('#cardholderNameInput').type('smith')
cy.get('#pensioCreditCardPaymentSubmitButton').click().wait(3000)
})
cy.get('body').should('contain', 'Order confirmation email has been sent').wait(3000)
}

klarna(KLARNA_DKK_TERMINAL_NAME) {
cy.contains(KLARNA_DKK_TERMINAL_NAME).click({ force: true })
cy.get('#confirmFormSubmit').click()
cy.wait(3000)
cy.get('#radio_pay_later').click().wait(8000)
cy.get('[id=submitbutton]').click().wait(5000)
cy.wait(5000)
}

visitAdminOrder() {
cy.fixture('config').then((conf) => {
cy.clearCookies()
cy.visit(conf.adminURL)
cy.get('#sw-field--username').type(conf.adminUsername)
cy.get('#sw-field--password').type(conf.adminPass)
cy.get('.sw-button').click().wait(3000)
cy.get('.sw-order > span.sw-admin-menu__navigation-link').click()
cy.get('.sw-admin-menu_flyout-holder > .sw-admin-menu__navigation-list-item > .sw-admin-menu__navigation-link').click()
cy.get('.sw-data-grid__row--0 > .sw-data-grid__cell--orderNumber > .sw-data-grid__cell-content > a').click()
cy.get('.sw-order-detail__tabs-tab-altaPay').click()
})
}

capture() {
cy.get(':nth-child(2) > .sw-container > :nth-child(1)').click()
cy.get('.sw-container > :nth-child(10)').should('have.text', '19.99 DKK');
}

refund() {
cy.get(':nth-child(2) > .sw-container > :nth-child(2)').click()
cy.get('.sw-container > :nth-child(12)').should('have.text', '19.99 DKK');
}

release() {
cy.get(':nth-child(2) > .sw-container > :nth-child(3)').click()
cy.get('.sw-container > :nth-child(6)').should('have.text', 'released');
}

fillCheckoutInfo() {
cy.get('#personalFirstName').type('Test')
cy.get('#personalLastName').type('Person')
cy.get('#personalMail').type('demo@example.com')
cy.get('#billingAddressAddressStreet').type('Sæffleberggate 56,1 mf')
cy.get('#billingAddressAddressZipcode').type('6800')
cy.get('#billingAddressAddressCity').type('Varde')
cy.get('.register-submit > .btn').click().wait(3000)
cy.get('#tos').click()
}
}

export default Order
81 changes: 81 additions & 0 deletions tests/integration-tests/cypress/e2e/test-scripts/payment.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/// <reference types= "cypress" />
import Order from "../commons/utils.cy"

it('CC Capture & Refund', function () {

const ord = new Order()
ord.clrcookies()
ord.visit()

ord.addProduct()
ord.fillCheckoutInfo()
cy.fixture('config').then((conf) => {
if (conf.CC_TERMINAL_NAME != "") {
cy.get('body').then(($a) => {
if ($a.find("label:contains('" + conf.CC_TERMINAL_NAME + "')").length) {
ord.cc(conf.CC_TERMINAL_NAME)
ord.visitAdminOrder()
ord.capture()
ord.refund()
} else {
cy.log(conf.CC_TERMINAL_NAME + ' not found in page')
this.skip()
}
})
}else {
cy.log('CC_TERMINAL_NAME skipped')
this.skip()
}
})
})

it('CC Release Payment', function () {
const ord = new Order()
ord.clrcookies()
ord.visit()

ord.addProduct()
ord.fillCheckoutInfo()
cy.fixture('config').then((conf) => {
if (conf.CC_TERMINAL_NAME != "") {
cy.get('body').then(($a) => {
if ($a.find("label:contains('" + conf.CC_TERMINAL_NAME + "')").length) {
ord.cc(conf.CC_TERMINAL_NAME)
ord.visitAdminOrder()
ord.release()
} else {
cy.log(conf.CC_TERMINAL_NAME + ' not found in page')
this.skip()
}
})
}else {
cy.log('CC_TERMINAL_NAME skipped')
this.skip()
}
})
})

it('Klarna Open Form', function () {

const ord = new Order()
ord.clrcookies()
ord.visit()

ord.addProduct()
ord.fillCheckoutInfo()
cy.fixture('config').then((conf) => {
if (conf.KLARNA_DKK_TERMINAL_NAME != "") {
cy.get('body').then(($a) => {
if ($a.find("label:contains('" + conf.KLARNA_DKK_TERMINAL_NAME + "')").length) {
ord.klarna(conf.KLARNA_DKK_TERMINAL_NAME)
} else {
cy.log(conf.KLARNA_DKK_TERMINAL_NAME + ' not found in page')
this.skip()
}
})
}else {
cy.log('CC_TERMINAL_NAME skipped')
this.skip()
}
})
})
8 changes: 8 additions & 0 deletions tests/integration-tests/cypress/fixtures/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"shopURL": "http://yoursite.com",
"adminURL": "http://yoursite.com/admin#/login",
"adminUsername": "admin_username",
"adminPass": "admin_password",
"CC_TERMINAL_NAME": "Your CC terminal name",
"KLARNA_DKK_TERMINAL_NAME": "Your Klarna DKK terminal name"
}
25 changes: 25 additions & 0 deletions tests/integration-tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
20 changes: 20 additions & 0 deletions tests/integration-tests/cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
Loading