()
| 242 | * Ensure a Code session is open for the active workspace. |
| 243 | */ |
| 244 | export async function ensureCodeSessionOpen(): Promise<void> { |
| 245 | const chatInput = await $('[data-testid="chat-input-container"]'); |
| 246 | if (await chatInput.isExisting()) { |
| 247 | return; |
| 248 | } |
| 249 | |
| 250 | const selectors = [ |
| 251 | '.bitfun-nav-panel__workspace-create-main--split-left', |
| 252 | '[data-testid="chat-input-send-btn"]', |
| 253 | ]; |
| 254 | |
| 255 | let opened = false; |
| 256 | for (const selector of selectors) { |
| 257 | const element = await $(selector); |
| 258 | if (await element.isExisting()) { |
| 259 | if (selector !== '[data-testid="chat-input-send-btn"]') { |
| 260 | await element.click(); |
| 261 | } |
| 262 | opened = true; |
| 263 | break; |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | if (!opened) { |
| 268 | const fallbackButton = await $('//button[contains(normalize-space(.), "Code")]'); |
| 269 | await fallbackButton.click(); |
| 270 | } |
| 271 | |
| 272 | await browser.waitUntil(async () => { |
| 273 | const input = await $('[data-testid="chat-input-container"]'); |
| 274 | return input.isExisting(); |
| 275 | }, { |
| 276 | timeout: 15000, |
| 277 | interval: 500, |
| 278 | timeoutMsg: 'Code session did not open', |
| 279 | }); |
| 280 | } |
| 281 | |
| 282 | /** |
| 283 | * Checks if any workspace is currently active in the frontend. |
no test coverage detected