Cypress tests

From shopsys/shopsys · View interactive version

Cypress tests is an AI agent skill from the GitHub repository shopsys/shopsys. Write, fix, and review Cypress acceptance tests for Shopsys storefront. Use when working with Cypress test files (.cy.ts), adding test IDs (TIDs), or debugging test failures. Enforces project conventions: TID-based selectors, proper snapshot setup, and support file patterns.

How to use this skill

Skill file

Cypress Test Writing for Shopsys Storefront

You are an expert Cypress test writer for the Shopsys Platform storefront. Follow these conventions when writing, reviewing, or fixing tests.

Choose coverage before writing a spec

Apply .agents/skills/test-writing/SKILL.md and the scenario ownership rules reached

through .agents/skills/storefront-tests/SKILL.md before adding or removing coverage.

Those skills own the cross-layer decision; this skill owns Cypress implementation.

Name the real integration/browser risk and reuse an existing flow when it covers it.

A screenshot needs its own visual purpose; important outcomes also need explicit assertions.

Historical specs and the examples below are not permission to bypass these rules:

Project Structure

project-base/storefront/cypress/
  tids.ts                           # TID enum — central registry of all data-tid values
  cypress.config.ts                 # Cypress configuration
  cypress.d.ts                      # Custom command type declarations
  fixtures/demodata.ts              # Static test data (users, products, categories, URLs)
  fixtures/translationKeys.ts       # Translation key constants
  support/index.ts                  # Custom commands, helpers, SNAPSHOT_GROUP enum
  support/api.ts                    # GraphQL API commands (login, addToCart, createOrder)
  support/navigation.ts             # Entity navigation helpers (visitEntityByUuid)
  support/translations.ts           # Translation loading and lookup
  e2e/
    featureName/
      featureName.cy.ts             # Test file
      featureNameSupport.ts          # Support helpers for this feature

Existing Test Categories

| Directory | Tests | Support File |

| -------------------- | ---------------------------------------------------------------------------- | ----------------------------- |

| authentication/ | login, registration | authenticationSupport.ts |

| b2bComplaints/ | complaints | complaintsSupport.ts |

| b2bUser/ | accountantViewOnly, editProfileB2b, orderWithdrawal | b2bSupport.ts |

| cart/ | cartInHeader, cartLogin, cartPage, productAddToCart | cartSupport.ts |

| comparison/ | productComparison | comparisonSupport.ts |

| customerUsers/ | customerUsers | customerUsersSupport.ts |

| deliveryOptions/ | deliveryOptionsPopup | deliveryOptionsSupport.ts |

| filterAndSort/ | categoryDetailFilterAndSort, parameterFilter | — |

| freeShipping/ | freeShipping | freeShippingSupport.ts |

| giftVouchers/ | giftVouchers | giftVouchersSupport.ts |

| giftWithProduct/ | giftWithProduct | giftWithProductSupport.ts |

| graphql/ | graphQLErrorHandling | — |

| limitedUser/ | limitedUser | limitedUserSupport.ts |

| matrix/ | matrixTest | — |

| order/ | contactInformation, createOrder, createOrderWithDeliveryAddress, orderRepeat | orderSupport.ts |

| productLists/ | comparisonRaceCondition, wishlistRaceCondition | — |

| seoCategory/ | seoCategory | — |

| ssr/ | serverSideRendering | — |

| stores/ | stores | storesSupport.ts |

| transportAndPayment/ | lastOrderTransportAndPayment, paymentSelect, transportSelect | transportAndPaymentSupport.ts |

| visits/ | blogArticle, fixedHeader, repeatedVisits, simpleVisitsWithScreenshots | visitsSupport.ts |

| watchdog/ | watchdog | — |

Running Tests

# Manual GUI regression mode (auto-reloads .cy.ts files)
make open-acceptance-tests-regression

# Headless specific test
make run-specific-test-regression SPEC=e2e/path/to/test.cy.ts

# All regression tests headless
make run-acceptance-tests-regression

# Specific group
make selected-acceptance-tests-regression  # Interactive group selection

# Functional-only run (also supported by selected, specific and GUI regression targets)
make run-acceptance-tests-regression SKIP_SNAPSHOTS=1
make run-specific-test-regression SPEC=e2e/cart/cartLogin.cy.ts SKIP_SNAPSHOTS=1

Use make help-tests for the primary commands and advanced reference-generation modes.

All local acceptance commands build the Cypress image before changing the environment,

then prepare test data and recreate the test storefront. A shared exit/signal handler

attempts every cleanup step after setup/test failure or interruption and preserves failure.

prepare-data-for-acceptance-tests, cypress-prepare and cypress-cleanup also work

as explicit targets; manual setup requires explicit cleanup.

These are commands for the user, not agent execution. The base variants generate

references rather than validating them; keep monorepo reference generation on CI.

SKIP_SNAPSHOTS defaults to 0. Both Makefiles pass it explicitly to the Cypress

container; 1 enables the existing skipSnapshots helper shortcut. It skips visual

capture/comparison and the helper's screenshot-only preparation, not the scenario's

functional assertions. Automatic screenshots on test failure remain enabled. Invalid

values and skipping snapshots in base mode are rejected. A functional-only green

run is not visual approval. The Makefile returns a failure after cleanup when Cypress

fails (including interactive selection and smoke). GitHub CI explicitly pins

SKIP_SNAPSHOTS=0 for regression and regeneration. The project GitLab template defaults

to 0 and forwards an optional pipeline variable only to regression; its manual

regeneration job always uses 0. The shared container entrypoint validates modes

before dependency installation; a typo must never fall back to reference generation.

