Skip to content

Commit 9a578ba

Browse files
Feat/remove handlebars helpers (#195)
1 parent a9748ca commit 9a578ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+4552
-3051
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ node_modules/
44
coverage/
55
templates/
66
scripts/
7+
*.test.ts

__tests__/github/handler.test.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,87 @@ import { Inputs } from '../../src/types'
1111
import { Report } from 'ctrf'
1212
import * as githubClient from '../../src/client/github'
1313
import { components } from '@octokit/openapi-types'
14+
import Handlebars from 'handlebars'
1415

1516
type IssueComment = components['schemas']['issue-comment']
1617

18+
beforeAll(() => {
19+
Handlebars.registerHelper(
20+
'formatDurationFromTimes',
21+
function (start: number, stop: number) {
22+
return '0ms'
23+
}
24+
)
25+
26+
Handlebars.registerHelper('getCtrfEmoji', (status: string) => {
27+
return '✅'
28+
})
29+
30+
Handlebars.registerHelper('addAll', function (...args: any[]) {
31+
return 0
32+
})
33+
34+
Handlebars.registerHelper('countFlaky', function (tests: any[]) {
35+
return 0
36+
})
37+
38+
Handlebars.registerHelper(
39+
'formatDurationFromTimes',
40+
function (start: number, stop: number) {
41+
return '0ms'
42+
}
43+
)
44+
45+
Handlebars.registerHelper('formatDurationMs', function (duration: number) {
46+
return '0ms'
47+
})
48+
49+
Handlebars.registerHelper('escapeMarkdown', function (text: string) {
50+
return text || ''
51+
})
52+
53+
Handlebars.registerHelper('gt', function (a: number, b: number) {
54+
return false
55+
})
56+
57+
Handlebars.registerHelper('lt', function (a: number, b: number) {
58+
return false
59+
})
60+
61+
Handlebars.registerHelper('eq', function (a: any, b: any) {
62+
return false
63+
})
64+
65+
Handlebars.registerHelper(
66+
'toPercent',
67+
function (value: number, decimals: number = 2) {
68+
return '0%'
69+
}
70+
)
71+
72+
Handlebars.registerHelper('uppercase', function (text: string) {
73+
return text || ''
74+
})
75+
76+
Handlebars.registerHelper(
77+
'slice',
78+
function (array: any[], start: number, end: number) {
79+
return []
80+
}
81+
)
82+
83+
Handlebars.registerHelper(
84+
'sliceString',
85+
function (str: string, _start: number, _end: number) {
86+
return str || ''
87+
}
88+
)
89+
90+
Handlebars.registerHelper('countFlakyTests', function (tests: any[]) {
91+
return 0
92+
})
93+
})
94+
1795
jest.mock('@actions/core')
1896
jest.mock('@actions/github', () => ({
1997
context: {

__tests__/handlebars/string.test.ts

Lines changed: 0 additions & 67 deletions
This file was deleted.

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

community-reports/cobra-report/cobra-report.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
| {{ctrf.summary.tests}} | {{ctrf.summary.passed}} | {{ctrf.summary.failed}} | {{ctrf.summary.skipped}} |
55

66
### Failed Tests:
7-
{{#if (anyFailedTests ctrf.tests)}}
7+
{{#if (gt ctrf.summary.failed 0)}}
88
<table>
99
<thead>
1010
<tr>
@@ -19,7 +19,7 @@
1919
<td>{{getCtrfEmoji "failed"}} {{name}}</td>
2020
<td>
2121
{{#if message}}
22-
{{~{formatMessage message}}}
22+
{{~{formatTestMessage message}}}
2323
{{else}}
2424
No failure message
2525
{{/if}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
| **Tests {{getCtrfEmoji "tests"}}** | **Passed {{getCtrfEmoji "passed"}}** | **Failed {{getCtrfEmoji "failed"}}** | **Duration {{getCtrfEmoji "duration"}}** |
22
| --- | --- | --- | --- |
3-
| {{ctrf.summary.tests}} | {{ctrf.summary.passed}} | {{ctrf.summary.failed}} | {{formatDuration ctrf.summary.start ctrf.summary.stop}} |
3+
| {{ctrf.summary.tests}} | {{ctrf.summary.passed}} | {{ctrf.summary.failed}} | {{formatDurationFromTimes ctrf.summary.start ctrf.summary.stop}} |

ctrf-reports/ctrf-report.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"duration": 800,
2828
"message": "\u001b[31mTimed out 5000ms waiting for \u001b[39m\u001b[2mexpect(\u001b[22m\u001b[31mlocator\u001b[39m\u001b[2m).\u001b[22mtoHaveTitle\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m)\u001b[22m\n\nLocator: locator(':root')\nExpected pattern: \u001b[32m/Playwrc cight/\u001b[39m\nReceived string: \u001b[31m\"Fast and reliable end-to-end testing for modern web apps | Playwright\"\u001b[39m\nCall log:\n \u001b[2m- expect.toHaveTitle with timeout 5000ms\u001b[22m\n\u001b[2m - waiting for locator(':root')\u001b[22m\n\u001b[2m - locator resolved to <html lang=\"en\" dir=\"ltr\" data-theme=\"light\" data-has-…>…</html>\u001b[22m\n\u001b[2m - unexpected value \"Fast and reliable end-to-end testing for modern web apps | Playwright\"\u001b[22m\n",
2929
"trace": "ProfileTest.js:45",
30-
"ai": "The test failed because the page title didn't match the expected value within the given timeout period.\n\nTo resolve this issue, you should first check if the title of the page is correct in your application. It seems there might be a typo or a misunderstanding about what the actual title should be. If 'Common Test Report Format' is indeed the correct title, you'll need to update your test expectations. On the other hand, if 'Uncommon Test Report Format' is the intended title, you'll need to fix the title in your application code.\n\nAnother possibility is that the page might be taking longer to load than expected, causing the title to not appear within the 5-second timeout. In this case, you could try increasing the timeout duration in your test to give the page more time to load completely.",
30+
"ai": "The test failed because the expected page title did not match the actual title within the specified 5000ms timeout. The test was looking for a title matching the pattern '/Playwrc cight/', but received 'Fast and reliable end-to-end testing for modern web apps | Playwright' instead. \n\nTo resolve this, you should verify if the page title in your application is correct. There might be a typo in the expected title pattern in your test, which should be corrected to match the actual title. Alternatively, if the page takes longer to load, consider increasing the timeout duration in your test to allow more time for the title to appear.",
3131
"filePath": "tests/login.test.ts",
3232
"suite": "login.test.ts > profile"
3333
},
@@ -61,7 +61,8 @@
6161
"message": "Network Timeout",
6262
"trace": "ProfileUpdateTest.js:60",
6363
"filePath": "tests/network.test.ts",
64-
"suite": "network.test.ts > network"
64+
"suite": "network.test.ts > network",
65+
"ai": "The test failed because of a \"Network Timeout\" error, as indicated in the error message. The stack trace points to line 60 in the file ProfileUpdateTest.js. This suggests that the test was designed to simulate a network failure during a profile update, but it actually encountered a real network timeout. To resolve this issue, you should check the network configuration in your test environment to ensure it's correctly set up to simulate the desired network conditions. Also, verify that the timeout settings in your test code are appropriate for the expected network behavior."
6566
},
6667
{
6768
"name": "should load user data",
@@ -93,6 +94,9 @@
9394
"filePath": "tests/network.test.ts",
9495
"suite": "network.test.ts > network"
9596
}
96-
]
97+
],
98+
"extra": {
99+
"ai": "The test suite experienced failures due to issues related to timing and network configuration. The first test failed because the expected page title did not match the actual title within the specified timeout, suggesting a potential mismatch in the expected title pattern or insufficient timeout duration. The second test encountered a real network timeout instead of the simulated failure it was designed to test, indicating problems with the network setup or timeout settings in the test environment. These failures point to a need for reviewing and adjusting both the expected outcomes and the test environment configurations to better align with actual application behavior and network conditions."
100+
}
97101
}
98102
}

dist/community-reports/cobra-report.hbs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/community-reports/summary-short.hbs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)