Skip to content

Commit 0cb1eb3

Browse files
committed
initializing rules
1 parent 7c86b73 commit 0cb1eb3

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
import { WebviewView, By } from 'vscode-extension-tester'
6+
7+
/**
8+
* Clicks the tools to get to the MCP server overlay
9+
* @param webviewView The WebviewView instance
10+
* @returns Promise<boolean> True if tools button was found and clicked, false otherwise
11+
*/
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')
25+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
import '../utils/setup'
6+
import { WebviewView } from 'vscode-extension-tester'
7+
import { closeAllTabs } from '../utils/cleanupUtils'
8+
import { testContext } from '../utils/testContext'
9+
import { clickRulesButton } from '../helpers/rulesHelper'
10+
import { sleep } from '../utils/generalUtils'
11+
12+
describe('Amazon Q Rules Functionality', function () {
13+
// this timeout is the general timeout for the entire test suite
14+
this.timeout(150000)
15+
let webviewView: WebviewView
16+
17+
before(async function () {
18+
webviewView = testContext.webviewView
19+
})
20+
21+
after(async function () {
22+
await closeAllTabs(webviewView)
23+
})
24+
25+
afterEach(async () => {})
26+
27+
it('Rules Test', async () => {
28+
/**
29+
* TODO abstractions
30+
*
31+
* click the rules button DONE
32+
* list all the possible rules (disappearing overlay again UGH)
33+
* check and uncheck a rule
34+
* click create new rule
35+
* enter rule name
36+
* click create rule
37+
* click cancel rule
38+
*/
39+
await clickRulesButton(webviewView)
40+
41+
await sleep(5000)
42+
})
43+
})

0 commit comments

Comments
 (0)