Skip to content

Commit 7d05656

Browse files
authored
Merge pull request #10 from genuineq/cypress-tests
PhoenixCart Cypress tests
2 parents e41506a + 6a024a1 commit 7d05656

File tree

10 files changed

+341
-37
lines changed

10 files changed

+341
-37
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ workflows:
5757
filters:
5858
branches:
5959
only:
60-
- cypress-tests
60+
- master
6161
- cypress/run:
6262
name: Run_phoenix_FULL_tests
6363
requires:
@@ -68,7 +68,7 @@ workflows:
6868
filters:
6969
branches:
7070
only:
71-
- cypress-tests
71+
- master
7272
# the following must run after all test passed
7373
# to show latest supported version in repository readme.md file
7474
- cypress/run:
@@ -81,4 +81,4 @@ workflows:
8181
filters:
8282
branches:
8383
only:
84-
- cypress-tests
84+
- master

README_Phoenix.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ available by a user.
55

66
Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0
77

8-
## Supported osCommerce versions
9-
10-
*The plugin has been tested with osCommerce CE Phoenix up to v1.0.8.5
8+
## Supported PhoenixCart versions [![Last succesfull test](https://log.derikon.ro/api/v1/log/read?tag=phoenixcart&view=svg&label=PhoenixCart&key=ecommerce&background=FC7F03)](https://log.derikon.ro/api/v1/log/read?tag=phoenixcart&view=html)
119

1210
## Installation
1311

Testing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ As you can see the plugin is bundled with Cypress testing on this repository. Yo
2727
"ENV_HTTP_USER": "", // if you have HTTP auth when accessing website
2828
"ENV_HTTP_PASS": "",
2929
"ENV_ADMIN_URL": "", // like http(s)://baseUrl/administrator
30+
"ENV_PHOENIX_ADMIN_URL": "",
3031
"ENV_CLIENT_USER": "", // frontend user
3132
"ENV_CLIENT_PASS": "",
3233
"ENV_ADMIN_USER": "", // admin user
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/// <reference types="cypress" />
2+
3+
'use strict';
4+
5+
import { TestMethods } from '../support/phoenix_test_methods.js';
6+
7+
describe('paylike plugin full test', () => {
8+
/**
9+
* Login into admin and frontend to store cookies.
10+
*/
11+
before(() => {
12+
cy.phoenixGoToPage(TestMethods.StoreUrl + '/login.php');
13+
TestMethods.loginIntoClientAccount();
14+
cy.phoenixGoToPage(Cypress.env('ENV_PHOENIX_ADMIN_URL'));
15+
TestMethods.loginIntoAdminBackend();
16+
});
17+
18+
/**
19+
* Run this on every test case bellow
20+
* - preserve cookies between tests
21+
*/
22+
beforeEach(() => {
23+
Cypress.Cookies.defaults({
24+
preserve: (cookie) => {
25+
return true;
26+
}
27+
});
28+
});
29+
30+
let captureModes = ['Instant', 'Delayed'];
31+
let currenciesToTest = Cypress.env('ENV_CURRENCIES_TO_TEST');
32+
33+
context(`make payments in "${captureModes[0]}" mode`, () => {
34+
/** Modify Paylike settings. */
35+
it(`change Paylike capture mode to "${captureModes[0]}"`, () => {
36+
TestMethods.changePaylikeCaptureMode(captureModes[0]);
37+
});
38+
39+
/** Make Instant payments */
40+
for (var currency of currenciesToTest) {
41+
TestMethods.payWithSelectedCurrency(currency);
42+
}
43+
});
44+
45+
context(`make payments in "${captureModes[1]}" mode`, () => {
46+
/** Modify Paylike settings. */
47+
it(`change Paylike capture mode to "${captureModes[1]}"`, () => {
48+
TestMethods.changePaylikeCaptureMode(captureModes[1]);
49+
});
50+
51+
for (var currency of currenciesToTest) {
52+
/**
53+
* HARDCODED currency
54+
*/
55+
if ('USD' == currency || 'RON' == currency) {
56+
TestMethods.payWithSelectedCurrency(currency);
57+
}
58+
}
59+
});
60+
}); // describe
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// <reference types="cypress" />
2+
3+
'use strict';
4+
5+
import { TestMethods } from '../support/phoenix_test_methods.js';
6+
7+
describe('paylike plugin version log remotely', () => {
8+
/**
9+
* Go to backend site admin
10+
*/
11+
before(() => {
12+
cy.goToPage(Cypress.env('ENV_PHOENIX_ADMIN_URL'));
13+
TestMethods.loginIntoAdminBackend();
14+
});
15+
16+
/** Send log after full test finished. */
17+
it('log shop & paylike versions remotely', () => {
18+
TestMethods.logVersions();
19+
});
20+
}); // describe
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/// <reference types="cypress" />
2+
3+
'use strict';
4+
5+
import { TestMethods } from '../support/phoenix_test_methods.js';
6+
7+
describe('paylike plugin quick test', () => {
8+
/**
9+
* Login into admin and frontend to store cookies.
10+
*/
11+
before(() => {
12+
cy.phoenixGoToPage(TestMethods.StoreUrl + '/login.php');
13+
TestMethods.loginIntoClientAccount();
14+
cy.phoenixGoToPage(Cypress.env('ENV_PHOENIX_ADMIN_URL'));
15+
TestMethods.loginIntoAdminBackend();
16+
});
17+
18+
/**
19+
* Run this on every test case bellow
20+
* - preserve cookies between tests
21+
*/
22+
beforeEach(() => {
23+
Cypress.Cookies.defaults({
24+
preserve: (cookie) => {
25+
return true;
26+
}
27+
});
28+
});
29+
30+
let currency = Cypress.env('ENV_CURRENCY_TO_CHANGE_WITH');
31+
let captureMode = 'Delayed';
32+
33+
/**
34+
* Modify Paylike capture mode
35+
*/
36+
it('modify Paylike settings for capture mode', () => {
37+
TestMethods.changePaylikeCaptureMode(captureMode);
38+
});
39+
40+
/** Pay and process order. */
41+
/** Capture */
42+
TestMethods.payWithSelectedCurrency(currency);
43+
44+
}); // describe

