11// Control UI tests cover GitHub link hover card behavior.
2+ import { mkdir } from "node:fs/promises" ;
3+ import path from "node:path" ;
24import { chromium , type Browser , type BrowserContext , type Locator } from "playwright" ;
35import { afterAll , afterEach , beforeAll , describe , expect , it } from "vitest" ;
46import {
@@ -119,8 +121,8 @@ describeControlUiE2e("GitHub link hover cards", () => {
119121 {
120122 type : "text" ,
121123 text : [
122- "Review [#99816]( https://github.com/openclaw/openclaw/pull/99816) ," ,
123- "then [#99815]( https://github.com/openclaw/openclaw/issues/99815) ." ,
124+ "Review https://github.com/openclaw/openclaw/pull/99816," ,
125+ "then https://github.com/openclaw/openclaw/issues/99815." ,
124126 "A [missing item](https://github.com/openclaw/openclaw/issues/999999) stays usable." ,
125127 "The [repository](https://github.com/openclaw/openclaw) has no item preview." ,
126128 "Styling notes live in [the docs](https://docs.openclaw.ai/web/control-ui)." ,
@@ -134,7 +136,19 @@ describeControlUiE2e("GitHub link hover cards", () => {
134136 } ) ;
135137 await page . goto ( `${ server . baseUrl } chat` ) ;
136138
137- const pullLink = page . getByRole ( "link" , { name : "#99816" } ) ;
139+ const message = page . locator ( ".chat-text" ) . filter ( { hasText : "Review" } ) ;
140+ const artifactDir = process . env . OPENCLAW_UI_E2E_ARTIFACT_DIR ?. trim ( ) ;
141+ if ( artifactDir ) {
142+ await mkdir ( artifactDir , { recursive : true } ) ;
143+ await message . screenshot ( { path : path . join ( artifactDir , "github-references-light.png" ) } ) ;
144+ await page . emulateMedia ( { colorScheme : "dark" } ) ;
145+ await expect . poll ( ( ) => page . locator ( "html" ) . getAttribute ( "data-theme-mode" ) ) . toBe ( "dark" ) ;
146+ await message . screenshot ( { path : path . join ( artifactDir , "github-references-dark.png" ) } ) ;
147+ await page . emulateMedia ( { colorScheme : "light" } ) ;
148+ await expect . poll ( ( ) => page . locator ( "html" ) . getAttribute ( "data-theme-mode" ) ) . toBe ( "light" ) ;
149+ }
150+
151+ const pullLink = page . getByRole ( "link" , { name : "openclaw/openclaw#99816" } ) ;
138152
139153 // The mark carries the link signal at rest, so the underline only returns on
140154 // hover. Non-GitHub links keep the base underline, which keeps the rule scoped.
@@ -160,7 +174,7 @@ describeControlUiE2e("GitHub link hover cards", () => {
160174 expect ( pullBox ! . x + pullBox ! . width ) . toBeLessThanOrEqual ( 1180 ) ;
161175 expect ( pullBox ! . y + pullBox ! . height ) . toBeLessThanOrEqual ( 800 ) ;
162176
163- const issueLink = page . getByRole ( "link" , { name : "#99815" } ) ;
177+ const issueLink = page . getByRole ( "link" , { name : "openclaw/openclaw #99815" } ) ;
164178 await issueLink . hover ( ) ;
165179 await expectText ( card , "Keep hover previews compact" ) ;
166180 await expectText ( card , "octocat" ) ;
0 commit comments