Skip to content

Commit 80b3b88

Browse files
astandrikAnton Standrik
and
Anton Standrik
authored
fix: add couple of template tests (#1662)
Co-authored-by: Anton Standrik <astandrik@Antons-MacBook-Air.local>
1 parent ce4693a commit 80b3b88

File tree

3 files changed

+75
-5
lines changed

3 files changed

+75
-5
lines changed

.github/workflows/ci.yml

+13-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Node.js CI
33
on:
44
pull_request:
55
branches: ['**']
6+
push:
7+
branches: ['main']
68
merge_group:
79
types: [checks_requested]
810

@@ -40,7 +42,6 @@ jobs:
4042
e2e_tests:
4143
name: Playwright Tests
4244
runs-on: ubuntu-latest
43-
if: ${{github.event.action != 'checks_requested'}}
4445
permissions:
4546
contents: read
4647

@@ -187,7 +188,7 @@ jobs:
187188
deploy_and_update:
188189
name: Deploy and Update PR
189190
needs: [e2e_tests, bundle_size]
190-
if: ${{always() && github.event.pull_request.head.repo.full_name == github.repository && github.event.action != 'checks_requested'}}
191+
if: ${{always() && (github.ref == 'refs/heads/main' || github.event.pull_request.head.repo.full_name == github.repository)}}
191192
runs-on: ubuntu-latest
192193
permissions:
193194
contents: write
@@ -213,8 +214,14 @@ jobs:
213214

214215
- name: Copy new report
215216
run: |
216-
mkdir -p gh-pages/${{ github.event.pull_request.number }}
217-
cp -r playwright-artifacts/playwright-report/* gh-pages/${{ github.event.pull_request.number }}/
217+
if [ "${{ github.event_name }}" = "pull_request" ]; then
218+
REPORT_DIR="${{ github.event.pull_request.number }}"
219+
else
220+
REPORT_DIR="main"
221+
fi
222+
rm -rf gh-pages/$REPORT_DIR
223+
mkdir -p gh-pages/$REPORT_DIR
224+
cp -r playwright-artifacts/playwright-report/* gh-pages/$REPORT_DIR/
218225
219226
- name: Deploy report to GitHub Pages
220227
uses: peaceiris/actions-gh-pages@v3
@@ -226,6 +233,7 @@ jobs:
226233

227234
- name: Count new tests
228235
id: count_tests
236+
if: github.event_name == 'pull_request'
229237
run: |
230238
git fetch origin main:main
231239
new_tests=0
@@ -253,6 +261,7 @@ jobs:
253261
echo "new_tests=$new_tests" >> $GITHUB_OUTPUT
254262
255263
- name: Update PR description
264+
if: github.event_name == 'pull_request'
256265
uses: actions/github-script@v6
257266
with:
258267
github-token: ${{secrets.GITHUB_TOKEN}}

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

+6-1
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/queryTemplates.test.ts

+56
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,61 @@ 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+
await page.waitForTimeout(500);
65+
66+
try {
67+
// Wait for either Completed or Failed status
68+
const status = await queryEditor.getExecutionStatus();
69+
70+
if (status === 'Failed') {
71+
// If failed, verify it's the expected "path exists" error
72+
const errorMessage = await queryEditor.getErrorMessage();
73+
expect(errorMessage).toContain('path exist, request accepts it');
74+
} else {
75+
// If not failed, verify it completed successfully
76+
expect(status).toBe('Completed');
77+
}
78+
} catch (error) {
79+
throw new Error(
80+
'Query execution neither completed successfully nor failed with expected error',
81+
);
82+
}
83+
});
84+
2985
test('Unsaved changes modal appears when switching between templates', async ({page}) => {
3086
const objectSummary = new ObjectSummary(page);
3187
const unsavedChangesModal = new UnsavedChangesModal(page);

0 commit comments

Comments
 (0)