diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25e967581..8acd59ac0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,8 @@ name: Node.js CI on: pull_request: branches: ['**'] + push: + branches: ['main'] merge_group: types: [checks_requested] @@ -40,7 +42,6 @@ jobs: e2e_tests: name: Playwright Tests runs-on: ubuntu-latest - if: ${{github.event.action != 'checks_requested'}} permissions: contents: read @@ -187,7 +188,7 @@ jobs: deploy_and_update: name: Deploy and Update PR needs: [e2e_tests, bundle_size] - if: ${{always() && github.event.pull_request.head.repo.full_name == github.repository && github.event.action != 'checks_requested'}} + if: ${{always() && (github.ref == 'refs/heads/main' || github.event.pull_request.head.repo.full_name == github.repository)}} runs-on: ubuntu-latest permissions: contents: write @@ -213,8 +214,14 @@ jobs: - name: Copy new report run: | - mkdir -p gh-pages/${{ github.event.pull_request.number }} - cp -r playwright-artifacts/playwright-report/* gh-pages/${{ github.event.pull_request.number }}/ + if [ "${{ github.event_name }}" = "pull_request" ]; then + REPORT_DIR="${{ github.event.pull_request.number }}" + else + REPORT_DIR="main" + fi + rm -rf gh-pages/$REPORT_DIR + mkdir -p gh-pages/$REPORT_DIR + cp -r playwright-artifacts/playwright-report/* gh-pages/$REPORT_DIR/ - name: Deploy report to GitHub Pages uses: peaceiris/actions-gh-pages@v3 @@ -226,6 +233,7 @@ jobs: - name: Count new tests id: count_tests + if: github.event_name == 'pull_request' run: | git fetch origin main:main new_tests=0 @@ -253,6 +261,7 @@ jobs: echo "new_tests=$new_tests" >> $GITHUB_OUTPUT - name: Update PR description + if: github.event_name == 'pull_request' uses: actions/github-script@v6 with: github-token: ${{secrets.GITHUB_TOKEN}} diff --git a/tests/suites/tenant/queryEditor/models/NewSqlDropdownMenu.ts b/tests/suites/tenant/queryEditor/models/NewSqlDropdownMenu.ts index 407ac0d3d..93dc58a6a 100644 --- a/tests/suites/tenant/queryEditor/models/NewSqlDropdownMenu.ts +++ b/tests/suites/tenant/queryEditor/models/NewSqlDropdownMenu.ts @@ -16,6 +16,11 @@ export enum AsyncReplicationTemplates { Drop = 'Drop async replication', } +export enum TablesTemplates { + UpdateTable = 'Update table', + CreateRowTable = 'Create row table', +} + export class NewSqlDropdownMenu { private dropdownButton: Locator; private menu: Locator; @@ -40,7 +45,7 @@ export class NewSqlDropdownMenu { await categoryItem.hover(); } - async selectTemplate(template: AsyncReplicationTemplates) { + async selectTemplate(template: AsyncReplicationTemplates | TablesTemplates) { const templateItem = this.subMenu.getByRole('menuitem').filter({hasText: template}); await templateItem.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT}); await templateItem.click(); diff --git a/tests/suites/tenant/queryEditor/queryTemplates.test.ts b/tests/suites/tenant/queryEditor/queryTemplates.test.ts index 3ad8d4acf..f5e098db6 100644 --- a/tests/suites/tenant/queryEditor/queryTemplates.test.ts +++ b/tests/suites/tenant/queryEditor/queryTemplates.test.ts @@ -8,6 +8,7 @@ import {RowTableAction} from '../summary/types'; import { AsyncReplicationTemplates, NewSqlDropdownMenu, + TablesTemplates, TemplateCategory, } from './models/NewSqlDropdownMenu'; import {QueryEditor, QueryTabs} from './models/QueryEditor'; @@ -26,6 +27,61 @@ test.describe('Query Templates', () => { await tenantPage.goto(pageQueryParams); }); + test('Update table template should not run successfully', async ({page}) => { + const newSqlDropdown = new NewSqlDropdownMenu(page); + const queryEditor = new QueryEditor(page); + + // Open dropdown and select Update table template + await newSqlDropdown.clickNewSqlButton(); + await newSqlDropdown.hoverCategory(TemplateCategory.Tables); + await newSqlDropdown.selectTemplate(TablesTemplates.UpdateTable); + + // Try to run the query + await queryEditor.clickRunButton(); + + // Verify that execution fails + try { + await queryEditor.waitForStatus('Failed'); + // If we reach here, the test passed because execution failed as expected + } catch (error) { + throw new Error('Update table template should not have executed successfully'); + } + }); + + test('Create row table template should handle both success and failure cases', async ({ + page, + }) => { + const newSqlDropdown = new NewSqlDropdownMenu(page); + const queryEditor = new QueryEditor(page); + + // Open dropdown and select Create row table template + await newSqlDropdown.clickNewSqlButton(); + await newSqlDropdown.hoverCategory(TemplateCategory.Tables); + await newSqlDropdown.selectTemplate(TablesTemplates.CreateRowTable); + + // Try to run the query + await queryEditor.clickRunButton(); + await page.waitForTimeout(500); + + try { + // Wait for either Completed or Failed status + const status = await queryEditor.getExecutionStatus(); + + if (status === 'Failed') { + // If failed, verify it's the expected "path exists" error + const errorMessage = await queryEditor.getErrorMessage(); + expect(errorMessage).toContain('path exist, request accepts it'); + } else { + // If not failed, verify it completed successfully + expect(status).toBe('Completed'); + } + } catch (error) { + throw new Error( + 'Query execution neither completed successfully nor failed with expected error', + ); + } + }); + test('Unsaved changes modal appears when switching between templates', async ({page}) => { const objectSummary = new ObjectSummary(page); const unsavedChangesModal = new UnsavedChangesModal(page);