Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
Fix error message display in the spec report
Browse files Browse the repository at this point in the history
  • Loading branch information
leordev committed Aug 23, 2024
1 parent 293e5b3 commit 0a5e653
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
52 changes: 52 additions & 0 deletions .github/actions/specs-report/__tests__/summary-report.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import * as core from '@actions/core'
import { TestVector, TestVectorReport } from '../src/test-vectors'
import { generateSummary } from '../src/summary-report'

describe('summary-report', () => {
it('should display the error message in the markdown table properly', () => {
jest.spyOn(core.summary, 'write').mockImplementation()

const tbdexKtErrorSample: TestVector = {
feature: 'Protocol',
name: 'parse_rfq',
file: '/home/runner/work/tbdex-kt/tbdex-kt/tbdex/hosted/test-vectors/protocol/vectors/parse-rfq.json',
testCases: [
{
name: 'parse_rfq',
classname: 'tbdex.sdk.protocol.TbdexTestVectorsProtocol',
time: 13.913,
error: [
{
inner:
'java.lang.IllegalStateException: Verification failed. Failed to resolve kid. Error: internalError\n\tat web5.sdk.jose.jws.DecodedJws.verify(Jws.kt:262)\n\tat tbdex.sdk.protocol.SignatureVerifier.verify(SignatureVerifier.kt:60)\n\tat tbdex.sdk.protocol.models.Message.verify(Message.kt:82)\n\tat tbdex.sdk.protocol.Parser.parseMessage(Parser.kt:45)\n\tat tbdex.sdk.protocol.TbdexTestVectorsProtocol.parse_rfq(TbdexTestVectorsProtocol.kt:145)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat java.base/jdk.internal.reflect....\n',
message:
'Verification failed. Failed to resolve kid. Error: internalError',
type: 'java.lang.IllegalStateException'
}
],
'system-err': [
'SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".\nSLF4J: Defaulting to no-operation (NOP) logger implementation\nSLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.\n'
]
}
]
}

const report: TestVectorReport = {
totalJunitFiles: 0,
totalTestVectors: 1,
totalJunitTestCases: 1,
specTestCases: 1,
specFailedTestCases: 1,
specPassedTestCases: 0,
specSkippedTestCases: 0,
missingVectors: [],
failedVectors: [tbdexKtErrorSample],
skippedVectors: [],
successVectors: []
}

const summary = generateSummary(report)

expect(summary).toContain('Failed to resolve kid.')
})
})
7 changes: 4 additions & 3 deletions .github/actions/specs-report/src/summary-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ const addFailedVectorsSection = (
{ data: 'Failure Message', header: true }
]
const failedTestsRows = vector.testCases
.filter(testCase => testCase.failure)
.filter(testCase => testCase.failure || testCase.error)
.map(testCase => [
testCase.name ?? 'Unnamed test',
failureToMessageRows(testCase.failure ?? [])
failureToMessageRows(testCase.error ?? testCase.failure ?? [])
])
core.summary.addTable([failedTestsHeaderRow, ...failedTestsRows])
}
Expand Down Expand Up @@ -175,9 +175,10 @@ const failureToMessageRows = (
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''')
.substring(0, 128)
return `<b>${detail.message}</b><br/><pre>${
escapedInnerHTML || 'Unknown error'
}\n</pre>`
}...\n</pre>`
})
.join('<br>\n')
}

0 comments on commit 0a5e653

Please sign in to comment.