fix: gracefully handle non-positive Qase IDs in runtime APIs#974
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 thatqase.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:
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
Versions