Targeted non-browser coverage lives in vitest/cypress/snapshotMode.test.ts and

vitest/cypress/entrypoint.test.ts; the latter uses a stub npm command, not Cypress.

Reference site for inspecting page structure: https://19-0.odin.shopsys.cloud/

CI reference regeneration

CRITICAL RULE: Search Existing Interaction Patterns First

Before writing or changing a Cypress interaction, search the whole Cypress codebase for the same component,

TID, helper, and interaction type. Trace the complete user flow — setup, opening, input, submission, closing,

navigation, and assertions — rather than copying only its primary action.

commands before introducing trigger() or custom event simulation.

popovers versus drawers, portals, mounted versus merely hidden content, disabled/loading states, debounce,

and animations before choosing assertions.

selection again. After clearing payment, assert that every option label is visible inside the payment

section; mounted enabled radios alone do not prove that the animated list has expanded for a screenshot.

Use cy.getByTID()

Locate elements with cy.getByTID(), or scope from a TID with .find(); form-library IDs are the one exception (see below). Raw data-tid, text, title or aria-label selectors drift with markup and translations.

How getByTID works

// Single TID → [data-tid=value]
cy.getByTID([TIDs.store_list]);

// TID with suffix → [data-tid=prefix_suffix]
cy.getByTID([[TIDs.blocks_product_list_listeditem_, '9177759']]);

// Nested (descendant) → [data-tid=parent] [data-tid=child]
cy.getByTID([[TIDs.blocks_product_list_listeditem_, catnum], TIDs.product_compare_button]);

Important: getByTID uses EXACT match (=), NOT starts-with (^=). You cannot use it to match all items with a prefix.

NEVER use these anti-patterns:

// NEVER: Translation-based finding
t('Store detail').then((translated) => {
    cy.contains(translated).click();
});

// NEVER: Manual data-tid selectors
cy.get('[data-tid="blocks_product_addtocart"]');
cy.get(`[data-tid^="${TIDs.blocks_product_list_listeditem_}"]`);

// NEVER: Title/aria-label selectors for clickable elements
cy.get('[title="Add to comparison"]');
cy.get(`button[aria-label="${translations.filter.clearAll}"]`);

// NEVER: Raw h1 when page_title TID exists
cy.get('h1')
    .should('contain', 'text')

    // NEVER: Text-based button matching in popups
    .find('button')
    .contains(/yes|remove/i)
    .click();

ALWAYS use these patterns:

// Direct TID
cy.getByTID([TIDs.page_title]).should('contain.text', linkText);
cy.getByTID([TIDs.popup_confirm_button]).click();

// TID + find for native controls; force only for the intentionally hidden custom checkbox input
cy.getByTID([TIDs.filter_panel]).find('input[type="checkbox"]').first().check({ force: true });
cy.getByTID([TIDs.filter_price_input_min]).find('input').clear().type('200').blur();

// Expandable items (collapsed by default)
cy.getByTID([TIDs.store_list]).find('[aria-expanded="false"]').first().click();

// Form fields by ID (acceptable — form libraries generate IDs)
cy.get('#customer-change-profile-form-street').should('not.be.disabled');

// Reset a filter applied by this scenario; missing required controls must fail
cy.getByTID([TIDs.selected_filters]).should('be.visible');
cy.getByTID([TIDs.clear_all_filters_button]).filter(':visible').first().click();
cy.getByTID([TIDs.selected_filters]).should('not.exist');

Adding New TIDs

Step 1: Register in tids.ts

// project-base/storefront/cypress/tids.ts
export enum TIDs {
    my_new_element = 'my_new_element',
}

Step 2: Add to React component

// Regular HTML element:
<div data-tid={TIDs.my_new_element}>

// Button component (uses `tid` prop, NOT `data-tid`):
<Button tid={TIDs.my_new_element}>

// LinkButton component:
<LinkButton tid={TIDs.my_new_element}>

Multiple items with the same TID is OK (e.g., product_compare_button on every product card). Use .first() or scope with parent TID.

TID Reference

All available TIDs are defined in project-base/storefront/cypress/tids.ts. Read this file to find existing TIDs before adding new ones. TIDs ending with _ are prefixes used with a suffix (e.g., blocks_product_list_listeditem_ + catnum).

Test File Template

import { staticData } from 'fixtures/demodata';
import {
    getSnapshotIndexingFunction,
    initializePersistStoreInLocalStorageToDefaultValues,
    SNAPSHOT_GROUP,
    takeSnapshotAndCompare,
} from 'support';
import { TIDs } from 'tids';

const SUBGROUP_INDEX = 0; // unique per test file within the SNAPSHOT_GROUP
const getSnapshotFullIndexAsString = getSnapshotIndexingFunction(SNAPSHOT_GROUP.MY_GROUP, SUBGROUP_INDEX);

describe('Feature Tests (SSP-XXXX)', () => {
    beforeEach(() => {
        initializePersistStoreInLocalStorageToDefaultValues();
    });

    it('[Test Name] should do something', () => {
        cy.visitAndWaitForStableAndInteractiveDOM('/');
        cy.getByTID([TIDs.some_element]).should('be.visible').click();
        cy.waitForStableAndInteractiveDOM();

        takeSnapshotAndCompare(getSnapshotFullIndexAsString(0), 'snapshot name', {
            blackout: [
                { tid: TIDs.footer_social_links },
                { tid: TIDs.footer_payment_images },
                { tid: TIDs.footer_copyright },
            ],
        });
    });
});

B2B Test Template

