Skip to content

CC-39427: Add Cypress tests for all demo AI features with dynamic fix… - #332

Open
vitaliiivanovspryker wants to merge 26 commits into
masterfrom
master-demo
Open

vitaliiivanovspryker wants to merge 26 commits into
masterfrom
master-demo

Conversation

@vitaliiivanovspryker

Copy link
Copy Markdown
Contributor

…tures and reusable page objects.

PR Description

Add a meaningful description here that will let us know what you want to fix with this PR or what functionality you want to add.

Steps before you submit a PR

  • Please add tests for the code you add if it's possible.
  • Please check out our contribution guide: https://docs.spryker.com/docs/dg/dev/code-contribution-guide.html
  • Add a contribution-license-agreement.txt file with the following content:
    I hereby agree to Spryker\'s Contribution License Agreement in https://github.com/spryker/cypress-tests/blob/HASH_OF_COMMIT_YOU_ARE_BASING_YOUR_BRANCH_FROM_MASTER_BRANCH/CONTRIBUTING.md.

This is a mandatory step to make sure you are aware of the license agreement and agree to it. HASH_OF_COMMIT_YOU_ARE_BASING_YOUR_BRANCH_FROM_MASTER_BRANCH is a hash of the commit you are basing your branch from the master branch. You can take it from commits list of master branch before you submit a PR.

Checklist

  • I agree with the Code Contribution License Agreement in CONTRIBUTING.md

vitaliiivanovspryker and others added 26 commits June 27, 2026 21:06
* Add new Cypress tests for enhanced demo AI feature coverage (e.g. Backoffice Assistant, AI Configuration, Quick Add by Image).
* Refactor existing tests to improve readability, reuse constants, and align input/output validation with expected behaviors.
* Expand test cases for scenarios like unsaved changes handling, provider failure recovery, and multipart form submissions.
* Introduce sortable/non-sortable column validations across workflows, audit logs, and analytics.
* Enhance Smart PIM and CMS tests to include attachment handling and AI prompt validations.
# Conflicts:
#	cypress/support/pages/yves/index.ts
…e assistant, and cost price tests for improved categorization and filtering
…`.env.example`

- test: enhance AI workflow tests with expanded coverage, dynamic configurations, and improved descriptions
- chore: refactor Backoffice Assistant and audit logs tests for better validation and modularity
* Add configurable system prompts for Smart PIM, Search by Image, and Quick Add-to-Cart in Cypress tests
* Refactor save bar assertions to prevent flakiness in dev environments
* Validate shipped default prompts and placeholder retention across tabs
* Introduce prompt override tests with persistence and restoration validation
* Extend AI Configuration page objects with group-level setting selectors
…inability

- Enforced "no comments in test code" policy by removing comments and relying on method/variable names for clarity
- Refactored parameterized test cases to eliminate duplication and use reusable helpers
- Consolidated closely-related assertions and merged redundant tests to reduce runtime
- Added `skipUnlessAiProviderEnabled` to conditionally skip tests for `@demo-full` tier gating
- Updated hardcoded strings (e.g., API tokens, regions) to constants for maintainability
- Improved selector names and structured data-driven tests for better readability
- Removed dead/unreferenced code and comments across test files
CC-39878 (ai-commerce @b2af09bc) reworked how streamed tool events render:

  case 'tool_call':
  -   this.#renderer.addToolCallMessage(data.name, data.arguments, null);
  +   this.#renderer.setLoadingIndicatorLabel(loadingEl, data.name);

A plain tool_call is now an in-progress signal only — it names the running
tool on the transient loading indicator ('Running %toolName%…') and no
longer creates a message block. Only tool_call_result renders a tool-call
block. The 'args' section (data-section="args", data-i18n-arguments and
the 'Arguments' translation key) was removed from chat-widget.twig.

The old test asserted a tool-call block WITH an arguments dump for a plain
tool_call, so it fails on both counts. Re-point it at the new invariant:
a tool_call yields no tool-call block, just the final assistant answer.
The loading label itself is not asserted — the whole indicator is removed
when the stream closes (BackofficeAssistant.js:406), so any assertion on
it after the response is inherently racy.

Drop the now-unused getWidgetToolCallArgs()/ArgsSelector() helpers.
Positive tool-call-block coverage stays in the tool_call_result sibling test.
…t_abstract

CI's 'Cypress / UI Demo' job failed 3 tests while the same cy:demo passed
locally:

    expected 'Edit Product Abstract: M53238' to include 'M53235'

The demo fixtures pinned BOTH an id and the SKU they assumed it resolves to:

    "product": { "idProductAbstract": 300, "sku": "M53235" }

Specs navigated by id 300, then asserted the page title contains M53235.
But id_product_abstract is an auto-increment assigned during data import,
so it is not a stable contract — M53235 and M53238 are ADJACENT rows in
data/import/common/common/product_abstract.csv, and a freshly seeded CI
database shifts the mapping by one. Verified against a live Back Office:
locally id 300 -> M53235 and 301 -> M53238; on CI's fresh import 300 is
M53238, so the specs opened the neighbouring product. Master's demo-data
changes in this upmerge (+5 HWB-* products, -1 retired) are what moved it.

Add BackofficePage::resolveProductAbstractIdBySku(), which looks the id up
from the product table endpoint (columns [id, name, sku, ...]) and asserts
a row for that SKU exists. Specs now resolve the id at runtime, so they are
ID-independent:

  cost-price.cy.ts   - resolve in beforeEach, 4 call sites
  smart-pim.cy.ts    - resolve in beforeEach, 16 call sites
  audit-logs.cy.ts   - resolve inline (@demo-full, inside a .then chain)

Also de-coupled two latent cases that had not failed yet:
  - static-audit-logs.json carried the same id/sku pairing
  - backoffice-assistant-page.ts hardcoded id-product-abstract=300 for its
    form-context host page (it never asserts the SKU, which is why it passed)

Drop idProductAbstract from all three demo fixtures and their types so the
coupling cannot be reintroduced. The SKU stays in the fixtures — it is
authored in the CSV and therefore stable.

Verified: resolver returns 300 for M53235 and 301 for M53238 (distinguishes
the neighbours rather than assuming a pairing); tsc and eslint clean;
cy:demo 10/10 specs, 93 passing, against a freshly re-imported database.
# Conflicts:
#	cypress/support/pages/mp/products/products-page.ts
# Conflicts:
#	cypress/support/pages/backoffice/index.ts
# Conflicts:
#	cypress/support/utils/index.ts
- Convert assertion-only page-object methods to getters and move the
  assertions into their specs (cost-price, smart-cms).
- Inline the action a .should() guard was protecting so the guard sits in
  an acting method (search-by-image).
- Add justified eslint-disable comments where the rule does not apply:
  cy.get('@alias.all') reads a cy.intercept() alias rather than a DOM
  selector, the XSS probes use generic tag names scoped by .within(), and
  a few page-object helpers are shared verifications by contract.
…to master-demo for CC-40515

# Conflicts:
#	cypress/support/pages/backoffice/index.ts
…r list--alert (shop form theme renamed the modifier)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants