|
3 | 3 | * SPDX-License-Identifier: Apache-2.0
|
4 | 4 | */
|
5 | 5 | import { WebviewView, By } from 'vscode-extension-tester'
|
| 6 | +import { waitForElement } from '../utils/generalUtils' |
6 | 7 |
|
7 | 8 | /**
|
8 |
| - * Clicks the tools to get to the MCP server overlay |
| 9 | + * Clicks the Rules button in the top bar |
9 | 10 | * @param webviewView The WebviewView instance
|
10 |
| - * @returns Promise<boolean> True if tools button was found and clicked, false otherwise |
11 | 11 | */
|
12 | 12 | export async function clickRulesButton(webviewView: WebviewView): Promise<void> {
|
13 |
| - const buttons = await webviewView.findElements( |
14 |
| - By.css('.mynah-button.mynah-button-secondary.fill-state-always.status-clear.mynah-ui-clickable-item') |
15 |
| - ) |
16 |
| - for (const button of buttons) { |
17 |
| - const span = await button.findElement(By.css('span')) |
18 |
| - const text = await span.getText() |
19 |
| - if (text === 'Rules') { |
20 |
| - await button.click() |
21 |
| - return |
22 |
| - } |
23 |
| - } |
24 |
| - throw new Error('Rules button not found') |
| 13 | + const wrapper = await webviewView.findElement(By.css('.mynah-chat-prompt-wrapper')) |
| 14 | + const topBar = await wrapper.findElement(By.css('.mynah-prompt-input-top-bar')) |
| 15 | + console.log('THIS WORKS 1') |
| 16 | + const buttons = await topBar.findElement(By.css('[data-testid="prompt-input-top-bar-button"]')) |
| 17 | + console.log('THIS WORKS 2') |
| 18 | + const button = await buttons.findElement(By.css('*')) |
| 19 | + console.log('THIS WORKS 3') |
| 20 | + await button.click() |
| 21 | +} |
| 22 | + |
| 23 | +/** |
| 24 | + * Creates a new rule with the specified name |
| 25 | + * @param webviewView The WebviewView instance |
| 26 | + * @param ruleName The name of the rule to create (defaults to "testRule") |
| 27 | + */ |
| 28 | +export async function createRule(webviewView: WebviewView, ruleName: string = 'testRule'): Promise<void> { |
| 29 | + const overlay = await waitForElement(webviewView, By.css('[data-testid="prompt-input-top-bar-action-overlay"]')) |
| 30 | + const create = overlay.findElement(By.css('[data-testid="prompt-input-quick-pick-item"]')) |
| 31 | + await create.click() |
| 32 | + const anotheroverlay = await waitForElement(webviewView, By.css('[data-testid="sheet-wrapper"]')) |
| 33 | + const input = await anotheroverlay.findElement(By.css('[data-testid="chat-item-form-item-text-input"]')) |
| 34 | + await input.sendKeys(ruleName) |
| 35 | + await clickCreateRule(webviewView) |
| 36 | +} |
| 37 | + |
| 38 | +/** |
| 39 | + * Clicks the Create button in the rule creation dialog |
| 40 | + * @param webviewView The WebviewView instance |
| 41 | + */ |
| 42 | +export async function clickCreateRule(webviewView: WebviewView): Promise<void> { |
| 43 | + const anotheroverlay = await waitForElement(webviewView, By.css('[data-testid="sheet-wrapper"]')) |
| 44 | + const buttonsContainer = await anotheroverlay.findElement(By.css('[data-testid="chat-item-buttons-wrapper"]')) |
| 45 | + const button = await buttonsContainer.findElements(By.css('[data-testid="chat-item-action-button"]')) |
| 46 | + await button[1].click() |
| 47 | +} |
| 48 | + |
| 49 | +/** |
| 50 | + * Clicks the Cancel button in the rule creation dialog |
| 51 | + * @param webviewView The WebviewView instance |
| 52 | + */ |
| 53 | +export async function clickCancelRule(webviewView: WebviewView): Promise<void> { |
| 54 | + const anotheroverlay = await waitForElement(webviewView, By.css('[data-testid="sheet-wrapper"]')) |
| 55 | + const buttonsContainer = await anotheroverlay.findElement(By.css('[data-testid="chat-item-buttons-wrapper"]')) |
| 56 | + const button = await buttonsContainer.findElements(By.css('[data-testid="chat-item-action-button"]')) |
| 57 | + await button[0].click() |
25 | 58 | }
|
0 commit comments