Skip to content

Commit

Permalink
MOL-439/MOL-527: write test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
tdang1-shopmacher committed Oct 10, 2024
1 parent 96d174a commit ee27c45
Show file tree
Hide file tree
Showing 8 changed files with 450 additions and 28 deletions.
1 change: 1 addition & 0 deletions application/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default defineConfig({
LOGIN_PASSWORD: process.env.CYPRESS_LOGIN_PASSWORD,
PROJECT_KEY: process.env.CYPRESS_PROJECT_KEY,
PACKAGE_NAME: process.env.CYPRESS_PACKAGE_NAME,
LOCALE: process.env.CYPRESS_LOCALE || 'en-GB',
},
};
},
Expand Down
3 changes: 2 additions & 1 deletion application/cypress/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ CYPRESS_LOGIN_USER=<your-user>
CYPRESS_LOGIN_PASSWORD=<your-password>
CYPRESS_PROJECT_KEY=<your-project-key>
CYPRESS_PACKAGE_NAME="application"
CYPRESS_BASE_URL="https://mc.europe-west1.gcp.commercetools.com/"
CYPRESS_BASE_URL="https://mc.europe-west1.gcp.commercetools.com/"
CYPRESS_LOCALE="en-GB"
60 changes: 60 additions & 0 deletions application/cypress/e2e/method-details.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/// <reference types="cypress" />
/// <reference types="@testing-library/cypress" />
/// <reference types="@commercetools-frontend/cypress" />

import {
entryPointUriPath,
APPLICATION_BASE_ROUTE,
} from '../support/constants';
beforeEach(() => {
cy.loginToMerchantCenter({
entryPointUriPath,
initialRoute: APPLICATION_BASE_ROUTE,
});

cy.fixture('forward-to').then((response) => {
cy.intercept('GET', '/proxy/forward-to', {
statusCode: 200,
body: response,
});
});
});

describe('Test welcome.cy.ts', () => {
it('should render method details page', () => {
const LOCALE = Cypress.env('LOCALE');
const paymentMethods = [
'PayPal',
'iDEAL Pay in 3 instalments, 0% interest',
'iDEAL',
'Bancontact',
'Blik',
];

cy.findByText(paymentMethods[0]).click();
cy.url().should('contain', 'general');

cy.findByTestId('status-select').should('exist');

cy.findByTestId(`name-input-${LOCALE}`).should('exist');
cy.findByTestId(`description-input-${LOCALE}`).should('exist');
cy.findByTestId(`display-order-input`).should('exist');
});

it('should update display order successfully', () => {
const paymentMethodIds = ['paypal', 'ideal', 'bancontact'];

cy.findByTestId(`display-order-column-${paymentMethodIds[0]}`).click();
cy.url().should('contain', 'general');

cy.findByTestId(`display-order-input`).should('exist');
cy.findByTestId(`display-order-input`).clear();
cy.findByTestId(`display-order-input`).type('20');
cy.findByTestId(`save-button`).click();
cy.findByLabelText('Go back').click();
cy.findByTestId(`display-order-column-${paymentMethodIds[0]}`).should(
'have.text',
20
);
});
});
Loading

0 comments on commit ee27c45

Please sign in to comment.