-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from metabase/add-query-builder-viewer-and-fix…
…-bugs Add query builder viewer and fix bugs
- Loading branch information
Showing
31 changed files
with
2,625 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: CI | ||
|
||
on: ['pull_request'] | ||
|
||
jobs: | ||
test: | ||
name: 🧪 Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: 🔧 Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
cache: 'yarn' | ||
|
||
- name: 📦 Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: 🧪 Run tests | ||
run: yarn test:ci | ||
|
||
- name: 📊 Upload test results | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: test-results | ||
path: | | ||
junit.xml | ||
coverage/ | ||
lint: | ||
name: 🔍 Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: 🔧 Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
cache: 'yarn' | ||
|
||
- name: 📦 Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: 🔍 Run ESLint | ||
run: yarn lint | ||
|
||
- name: 💅 Check formatting | ||
run: yarn format:check | ||
|
||
typecheck: | ||
name: ʦ Type check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: 🔧 Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
cache: 'yarn' | ||
|
||
- name: 📦 Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: ʦ Type check | ||
run: yarn tsc --noEmit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { describe, it, expect } from 'vitest' | ||
|
||
import { ConsoleOutput } from './ConsoleOutput' | ||
import { fireEvent, render, screen } from '../test/test-utils' | ||
|
||
const sampleErrors = [ | ||
'"[webpack-dev-server] ERROR in ./components/ErrorPages/utils.ts\\n × Module not found: Error message 1"', | ||
'"Warning: Something went wrong\\nStack trace for warning"', | ||
'"[webpack-dev-server] Another error occurred\\nStack trace for error"', | ||
'{"level": "info", "message": "Server started successfully", "stack": "Info stack trace"}', | ||
'"Regular log message without specific level"', | ||
] | ||
|
||
describe('ConsoleOutput', () => { | ||
it('renders without crashing', () => { | ||
expect(() => render(<ConsoleOutput errors={[]} />)).not.toThrow() | ||
}) | ||
|
||
it('displays errors correctly', () => { | ||
render(<ConsoleOutput errors={sampleErrors} />) | ||
|
||
// Using more precise text matching | ||
expect( | ||
screen.getByText('[webpack-dev-server] ERROR in ./components/ErrorPages/utils.ts') | ||
).toBeInTheDocument() | ||
expect(screen.getByText('Warning: Something went wrong')).toBeInTheDocument() | ||
expect(screen.getByText('[webpack-dev-server] Another error occurred')).toBeInTheDocument() | ||
}) | ||
|
||
it('filters errors based on search input', () => { | ||
render(<ConsoleOutput errors={sampleErrors} />) | ||
|
||
const searchInput = screen.getByPlaceholderText('Search logs...') | ||
fireEvent.change(searchInput, { target: { value: 'message 1' } }) | ||
|
||
expect( | ||
screen.getByText('[webpack-dev-server] ERROR in ./components/ErrorPages/utils.ts') | ||
).toBeInTheDocument() | ||
expect(screen.queryByText('Warning: Something went wrong')).not.toBeInTheDocument() | ||
expect( | ||
screen.queryByText('[webpack-dev-server] Another error occurred') | ||
).not.toBeInTheDocument() | ||
}) | ||
|
||
it('toggles error details when clicked', () => { | ||
render(<ConsoleOutput errors={sampleErrors} />) | ||
|
||
// Find and click the first error | ||
const firstError = screen.getByText( | ||
'[webpack-dev-server] ERROR in ./components/ErrorPages/utils.ts' | ||
) | ||
fireEvent.click(firstError) | ||
|
||
// Check if stack trace is visible | ||
expect(screen.getByText('× Module not found: Error message 1')).toBeInTheDocument() | ||
}) | ||
|
||
it('applies correct styling based on error level', () => { | ||
render(<ConsoleOutput errors={sampleErrors} />) | ||
|
||
// Error should have red styling | ||
const errorElement = screen | ||
.getByText('[webpack-dev-server] ERROR in ./components/ErrorPages/utils.ts') | ||
.closest('.bg-red-100') | ||
expect(errorElement).toBeInTheDocument() | ||
|
||
// Warning should have yellow styling | ||
const warningElement = screen | ||
.getByText('Warning: Something went wrong') | ||
.closest('.bg-yellow-100') | ||
expect(warningElement).toBeInTheDocument() | ||
}) | ||
|
||
it('handles empty error list', () => { | ||
render(<ConsoleOutput errors={[]} />) | ||
const searchInput = screen.getByPlaceholderText('Search logs...') | ||
expect(searchInput).toBeInTheDocument() | ||
expect(screen.queryByRole('button')).not.toBeInTheDocument() | ||
}) | ||
|
||
it('expands info logs to show stack trace', () => { | ||
render(<ConsoleOutput errors={[sampleErrors[3]]} />) | ||
|
||
// Find and click the info message | ||
const infoMessage = screen.getByText('Server started successfully') | ||
fireEvent.click(infoMessage) | ||
|
||
// Check if stack trace is visible | ||
expect(screen.getByText('Info stack trace')).toBeInTheDocument() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.