JavaScript · Cypress
ERP with Cypress
A sortable, paginated inventory grid, purchase orders with dynamic line items and GST totals, and a two-role approval workflow with an audit trail.
App under test
🏭 CoreERP
- URL
- /apps/erp
- Buyer
- buyer / Erp@123
- Manager
- manager / Erp@123
- Tax
- GST 18%
Scenarios to automate
Work top to bottom — each one adds a new technique.
- 1
Role-based access
BeginnerAs buyer, open /apps/erp/approvals and assert access-denied; the manager sees the queue.
- 2
Grid sorting
IntermediateClick sort-qty twice and verify qty-* values are descending; aria-sort reflects the state.
- 3
Filters & pagination
IntermediateCombine inventory-search, warehouse-filter, low-stock-only and page-size; walk page-next.
- 4
Reorder shortcut
Intermediatereorder-<sku> opens a new PO with that item pre-filled on line 0.
- 5
Dynamic line items
AdvancedAdd 3 lines, remove the middle one, and check the remaining line-*-total and po-total.
- 6
PO validation
IntermediateSubmitting with no vendor, no lines, qty 0 or duplicate items shows po-errors and error-*.
- 7
Two-user workflow
AdvancedBuyer submits → logout → manager approves; po-status and po-timeline update.
- 8
Rejection with comment
Advancedreject-po requires a 10+ char reject-comment; it appears as po-comment in the timeline.
Sample Cypress suite
A working starting point that finds elements every way Cypress can — by role, label, text, id, name, CSS, XPath and data-testid — so you practice them all. Pick your language, switch to data-testid only to compare, or try your own in the Locator Playground.
Cypress runs inside the browser, so it only supports JavaScript and TypeScript — there is no Python, Java or C# version of Cypress. For those languages, see Selenium or Playwright.
// Uses the getByTestId custom command from the Cypress setup (cypress/support/commands.js).
// Locators in this suite: cy.contains ×6 · #id ×4 · [name] ×3 · getByTestId ×8
describe('CoreERP — procurement', () => {
it('raises and approves a purchase order', () => {
cy.visit('/apps/erp');
// Buyer raises the purchase order
cy.get('#erp-username').type('buyer');
cy.get('[name="erp-password"]').type('Erp@123');
cy.contains('button', 'Sign in').click();
cy.location('pathname').should('include', '/apps/erp/dashboard');
cy.getByTestId('nav-purchase-orders').click();
cy.getByTestId('new-po').click();
cy.get('#po-vendor').select('v2');
cy.getByTestId('po-delivery-14').click();
cy.getByTestId('add-line').click();
cy.get('[name="line-0-item"]').select('SKU-1004');
cy.get('#line-0-qty').type('25');
cy.getByTestId('line-0-total').should('contain', '8,400.00');
cy.getByTestId('po-total').should('contain', '9,912.00');
cy.contains('button', 'Submit for approval').click();
cy.location('pathname').should('include', '/apps/erp/po/');
cy.getByTestId('po-status').should('contain', 'Pending approval');
cy.contains('button', 'Log out').click();
// Manager approves it
cy.get('#erp-username').type('manager');
cy.get('[name="erp-password"]').type('Erp@123');
cy.contains('button', 'Sign in').click();
cy.location('pathname').should('include', '/apps/erp/dashboard');
cy.contains('a', 'Approvals').click();
cy.getByTestId('approval-review').eq(0).click();
cy.contains('button', 'Approve').click();
cy.getByTestId('po-status').should('contain', 'Approved');
});
});