Skip to content

Commit

Permalink
Fix tests; navigate through admin pages based on URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
makotom committed Jun 11, 2024
1 parent f41ecb2 commit 8e276f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions tests/cypress/e2e/admin.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ describe('KOMOJU for WooCommerce: Admin', () => {

it('lets me add and remove specialized payment gateways', () => {
cy.setupKomoju(['konbini', 'credit_card']);
cy.contains('Payments').click();
cy.clickPaymentTab();

cy.get('.form-table').should('include.text', 'Komoju - Konbini');
cy.get('.form-table').should('include.text', 'Komoju - Credit Card');

cy.setupKomoju(['paypay', 'linepay']);
cy.contains('Payments').click();
cy.clickPaymentTab();

cy.get('.form-table').should('not.include.text', 'Komoju - Konbini');
cy.get('.form-table').should('not.include.text', 'Komoju - Credit Card');
Expand Down
8 changes: 4 additions & 4 deletions tests/cypress/e2e/checkout.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('KOMOJU for WooCommerce: Checkout', () => {

it('lets me make a payment using the specialized konbini gateway', () => {
cy.setupKomoju(['konbini', 'credit_card']);
cy.contains('Payments').click();
cy.clickPaymentTab();
cy.enablePaymentGateway('komoju_konbini');
cy.goToStore();
cy.addItemAndProceedToCheckout();
Expand Down Expand Up @@ -38,7 +38,7 @@ describe('KOMOJU for WooCommerce: Checkout', () => {

it('lets me make a payment using the specialized credit card gateway', () => {
cy.setupKomoju(['credit_card']);
cy.contains('Payments').click();
cy.clickPaymentTab();
cy.enablePaymentGateway('komoju_credit_card');
cy.contains('Save changes').click();
cy.goToStore();
Expand All @@ -62,7 +62,7 @@ describe('KOMOJU for WooCommerce: Checkout', () => {

it('lets me use the specialized WebMoney gateway, despite it being unsupported by Fields', () => {
cy.setupKomoju(['credit_card', 'konbini', 'web_money']);
cy.contains('Payments').click();
cy.clickPaymentTab();
cy.enablePaymentGateway('komoju_web_money');
cy.contains('Save changes').click();
cy.goToStore();
Expand All @@ -83,7 +83,7 @@ describe('KOMOJU for WooCommerce: Checkout', () => {

it('lets me turn checkout icons on and off', () => {
cy.setupKomoju(['konbini', 'credit_card']);
cy.contains('Payments').click();
cy.clickPaymentTab();
cy.enablePaymentGateway('komoju_credit_card');

cy.get('[data-gateway_id="komoju_credit_card"] a.button')
Expand Down
6 changes: 5 additions & 1 deletion tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,8 @@ Cypress.Commands.add('addItemAndProceedToCheckout', () => {
cy.wait(100);
cy.contains('Go to checkout').click();
cy.wait(100);
});
});

Cypress.Commands.add('clickPaymentTab', () => {
cy.visit('/wp-admin/admin.php?page=wc-settings&tab=checkout');
});

0 comments on commit 8e276f7

Please sign in to comment.