Elffuss BraidHub

kikocis/continue public

bd477015e5d4 · 4.9 KiBRawPermalink
1import { By, WebDriver, WebView } from "vscode-extension-tester";
2
3import { SelectorUtils } from "./SelectorUtils";
4
5export class GUISelectors {
6 public static getDescription(view: WebView) {
7 return view.findWebElement(By.xpath("//*[contains(text(), 'quickly')]"));
8 }
9
10 public static getMessageInputFields(view: WebView) {
11 return view.findWebElements(By.className("tiptap"));
12 }
13
14 public static async getMessageInputFieldAtIndex(
15 view: WebView,
16 index: number,
17 ) {
18 const elements = await this.getMessageInputFields(view);
19 return elements[index];
20 }
21
22 public static getAllIframes(driver: WebDriver) {
23 return driver.findElements(By.css("iframe"));
24 }
25
26 public static getReactIframe(driver: WebDriver) {
27 return driver.findElement(By.css("iframe"));
28 }
29
30 public static getSubmitInputButton(view: WebView) {
31 return SelectorUtils.getElementByDataTestId(view, "submit-input-button");
32 }
33
34 public static getAcceptToolCallButton(view: WebView) {
35 return view.findWebElement(
36 By.css("[data-testid*='accept-tool-call-button']"),
37 );
38 }
39
40 public static getRejectToolCallButton(view: WebView) {
41 return view.findWebElement(
42 By.css("[data-testid*='reject-tool-call-button']"),
43 );
44 }
45
46 public static getToolCallStatusMessage(view: WebView) {
47 return SelectorUtils.getElementByDataTestId(view, "tool-call-title");
48 }
49
50 public static getToolButton(view: WebView) {
51 return SelectorUtils.getElementByDataTestId(
52 view,
53 `block-settings-toolbar-icon-tools`,
54 );
55 }
56
57 public static getToolPolicyButton(view: WebView, toolName: string) {
58 return SelectorUtils.getElementByDataTestId(
59 view,
60 `tool-policy-item-${toolName}`,
61 );
62 }
63
64 public static getModelDropdownButton(view: WebView) {
65 return SelectorUtils.getElementByDataTestId(view, "model-select-button");
66 }
67
68 public static getModeDropdownButton(view: WebView) {
69 return SelectorUtils.getElementByDataTestId(view, "mode-select-button");
70 }
71
72 public static getFirstContextProviderDropdownItem(view: WebView) {
73 return SelectorUtils.getElementByDataTestId(
74 view,
75 "context-provider-dropdown-item",
76 );
77 }
78
79 public static getContextItemsPeek(view: WebView) {
80 return SelectorUtils.getElementByDataTestId(view, "context-items-peek");
81 }
82
83 public static getFirstContextItemsPeekItem(view: WebView) {
84 return SelectorUtils.getElementByDataTestId(
85 view,
86 "context-items-peek-item",
87 );
88 }
89
90 public static getRulesPeek(view: WebView) {
91 return SelectorUtils.getElementByDataTestId(view, "rules-peek");
92 }
93
94 public static getFirstRulesPeekItem(view: WebView) {
95 return SelectorUtils.getElementByDataTestId(view, "rules-peek-item");
96 }
97
98 public static getNthHistoryTableRow(view: WebView, index: number) {
99 return SelectorUtils.getElementByDataTestId(view, `history-row-${index}`);
100 }
101
102 public static getNthMessageDeleteButton(view: WebView, index: number) {
103 return SelectorUtils.getElementByDataTestId(
104 view,
105 `delete-button-${index}`,
106 );
107 }
108
109 public static getModelDropdownOption(view: WebView, option: string) {
110 return view.findWebElement(
111 By.xpath(`//*[@role="listbox"]//*[contains(text(), "${option}")]`),
112 );
113 }
114
115 public static getModeDropdownOption(view: WebView, option: string) {
116 return view.findWebElement(
117 By.xpath(`//*[@role="listbox"]//*[contains(text(), "${option}")]`),
118 );
119 }
120
121 public static getOnboardingTabButton(view: WebView, title: string) {
122 return SelectorUtils.getElementByDataTestId(
123 view,
124 `onboarding-tab-${title}`,
125 );
126 }
127
128 public static getBestChatApiKeyInput(view: WebView) {
129 return SelectorUtils.getElementByDataTestId(
130 view,
131 "best-chat-api-key-input",
132 );
133 }
134
135 public static getBestAutocompleteApiKeyInput(view: WebView) {
136 return SelectorUtils.getElementByDataTestId(
137 view,
138 "best-autocomplete-api-key-input",
139 );
140 }
141
142 public static getTutorialCard(view: WebView) {
143 return SelectorUtils.getElementByDataTestId(view, "tutorial-card");
144 }
145
146 public static getThreadMessageByText(view: WebView, text: string) {
147 return view.findWebElement(
148 By.xpath(`//*[@class="thread-message"]//*[contains(text(), "${text}")]`),
149 );
150 }
151
152 public static getHistoryNavButton(view: WebView) {
153 return SelectorUtils.getElementByAriaLabel(view, "View History");
154 }
155
156 public static getNewSessionNavButton(view: WebView) {
157 return SelectorUtils.getElementByAriaLabel(view, "New Session");
158 }
159
160 public static async getInputBoxCodeBlockAtIndex(
161 view: WebView,
162 index: number,
163 ) {
164 const firstInputField = await this.getMessageInputFieldAtIndex(view, index);
165
166 const codeBlockElement = await firstInputField.findElement(
167 By.xpath(".//code"),
168 );
169
170 return codeBlockElement;
171 }
172
173 public static getContinueExtensionBadge(view: WebView) {
174 return SelectorUtils.getElementByAriaLabel(view, "Continue");
175 }
176}