cypress/support/index.js

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,7 @@
1515

1616
// Import commands.js using ES2015 syntax:
1717
import './commands'
18+
import './phoenix_commands'
1819

1920
// Alternatively you can use CommonJS syntax:
20-
// require('./commands')
21-
22-
23-
/**
24-
* ****************************************************************************
25-
* *********************** custom code for Zencart ****************************
26-
* ****************************************************************************
27-
*
28-
* We need this because a third-party JS code has not been loaded correctly,
29-
* so errors are blocking the testing process.
30-
*
31-
* We want to get over some errors, not all of them.
32-
*/
33-
Cypress.on('uncaught:exception', (err, runnable) => {
34-
/**
35-
* we expect a 3rd party library error with message 'foo' is not defined'
36-
* and don't want to fail the test so we return false
37-
*
38-
*/
39-
if (err.message.includes('$ is not defined')) {
40-
return false
41-
}
42-
/** if other libraries don't load, we skip these errors. */
43-
if (err.message.includes('Cannot read properties of undefined')) {
44-
return false
45-
}
46-
/**
47-
* we still want to ensure there are no other unexpected
48-
* errors, so we let them fail the test
49-
*/
50-
});
21+
// require('./commands')
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// ***********************************************
2+
// For more comprehensive examples of custom
3+
// commands please read more here:
4+
// https://on.cypress.io/custom-commands
5+
// ***********************************************
6+
// -- This is a parent command --
7+
// Cypress.Commands.add('login', (email, password) => { ... })
8+
// -- This is a child command --
9+
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
10+
// -- This is a dual command --
11+
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
12+
// -- This will overwrite an existing command --
13+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
14+
15+
16+
/**
17+
* Parent commands
18+
*/
19+
20+
/**
21+
* Go to specified Url
22+
* Enhanced with auth for HTTP protected websites
23+
*/
24+
Cypress.Commands.add('phoenixGoToPage', (pageUrl) => {
25+
/** Check if pageUrl is NOT a ful url, then add admin url to it. */
26+
if (! pageUrl.match(/^http/g)) {
27+
pageUrl = Cypress.env('ENV_PHOENIX_ADMIN_URL') + pageUrl;
28+
}
29+
30+
if (Cypress.env('ENV_HTTP_AUTH_ENABLED')) {
31+
cy.visit(pageUrl, {
32+
auth: {
33+
username: Cypress.env('ENV_HTTP_USER'),
34+
password: Cypress.env('ENV_HTTP_PASS'),
35+
},
36+
});
37+
} else {
38+
cy.visit(pageUrl);
39+
}
40+
});

0 commit comments

Comments
 (0)