mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-17 09:00:06 +00:00
feat(sasjs-tests): granular test rerun
This commit is contained in:
@@ -32,6 +32,40 @@ export class TestSuiteElement extends HTMLElement {
|
|||||||
return this._suiteIndex
|
return this._suiteIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateTest(testIndex: number, testData: any) {
|
||||||
|
if (!this._suiteData) return
|
||||||
|
|
||||||
|
// Update the data
|
||||||
|
this._suiteData.completedTests[testIndex] = testData
|
||||||
|
|
||||||
|
// Update stats
|
||||||
|
this.updateStats()
|
||||||
|
|
||||||
|
// Update the specific test card
|
||||||
|
const testsContainer = this.shadow.getElementById('tests-container')
|
||||||
|
if (testsContainer) {
|
||||||
|
const cards = testsContainer.querySelectorAll('test-card')
|
||||||
|
const card = cards[testIndex] as TestCard
|
||||||
|
if (card) {
|
||||||
|
card.testData = testData
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateStats() {
|
||||||
|
if (!this._suiteData) return
|
||||||
|
|
||||||
|
const { completedTests } = this._suiteData
|
||||||
|
const passed = completedTests.filter((t) => t.status === 'passed').length
|
||||||
|
const failed = completedTests.filter((t) => t.status === 'failed').length
|
||||||
|
const running = completedTests.filter((t) => t.status === 'running').length
|
||||||
|
|
||||||
|
const statsEl = this.shadow.querySelector('.stats')
|
||||||
|
if (statsEl) {
|
||||||
|
statsEl.textContent = `Passed: ${passed} | Failed: ${failed} | Running: ${running}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (!this._suiteData) return
|
if (!this._suiteData) return
|
||||||
|
|
||||||
|
|||||||
@@ -146,8 +146,12 @@ export class TestsView extends HTMLElement {
|
|||||||
await this.testRunner.rerunTest(
|
await this.testRunner.rerunTest(
|
||||||
suiteIndex,
|
suiteIndex,
|
||||||
testIndex,
|
testIndex,
|
||||||
(completedSuites) => {
|
(suiteIdx, testIdx, testData) => {
|
||||||
this.renderResults(container, completedSuites)
|
const suites = container.querySelectorAll('test-suite')
|
||||||
|
const suiteElement = suites[suiteIdx] as TestSuiteElement
|
||||||
|
if (suiteElement && suiteElement.updateTest) {
|
||||||
|
suiteElement.updateTest(testIdx, testData)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,11 @@ export class TestRunner {
|
|||||||
async rerunTest(
|
async rerunTest(
|
||||||
suiteIndex: number,
|
suiteIndex: number,
|
||||||
testIndex: number,
|
testIndex: number,
|
||||||
onUpdate?: (completedSuites: CompletedTestSuite[]) => void
|
onUpdate?: (
|
||||||
|
suiteIndex: number,
|
||||||
|
testIndex: number,
|
||||||
|
testData: CompletedTest
|
||||||
|
) => void
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const suite = this.testSuites[suiteIndex]
|
const suite = this.testSuites[suiteIndex]
|
||||||
const test = suite.tests[testIndex]
|
const test = suite.tests[testIndex]
|
||||||
@@ -131,7 +135,11 @@ export class TestRunner {
|
|||||||
this.completedTestSuites[suiteIndex].completedTests[testIndex].status =
|
this.completedTestSuites[suiteIndex].completedTests[testIndex].status =
|
||||||
'running'
|
'running'
|
||||||
if (onUpdate) {
|
if (onUpdate) {
|
||||||
onUpdate([...this.completedTestSuites])
|
onUpdate(
|
||||||
|
suiteIndex,
|
||||||
|
testIndex,
|
||||||
|
this.completedTestSuites[suiteIndex].completedTests[testIndex]
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute test
|
// Execute test
|
||||||
@@ -147,7 +155,11 @@ export class TestRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (onUpdate) {
|
if (onUpdate) {
|
||||||
onUpdate([...this.completedTestSuites])
|
onUpdate(
|
||||||
|
suiteIndex,
|
||||||
|
testIndex,
|
||||||
|
this.completedTestSuites[suiteIndex].completedTests[testIndex]
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user