Skip to content

Commit a9c0b5c

Browse files
chore: Polish UI review workflow and scripts
- Fix ESLint and Prettier errors in `scripts/ci/run-ui-review.ts` by using `unknown` for strict type checking instead of `any`. - Polish regex pattern array mapping for Bot commands in `.github/workflows/comment-ops.yml` to correctly identify `gemini-review`. Co-authored-by: arii <342438+arii@users.noreply.github.com>
1 parent e448d1d commit a9c0b5c

2 files changed

Lines changed: 49 additions & 32 deletions

File tree

.github/workflows/comment-ops.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
BODY: ${{ github.event.comment.body }}
3737
run: |
3838
COMMANDS=(
39-
"gemini-bot:review"
39+
"(gemini-bot|gemini-review):review"
4040
"pr-squash:squash"
4141
"conflict-resolve:resolve"
4242
"gemini-triage:triage"

scripts/ci/run-ui-review.ts

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ async function performUIReview() {
1313

1414
const baseUrl = process.env.DEPLOYMENT_URL || 'http://localhost:3000'
1515

16-
await context.addCookies([{ name: 'session-id', value: 'mock', url: baseUrl }])
16+
await context.addCookies([
17+
{ name: 'session-id', value: 'mock', url: baseUrl },
18+
])
1719

1820
const page = await context.newPage()
1921
const targetUrl = new URL(baseUrl)
@@ -28,7 +30,11 @@ async function performUIReview() {
2830
})
2931

3032
// Inject mock application state so the UI review has something to analyze
31-
await page.waitForFunction(() => !!(window as any).__TEST_CONTROLS__)
33+
await page.waitForFunction(
34+
() =>
35+
!!(window as unknown as { __TEST_CONTROLS__: boolean })
36+
.__TEST_CONTROLS__
37+
)
3238

3339
// Build type-safe messages outside evaluate to ensure types are correct at compile time
3440
const timerMessage: ServerMessage = {
@@ -42,26 +48,28 @@ async function performUIReview() {
4248
mode: 'TABATA',
4349
workDuration: 30,
4450
restDuration: 10,
45-
soundEventId: 0
46-
}
51+
soundEventId: 0,
52+
},
4753
}
4854

4955
const hrmMessage: ServerMessage = {
5056
type: 'HRM_UPDATE',
51-
payload: [{
52-
clientId: 'mock-1',
53-
value: 155,
54-
maxHr: 185,
55-
zone: 'ZONE_3',
56-
percentage: 85,
57-
name: 'Mock Device',
58-
calories: 120
59-
}]
57+
payload: [
58+
{
59+
clientId: 'mock-1',
60+
value: 155,
61+
maxHr: 185,
62+
zone: 'ZONE_3',
63+
percentage: 85,
64+
name: 'Mock Device',
65+
calories: 120,
66+
},
67+
],
6068
}
6169

6270
const spotifyInitMessage: ServerMessage = {
6371
type: 'SPOTIFY_SERVICE_INIT_UPDATE',
64-
payload: true
72+
payload: true,
6573
}
6674

6775
const spotifyMessage: ServerMessage = {
@@ -74,28 +82,35 @@ async function performUIReview() {
7482
name: 'UI Review Track',
7583
artist: 'Gemini',
7684
albumName: 'Review Album',
77-
albumArtUrl: ''
85+
albumArtUrl: '',
7886
},
7987
is_playing: true,
8088
volume_percent: 50,
8189
isMuted: false,
82-
progress_ms: 30000
83-
}
84-
}
90+
progress_ms: 30000,
91+
},
92+
},
8593
}
8694

87-
await page.evaluate(({ timerMsg, hrmMsg, spotifyInitMsg, spotifyMsg }) => {
88-
const dispatch = (window as any).__TEST_CONTROLS__.dispatch
89-
dispatch(timerMsg)
90-
dispatch(hrmMsg)
91-
dispatch(spotifyInitMsg)
92-
dispatch(spotifyMsg)
93-
}, {
94-
timerMsg: timerMessage,
95-
hrmMsg: hrmMessage,
96-
spotifyInitMsg: spotifyInitMessage,
97-
spotifyMsg: spotifyMessage
98-
})
95+
await page.evaluate(
96+
({ timerMsg, hrmMsg, spotifyInitMsg, spotifyMsg }) => {
97+
const dispatch = (
98+
window as unknown as {
99+
__TEST_CONTROLS__: { dispatch: (msg: ServerMessage) => void }
100+
}
101+
).__TEST_CONTROLS__.dispatch
102+
dispatch(timerMsg)
103+
dispatch(hrmMsg)
104+
dispatch(spotifyInitMsg)
105+
dispatch(spotifyMsg)
106+
},
107+
{
108+
timerMsg: timerMessage,
109+
hrmMsg: hrmMessage,
110+
spotifyInitMsg: spotifyInitMessage,
111+
spotifyMsg: spotifyMessage,
112+
}
113+
)
99114

100115
// Force layout stabilization for the screenshot
101116
await page.addStyleTag({
@@ -134,7 +149,9 @@ async function performUIReview() {
134149
])
135150

136151
const response = await result.response
137-
const feedback = response.candidates?.[0]?.content?.parts?.[0]?.text || "No feedback generated."
152+
const feedback =
153+
response.candidates?.[0]?.content?.parts?.[0]?.text ||
154+
'No feedback generated.'
138155

139156
const prNumber = process.env.PR_NUMBER
140157
const githubToken = process.env.GITHUB_TOKEN

0 commit comments

Comments
 (0)