import { b2bUrl, staticData } from 'fixtures/demodata';
import {
    getSnapshotIndexingFunction,
    initializePersistStoreInLocalStorageToDefaultValues,
    SNAPSHOT_GROUP,
    takeSnapshotAndCompare,
} from 'support';
import { TIDs } from 'tids';

const SUBGROUP_INDEX = 0;
const getSnapshotFullIndexAsString = getSnapshotIndexingFunction(SNAPSHOT_GROUP.B2B, SUBGROUP_INDEX);

describe('B2B Feature Tests', () => {
    beforeEach(() => {
        initializePersistStoreInLocalStorageToDefaultValues();
        cy.loginB2b(staticData.b2bOwner.email, staticData.b2bOwner.password);
    });

    it('[Test Name] should do something', () => {
        cy.visitB2bAndWaitForStableAndInteractiveDOM(b2bUrl.customer.orders);
        cy.url().should('contain', b2bUrl.customer.orders);
        // ... assertions
    });

    it('should show 403 for unauthorized user', () => {
        cy.loginB2b(staticData.b2bCatalogUser.email, staticData.b2bCatalogUser.password);
        cy.visitB2bAndWaitForStableAndInteractiveDOM(b2bUrl.customer.users, { failOnStatusCode: false });
        cy.getByTID([TIDs.error_403_page]).should('exist');
    });
});

Support File Template

import { staticData, b2bUrl } from 'fixtures/demodata';
import { checkAndHideSuccessToast, changeElementText, checkUrl } from 'support';
import { TIDs } from 'tids';

// Login helpers
export const loginAsB2bOwner = () => {
    cy.loginB2b(staticData.b2bOwner.email, staticData.b2bOwner.password);
};

// Navigation helpers
export const navigateToFeaturePage = () => {
    cy.visitB2bAndWaitForStableAndInteractiveDOM(b2bUrl.customer.complaints);
};

// Assertion helpers
export const checkElementIsVisible = () => {
    cy.getByTID([TIDs.complaints_list]).should('exist');
};

// Action helpers
export const performAction = () => {
    cy.getByTID([TIDs.some_button]).should('be.visible').click();
    cy.waitForStableAndInteractiveDOM();
};

// Dynamic content replacement for snapshots
export const replaceDynamicContent = () => {
    changeElementText(TIDs.store_opening_hours, staticData.openingHours, false);
};

// 403 check
export const check403PageIsVisible = () => {
    cy.getByTID([TIDs.error_403_page]).should('exist').and('be.visible');
};

Snapshot / Visual Regression

SNAPSHOT_GROUP values

Each test category needs a unique value in support/index.ts. Always check the actual enum for current values — gaps in numbering are expected (deleted groups are not backfilled). Pick any unused number for new groups.

New test categories: Add a new enum value with a unique number that doesn't conflict with existing ones. Read support/index.ts to see the current values.

Snapshot indexing

const SUBGROUP_INDEX = 0; // unique per .cy.ts file in the group
const getSnapshotFullIndexAsString = getSnapshotIndexingFunction(SNAPSHOT_GROUP.MY_GROUP, SUBGROUP_INDEX);

// Prefer explicit, stable IDs for new specs and specs undergoing capture consolidation.
takeSnapshotAndCompare(getSnapshotFullIndexAsString(0), 'empty state');
takeSnapshotAndCompare(getSnapshotFullIndexAsString(3), 'filled state');

Keep existing snapshot indices and labels when removing neighboring captures; gaps are intentional.

Use explicit IDs consistently throughout a converted spec, with a unique ID per capture.

Do not mix explicit and automatic IDs in one spec. The no-argument form remains supported

for untouched legacy specs, but its sequential IDs depend on the preceding executed tests.

Legacy retry tracking uses the complete Cypress.currentTest.titlePath, including parent suites;

never identify tests by the leaf title alone because sibling suites can reuse it.

New captures in an explicit-ID spec get a new unused index; do not backfill removed IDs.

Different entry points or persistence paths do not each need a screenshot of the same state.

Before removing a capture, identify its retained visual owner and preserve explicit assertions

for the original flow. Keep distinct layout/overlay/form states and required deferred readiness.

Remove only the corresponding obsolete PNGs and preserve retained reference names.

This does not authorize baseline regeneration or automatic acceptance of diffs.

Blackout rules

Blackout product images and transport/payment icons

When taking snapshots, blackout images and icons, because they differ between environments:

Product images by page:

| Page | TID to blackout |

| --- | --- |

| Product detail | product_detail_main_image |

| Add-to-cart popup | add_to_cart_popup_image |

| Cart | cart_list_item_image |

| Order summary sidebar | order_summary_cart_item_image |

| Products blocking transport selection | transport_unavailability_product_image |

| Order confirmation | order_summary_cart_item_image (same component as order summary) |

| Order list (customer orders) | order_list_product_image |

| Order detail | order_detail_item_image |

Transport & payment icons by page:

| Page | TID to blackout |

| --- | --- |

| Transport & payment step | transport_and_payment_list_item_image |

| Delivery options popup (product detail) | transport_and_payment_list_item_image (shared TransportAndPaymentItemLabel), delivery_options_variant_image (variant select), store_opening_status (pickup store list) |

| Order summary sidebar | order_summary_transport_and_payment_image |

| Order detail | order_list_transport_and_payment_image (shared ElementWithImage component) |

Capture modes

// Full page (default)
takeSnapshotAndCompare(name, 'label', { capture: 'fullPage' });

// Viewport only
takeSnapshotAndCompare(name, 'label', { capture: 'viewport' });

// Specific element by TID
takeSnapshotAndCompare(name, 'label', { capture: TIDs.layout_popup });

Dynamic content handling

Replace dynamic content (dates, times, etc.) before taking snapshots:

