-
Notifications
You must be signed in to change notification settings - Fork 0
Add Allure upload support #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
satvik007
wants to merge
1
commit into
main
Choose a base branch
from
feat/allure-upload-pr
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Keep invalid JSON fixtures unformatted for parser tests | ||
| src/tests/fixtures/allure/parser/malformed-result.json | ||
| AGENTS.md |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| CLAUDE.md |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| import { beforeAll, describe, expect, test, vi } from 'vitest' | ||
| import { parseAllureResults } from '../utils/result-upload/allureParser' | ||
|
|
||
| const allureParserBasePath = './src/tests/fixtures/allure/parser' | ||
|
|
||
| let testcases: Awaited<ReturnType<typeof parseAllureResults>> | ||
|
|
||
| describe('Allure results parsing', () => { | ||
| beforeAll(async () => { | ||
| testcases = await parseAllureResults(allureParserBasePath, allureParserBasePath, { | ||
| skipStdout: 'never', | ||
| skipStderr: 'never', | ||
| }) | ||
| }) | ||
|
|
||
| test('Should parse results directory and ignore non-result files', () => { | ||
| expect(testcases).toHaveLength(9) | ||
|
|
||
| const statuses = testcases.map((tc) => tc.status) | ||
| expect(statuses).toContain('passed') | ||
| expect(statuses).toContain('failed') | ||
| expect(statuses).toContain('blocked') | ||
| expect(statuses).toContain('skipped') | ||
| }) | ||
|
|
||
| test('Should derive folders from labels with correct priority', () => { | ||
| const suiteCase = testcases.find((tc) => tc.name.includes('Login happy path')) | ||
| const parentCase = testcases.find((tc) => tc.name.includes('Payment error')) | ||
| const featureCase = testcases.find((tc) => tc.name.includes('Broken flow')) | ||
| const packageCase = testcases.find((tc) => tc.name.includes('Skipped TEST-003')) | ||
| const noLabelCase = testcases.find((tc) => tc.name.includes('Unknown status test')) | ||
|
|
||
| expect(suiteCase?.folder).toBe('SuiteA') | ||
| expect(parentCase?.folder).toBe('ParentOnly') | ||
| expect(featureCase?.folder).toBe('FeatureOnly') | ||
| expect(packageCase?.folder).toBe('pkg.module') | ||
| expect(noLabelCase?.folder).toBe('') | ||
| }) | ||
|
|
||
| test('Should calculate durations from start/stop timestamps', () => { | ||
| const suiteCase = testcases.find((tc) => tc.name.includes('Login happy path')) | ||
| const parentCase = testcases.find((tc) => tc.name.includes('Payment error')) | ||
|
|
||
| expect(suiteCase?.timeTaken).toBe(1500) | ||
| expect(parentCase?.timeTaken).toBe(600) | ||
| }) | ||
|
|
||
| test('Should map Allure statuses to QA Sphere statuses', () => { | ||
| const brokenCase = testcases.find((tc) => tc.name.includes('Broken flow')) | ||
| const unknownCase = testcases.find((tc) => tc.name.includes('Unknown status test')) | ||
|
|
||
| expect(brokenCase?.status).toBe('blocked') | ||
| expect(unknownCase?.status).toBe('passed') | ||
| }) | ||
|
|
||
| test('Should build messages from status details', () => { | ||
| const parentCase = testcases.find((tc) => tc.name.includes('Payment error')) | ||
| const brokenCase = testcases.find((tc) => tc.name.includes('Broken flow')) | ||
| const skippedCase = testcases.find((tc) => tc.name.includes('Skipped TEST-003')) | ||
|
|
||
| expect(parentCase?.message).toContain('AssertionError') | ||
| expect(parentCase?.message).toContain('Trace line 1') | ||
| expect(brokenCase?.message).toContain('NullPointerException') | ||
| expect(skippedCase?.message).toBe('') | ||
| }) | ||
|
|
||
| test('Should resolve attachments from result directory', () => { | ||
| const parentCase = testcases.find((tc) => tc.name.includes('Payment error')) | ||
| expect(parentCase?.attachments).toHaveLength(1) | ||
| expect(parentCase?.attachments[0].filename).toBe('failure-log.txt') | ||
| expect(parentCase?.attachments[0].buffer).not.toBeNull() | ||
| }) | ||
|
|
||
| test('Should handle missing or empty attachments arrays', () => { | ||
| const suiteCase = testcases.find((tc) => tc.name.includes('Login happy path')) | ||
| const brokenCase = testcases.find((tc) => tc.name.includes('Broken flow')) | ||
|
|
||
| expect(suiteCase?.attachments).toHaveLength(0) | ||
| expect(brokenCase?.attachments).toHaveLength(0) | ||
| }) | ||
|
|
||
| test('Should keep marker when present in test name', () => { | ||
| const suiteCase = testcases.find((tc) => tc.name.includes('Login happy path')) | ||
| expect(suiteCase?.name).toContain('TEST-002') | ||
| }) | ||
|
|
||
| test('Should extract markers from TMS links', () => { | ||
| const tmsUrlCase = testcases.find((tc) => tc.name.includes('TMS URL linked test')) | ||
| const tmsNameCase = testcases.find((tc) => tc.name.includes('TMS name linked test')) | ||
|
|
||
| expect(tmsUrlCase?.name.startsWith('ALR-123:')).toBe(true) | ||
| expect(tmsNameCase?.name.startsWith('TESTCASE-002:')).toBe(true) | ||
| }) | ||
|
|
||
| test('Should keep parameterized results as separate entries', () => { | ||
| const paramCases = testcases.filter((tc) => tc.name.startsWith('Param test')) | ||
| expect(paramCases).toHaveLength(2) | ||
| }) | ||
|
|
||
| test('Should handle empty results directory', async () => { | ||
| const emptyResults = await parseAllureResults( | ||
| './src/tests/fixtures/allure/empty', | ||
| './src/tests/fixtures/allure/empty', | ||
| { | ||
| skipStdout: 'never', | ||
| skipStderr: 'never', | ||
| } | ||
| ) | ||
| expect(emptyResults).toHaveLength(0) | ||
| }) | ||
|
|
||
| test('Should skip malformed or invalid result files with warnings', async () => { | ||
| const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}) | ||
|
|
||
| const results = await parseAllureResults(allureParserBasePath, allureParserBasePath, { | ||
| skipStdout: 'never', | ||
| skipStderr: 'never', | ||
| }) | ||
|
|
||
| expect(results).toHaveLength(9) | ||
| expect(warnSpy.mock.calls.length).toBeGreaterThanOrEqual(2) | ||
|
|
||
| const warnings = warnSpy.mock.calls.map((call) => String(call[0])) | ||
| expect(warnings.some((w) => w.includes('malformed-result.json'))).toBe(true) | ||
| expect(warnings.some((w) => w.includes('invalid-schema-result.json'))).toBe(true) | ||
|
|
||
| warnSpy.mockRestore() | ||
| }) | ||
| }) | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "name": "Test cart TEST-002", | ||
| "status": "passed", | ||
| "uuid": "et-2", | ||
| "start": 1700000200000, | ||
| "stop": 1700000200300, | ||
| "labels": [{ "name": "suite", "value": "ui.cart.spec.ts" }] | ||
| } |
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| matching attachment |
15 changes: 15 additions & 0 deletions
15
src/tests/fixtures/allure/matching-tcases/tc-2-result.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "name": "Test cart TEST-002", | ||
| "status": "passed", | ||
| "uuid": "tc-2", | ||
| "start": 1700000000000, | ||
| "stop": 1700000000500, | ||
| "attachments": [ | ||
| { | ||
| "name": "Attachment", | ||
| "source": "attachment.txt", | ||
| "type": "text/plain" | ||
| } | ||
| ], | ||
| "labels": [{ "name": "suite", "value": "ui.cart.spec.ts" }] | ||
| } |
15 changes: 15 additions & 0 deletions
15
src/tests/fixtures/allure/matching-tcases/tc-3-result.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "name": "Test checkout TEST-003", | ||
| "status": "passed", | ||
| "uuid": "tc-3", | ||
| "start": 1700000001000, | ||
| "stop": 1700000001400, | ||
| "attachments": [ | ||
| { | ||
| "name": "Attachment", | ||
| "source": "attachment.txt", | ||
| "type": "text/plain" | ||
| } | ||
| ], | ||
| "labels": [{ "name": "suite", "value": "ui.cart.spec.ts" }] | ||
| } |
15 changes: 15 additions & 0 deletions
15
src/tests/fixtures/allure/matching-tcases/tc-4-result.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "name": "About page content TEST-004", | ||
| "status": "passed", | ||
| "uuid": "tc-4", | ||
| "start": 1700000002000, | ||
| "stop": 1700000002700, | ||
| "attachments": [ | ||
| { | ||
| "name": "Attachment", | ||
| "source": "attachment.txt", | ||
| "type": "text/plain" | ||
| } | ||
| ], | ||
| "labels": [{ "name": "suite", "value": "ui.contents.spec.ts" }] | ||
| } |
15 changes: 15 additions & 0 deletions
15
src/tests/fixtures/allure/matching-tcases/tc-5-result.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "name": "Menu page content TEST-005", | ||
| "status": "passed", | ||
| "uuid": "tc-5", | ||
| "start": 1700000003000, | ||
| "stop": 1700000003600, | ||
| "attachments": [ | ||
| { | ||
| "name": "Attachment", | ||
| "source": "attachment.txt", | ||
| "type": "text/plain" | ||
| } | ||
| ], | ||
| "labels": [{ "name": "suite", "value": "ui.contents.spec.ts" }] | ||
| } |
15 changes: 15 additions & 0 deletions
15
src/tests/fixtures/allure/matching-tcases/tc-6-result.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "name": "Navigation bar items TEST-006", | ||
| "status": "failed", | ||
| "uuid": "tc-6", | ||
| "start": 1700000004000, | ||
| "stop": 1700000004800, | ||
| "attachments": [ | ||
| { | ||
| "name": "Attachment", | ||
| "source": "attachment.txt", | ||
| "type": "text/plain" | ||
| } | ||
| ], | ||
| "labels": [{ "name": "suite", "value": "ui.contents.spec.ts" }] | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| attachment content |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing test coverage for
skipStdout/skipStderron-successbehavior: Every test here usesskipStdout: 'never'andskipStderr: 'never'. ThebuildMessagefunction has branching logic foron-successthat is never exercised. The JUnit and Playwright parser tests each have dedicated tests for this behavior.Suggested additions:
messageis omitted for passed tests whenskipStdoutison-successtraceis omitted for passed tests whenskipStderrison-successon-successoptions