-
Notifications
You must be signed in to change notification settings - Fork 593
Add preliminary UI tests #210
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
210975e
Add test dependencies
olaservo fc76a7c
Add setup file and remove old testing mock that no longer exists from…
olaservo 85f0e21
Use commonjs for jest
olaservo 668cc91
Add jest-dom types
olaservo 4517044
Remove setup
olaservo 61e229a
Add sidebar tests
olaservo cab1ed3
Add some json form tests and handle css in ui tests
olaservo 5735f23
Add tests related to issues/187 to confirm fixed
olaservo fa3e286
Fix formatting
olaservo a7f2515
Add failing ToolsTab test that should get fixed with pull/198
olaservo b7fa236
Fix formatting
olaservo 40213bb
Merge branch 'main' into add-ui-tests
olaservo 379486b
Add failing test for pull/206
olaservo 951db44
Merge branch 'add-ui-tests' of https://github.com/olaservo/inspector …
olaservo 65a0d46
Fix formatting
olaservo 25f5bb7
Merge branch 'main' into add-ui-tests
olaservo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 @@ | ||
module.exports = {}; |
This file contains hidden or 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,95 @@ | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import { describe, it, expect, jest } from '@jest/globals'; | ||
import DynamicJsonForm from '../DynamicJsonForm'; | ||
import type { JsonSchemaType } from '../DynamicJsonForm'; | ||
|
||
describe('DynamicJsonForm String Fields', () => { | ||
const renderForm = (props = {}) => { | ||
const defaultProps = { | ||
schema: { | ||
type: "string" as const, | ||
description: "Test string field" | ||
} satisfies JsonSchemaType, | ||
value: undefined, | ||
onChange: jest.fn() | ||
}; | ||
return render(<DynamicJsonForm {...defaultProps} {...props} />); | ||
}; | ||
|
||
describe('Type Validation', () => { | ||
it('should handle numeric input as string type', () => { | ||
const onChange = jest.fn(); | ||
renderForm({ onChange }); | ||
|
||
const input = screen.getByRole('textbox'); | ||
fireEvent.change(input, { target: { value: '123321' } }); | ||
|
||
expect(onChange).toHaveBeenCalledWith('123321'); | ||
// Verify the value is a string, not a number | ||
expect(typeof onChange.mock.calls[0][0]).toBe('string'); | ||
}); | ||
|
||
it('should render as text input, not number input', () => { | ||
renderForm(); | ||
const input = screen.getByRole('textbox'); | ||
expect(input).toHaveProperty('type', 'text'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('DynamicJsonForm Integer Fields', () => { | ||
const renderForm = (props = {}) => { | ||
const defaultProps = { | ||
schema: { | ||
type: "integer" as const, | ||
description: "Test integer field" | ||
} satisfies JsonSchemaType, | ||
value: undefined, | ||
onChange: jest.fn() | ||
}; | ||
return render(<DynamicJsonForm {...defaultProps} {...props} />); | ||
}; | ||
|
||
describe('Basic Operations', () => { | ||
it('should render number input with step=1', () => { | ||
renderForm(); | ||
const input = screen.getByRole('spinbutton'); | ||
expect(input).toHaveProperty('type', 'number'); | ||
expect(input).toHaveProperty('step', '1'); | ||
}); | ||
|
||
it('should pass integer values to onChange', () => { | ||
const onChange = jest.fn(); | ||
renderForm({ onChange }); | ||
|
||
const input = screen.getByRole('spinbutton'); | ||
fireEvent.change(input, { target: { value: '42' } }); | ||
|
||
expect(onChange).toHaveBeenCalledWith(42); | ||
// Verify the value is a number, not a string | ||
expect(typeof onChange.mock.calls[0][0]).toBe('number'); | ||
}); | ||
|
||
it('should not pass string values to onChange', () => { | ||
const onChange = jest.fn(); | ||
renderForm({ onChange }); | ||
|
||
const input = screen.getByRole('spinbutton'); | ||
fireEvent.change(input, { target: { value: 'abc' } }); | ||
|
||
expect(onChange).not.toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
describe('Edge Cases', () => { | ||
it('should handle non-numeric input by not calling onChange', () => { | ||
const onChange = jest.fn(); | ||
renderForm({ onChange }); | ||
|
||
const input = screen.getByRole('spinbutton'); | ||
fireEvent.change(input, { target: { value: 'abc' } }); | ||
|
||
expect(onChange).not.toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.