|
| 1 | +// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +package software.aws.toolkits.jetbrains.uitests.docTests.scripts |
| 5 | + |
| 6 | +// language=TS |
| 7 | +val updateReadmeSpecificChangesMakeChangesFlowScript = """ |
| 8 | + |
| 9 | + const puppeteer = require('puppeteer'); |
| 10 | + |
| 11 | + async function testNavigation() { |
| 12 | + const browser = await puppeteer.connect({ |
| 13 | + browserURL: 'http://localhost:9222' |
| 14 | + }); |
| 15 | + |
| 16 | + try { |
| 17 | + |
| 18 | + const pages = await browser.pages(); |
| 19 | + |
| 20 | + for(const page of pages) { |
| 21 | + const contents = await page.evaluate(el => el.innerHTML, await page.${'$'}(':root')); |
| 22 | + |
| 23 | + const element = await page.${'$'}('.mynah-chat-prompt-input'); |
| 24 | + if(element) { |
| 25 | + |
| 26 | + console.log('Typing /doc in the chat window'); |
| 27 | + |
| 28 | + await page.type('.mynah-chat-prompt-input', '/doc'); |
| 29 | + await page.keyboard.press('Enter'); |
| 30 | + |
| 31 | + console.log('Attempting to find and click Update an existing README button'); |
| 32 | + await findAndClickButton(page, 'Update an existing README', true, 10000); |
| 33 | + console.log('Attempting to find and click Make a specific change button'); |
| 34 | + await findAndClickButton(page, 'Make a specific change', true, 10000); |
| 35 | + console.log('Attempting to find and click Yes button to confirm option'); |
| 36 | + await findAndClickButton(page, 'Yes', true, 10000); |
| 37 | + |
| 38 | + console.log('Typing specific change instructions in the chat window'); |
| 39 | + await page.type('.mynah-chat-prompt-input', 'Add new section titled Programming Languages which describes the programming languages and version of programming language used in this project.'); |
| 40 | + await page.keyboard.press('Enter'); |
| 41 | + |
| 42 | + console.log('Waiting for updated README to be generated'); |
| 43 | + await new Promise(resolve => setTimeout(resolve, 90000)); |
| 44 | + console.log('Attempting to find and click Make changes button'); |
| 45 | + await findAndClickButton(page, 'Make changes', true, 10000); |
| 46 | + |
| 47 | + if (!makeChangeText) { |
| 48 | + console.log('Error: Test Failed'); |
| 49 | + console.log('Unable to find placeholder description test in Make Changes flow'); |
| 50 | + } else { |
| 51 | + console.log('Found expected placeholder text for Make Changes flow'); |
| 52 | + console.log('Test Successful'); |
| 53 | + } |
| 54 | + |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + } finally { |
| 59 | + await browser.close(); |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + testNavigation().catch((error) => { |
| 64 | + console.log('Error: Test Failed'); |
| 65 | + console.error(error); |
| 66 | + }); |
| 67 | +
|
| 68 | +""".trimIndent() |
| 69 | + |
| 70 | +// language=TS |
| 71 | +val updateReadmeSpecificChangesScript = """ |
| 72 | + |
| 73 | + const puppeteer = require('puppeteer'); |
| 74 | + |
| 75 | + async function testNavigation() { |
| 76 | + const browser = await puppeteer.connect({ |
| 77 | + browserURL: 'http://localhost:9222' |
| 78 | + }); |
| 79 | +
|
| 80 | + try { |
| 81 | +
|
| 82 | + const pages = await browser.pages(); |
| 83 | + |
| 84 | + for(const page of pages) { |
| 85 | + const contents = await page.evaluate(el => el.innerHTML, await page.${'$'}(':root')); |
| 86 | + |
| 87 | + const element = await page.${'$'}('.mynah-chat-prompt-input'); |
| 88 | +
|
| 89 | + if(element) { |
| 90 | + |
| 91 | + console.log('Typing /doc in the chat window'); |
| 92 | + |
| 93 | + await page.type('.mynah-chat-prompt-input', '/doc'); |
| 94 | + await page.keyboard.press('Enter'); |
| 95 | +
|
| 96 | + console.log('Attempting to find and click Update an existing README button'); |
| 97 | + await findAndClickButton(page, 'Update an existing README', true, 10000); |
| 98 | + console.log('Attempting to find and click Make a specific change button'); |
| 99 | + await findAndClickButton(page, 'Make a specific change', true, 10000); |
| 100 | + console.log('Attempting to find and click Yes button to confirm option'); |
| 101 | + await findAndClickButton(page, 'Yes', true, 10000); |
| 102 | + |
| 103 | + console.log('Typing specific change instructions in the chat window'); |
| 104 | + await page.type('.mynah-chat-prompt-input', 'Add new section titled Programming Languages which describes the programming languages and version of programming language used in this project.'); |
| 105 | + await page.keyboard.press('Enter'); |
| 106 | +
|
| 107 | + console.log('Waiting for updated README to be generated'); |
| 108 | + await new Promise(resolve => setTimeout(resolve, 90000)); |
| 109 | + |
| 110 | + console.log('Attempting to find and click Accept button'); |
| 111 | + await findAndClickButton(page, 'Accept', true, 10000); |
| 112 | + |
| 113 | + // find and confirm the updated readme |
| 114 | +
|
| 115 | + } |
| 116 | + } |
| 117 | +
|
| 118 | + } finally { |
| 119 | + await browser.close(); |
| 120 | + } |
| 121 | + } |
| 122 | +
|
| 123 | + testNavigation().catch((error) => { |
| 124 | + console.log('Error: Test Failed'); |
| 125 | + console.error(error); |
| 126 | + }); |
| 127 | + |
| 128 | +""".trimIndent() |
| 129 | + |
| 130 | +val updateReadmeSpecificChangesMakeChangesFlowTestScript = updateReadmeSpecificChangesMakeChangesFlowScript.plus(findAndClickButtonScript) |
| 131 | +val updateReadmeSpecificChangesTestScript = updateReadmeSpecificChangesScript.plus(findAndClickButtonScript) |
0 commit comments