Skip to content

Commit 9ec4551

Browse files
Anton StandrikAnton Standrik
authored andcommitted
fix: add couple of template tests
1 parent 0e5c356 commit 9ec4551

File tree

3 files changed

+63
-1
lines changed

3 files changed

+63
-1
lines changed

tests/suites/tenant/queryEditor/models/NewSqlDropdownMenu.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ export enum AsyncReplicationTemplates {
1616
Drop = 'Drop async replication',
1717
}
1818

19+
export enum TablesTemplates {
20+
UpdateTable = 'Update table',
21+
CreateRowTable = 'Create row table',
22+
}
23+
1924
export class NewSqlDropdownMenu {
2025
private dropdownButton: Locator;
2126
private menu: Locator;
@@ -40,7 +45,7 @@ export class NewSqlDropdownMenu {
4045
await categoryItem.hover();
4146
}
4247

43-
async selectTemplate(template: AsyncReplicationTemplates) {
48+
async selectTemplate(template: AsyncReplicationTemplates | TablesTemplates) {
4449
const templateItem = this.subMenu.getByRole('menuitem').filter({hasText: template});
4550
await templateItem.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
4651
await templateItem.click();

tests/suites/tenant/queryEditor/models/QueryEditor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,13 @@ export class QueryEditor {
109109
async clickRunButton() {
110110
await this.runButton.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
111111
await this.runButton.click();
112+
await this.page.waitForTimeout(1000);
112113
}
113114

114115
async clickExplainButton() {
115116
await this.explainButton.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
116117
await this.explainButton.click();
118+
await this.page.waitForTimeout(1000);
117119
}
118120

119121
async getExplainResult(type: ExplainResultType) {

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {RowTableAction} from '../summary/types';
88
import {
99
AsyncReplicationTemplates,
1010
NewSqlDropdownMenu,
11+
TablesTemplates,
1112
TemplateCategory,
1213
} from './models/NewSqlDropdownMenu';
1314
import {QueryEditor, QueryTabs} from './models/QueryEditor';
@@ -26,6 +27,60 @@ test.describe('Query Templates', () => {
2627
await tenantPage.goto(pageQueryParams);
2728
});
2829

30+
test('Update table template should not run successfully', async ({page}) => {
31+
const newSqlDropdown = new NewSqlDropdownMenu(page);
32+
const queryEditor = new QueryEditor(page);
33+
34+
// Open dropdown and select Update table template
35+
await newSqlDropdown.clickNewSqlButton();
36+
await newSqlDropdown.hoverCategory(TemplateCategory.Tables);
37+
await newSqlDropdown.selectTemplate(TablesTemplates.UpdateTable);
38+
39+
// Try to run the query
40+
await queryEditor.clickRunButton();
41+
42+
// Verify that execution fails
43+
try {
44+
await queryEditor.waitForStatus('Failed');
45+
// If we reach here, the test passed because execution failed as expected
46+
} catch (error) {
47+
throw new Error('Update table template should not have executed successfully');
48+
}
49+
});
50+
51+
test('Create row table template should handle both success and failure cases', async ({
52+
page,
53+
}) => {
54+
const newSqlDropdown = new NewSqlDropdownMenu(page);
55+
const queryEditor = new QueryEditor(page);
56+
57+
// Open dropdown and select Create row table template
58+
await newSqlDropdown.clickNewSqlButton();
59+
await newSqlDropdown.hoverCategory(TemplateCategory.Tables);
60+
await newSqlDropdown.selectTemplate(TablesTemplates.CreateRowTable);
61+
62+
// Try to run the query
63+
await queryEditor.clickRunButton();
64+
65+
try {
66+
// Wait for either Completed or Failed status
67+
const status = await queryEditor.getExecutionStatus();
68+
69+
if (status === 'Failed') {
70+
// If failed, verify it's the expected "path exists" error
71+
const errorMessage = await queryEditor.getErrorMessage();
72+
expect(errorMessage).toContain('path exist, request accepts it');
73+
} else {
74+
// If not failed, verify it completed successfully
75+
expect(status).toBe('Completed');
76+
}
77+
} catch (error) {
78+
throw new Error(
79+
'Query execution neither completed successfully nor failed with expected error',
80+
);
81+
}
82+
});
83+
2984
test('Unsaved changes modal appears when switching between templates', async ({page}) => {
3085
const objectSummary = new ObjectSummary(page);
3186
const unsavedChangesModal = new UnsavedChangesModal(page);

0 commit comments

Comments
 (0)