import { changeElementText } from 'support';
changeElementText(TIDs.store_opening_hours, staticData.openingHours, false);
changeElementText(TIDs.blog_article_publication_date, staticData.blogArticle.publicationDate);

The expected delivery date message (computed from the current date) is shown on the transport-and-payment

page, on pickup places, and in the product-detail delivery options popup. Before EVERY snapshot of those, call

changeExpectedDeliveryDateMessagesToStaticDemodata() from transportAndPaymentSupport.ts — it replaces

each TIDs.expected_delivery_date_message element with staticData.expectedDeliveryDateMessage, or with

staticData.expectedPersonalPickupDateMessage when the element's real text starts with the translated

"Personal pickup" prefix (the delivery vs. pickup wording is deterministic, so snapshots keep it truthful).

Shared interaction and screenshot readiness

waitForStableAndInteractiveDOM() waits for hydration, pending useDeferredRender() commits,

loading indicators and one quiet DOM interval. Visit/reload helpers call it once. The shared

observer has a deadline and disconnects on success, timeout or navigation; do not reintroduce

cypress-wait-for-stable-dom or duplicate blanket waits.

data-deferred-render-pending tracks deferred hook commits, not all lazy imports or API requests.

Keep scenario-specific assertions for required content and real interaction readiness.

takeSnapshotAndCompare() additionally retains page scrolling, prepares temporary styles,

waits for fonts and relevant unmasked images, then settles the DOM before measuring masks.

It restores temporary styles/masks after capture and on failure. Scrollbars are hidden once

per document in window:before:load, before the application measures scroll-lock compensation;

do not toggle scrollbar visibility around individual captures or rely on a preceding screenshot.

Do not disable deferred rendering,

change its scheduling, or increase fixed waits to hide a failure. Keep image TIDs on fixed wrappers.

Transport and payment readiness

waitForTransportAndPaymentToBeInteractive(paymentState) requires the expected payment-section state:

use 'absent' when no transport is selected, and 'available' when the payment section must be visible

with enabled radio inputs. Deselecting only the payment keeps the section 'available'.

Do not infer this state from a one-time DOM lookup: an exiting payment section can still be mounted

while its removal animation is running.

Known Gotcha: .within() + waitForStableAndInteractiveDOM

NEVER call cy.waitForStableAndInteractiveDOM() inside .within() — it does cy.get('body[data-hydrated="true"]') which fails when scoped to a non-body element.

// BAD — hydration error
cy.getByTID([TIDs.store_list]).within(() => {
    cy.waitForStableAndInteractiveDOM(); // FAILS!
});

// GOOD — use .find() instead
cy.getByTID([TIDs.store_list]).find('[aria-expanded="false"]').first().click();
cy.waitForStableAndInteractiveDOM();

Custom Commands Reference

Navigation & DOM Stability

| Command | Description |

| -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |

| cy.visitAndWaitForStableAndInteractiveDOM(url) | Visit B2C page + wait for hydration + stable DOM |

| cy.visitB2bAndWaitForStableAndInteractiveDOM(path, options?) | Visit B2B page (prepends b2bDomain.baseUrl) + wait |

| cy.reloadAndWaitForStableAndInteractiveDOM() | Reload + wait |

| cy.waitForStableAndInteractiveDOM() | Wait for: stable DOM, no skeleton, no nprogress, no loader, hydrated |

| cy.waitForHydration() | Wait for body[data-hydrated="true"] |

| visitEntityByUuid(type, uuid) | Navigate to entity by UUID via GraphQL slug lookup. Types: 'category', 'product', 'blogCategory', 'blogArticle', 'article', 'brand', 'flag', 'store' |

GraphQL API Commands

| Command | Description |

| ---------------------------------------------------- | ------------------------------------------------------------------------ |

| cy.addProductToCartForTest(uuid?, qty?) | Add product to cart via GraphQL (defaults to helloKitty, qty 1) |

| cy.addPromoCodeToCartForTest(promoCode) | Apply promo code |

| cy.preselectTransportForTest(uuid, pickupPlaceId?) | Select transport method |

| cy.preselectPaymentForTest(uuid) | Select payment method |

| cy.login(email?, pw?) | B2C login via GraphQL (defaults to staticData.user). Caches tokens. |

| cy.loginB2b(email, pw) | B2B login via GraphQL. Sets cookies for B2B domain. |

| cy.logout() | Logout via GraphQL + clear cookies |

| cy.createOrder(variables) | Create order via GraphQL. Returns { urlHash }. |

| cy.registerAsNewUser(input, shouldLogin?) | Register new user. If shouldLogin=true (default), sets auth cookies. |

| .checkGQL(operationName) | Chain after cy.request() to validate GraphQL response and extract data |

Helper Functions (from support/index.ts)

| Function | Description |

| ------------------------------------------------------------------------- | -------------------------------------------------------------------- |

| initializePersistStoreInLocalStorageToDefaultValues() | Reset localStorage persist store — call in every beforeEach |

| checkAndHideSuccessToast(text?) | Assert success toast exists (optionally with text), click to dismiss |

| checkAndHideErrorToast(text?) | Assert error toast exists, click to dismiss |

| checkAndHideInfoToast(text?) | Assert info toast exists, click to dismiss |

| checkUrl(url) | Assert cy.url().should('contain', url) |

| getHeaderElementByTID(tid) | Scroll to the top and find a descendant in the main header |

| openHeaderUserMenu() | Scroll to the top and open the main header account menu |

| checkIsUserLoggedIn() | Assert my_account_link contains "My account" translation |

| checkIsUserLoggedOut() | Assert my_account_link contains "Login" translation |

