Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tests/fixtures/allure/matching-tcases/005-result.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"attachments": [
{
"name": "attachment",
"source": "shared-attachment.txt",
"source": "006-container.json",
"type": "text/plain"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"attachments": [
{
"name": "attachment",
"source": "existing-attachment.txt",
"source": "001-result.json",
"type": "text/plain"
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/tests/fixtures/junit-xml/matching-tcases.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
<testcase name="Menu page content TEST-007" classname="ui.contents.spec.ts" time="3.325">
<system-out>
<![CDATA[
[[ATTACHMENT|./matching-tcases.xml]]
[[ATTACHMENT|./empty-tsuite.xml]]
]]>
</system-out>
</testcase>
Expand Down
2 changes: 1 addition & 1 deletion src/tests/fixtures/junit-xml/missing-attachments.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
<testcase name="Menu page content TEST-007" classname="ui.contents.spec.ts" time="3.325">
<system-out>
<![CDATA[
[[ATTACHMENT|./matching-tcases.xml]]
[[ATTACHMENT|./empty-tsuite.xml]]
]]>
</system-out>
</testcase>
Expand Down
2 changes: 1 addition & 1 deletion src/tests/fixtures/playwright-json/matching-tcases.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
{
"name": "attachment",
"contentType": "application/json",
"path": "./matching-tcases.json"
"path": "./empty-tsuite.json"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
{
"name": "attachment",
"contentType": "application/json",
"path": "./matching-tcases.json"
"path": "./empty-tsuite.json"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"suites": [
{
"title": "multi-annotation.spec.ts",
"specs": [
{
"title": "Login flow covers multiple cases",
"tags": [],
"tests": [
{
"annotations": [
{
"type": "test case",
"description": "https://qas.eu1.qasphere.com/project/TEST/tcase/10427"
},
{
"type": "test case",
"description": "https://qas.eu1.qasphere.com/project/TEST/tcase/10427"
},
{
"type": "test case",
"description": "https://qas.eu1.qasphere.com/project/TEST/tcase/10428"
}
],
"expectedStatus": "passed",
"projectName": "chromium",
"results": [
{
"status": "passed",
"errors": [],
"stdout": [],
"stderr": [],
"retry": 0,
"duration": 2500,
"attachments": [
{
"name": "attachment",
"contentType": "application/json",
"path": "./multi-annotation-with-attachments.json"
}
]
}
],
"status": "expected"
}
]
},
{
"title": "Navigation bar items TEST-006",
"tags": [],
"tests": [
{
"annotations": [],
"expectedStatus": "passed",
"projectName": "chromium",
"results": [
{
"status": "passed",
"errors": [],
"stdout": [],
"stderr": [],
"retry": 0,
"duration": 1000,
"attachments": [
{
"name": "attachment",
"contentType": "application/json",
"path": "./multi-annotation-with-attachments.json"
}
]
}
],
"status": "expected"
}
]
}
],
"suites": []
}
]
}
34 changes: 34 additions & 0 deletions src/tests/fixtures/testcases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,38 @@ export const runTestCases = [
pos: 1,
},
},
{
id: '1CBd7Qsn1_abc10427xyz',
version: 1,
folderId: 13,
pos: 4,
seq: 10427,
title: 'Login flow case 1',
priority: 'medium',
status: 'open',
folder: {
id: 13,
parentId: 7,
title: 'multi-annotation.spec.ts',
projectId: '1CBd7PKmG_khB9xTm8gL2oe',
pos: 1,
},
},
{
id: '1CBd7Qsn2_abc10428xyz',
version: 1,
folderId: 13,
pos: 5,
seq: 10428,
title: 'Login flow case 2',
priority: 'medium',
status: 'open',
folder: {
id: 13,
parentId: 7,
title: 'multi-annotation.spec.ts',
projectId: '1CBd7PKmG_khB9xTm8gL2oe',
pos: 1,
},
},
]
42 changes: 42 additions & 0 deletions src/tests/marker-parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,48 @@ describe('nameMatchesTCase', () => {
test('no match for wrong seq', () => {
expect(junit.nameMatchesTCase('TEST-002 Cart', 'TEST', 3)).toBe(false)
})

describe('does not prefix-match longer sequences', () => {
test('QS1-104 does not match name containing QS1-10427', () => {
expect(playwright.nameMatchesTCase('QS1-10427: some test', 'QS1', 104)).toBe(false)
})

test('QS1-107 does not match name containing QS1-10775', () => {
expect(playwright.nameMatchesTCase('QS1-10775: some test', 'QS1', 107)).toBe(false)
})

test('QS1-10427 still matches itself', () => {
expect(playwright.nameMatchesTCase('QS1-10427: some test', 'QS1', 10427)).toBe(true)
})

test('QS1-104 matches when it appears exactly', () => {
expect(playwright.nameMatchesTCase('QS1-104: some test', 'QS1', 104)).toBe(true)
})

test('QS1-104 matches at end of name', () => {
expect(playwright.nameMatchesTCase('some test QS1-104', 'QS1', 104)).toBe(true)
})

test('QS1-104 matches in middle of name with boundaries', () => {
expect(playwright.nameMatchesTCase('some QS1-104 test', 'QS1', 104)).toBe(true)
})

test('marker surrounded by parens still matches', () => {
expect(playwright.nameMatchesTCase('some test (QS1-10427)', 'QS1', 10427)).toBe(true)
})

test('marker surrounded by parens does not prefix-match', () => {
expect(playwright.nameMatchesTCase('some test (QS1-10427)', 'QS1', 104)).toBe(false)
})

test('marker adjacent to underscore still matches', () => {
expect(playwright.nameMatchesTCase('test_QS1-104_login', 'QS1', 104)).toBe(true)
})

test('marker adjacent to bracket still matches', () => {
expect(playwright.nameMatchesTCase('case[QS1-104]', 'QS1', 104)).toBe(true)
})
})
})

describe('separator-bounded hyphenless (JUnit only)', () => {
Expand Down
132 changes: 132 additions & 0 deletions src/tests/playwright-json-parsing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,138 @@ describe('Playwright JSON parsing', () => {
expect(testcases[2].name).toBe('PRJ-789: PRJ-456: Test with marker in name and annotation')
})

test('Should fan out multiple results for test with multiple annotations', async () => {
const jsonPath = `${playwrightJsonBasePath}/multi-annotation-with-attachments.json`
const jsonContent = await readFile(jsonPath, 'utf8')

const { testCaseResults: testcases } = await parsePlaywrightJson(jsonContent, '', {
skipStdout: 'never',
skipStderr: 'never',
})

// Fixture has 1 test with 3 annotations (2x 10427 deduped to 1, plus 10428) + 1 test with no annotations = 3 results
expect(testcases).toHaveLength(3)
expect(testcases[0].name).toBe('TEST-10427: Login flow covers multiple cases')
expect(testcases[1].name).toBe('TEST-10428: Login flow covers multiple cases')
expect(testcases[2].name).toBe('Navigation bar items TEST-006')

// The two fan-out entries share the same status, duration, folder
for (const tc of testcases.slice(0, 2)) {
expect(tc.status).toBe('passed')
expect(tc.timeTaken).toBe(2500)
expect(tc.folder).toBe('multi-annotation.spec.ts')
}

// All three entries have attachments from the fixture
for (const tc of testcases) {
expect(tc.attachments).toHaveLength(1)
}
})

test('Should still produce one result for single annotation', async () => {
const jsonContent = JSON.stringify({
suites: [
{
title: 'single.spec.ts',
specs: [
{
title: 'Simple test',
tags: [],
tests: [
{
annotations: [
{
type: 'test case',
description: 'https://qas.eu1.qasphere.com/project/PRJ/tcase/100',
},
],
expectedStatus: 'passed',
projectName: 'chromium',
results: [
{
status: 'passed',
errors: [],
stdout: [],
stderr: [],
retry: 0,
duration: 1000,
attachments: [],
},
],
status: 'expected',
},
],
},
],
suites: [],
},
],
})

const { testCaseResults: testcases } = await parsePlaywrightJson(jsonContent, '', {
skipStdout: 'never',
skipStderr: 'never',
})

expect(testcases).toHaveLength(1)
expect(testcases[0].name).toBe('PRJ-100: Simple test')
})

test('Should fan out by annotations even when name has a marker', async () => {
const jsonContent = JSON.stringify({
suites: [
{
title: 'precedence.spec.ts',
specs: [
{
title: 'PRJ-999: Test with marker in name',
tags: [],
tests: [
{
annotations: [
{
type: 'test case',
description: 'https://qas.eu1.qasphere.com/project/PRJ/tcase/100',
},
{
type: 'test case',
description: 'https://qas.eu1.qasphere.com/project/PRJ/tcase/200',
},
],
expectedStatus: 'passed',
projectName: 'chromium',
results: [
{
status: 'passed',
errors: [],
stdout: [],
stderr: [],
retry: 0,
duration: 1000,
attachments: [],
},
],
status: 'expected',
},
],
},
],
suites: [],
},
],
})

const { testCaseResults: testcases } = await parsePlaywrightJson(jsonContent, '', {
skipStdout: 'never',
skipStderr: 'never',
})

// Annotations take precedence — two results, not one from the name marker
expect(testcases).toHaveLength(2)
expect(testcases[0].name).toBe('PRJ-100: PRJ-999: Test with marker in name')
expect(testcases[1].name).toBe('PRJ-200: PRJ-999: Test with marker in name')
})

test('Should map test status correctly', async () => {
const jsonContent = JSON.stringify({
suites: [
Expand Down
Loading
Loading