MCPcopy Create free account
hub / github.com/GCWing/BitFun / ensureCodeSessionOpen

Function ensureCodeSessionOpen

tests/e2e/helpers/workspace-helper.ts:244–280  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

242 * Ensure a Code session is open for the active workspace.
243 */
244export 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.

Callers 3

ensureWorkspaceOpenFunction · 0.90

Calls 2

clickMethod · 0.80
$Function · 0.50

Tested by

no test coverage detected