Skip to content

Commit 3978474

Browse files
committed
made specific specs for Phoenix
1 parent cae62b2 commit 3978474

6 files changed

Lines changed: 54 additions & 13 deletions

File tree

cypress/integration/phoenix_full_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
'use strict';
44

5-
import { TestMethods } from '../support/test_methods.js';
5+
import { TestMethods } from '../support/phoenix_test_methods.js';
66

77
describe('paylike plugin full test', () => {
88
/**
99
* Login into admin and frontend to store cookies.
1010
*/
1111
before(() => {
12-
cy.goToPage(TestMethods.StoreUrl);
12+
cy.phoenixGoToPage(TestMethods.StoreUrl);
1313
TestMethods.loginIntoClientAccount();
14-
cy.goToPage(Cypress.env('ENV_ADMIN_URL'));
14+
cy.phoenixGoToPage(Cypress.env('ENV_PHOENIX_ADMIN_URL'));
1515
TestMethods.loginIntoAdminBackend();
1616
});
1717

cypress/integration/phoenix_log_version.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
'use strict';
44

5-
import { TestMethods } from '../support/test_methods.js';
5+
import { TestMethods } from '../support/phoenix_test_methods.js';
66

77
describe('paylike plugin version log remotely', () => {
88
/**
99
* Go to backend site admin
1010
*/
1111
before(() => {
12-
cy.goToPage(Cypress.env('ENV_ADMIN_URL'));
12+
cy.goToPage(Cypress.env('ENV_PHOENIX_ADMIN_URL'));
1313
TestMethods.loginIntoAdminBackend();
1414
});
1515

cypress/integration/phoenix_quick_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
'use strict';
44

5-
import { TestMethods } from '../support/test_methods.js';
5+
import { TestMethods } from '../support/phoenix_test_methods.js';
66

77
describe('paylike plugin quick test', () => {
88
/**
99
* Login into admin and frontend to store cookies.
1010
*/
1111
before(() => {
12-
cy.goToPage(TestMethods.StoreUrl);
12+
cy.phoenixGoToPage(TestMethods.StoreUrl);
1313
TestMethods.loginIntoClientAccount();
14-
cy.goToPage(Cypress.env('ENV_ADMIN_URL'));
14+
cy.phoenixGoToPage(Cypress.env('ENV_PHOENIX_ADMIN_URL'));
1515
TestMethods.loginIntoAdminBackend();
1616
});
1717

cypress/support/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +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:
2021
// 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+
});

cypress/support/phoenix_test_methods.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { PaylikeTestHelper } from './test_helper.js';
77
export var TestMethods = {
88

99
/** Admin & frontend user credentials. */
10-
StoreUrl: (Cypress.env('ENV_ADMIN_URL').match(/^(?:http(?:s?):\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n?]+)/im))[0],
11-
AdminUrl: Cypress.env('ENV_ADMIN_URL'),
10+
StoreUrl: (Cypress.env('ENV_PHOENIX_ADMIN_URL').match(/^(?:http(?:s?):\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n?]+)/im))[0],
11+
AdminUrl: Cypress.env('ENV_PHOENIX_ADMIN_URL'),
1212
RemoteVersionLogUrl: Cypress.env('REMOTE_LOG_URL'),
1313

1414
/** Construct some variables to be used bellow. */
@@ -38,7 +38,7 @@ export var TestMethods = {
3838
*/
3939
changePaylikeCaptureMode(captureMode) {
4040
/** Go to Paylike payment method. */
41-
cy.goToPage(this.PaymentMethodsAdminUrl);
41+
cy.phoenixGoToPage(this.PaymentMethodsAdminUrl);
4242

4343
/** Select Paylike. */
4444
cy.get('.dataTableContent').contains(this.PaylikeName, {matchCase: false}).click();
@@ -70,7 +70,7 @@ export var TestMethods = {
7070
*/
7171
makePaymentFromFrontend(currency) {
7272
/** Go to store frontend. */
73-
cy.goToPage(this.StoreUrl);
73+
cy.phoenixGoToPage(this.StoreUrl);
7474

7575
/** Change currency. */
7676
this.changeShopCurrency(currency);
@@ -133,7 +133,7 @@ export var TestMethods = {
133133
*/
134134
logVersions() {
135135
/** Go to system information. */
136-
cy.goToPage(this.SystemInfoAdminUrl);
136+
cy.phoenixGoToPage(this.SystemInfoAdminUrl);
137137

138138
cy.wait(1000);
139139

0 commit comments

Comments
 (0)