Skip to content

fix: gracefully handle non-positive Qase IDs in runtime APIs#974

Merged
gibiw merged 1 commit into
mainfrom
fix/non-positive-qase-id-runtime-api
Jun 10, 2026
Merged

fix: gracefully handle non-positive Qase IDs in runtime APIs#974
gibiw merged 1 commit into
mainfrom
fix/non-positive-qase-id-runtime-api

Conversation

@gibiw

@gibiw gibiw commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #973. The previous PR filtered non-positive Qase test case IDs at the parser layer (parseQaseIdsFromString, parseProjectMappingFromTitle, parseProjectMappingFromTags, and three reporter-local parsers). A user reported that qase.id(0) in playwright still produced HTTP 400 — and they were right.

Root cause: playwright and wdio expose runtime metadata APIs that write IDs into test metadata directly, bypassing all parsers:

Reporter API Side-effect
playwright `qase(0, name)` `PlaywrightQaseReporter.addIds([0], "...")` → registry override
playwright `qase.id(0)` `addMetadata({ ids: [0] })` — primary culprit reported by user
playwright `qase.projects({ PROJ1: [0] })` `addMetadata({ projectMapping: { PROJ1: [0] } })`
wdio `qase.id(0)` `process.emit('addQaseID', { ids: [0] })`

Other reporters (jest, mocha, cypress, wdio's `qase()`) only build titles like `"name (Qase ID: 0)"` which were already filtered by the parser fix — they don't need changes.

Fix

Apply `filterPositiveIds()` (already exported from `qase-javascript-commons/internal`) in each runtime API. If everything filters out, the metadata attach / event emit is skipped entirely (no point writing empty metadata that would shadow the absence of an ID).

Verified end-to-end

Created an example playwright spec covering all four formats from the user's bug report and ran it with the locally-built reporter (`QASE_MODE=off`). Output:
```
✓ Format 1: qase(0, name)
✓ Format 2: qase.id(0) inside test
✓ Format 3: annotation QaseID = "0"
✓ Format 4: qase.projects with zero IDs
4 passed (1.2s)
```
Each emits the expected `[qase] Warning: Qase test case ID must be greater than 0, got "0"` and the test result is reported without an ID (the user's bug — HTTP 400 — no longer reproduces).

Test plan

  • `npm test` in `qase-playwright` — 98/98 (6 new regression tests for `qase()`, `qase.id()`, `qase.projects()` with non-positive IDs)
  • `npm test` in `qase-wdio` — 99/99 (4 new tests for `qase.id()`)
  • `npm run build` — both packages build with the new commons `~2.7.4` pin
  • Manual end-to-end repro of the user's bug — no HTTP 400, warning emitted, result reported without ID

Versions

  • `playwright-qase-reporter` 2.5.3 → 2.5.4
  • `wdio-qase-reporter` 1.5.3 → 1.5.4
  • Commons pin updated to `~2.7.4` in both.

Follow-up to #973: the previous fix filtered IDs at the parser layer, but
the playwright and wdio reporters also expose runtime metadata APIs that
write IDs straight into test metadata, bypassing all parsers:

  - playwright qase.id(N)        → addMetadata({ ids: [N] })
  - playwright qase(N, name)     → PlaywrightQaseReporter.addIds([N], ...)
  - playwright qase.projects({}) → addMetadata({ projectMapping: ... })
  - wdio       qase.id(N)        → process.emit('addQaseID', { ids: [N] })

Apply filterPositiveIds in each of these so IDs <= 0 are dropped with a
warning and the result is reported without an ID, matching the parser
behavior. Without this, qase.id(0) still produced HTTP 400 from the API.
@gibiw gibiw merged commit 74f1f72 into main Jun 10, 2026
52 checks passed
@gibiw gibiw deleted the fix/non-positive-qase-id-runtime-api branch June 10, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant