|
1 | 1 | import { Selector, t } from 'testcafe';
|
2 | 2 | import { InstancePage } from './instance-page';
|
| 3 | +import { Common } from '../helpers/common'; |
3 | 4 |
|
4 | 5 | export class WorkbenchPage extends InstancePage {
|
5 | 6 | //CSS selectors
|
@@ -48,6 +49,13 @@ export class WorkbenchPage extends InstancePage {
|
48 | 49 | parametersAnchor = Selector('[data-testid=parameters-anchor]');
|
49 | 50 | clearResultsBtn = Selector('[data-testid=clear-history-btn]');
|
50 | 51 |
|
| 52 | + // OVERLAY/LOADING ELEMENTS |
| 53 | + // Selector for the problematic overlay that obstructs workbench interactions in CI |
| 54 | + overlayContainer = Selector('.RI-flex-group.RI-flex-row').filter((node) => { |
| 55 | + const style = node.getAttribute('style'); |
| 56 | + return !!(style && style.includes('height: 100%')); |
| 57 | + }); |
| 58 | + |
51 | 59 | //ICONS
|
52 | 60 | noCommandHistoryIcon = Selector('[data-testid=wb_no-results__icon]');
|
53 | 61 | groupModeIcon = Selector('[data-testid=group-mode-tooltip]');
|
@@ -144,16 +152,44 @@ export class WorkbenchPage extends InstancePage {
|
144 | 152 | }
|
145 | 153 |
|
146 | 154 | /**
|
147 |
| - * Send a command in Workbench |
| 155 | + * Send a command in Workbench with retry mechanism for CI overlay issues |
148 | 156 | * @param command The command
|
149 | 157 | * @param speed The speed in seconds. Default is 1
|
150 |
| - * @param paste |
| 158 | + * @param paste Whether to paste the command. Default is true |
151 | 159 | */
|
152 | 160 | async sendCommandInWorkbench(command: string, speed = 1, paste = true): Promise<void> {
|
153 |
| - await t |
154 |
| - .click(this.queryInput) |
155 |
| - .typeText(this.queryInput, command, { replace: true, speed, paste }) |
156 |
| - .click(this.submitCommandButton); |
| 161 | + const maxRetries = 3; |
| 162 | + let lastError: Error | null = null; |
| 163 | + |
| 164 | + for (let i = 0; i < maxRetries; i++) { |
| 165 | + try { |
| 166 | + // Wait for any loading states to complete before attempting interaction |
| 167 | + await Common.waitForElementNotVisible(this.runButtonSpinner); |
| 168 | + await Common.waitForElementNotVisible(this.loadedCommand); |
| 169 | + |
| 170 | + // Wait for the problematic overlay to disappear (CI-specific issue) |
| 171 | + await Common.waitForElementNotVisible(this.overlayContainer); |
| 172 | + |
| 173 | + // Perform the actual workbench interaction |
| 174 | + await t |
| 175 | + .click(this.queryInput) |
| 176 | + .typeText(this.queryInput, command, { replace: true, speed, paste }) |
| 177 | + .click(this.submitCommandButton); |
| 178 | + |
| 179 | + return; // Success, exit the retry loop |
| 180 | + } catch (error) { |
| 181 | + lastError = error as Error; |
| 182 | + console.warn(`Workbench command attempt ${i + 1}/${maxRetries} failed:`, error); |
| 183 | + |
| 184 | + if (i === maxRetries - 1) { |
| 185 | + // Final attempt failed, throw the error |
| 186 | + throw new Error(`Failed to send command "${command}" after ${maxRetries} attempts. Last error: ${lastError.message}`); |
| 187 | + } |
| 188 | + |
| 189 | + // Wait before retrying to allow any animations/transitions to complete |
| 190 | + await t.wait(1000); |
| 191 | + } |
| 192 | + } |
157 | 193 | }
|
158 | 194 |
|
159 | 195 | /**
|
|
0 commit comments