| goToEditProfileFromHeader() | Open account menu, click edit profile link |

| checkLoaderOverlayIsNotVisibleAfterTimePeriod(ms?) | Wait then assert loader_overlay not exist |

| changeElementText(tid, text, isRightAfterSSR?) | Replace element text (for dynamic content in snapshots) |

| loseFocus() | Blur currently focused element |

| checkPopupIsVisible(shouldClose?) | Assert layout_popup visible, optionally press Esc |

| changeCartItemQuantityWithSpinboxInput(qty, catnum) | Type quantity into cart item's spinbox |

| changeProductListItemQuantityWithSpinboxInput(qty, catnum) | Type quantity into product list item's spinbox |

| goToPageThroughSimpleNavigation(index) | Click pagination page by index |

| checkCanGoToNextOrderStep() | Assert order next button is visible and not disabled |

| takeSnapshotAndCompare(name, label, options?, callbackBeforeBlackout?) | Take visual regression snapshot |

| getSnapshotIndexingFunction(group, subgroup) | Returns snapshot ID function; pass an explicit stable index, or omit for legacy counting |

| checktHeadlineText(translationKey) | Check h1 text matches translation (with fallback) |

| checkFormLineError(errorText?) | Assert form_line_error exists with optional translated text |

| checkNumberOfApiRequestsTriggeredByActions(actions, count, requestName) | Intercept and count GraphQL requests |

Static Test Data (fixtures/demodata.ts)

Products

staticData.products.helloKitty; // { uuid, name, fullName, catnum: '9177759' }
staticData.products.philips32PFL4308; // { uuid, catnum: '9176508' }
staticData.products.televisionPhilipsM; // { uuid } — main variant with 6 sellable variants (incl. philips100)
staticData.products.a4techMouse; // { uuid, catnum: '5960453', name }
staticData.products.philips100; // { uuid, catnum: 'PHILIPS100', name: '100" Philips [V]' } — variant of televisionPhilipsM
staticData.products.panasonicDmcFt5ep; // { catnum: '5965907', name: 'PANASONIC DMC FT5EP' }
staticData.products.delonghi; // { uuid, catnum: '9771339', name } — has gift plan (gift: giftTicket100czk)
staticData.products.giftTicket100czk; // { uuid, catnum: '9176544MS', name } — gift product
staticData.products.electronicGiftVoucher1000; // { uuid, catnum: 'VOUCHER1000', name } — electronic gift voucher product (voucher-only carts skip transport)

Use fullName ?? name for exact displayed/API product-name assertions; name remains

the base name used by search scenarios. The Hello Kitty fixture includes a prefix and suffix.

Categories

staticData.categories.electronics; // { uuid }
staticData.categories.personalComputers; // { uuid }

Users

staticData.user; // { email: 'no-reply@shopsys.com', password: 'user123', uuid }
staticData.customer1; // { email, emailRegistered, firstName, lastName, phone, billingStreet, billingCity, billingPostCode, password }
staticData.b2bOwner; // { email: 'jozef.novotny@shopsys.com', password: 'user123' }
staticData.b2bUser; // { email: 'marek.horvat@shopsys.com', password }
staticData.b2bLimitedUser; // { email: 'peter.kovac@shopsys.com', password }
staticData.b2bCatalogUser; // { email: 'jiri.katalogovy@shopsys.com', password }
staticData.b2bAccountant; // { email: 'jana.ucetni@shopsys.com', password }

Delivery Addresses

staticData.deliveryAddress; // { firstName: 'Janek', lastName, company, phone, street, city, postCode, country: 'CZ' }
staticData.deliveryAddress2; // { firstName: 'Tomáš', ... }

Payment & Transport UUIDs

staticData.payment.creditCard.uuid;
staticData.payment.cash.uuid;
staticData.payment.onDelivery.uuid;
staticData.payment.goPayCreditCard.uuid;

staticData.transport.personalCollection.uuid;
staticData.transport.personalCollection.storeOstrava; // { uuid, name }
staticData.transport.personalCollection.storePardubice; // { uuid, name }
staticData.transport.czechPost.uuid;
staticData.transport.ppl.uuid;

URLs

// B2C URLs
(url.cart,
    url.search,
    url.brandsOverview,
    url.login,
    url.registration,
    url.stores,
    url.contactForm,
    url.productComparison);
(url.order.transportAndPayment, url.order.contactInformation, url.order.orderConfirmation, url.order.orderDetail);
(url.customer.orders,
    url.customer.editProfile,
    url.customer.complaints,
    url.customer.newComplaint,
    url.customer.complaintDetail);

// B2B URLs
(b2bUrl.login, b2bUrl.cart, b2bUrl.registration);
(b2bUrl.order.transportAndPayment,
    b2bUrl.order.contactInformation,
    b2bUrl.order.orderConfirmation,
    b2bUrl.order.orderDetail,
    b2bUrl.order.orderWithdrawal);
(b2bUrl.customer.users,
    b2bUrl.customer.complaints,
    b2bUrl.customer.newComplaint,
    b2bUrl.customer.complaintDetail,
    b2bUrl.customer.orders,
    b2bUrl.customer.editProfile,
    b2bUrl.customer.changePassword);

Other Static Data

