-
Notifications
You must be signed in to change notification settings - Fork 368
[test] Add component tests for some Vue Widget components #5409
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
Conversation
🎭 Playwright Test Results✅ All tests passed across all browsers! ⏰ Completed at: 09/07/2025, 06:04:55 AM UTC 📊 Test Reports by Browser🎉 Your tests are passing across all browsers! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests in here look pretty good, but it's kind of hard to see what differentiates one from another when there's so much similarity in the arrange/act sections
You already have a convenience setup function for the widget data, what about one for the wrapper too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could probably have a similar utility to batch the operations like finding the child element, setting value, then blurring. If that's the standard, anything that deviates will stand out as interesting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}) | ||
|
||
const input = wrapper.find('input[type="text"]') | ||
expect((input.element as HTMLInputElement).disabled).toBe(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be inside an instanceof
gate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 77b0207
callback | ||
}) | ||
|
||
const mountComponent = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! Like this!
const input = wrapper.find('input[type="number"]') | ||
expect((input.element as HTMLInputElement).value).toBe('42') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you moved these into an assertion utility, you could explicitly check that input.element instanceof HTMLInputElement
and throw otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 77b0207
…@DrJKL's review feedback - Add mountComponent utility function for consistent test setup - Add setInputValueAndTrigger helper to batch common test operations - Replace type assertions with proper instanceof checks for type safety - Remove duplicate test setup code to improve test readability - Fix TypeScript errors in WidgetSlider tests These changes address all review comments by making tests easier to read and understand while ensuring proper type checking.
77b0207
it('disables components in readonly mode', () => { | ||
const widget = createMockWidget(5) | ||
const wrapper = mountComponent(widget, 5, true) | ||
|
||
const slider = wrapper.findComponent({ name: 'Slider' }) | ||
expect(slider.props('disabled')).toBe(true) | ||
|
||
const input = wrapper.find('input[type="number"]') | ||
expect((input.element as HTMLInputElement).disabled).toBe(true) | ||
}) | ||
}) | ||
|
||
describe('Component Rendering', () => { | ||
it('renders slider and input components', () => { | ||
const widget = createMockWidget(5) | ||
const wrapper = mountComponent(widget, 5) | ||
|
||
expect(wrapper.findComponent({ name: 'Slider' }).exists()).toBe(true) | ||
expect(wrapper.find('input[type="number"]').exists()).toBe(true) | ||
}) | ||
|
||
it('displays initial value in input field', () => { | ||
const widget = createMockWidget(42) | ||
const wrapper = mountComponent(widget, 42) | ||
|
||
const input = wrapper.find('input[type="number"]') | ||
expect((input.element as HTMLInputElement).value).toBe('42') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed duplicate tests
- Add mountComponent utility function for consistent test setup - Add setSelectValueAndEmit helper to batch select operations - Remove repetitive mount boilerplate code throughout tests - Maintain existing test coverage while improving readability This ensures all widget component tests follow the same patterns established in WidgetInputText and WidgetSlider tests.
* add component tests for vue widgets * [refactor] improve widget test readability and type safety - addresses @DrJKL's review feedback - Add mountComponent utility function for consistent test setup - Add setInputValueAndTrigger helper to batch common test operations - Replace type assertions with proper instanceof checks for type safety - Remove duplicate test setup code to improve test readability - Fix TypeScript errors in WidgetSlider tests These changes address all review comments by making tests easier to read and understand while ensuring proper type checking. * [refactor] apply consistent test patterns to WidgetSelect.test.ts - Add mountComponent utility function for consistent test setup - Add setSelectValueAndEmit helper to batch select operations - Remove repetitive mount boilerplate code throughout tests - Maintain existing test coverage while improving readability This ensures all widget component tests follow the same patterns established in WidgetInputText and WidgetSlider tests.
Summary
Adds component tests for some Vue Widget components.
Changes
Review Focus
┆Issue is synchronized with this Notion page by Unito