Skip to content

Commit ba77cb9

Browse files
committed
Update test_methods.js
1 parent 969279f commit ba77cb9

1 file changed

Lines changed: 24 additions & 86 deletions

File tree

cypress/support/test_methods.js

Lines changed: 24 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -12,61 +12,55 @@ export var TestMethods = {
1212
RemoteVersionLogUrl: Cypress.env('REMOTE_LOG_URL'),
1313

1414
/** Construct some variables to be used bellow. */
15-
ShopName: 'zencart',
15+
ShopName: 'oscommerce',
1616
PaylikeName: 'paylike',
17-
PaymentMethodsAdminUrl: '/index.php?cmd=modules&set=payment',
18-
OrdersPageAdminUrl: '/index.php?cmd=orders',
17+
PaymentMethodsAdminUrl: '/modules.php?set=payment',
1918

2019
/**
2120
* Login to admin backend account
2221
*/
2322
loginIntoAdminBackend() {
24-
cy.loginIntoAccount('input[name=admin_name]', 'input[name=admin_pass]', 'admin');
23+
cy.loginIntoAccount('input[name=username]', 'input[name=password]', 'admin');
2524
},
2625
/**
2726
* Login to client|user frontend account
2827
*/
2928
loginIntoClientAccount() {
30-
cy.get('a[href*=login]').first().click();
31-
cy.loginIntoAccount('#login-email-address', '#login-password', 'client');
29+
cy.get('a[id=tdb3]').click();
30+
cy.loginIntoAccount('input[name=email_address]', 'input[name=password]', 'client');
3231
},
3332

3433
/**
35-
* Modify Paylike settings
34+
* Modify Paylike capture mode
35+
*
3636
* @param {String} captureMode
3737
*/
3838
changePaylikeCaptureMode(captureMode) {
3939
/** Go to Paylike payment method. */
4040
cy.goToPage(this.PaymentMethodsAdminUrl);
4141

4242
/** Select Paylike. */
43-
cy.get('.dataTableContent').contains(this.PaylikeName).click();
43+
cy.get('.dataTableContent').contains(this.PaylikeName, {matchCase: false}).click();
4444

45-
cy.get('#editButton').click();
45+
cy.get('#tdb2').click();
4646

4747
/** Select capture mode. */
4848
cy.get(`input[value=${captureMode}]`).click()
4949

50-
cy.get('#saveButton').click();
50+
cy.get('#tdb2').click();
5151
},
5252

5353
/**
54-
* Make payment with specified currency and process order
54+
* Make payment with specified currency
55+
* -- order must be process from app.paylike.io panel
5556
*
5657
* @param {String} currency
57-
* @param {String} paylikeAction
58-
* @param {Boolean} partialAmount
5958
*/
60-
payWithSelectedCurrency(currency, paylikeAction, partialAmount = false) {
59+
payWithSelectedCurrency(currency) {
6160
/** Make an instant payment. */
6261
it(`makes a Paylike payment with "${currency}"`, () => {
6362
this.makePaymentFromFrontend(currency);
6463
});
65-
66-
/** Process last order from admin panel. */
67-
it(`process (${paylikeAction}) an order from admin panel`, () => {
68-
this.processOrderFromAdmin(paylikeAction, partialAmount);
69-
});
7064
},
7165

7266
/**
@@ -82,34 +76,31 @@ export var TestMethods = {
8276

8377
cy.wait(500);
8478

85-
/** Select random product. */
86-
var randomInt = PaylikeTestHelper.getRandomInt(/*max*/ 6);
87-
cy.get('.centerBoxContentsNew a img').eq(randomInt).click();
88-
89-
cy.get('.button_in_cart').click();
79+
/** Select random product (products are randomize by default). */
80+
cy.get('td a img').first().click();
9081

91-
cy.wait(200);
82+
cy.get('button#tdb5').click();
9283

9384
/** Go to checkout. */
94-
cy.get('.button_checkout').click();
85+
cy.get('.ui-button-icon-primary.ui-icon.ui-icon-triangle-1-e').first().click();
9586

9687
/** Continue checkout. */
97-
cy.get('.button_continue_checkout').click();
88+
cy.get('button#tdb6').click();
9889

9990
/** Choose Paylike. */
100-
cy.get(`input[id*=${this.PaylikeName}]`).click();
91+
cy.get(`input[value=${this.PaylikeName}]`).click();
10192

10293
/** Continue checkout. */
103-
cy.get('#paymentSubmit').click();
94+
cy.get('button#tdb6').click();
10495

10596
/** Get total amount. */
106-
cy.get('#ottotal .totalBox').then($grandTotal => {
97+
cy.get(':nth-child(2) > strong').then($grandTotal => {
10798
var expectedAmount = PaylikeTestHelper.filterAndGetAmountInMinor($grandTotal, currency);
10899
cy.wrap(expectedAmount).as('expectedAmount');
109100
});
110101

111102
/** Show paylike popup. */
112-
cy.get('#btn_submit').click();
103+
cy.get('#payLikeCheckout').click();
113104

114105
/** Get paylike amount. */
115106
cy.get('.paylike .payment .amount').then($paylikeAmount => {
@@ -126,67 +117,14 @@ export var TestMethods = {
126117

127118
cy.wait(500);
128119

129-
cy.get('h1#checkoutSuccessHeading').should('be.visible');
130-
},
131-
132-
/**
133-
* Process last order from admin panel
134-
* @param {String} paylikeAction
135-
* @param {Boolean} partialAmount
136-
*/
137-
processOrderFromAdmin(paylikeAction, partialAmount = false) {
138-
/** Go to admin orders page. */
139-
cy.goToPage(this.OrdersPageAdminUrl);
140-
141-
/** Click on first (latest in time) order from orders table. */
142-
cy.get('#defaultSelected').click();
143-
144-
/**
145-
* Take specific action on order
146-
*/
147-
this.paylikeActionOnOrderAmount(paylikeAction, partialAmount);
148-
},
149-
150-
/**
151-
* Capture an order amount
152-
* @param {String} paylikeAction
153-
* @param {Boolean} partialAmount
154-
*/
155-
paylikeActionOnOrderAmount(paylikeAction, partialAmount = false) {
156-
/** Show payment info. */
157-
cy.get('#payinfo').click();
158-
159-
switch (paylikeAction) {
160-
case 'capture':
161-
cy.get('#capture_click').click();
162-
break;
163-
case 'refund':
164-
cy.get('#refund_click').click();
165-
if (partialAmount) {
166-
/**
167-
* Put 8 major units to be refunded.
168-
* Premise: any product must have price >= 8.
169-
*/
170-
cy.get('input[name=refamt]').clear().type(8);
171-
cy.get('input[name=partialrefund]').click();
172-
} else {
173-
cy.get('input[name=fullrefund]').click();
174-
}
175-
break;
176-
case 'void':
177-
cy.get('#void_click').click();
178-
break;
179-
}
180-
181-
/** Check if success message. */
182-
cy.get('.alert-success').should('be.visible');
120+
cy.get('h1').should('contain', 'Your Order Has Been Processed!');
183121
},
184122

185123
/**
186124
* Change shop currency in frontend
187125
*/
188126
changeShopCurrency(currency) {
189-
cy.get('#select-currency').select(currency);
127+
cy.get('select[name=currency]').select(currency);
190128
},
191129

192130
/**

0 commit comments

Comments
 (0)