1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-10 17:04:36 +00:00

feat(sasjs-tests): granular test rerun

This commit is contained in:
mulahasanovic
2025-11-18 17:13:37 +01:00
parent f26d51747f
commit 6f73011bc1
3 changed files with 55 additions and 5 deletions

View File

@@ -32,6 +32,40 @@ export class TestSuiteElement extends HTMLElement {
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() {
if (!this._suiteData) return

View File

@@ -146,8 +146,12 @@ export class TestsView extends HTMLElement {
await this.testRunner.rerunTest(
suiteIndex,
testIndex,
(completedSuites) => {
this.renderResults(container, completedSuites)
(suiteIdx, testIdx, testData) => {
const suites = container.querySelectorAll('test-suite')
const suiteElement = suites[suiteIdx] as TestSuiteElement
if (suiteElement && suiteElement.updateTest) {
suiteElement.updateTest(testIdx, testData)
}
}
)
}

View File

@@ -117,7 +117,11 @@ export class TestRunner {
async rerunTest(
suiteIndex: number,
testIndex: number,
onUpdate?: (completedSuites: CompletedTestSuite[]) => void
onUpdate?: (
suiteIndex: number,
testIndex: number,
testData: CompletedTest
) => void
): Promise<void> {
const suite = this.testSuites[suiteIndex]
const test = suite.tests[testIndex]
@@ -131,7 +135,11 @@ export class TestRunner {
this.completedTestSuites[suiteIndex].completedTests[testIndex].status =
'running'
if (onUpdate) {
onUpdate([...this.completedTestSuites])
onUpdate(
suiteIndex,
testIndex,
this.completedTestSuites[suiteIndex].completedTests[testIndex]
)
}
// Execute test
@@ -147,7 +155,11 @@ export class TestRunner {
}
if (onUpdate) {
onUpdate([...this.completedTestSuites])
onUpdate(
suiteIndex,
testIndex,
this.completedTestSuites[suiteIndex].completedTests[testIndex]
)
}
}