Skip to content

Commit e8e6e69

Browse files
Anton StandrikAnton Standrik
authored andcommitted
fix: add status check test
1 parent 07bd3f6 commit e8e6e69

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

tests/suites/tenant/queryEditor/QueryEditor.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,4 +237,20 @@ export class QueryEditor {
237237
await this.indicatorIcon.waitFor({state: 'hidden', timeout: VISIBILITY_TIMEOUT});
238238
return true;
239239
}
240+
241+
async waitForStatus(expectedStatus: string, timeout = VISIBILITY_TIMEOUT) {
242+
await this.executionStatus.waitFor({state: 'visible', timeout});
243+
244+
// Keep checking status until it matches or times out
245+
const startTime = Date.now();
246+
while (Date.now() - startTime < timeout) {
247+
const status = await this.executionStatus.innerText();
248+
if (status === expectedStatus) {
249+
return true;
250+
}
251+
await this.page.waitForTimeout(100); // Small delay between checks
252+
}
253+
254+
throw new Error(`Status did not change to ${expectedStatus} within ${timeout}ms`);
255+
}
240256
}

tests/suites/tenant/queryEditor/queryEditor.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ test.describe('Test Query Editor', async () => {
7373
await queryEditor.setQuery(invalidQuery);
7474
await queryEditor.clickRunButton();
7575

76-
const statusElement = await queryEditor.getExecutionStatus();
77-
await expect(statusElement).toBe('Failed');
78-
76+
await expect(queryEditor.waitForStatus('Failed')).resolves.toBe(true);
7977
const errorMessage = await queryEditor.getErrorMessage();
8078
await expect(errorMessage).toContain('Column references are not allowed without FROM');
8179
});
@@ -123,13 +121,9 @@ test.describe('Test Query Editor', async () => {
123121
await queryEditor.clickRunButton();
124122

125123
await expect(queryEditor.isStopButtonVisible()).resolves.toBe(true);
126-
127124
await queryEditor.clickStopButton();
128-
await page.waitForTimeout(1000); // Wait for the editor to initialize
129125

130-
// Check for a message or indicator that the query was stopped
131-
const statusElement = await queryEditor.getExecutionStatus();
132-
await expect(statusElement).toBe('Stopped');
126+
await expect(queryEditor.waitForStatus('Stopped')).resolves.toBe(true);
133127
});
134128

135129
test('Stop button is not visible for quick queries', async ({page}) => {
@@ -239,4 +233,12 @@ test.describe('Test Query Editor', async () => {
239233
await queryEditor.clickRunButton();
240234
await expect(queryEditor.resultTable.getResultHeadText()).resolves.toBe('Truncated(1)');
241235
});
236+
237+
test('Query execution status changes correctly', async ({page}) => {
238+
const queryEditor = new QueryEditor(page);
239+
await queryEditor.setQuery(testQuery);
240+
await queryEditor.clickRunButton();
241+
242+
await expect(queryEditor.waitForStatus('Completed')).resolves.toBe(true);
243+
});
242244
});

0 commit comments

Comments
 (0)