@@ -327,3 +327,101 @@ val unsupportedLanguagePath = """
327
327
}
328
328
testNavigation().catch(console.error);
329
329
""" .trimIndent()
330
+
331
+ val testRejectPathScript = """
332
+ const puppeteer = require('puppeteer');
333
+ async function testNavigation() {
334
+ const browser = await puppeteer.connect({
335
+ browserURL: "http://localhost:9222"
336
+ })
337
+ try {
338
+ const pages = await browser.pages()
339
+ for(const page of pages) {
340
+ const contents = await page.evaluate(el => el.innerHTML, await page.${' $' } (':root'));
341
+ const element = await page.${' $' } ('.mynah-chat-prompt-input')
342
+ if(element) {
343
+ const elements = await page.${' $' }${' $' } ('.mynah-chat-command-selector-command');
344
+ const attr = await Promise.all(
345
+ elements.map(elem => elem.evaluate(el => el.getAttribute('command')))
346
+ );
347
+ await page.type('.mynah-chat-prompt-input', '/test')
348
+ await page.keyboard.press('Enter');
349
+ await page.keyboard.press('Enter');
350
+ try {
351
+ await waitForElementWithText(page, "Q - Test")
352
+ console.log("new tab opened")
353
+ await page.waitForFunction(
354
+ () => {
355
+ const button = document.querySelector('button[action-id="utg_view_diff"]');
356
+ return button && button.isEnabled !== false && button.disabled !== true;
357
+ },
358
+ { timeout: 300000 }
359
+ );
360
+ await page.evaluate(() => {
361
+ const button = document.querySelector('button[action-id="utg_view_diff"]');
362
+ if (button) {
363
+ button.click();
364
+ } else {
365
+ throw new Error('Button not found after waiting');
366
+ }
367
+ });
368
+ console.log("View Diff opened")
369
+ await page.waitForFunction(
370
+ () => {
371
+ const button = document.querySelector('button[action-id="utg_reject"]');
372
+ return button && button.isEnabled !== false && button.disabled !== true;
373
+ },
374
+ { timeout: 300000 }
375
+ );
376
+ await page.evaluate(() => {
377
+ const button = document.querySelector('button[action-id="utg_reject"]');
378
+ if (button) {
379
+ button.click();
380
+ } else {
381
+ throw new Error('Accept button not found after waiting');
382
+ }
383
+ });
384
+ console.log("Result Reject")
385
+ await waitForElementWithText(page, "Unit test generation completed.")
386
+ console.log("Unit test generation completed.")
387
+ } catch (e) {
388
+ console.log("Element with text not found")
389
+ console.log(e)
390
+ throw e
391
+ }
392
+
393
+ }
394
+ }
395
+ } finally {
396
+ await browser.close();
397
+ }
398
+ }
399
+
400
+ async function waitForElementWithText(page, text) {
401
+ await page.waitForFunction(
402
+ (expectedText) => {
403
+ const elements = document.querySelectorAll('*');
404
+ return Array.from(elements).find(element =>
405
+ element.textContent?.trim() === expectedText
406
+ );
407
+ },
408
+ {},
409
+ text
410
+ );
411
+ }
412
+
413
+ async function waitAndGetElementByText(page, text) {
414
+ const element = await page.waitForFunction(
415
+ (expectedText) => {
416
+ const elements = document.querySelectorAll('*');
417
+ return Array.from(elements).find(element =>
418
+ element.textContent?.trim() === expectedText
419
+ );
420
+ },
421
+ {},
422
+ text
423
+ );
424
+ return element;
425
+ }
426
+ testNavigation().catch(console.error);
427
+ """ .trimIndent()
0 commit comments