Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add couple of template tests #1662

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Node.js CI
on:
pull_request:
branches: ['**']
push:
branches: ['main']
merge_group:
types: [checks_requested]

Expand Down Expand Up @@ -40,7 +42,6 @@ jobs:
e2e_tests:
name: Playwright Tests
runs-on: ubuntu-latest
if: ${{github.event.action != 'checks_requested'}}
permissions:
contents: read

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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}}
Expand Down
7 changes: 6 additions & 1 deletion tests/suites/tenant/queryEditor/models/NewSqlDropdownMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
56 changes: 56 additions & 0 deletions tests/suites/tenant/queryEditor/queryTemplates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {RowTableAction} from '../summary/types';
import {
AsyncReplicationTemplates,
NewSqlDropdownMenu,
TablesTemplates,
TemplateCategory,
} from './models/NewSqlDropdownMenu';
import {QueryEditor, QueryTabs} from './models/QueryEditor';
Expand All @@ -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);
Expand Down
Loading