Skip to content

Commit

Permalink
Add OneClick
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennelandais committed Apr 8, 2019
1 parent b163ba9 commit 2e1886b
Show file tree
Hide file tree
Showing 80 changed files with 2,201 additions and 853 deletions.
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Expand Up @@ -65,7 +65,7 @@ test-cypress-1:
- curl --retry 10 --retry-delay 20 -v http:\/\/${DOCKER_SERVICE}-${CI_COMMIT_REF_SLUG}-${CI_JOB_ID}-web/
- cd bin/tests
- yarn install
- bash ./run_test.sh -p 0 -e $EXCLUDED_TEST_FILES --config baseUrl=http://${DOCKER_SERVICE}-${CI_COMMIT_REF_SLUG}-${CI_JOB_ID}-web/ --env $CYPRESS_ENV
- bash /tools/run-cypress-test.sh -f $TESTS_FOLDERS_1 -e $EXCLUDED_TEST_FILES --config baseUrl=http://${DOCKER_SERVICE}-${CI_COMMIT_REF_SLUG}-${CI_JOB_ID}-web/ --env $CYPRESS_ENV
after_script:
- /tools/clean-job.sh $PROJECT_NAME_TEST_1 docker-compose.test.yml wordpress ${DOCKER_STACK}-${DOCKER_SERVICE}_web:${CI_COMMIT_REF_SLUG}

Expand All @@ -82,7 +82,7 @@ test-cypress-2:
- curl --retry 10 --retry-delay 20 -v http:\/\/${DOCKER_SERVICE}-${CI_COMMIT_REF_SLUG}-${CI_JOB_ID}-web/
- cd bin/tests
- yarn install
- bash ./run_test.sh -p 1 -e $EXCLUDED_TEST_FILES --config baseUrl=http://${DOCKER_SERVICE}-${CI_COMMIT_REF_SLUG}-${CI_JOB_ID}-web/ --env $CYPRESS_ENV
- bash /tools/run-cypress-test.sh -f $TESTS_FOLDERS_2 -e $EXCLUDED_TEST_FILES --config baseUrl=http://${DOCKER_SERVICE}-${CI_COMMIT_REF_SLUG}-${CI_JOB_ID}-web/ --env $CYPRESS_ENV
after_script:
- /tools/clean-job.sh $PROJECT_NAME_TEST_2 docker-compose.test.yml wordpress ${DOCKER_STACK}-${DOCKER_SERVICE}_web:${CI_COMMIT_REF_SLUG}

Expand Down
1 change: 1 addition & 0 deletions bin/docker/images/woocommerce/setup-woocommerce.sh
Expand Up @@ -56,6 +56,7 @@ sleep 20
SHIPPING_ZONE=$(wp wc shipping_zone create --allow-root --name="FR" --user=admin-wordpress@hipay.com --porcelain)
wp wc --allow-root shipping_zone_method create $SHIPPING_ZONE --method_id="flat_rate" --user=admin-wordpress@hipay.com
wp wc --allow-root shop_coupon create --code=test --amount=12.25 --discount_type=percent --user=admin-wordpress@hipay.com
wp wc --allow-root customer create --email='d.denis@hipay.com' --user=1 --password='password123'