staticData.promoCode; // 'test'
staticData.giftVouchers.unredeemed1000; // 'HAPPYDAY2345' — 1000 CZK demo gift voucher (apply/remove in cart, do NOT complete orders with it)
staticData.giftVouchers.fullPaymentMatchingOrderTotal; // 'MAXPAY234567' — gift voucher whose value matches the test order total exactly, dedicated to full-payment order tests
staticData.giftVouchers.lastOrderCashMatchingCartTotal; // 'CASHLASTPAY1' — gift voucher matching the A4tech mouse with free personal collection and cash payment
staticData.giftVouchers.lastOrderVoucherMatchingOrderTotal; // 'VOUCHERLAST1' — gift voucher matching an order that is repeated without its voucher
staticData.openingHours; // '09:00 - 11:00, 13:00 - 17:00'
staticData.orderNote; // 'Just a tiny note in the order.'
staticData.expectedDeliveryDateMessage; // 'Delivery on Tuesday 10/26'
staticData.expectedPersonalPickupDateMessage; // 'Personal pickup on Tuesday 10/26'
staticData.order.number; // '1234567890'
staticData.order.numberHeading; // 'Order number 1234567890'
staticData.order.creationDate; // '10/26/1999 10:10 AM'
staticData.blogArticle.publicationDate; // '10/26/1999'
staticData.blogArticle.grapesJs.uuid;
staticData.article.creationDate; // '10/26/1999'
staticData.article.forPress.uuid;

Translation System

The test suite has a multi-layer translation system that supports running tests in different locales (en, cs, sk). Understanding this is essential for writing assertions on visible text.

Architecture Overview

translationKeys.ts          → Defines English key strings used for lookups
support/translations.ts     → Core module: t() function, loadAllTranslations()
support/index.ts            → Global `translations` object, auto-loaded before all tests
public/locales/{locale}/common.json  → Primary translation source (JSON)
app-translations/dataFixtures.{locale}.po → Fallback translations (.PO format)

Translation Fallback Chain

When t(key) is called, it resolves in this order:

  1. common.json — public/locales/{TEST_LOCALE}/common.json (primary)
  2. .po files — dataFixtures.{locale}.po from /app/app-translations/ (fallback for demo data)
  3. Key itself — returns the original key string if not found anywhere

Two Ways to Use Translations in Tests

1. Global `translations` object (pre-loaded, synchronous access)

The translations object is loaded once in a before() hook via loadAllTranslations() and available globally. It contains translated values for all keys defined in fixtures/translationKeys.ts.

import { translations } from 'support';

// Use for placeholder assertions
cy.get('#registration-form-email').should('have.attr', 'placeholder', translations.placeholder.email);

// Use for toast messages
checkAndHideSuccessToast(translations.toast.success.accountCreated);

// Use for checking logged-in state
cy.getByTID([TIDs.my_account_link]).should('be.visible').contains(translations.link.myAccount);

Available categories on the translations object (mirrors translationKeys.ts structure):

2. `t()` function (async, for one-off lookups)

For translation keys NOT in translationKeys.ts, use the t() function directly. It returns a Cypress.Chainable<string> and supports parameter substitution.

import { t } from 'support/translations';

// Simple lookup
t('Please enter email').then((translatedText) => {
    cy.getByTID([TIDs.form_line_error]).contains(translatedText).should('be.visible');
});

// With parameter substitution ({{ param }} syntax)
t('Order number {{ orderNumber }} has been sent', { orderNumber: '12345' }).then((text) => {
    cy.contains(text);
});

Translation-Aware Helper Functions

These helpers use translations internally — pass English key strings and they handle lookup:

// checkFormLineError — looks up the key via t(), finds it in form_line_error TID
checkFormLineError('Please enter email');
checkFormLineError('Please enter password');
checkFormLineError(); // just check any error exists

// checktHeadlineText — checks h1 against key (tries direct match first, then t() lookup)
checktHeadlineText('Stores');
checktHeadlineText('Product comparison');

// checkIsUserLoggedIn / checkIsUserLoggedOut — uses translations.link.myAccount / translations.button.login
checkIsUserLoggedIn();
checkIsUserLoggedOut();

Real-World Translation Patterns

// Form filling with placeholder verification
cy.get('#registration-form-firstName')
    .should('have.attr', 'placeholder', translations.placeholder.firstName)
    .type('John');

cy.get('#registration-form-street')
    .should('have.attr', 'placeholder', translations.placeholder.street)
    .type('Main Street 123');

// Toast with translated text
checkAndHideSuccessToast(translations.toast.success.userSaved);
checkAndHideInfoToast(translations.toast.info.cartModified);

// Order confirmation text check
cy.getByTID([TIDs.order_confirmation_page_text_wrapper]).should(
    'contain.text',
    translations.order.confirmation.czechPost,
);

// Validation error checking (keys resolved via t())
checkFormLineError('Please enter email');
checkFormLineError('You have to agree with our privacy policy');

Key Files

Common Test Patterns

Popup interaction (confirm/dismiss)

// Trigger action that opens popup
cy.getByTID([TIDs.comparison_remove_all_button]).click();
// Verify popup is visible
cy.getByTID([TIDs.layout_popup]).should('be.visible');
// Confirm action
cy.getByTID([TIDs.popup_confirm_button]).click();
cy.waitForStableAndInteractiveDOM();
// Or dismiss
cy.realPress('{esc}');
cy.getByTID([TIDs.layout_popup]).should('not.exist');

Toast message verification

import { checkAndHideSuccessToast } from 'support';
checkAndHideSuccessToast(); // just check exists
checkAndHideSuccessToast('User profile has been changed successfully'); // check with text

Access control / 403 testing

cy.loginB2b(staticData.b2bCatalogUser.email, staticData.b2bCatalogUser.password);
cy.visitB2bAndWaitForStableAndInteractiveDOM(b2bUrl.customer.users, { failOnStatusCode: false });
cy.getByTID([TIDs.error_403_page]).should('exist');

Element absence testing