CONFIG=$(wp option --allow-root get hipay_enterprise --format=json)
CONFIG=${CONFIG/'"api_username_sandbox":""'/'"api_username_sandbox":"'$HIPAY_API_USER_TEST'"'}
Expand Down
3 changes: 2 additions & 1 deletion bin/tests/cypress/fixtures/customerFR.json
Expand Up @@ -6,5 +6,6 @@
"city": "Nantes",
"zipCode": "44000",
"country": "FR",
"phone": "0210236596"
"phone": "0210236596",
"password": "password123"
}
4 changes: 2 additions & 2 deletions bin/tests/cypress/fixtures/order.json
@@ -1,4 +1,4 @@
{
"lastOrderId": "213",
"lastCapturedOrderId": ""
"lastOrderId": "117",
"lastCapturedOrderId": "145"
}
Expand Up @@ -5,6 +5,9 @@ describe('Pay by Aura', function () {
before(function () {
cy.logToAdmin();
cy.goToPaymentsTab();
cy.goToAdminHipayConfig();
cy.activateAstropayMethods();
cy.goToPaymentsTab();
cy.activatePaymentMethods("aura");
cy.switchWooCurrency("BRL");
cy.adminLogOut();
Expand Down
Expand Up @@ -6,6 +6,9 @@ describe('Pay by Banamex', function () {

cy.logToAdmin();
cy.goToPaymentsTab();
cy.goToAdminHipayConfig();
cy.activateAstropayMethods();
cy.goToPaymentsTab();
cy.activatePaymentMethods("banamex");
cy.switchWooCurrency("MXN");
cy.adminLogOut();
Expand Down
Expand Up @@ -6,6 +6,9 @@ describe('Pay by Banco Do Brasil', function () {

cy.logToAdmin();
cy.goToPaymentsTab();
cy.goToAdminHipayConfig();
cy.activateAstropayMethods();
cy.goToPaymentsTab();
cy.activatePaymentMethods("banco_do_brasil");
cy.switchWooCurrency("BRL");
cy.adminLogOut();
Expand Down
Expand Up @@ -6,6 +6,9 @@ describe('Pay by BBVA Bancomer', function () {

cy.logToAdmin();
cy.goToPaymentsTab();
cy.goToAdminHipayConfig();
cy.activateAstropayMethods();
cy.goToPaymentsTab();
cy.activatePaymentMethods("bbva_bancomer");
cy.switchWooCurrency("MXN");
cy.adminLogOut();
Expand All @@ -31,7 +34,6 @@ describe('Pay by BBVA Bancomer', function () {

it('Pay by BBVA Bancomer', function () {

cy.waitOrderUpdate();
cy.get('[for="payment_method_hipayenterprise_bbva_bancomer"]').click({force: true});
cy.get('#bbva-bancomer-national_identification_number')
.type(bbvaBancomerJson.data.national_identification_number, {force: true})
Expand Down
Expand Up @@ -6,6 +6,9 @@ describe('Pay by Boleto Bancario', function () {

cy.logToAdmin();
cy.goToPaymentsTab();
cy.goToAdminHipayConfig();
cy.activateAstropayMethods();
cy.goToPaymentsTab();
cy.activatePaymentMethods("boleto_bancario");
cy.switchWooCurrency("BRL");
cy.adminLogOut();
Expand Down
Expand Up @@ -6,6 +6,9 @@ describe('Pay by Bradesco', function () {

cy.logToAdmin();
cy.goToPaymentsTab();
cy.goToAdminHipayConfig();
cy.activateAstropayMethods();
cy.goToPaymentsTab();
cy.activatePaymentMethods("bradesco");
cy.switchWooCurrency("BRL");
cy.adminLogOut();
Expand Down
Expand Up @@ -6,6 +6,9 @@ describe('Pay by Caïxa', function () {

cy.logToAdmin();
cy.goToPaymentsTab();
cy.goToAdminHipayConfig();
cy.activateAstropayMethods();
cy.goToPaymentsTab();
cy.activatePaymentMethods("caixa");
cy.switchWooCurrency("BRL");
cy.adminLogOut();
Expand Down
Expand Up @@ -6,6 +6,9 @@ describe('Pay by Itau', function () {

cy.logToAdmin();
cy.goToPaymentsTab();
cy.goToAdminHipayConfig();
cy.activateAstropayMethods();
cy.goToPaymentsTab();
cy.activatePaymentMethods("itau");
cy.switchWooCurrency("BRL");
cy.adminLogOut();
Expand Down
Expand Up @@ -6,6 +6,9 @@ describe('Pay by Oxxo', function () {

cy.logToAdmin();
cy.goToPaymentsTab();
cy.goToAdminHipayConfig();
cy.activateAstropayMethods();
cy.goToPaymentsTab();
cy.activatePaymentMethods("oxxo");
cy.switchWooCurrency("MXN");
cy.adminLogOut();
Expand Down
Expand Up @@ -6,6 +6,9 @@ describe('Pay by Santander Cash', function () {

cy.logToAdmin();
cy.goToPaymentsTab();
cy.goToAdminHipayConfig();
cy.activateAstropayMethods();
cy.goToPaymentsTab();
cy.activatePaymentMethods("santander_cash");
cy.switchWooCurrency("MXN");
cy.adminLogOut();
Expand Down
Expand Up @@ -6,6 +6,9 @@ describe('Pay by Santander HomeBanking', function () {

cy.logToAdmin();
cy.goToPaymentsTab();
cy.goToAdminHipayConfig();
cy.activateAstropayMethods();
cy.goToPaymentsTab();
cy.activatePaymentMethods("santander_home_banking");
cy.switchWooCurrency("BRL");
cy.adminLogOut();
Expand Down
104 changes: 104 additions & 0 deletions bin/tests/cypress/integration/007_ONE_CLICK/001-one-click.js
@@ -0,0 +1,104 @@
describe('Pay by credit card One click', function () {

it('Pay by : visa_ok', function () {

cy.logToAdmin();
cy.goToPaymentsTab();
cy.activatePaymentMethods("credit_card");
cy.goToAdminHipayConfig();

cy.get('#methods-tab').click();
cy.get('#operating_mode').select("hosted_fields");
cy.get('#card_token').check();

cy.resetCCConfigForm();

cy.get('.submit > .button-primary').click();

cy.adminLogOut();

cy.customerLogIn();
cy.goToFront();
cy.selectItemAndGoToCart();
cy.addProductQuantity(15);
cy.goToCheckout();
cy.fillBillingForm();

cy.get('[for="payment_method_hipayenterprise_credit_card"]').click({force: true});
cy.get('#hipay-field-cardHolder > iframe');
cy.wait(3000);

cy.fill_hostedfield_card('visa_ok');
cy.get("#wc-hipayenterprise_credit_card-new-payment-method").check();
cy.get('#place_order').click({force: true});
cy.checkOrderSuccess();
cy.saveLastOrderId();
});


it('Send authorization notification', function () {
cy.fixture('notification').as("notification");
cy.connectAndSelectAccountOnHipayBO();
cy.fixture('order').then((order) => {
cy.openTransactionOnHipayBO(order.lastOrderId + "-");
cy.openNotificationOnHipayBO(116).then(() => {
cy.sendNotification(this.notification.url, {data: this.data, hash: this.hash});
});
});
});

it('Check card in My account', function () {
cy.customerLogIn();
cy.get('.woocommerce-MyAccount-navigation-link--payment-methods').click();
cy.get(".woocommerce-MyAccount-paymentMethods > tbody > tr:last-child > td:nth-child(1)")
.contains("Visa ending in 411111******1111");

});

it('Pay by : one click', function () {

cy.logToAdmin();
cy.goToPaymentsTab();
cy.activatePaymentMethods("credit_card");
cy.goToAdminHipayConfig();

cy.get('#methods-tab').click();
cy.get('#operating_mode').select("hosted_fields");
cy.get('#card_token').check();

cy.resetCCConfigForm();

cy.get('.submit > .button-primary').click();

cy.adminLogOut();

cy.customerLogIn();
cy.goToFront();
cy.selectItemAndGoToCart();
cy.addProductQuantity(15);
cy.goToCheckout();
cy.fillBillingForm();

cy.get('[for="payment_method_hipayenterprise_credit_card"]').click({force: true});
cy.get('#hipay-field-cardHolder > iframe');
cy.wait(3000);

cy.get('#place_order').click({force: true});
cy.checkOrderSuccess();
cy.saveLastOrderId();
});

// it('Add card in My account', function () {
// cy.customerLogIn();
// cy.get('.woocommerce-MyAccount-navigation-link--payment-methods').click();
// cy.get('.woocommerce-MyAccount-content > a').click();
//
// cy.get('[for="payment_method_hipayenterprise_credit_card"]').click({force: true});
// cy.get('#hipay-field-cardHolder > iframe');
// cy.wait(3000);
// cy.fill_hostedfield_card('mastercard_ok');
// cy.get('#place_order').click();
// cy.get(".woocommerce-MyAccount-paymentMethods > tbody > tr:last-child > td:nth-child(1)")
// .contains("MasterCard ending in 539999******9999");
// });
});
5 changes: 5 additions & 0 deletions bin/tests/cypress/support/admin.js
Expand Up @@ -52,6 +52,11 @@ Cypress.Commands.add("switchWooCurrency", (currency) => {
/**
* Go to Hipay configuration
*/
Cypress.Commands.add("activateAstropayMethods", () => {
cy.get('#enableAstropay').check({force: true});
cy.get('button[name="save"]').click();
});

Cypress.Commands.add("goToAdminHipayConfig", () => {
cy.get('[data-gateway_id="hipayenterprise_credit_card"] > .name > .wc-payment-gateway-method-title').click({force: true});
});
Expand Down
9 changes: 9 additions & 0 deletions bin/tests/cypress/support/checkout.js
Expand Up @@ -225,3 +225,12 @@ Cypress.Commands.add("waitOrderUpdate", () => {
cy.route('POST', "/?wc-ajax=update_order_review").as("updateOrder");
cy.wait("@updateOrder");
});

Cypress.Commands.add("customerLogIn", () => {
cy.fixture('customerFR').then((customer) => {
cy.visit('/my-account/');
cy.get('#username').type(customer.email);
cy.get('#password').type(customer.password);
cy.get('[name="login"]').click();
});
});
88 changes: 0 additions & 88 deletions bin/tests/run_test.sh

This file was deleted.

0 comments on commit 2e1886b

Please sign in to comment.