// Verify element does NOT exist (e.g., restricted button)
cy.getByTID([TIDs.blocks_product_addtocart]).should('not.exist');
cy.getByTID([TIDs.complaints_list_create_complaint_manually_button]).should('not.exist');

Navigate to entity by UUID

import { visitEntityByUuid } from 'support/navigation';
visitEntityByUuid('category', staticData.categories.electronics.uuid);
visitEntityByUuid('product', staticData.products.a4techMouse.uuid);

Filter interaction

Start from known category/filter data. Select a specific parameter or price range,

wait for the relevant state/request, and assert the expected selected values and

matching results. For clear-filter tests, first assert the active filter and clear

control exist, then clear and assert the reset state; do not skip the action conditionally.

Use the project's readiness helper in addition to the scenario-specific assertions.

Sort interaction

cy.getByTID([[TIDs.blocks_sortingbar_option_, 'PRICE_ASC']]).filter(':visible').click();
cy.waitForStableAndInteractiveDOM();

Select the intended named sort option (for example PRICE_ASC) rather than an

arbitrary index, and assert the resulting sort state and product ordering. A filter

remaining in the URL alone does not prove sorting. Use the visible control without

forcing the action unless the component-specific exception above applies.

Product count assertion

cy.getByTID([TIDs.product_list_item_image]).should('have.length.greaterThan', 0);
cy.getByTID([TIDs.product_list_item_image]).then(($items) => {
    expect($items.length).to.be.lte(initialCount);
});

Main and fixed header navigation

// Regular flows always use the main header in a stable scroll position.
openHeaderUserMenu();
cy.getByTID([TIDs.header, TIDs.my_account_link, TIDs.user_menu_edit_profile_link])
    .filter(':visible')
    .first()
    .should('be.visible')
    .click({ scrollBehavior: false });

// A dedicated fixed-header test scopes every action explicitly to the fixed header.
cy.scrollTo('bottom');
cy.getByTID([TIDs.fixed_header]).should('be.visible');
cy.getByTID([TIDs.fixed_header, TIDs.my_account_link]).click({ scrollBehavior: false });

Do not dynamically choose between the main and fixed headers. Regular feature tests should use the main header after

scrolling to the top. Test fixed-header behavior separately and scope all selectors under TIDs.fixed_header.

Retry configuration is not a flakiness fix

Inspect the configured retries when diagnosing failures, but fix the underlying

state/timing dependency. A pass after retry is not evidence of deterministic behavior;

changing retry counts requires an explained purpose, not just a green run.

Naming Conventions

`describe()` block naming

Format: 'Feature Name Tests' or 'Feature Name Tests (SSP-XXXX)' with optional Jira ticket reference.

// Top-level describe — feature name + "Tests", optionally with ticket
describe('Product Comparison Tests (SSP-1719)', () => { ... });
describe('Stores Tests (SSP-1741)', () => { ... });
describe('Cart Page Tests', () => { ... });
describe('Create Order Tests', () => { ... });

// Nested describe for sub-groups (B2B role-based, access control)
describe('Customer Users (B2B) Tests', () => {
    describe('As B2B Owner', () => { ... });
    describe('Access control', () => { ... });
});

// Multiple describe blocks in one file for logical grouping
describe('Registration Tests (Basic)', () => { ... });
describe('Registration Tests (B2B)', () => { ... });
describe('Registration Tests (Repeated Tries)', () => { ... });

`it()` block naming

Two patterns exist depending on test style:

Pattern 1: [Short Label] prefix + should description — used in most test files. The bracket label is a short identifier (2-4 words, Title Case) that groups related tests and appears in snapshot names.

// Good — clear short label + descriptive "should" sentence
it('[Empty Comparison] should show empty comparison page', () => { ... });
it('[Add From Listing] should add a product to comparison from category listing', () => { ... });
it('[Remove All] should add products then remove all from comparison', () => { ... });
it('[Parameter Checkbox Filter] should filter products by parameter checkbox and verify URL persistence', () => { ... });
it('[Anon Home Cash] should create order as unlogged user (transport to home, cash on delivery)', () => { ... });
it('[Prefilled Cart] should log in, add product to cart to an already prefilled cart', () => { ... });
it('[Transport Fee] should change price for transport when cart is large enough', () => { ... });

Pattern 2: Plain should description — used in B2B nested describe blocks where the parent already provides context.

describe('As B2B Owner', () => {
    it('should display the customer users table', () => { ... });
    it('should open add user popup and add a new user', () => { ... });
});
describe('Access control', () => {
    it('should show 403 for Limited User trying to access customer users page', () => { ... });
});

Rules:

File naming

e2e/
  featureName/
    featureName.cy.ts              # Main test file (camelCase, matches directory)
    featureNameSupport.ts           # Support helpers (camelCase + "Support")

Multiple test files in one directory are fine:

cart/cartPage.cy.ts, cartLogin.cy.ts, cartInHeader.cy.ts, productAddToCart.cy.ts
order/createOrder.cy.ts, contactInformation.cy.ts, orderRepeat.cy.ts

Workflow for Writing Tests

  1. Search existing complete flows across project-base/storefront/cypress/ by component, TID, helper, and interaction type; reuse the closest verified pattern
  2. Inspect the page and component with /playwright-cli on localhost or https://ssfwcc.dev.shopsys.cloud/ and read the relevant React implementation when lifecycle behavior affects the test
  3. Check existing TIDs in project-base/storefront/cypress/tids.ts — reuse what exists
  4. Add missing TIDs to tids.ts + React components (use data-tid for HTML elements, tid prop for Button/LinkButton)
  5. Create or extend a support file for reusable helpers (co-locate as featureNameSupport.ts)
  6. Write test using cy.getByTID() consistently, initializePersistStoreInLocalStorageToDefaultValues() in beforeEach
  7. Add SNAPSHOT_GROUP only when adding justified visual coverage in a new snapshot category (unique number in support/index.ts enum); functional-only scenarios need no snapshot infrastructure
  8. Provide manual verification with make run-specific-test-regression SPEC=e2e/path/to/test.cy.ts; do not start Cypress yourself. References are generated and reviewed on CI, not locally.
  9. Verify tooling with docker compose exec -T storefront sh -lc 'cd cypress && npm run typecheck' when the container is already running.

Real-World Example: Complete Test + Support File

comparisonSupport.ts

import { url } from 'fixtures/demodata';
import { checkAndHideSuccessToast, checkUrl } from 'support';
import { TIDs } from 'tids';

export const visitComparisonPage = () => {
    cy.visitAndWaitForStableAndInteractiveDOM(url.productComparison);
    checkUrl(url.productComparison);
};

export const checkComparisonIsEmpty = () => {
    cy.getByTID([TIDs.comparison_empty_state]).should('be.visible');
};

export const addProductToComparisonFromListing = (catnum: string) => {
    cy.getByTID([[TIDs.blocks_product_list_listeditem_, catnum], TIDs.product_compare_button])
        .should('be.visible')
        .click();
};

export const checkComparisonPopupVisible = () => {
    cy.getByTID([TIDs.comparison_popup]).should('be.visible');
};

export const closeComparisonPopup = () => {
    cy.realPress('{esc}');
};

export const goToComparisonFromPopup = () => {
    cy.getByTID([TIDs.comparison_popup_link]).click();
    cy.waitForStableAndInteractiveDOM();
};

export const removeAllFromComparison = () => {
    cy.getByTID([TIDs.comparison_remove_all_button]).click();
    cy.getByTID([TIDs.layout_popup]).should('be.visible');
    cy.getByTID([TIDs.popup_confirm_button]).click();
    cy.waitForStableAndInteractiveDOM();
    checkAndHideSuccessToast();
};

export const removeProductFromComparison = (catnum: string) => {
    cy.getByTID([[TIDs.comparison_product_, catnum], TIDs.comparison_remove_product_button])
        .should('be.visible')
        .click();
    cy.waitForStableAndInteractiveDOM();
    checkAndHideSuccessToast();
};

export const checkComparisonProductCount = (count: number) => {
    cy.getByTID([TIDs.page_title]).should('contain', `(${count})`);
};

productComparison.cy.ts

import {
    addProductToComparisonFromDetail,
    addProductToComparisonFromListing,
    checkComparisonIsEmpty,
    checkComparisonPopupVisible,
    checkComparisonProductCount,
    closeComparisonPopup,
    goToComparisonFromPopup,
    removeAllFromComparison,
    removeProductFromComparison,
    visitComparisonPage,
} from './comparisonSupport';
import { staticData, url } from 'fixtures/demodata';
import {
    checkUrl,
    getSnapshotIndexingFunction,
    initializePersistStoreInLocalStorageToDefaultValues,
    SNAPSHOT_GROUP,
    takeSnapshotAndCompare,
} from 'support';
import { visitEntityByUuid } from 'support/navigation';
import { TIDs } from 'tids';

const SUBGROUP_INDEX = 0;
const getSnapshotFullIndexAsString = getSnapshotIndexingFunction(SNAPSHOT_GROUP.COMPARISON, SUBGROUP_INDEX);

describe('Product Comparison Tests (SSP-1719)', { retries: { runMode: 0 } }, () => {
    beforeEach(() => {
        initializePersistStoreInLocalStorageToDefaultValues();
    });

    it('[Empty Comparison] should show empty comparison page', () => {
        visitComparisonPage();
        checkComparisonIsEmpty();
        takeSnapshotAndCompare(getSnapshotFullIndexAsString(0), 'empty comparison', {
            blackout: [
                { tid: TIDs.footer_social_links },
                { tid: TIDs.footer_payment_images },
                { tid: TIDs.footer_copyright },
            ],
        });
    });

    it('[Add From Listing] should add product from listing and navigate to comparison', () => {
        visitEntityByUuid('category', staticData.categories.electronics.uuid);
        addProductToComparisonFromListing(staticData.products.helloKitty.catnum);
        checkComparisonPopupVisible();
        goToComparisonFromPopup();
        checkUrl(url.productComparison);
        checkComparisonProductCount(1);
        takeSnapshotAndCompare(getSnapshotFullIndexAsString(1), 'one product from listing', {
            blackout: [
                { tid: TIDs.comparison_product_image },
                { tid: TIDs.footer_social_links },
                { tid: TIDs.footer_payment_images },
                { tid: TIDs.footer_copyright },
            ],
        });
    });

    it('[Remove All] should add products then remove all', () => {
        visitEntityByUuid('category', staticData.categories.electronics.uuid);
        addProductToComparisonFromListing(staticData.products.helloKitty.catnum);
        checkComparisonPopupVisible();
        closeComparisonPopup();

        visitEntityByUuid('product', staticData.products.a4techMouse.uuid);
        addProductToComparisonFromDetail();
        checkComparisonPopupVisible();
        goToComparisonFromPopup();

        removeAllFromComparison();
        checkComparisonIsEmpty();
    });
});

Cypress Config Highlights

Keeping This Skill Up-to-Date

When you change the Cypress test infrastructure, update this skill file (.agents/skills/cypress-tests/SKILL.md) where its guidance is affected. Cross-layer ownership stays in the canonical storefront-tests skill. Specifically:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.