-
Notifications
You must be signed in to change notification settings - Fork 523
fix: show load widget inputs in media dropdown #9670
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
+187
−66
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
eb1153d
fix: update FormDropdown filteredItems when items prop changes
christian-byrne b2c1f1f
fix: forward watcher cleanup into searcher
christian-byrne 0f48eec
fix: restore media dropdown inputs for load widgets
DrJKL 6c2d77a
fix: pass through non-array values in bindDynamicValuesOption
DrJKL 2977e3d
Merge branch 'main' into drjkl/computed-async-filtered-items
DrJKL 39638c1
fix: replace stacked nextTick with flushPromises in FormDropdown tests
DrJKL 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
115 changes: 115 additions & 0 deletions
115
src/renderer/extensions/vueNodes/widgets/components/form/dropdown/FormDropdown.test.ts
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,115 @@ | ||
| import { flushPromises, mount } from '@vue/test-utils' | ||
| import PrimeVue from 'primevue/config' | ||
| import { createI18n } from 'vue-i18n' | ||
| import { describe, expect, it, vi } from 'vitest' | ||
| import { defineComponent, h } from 'vue' | ||
|
|
||
| import FormDropdown from './FormDropdown.vue' | ||
| import type { FormDropdownItem } from './types' | ||
|
|
||
| function createItem(id: string, name: string): FormDropdownItem { | ||
| return { id, preview_url: '', name, label: name } | ||
| } | ||
|
|
||
| const i18n = createI18n({ legacy: false, locale: 'en', messages: { en: {} } }) | ||
|
|
||
| vi.mock('@/platform/updates/common/toastStore', () => ({ | ||
| useToastStore: () => ({ | ||
| addAlert: vi.fn() | ||
| }) | ||
| })) | ||
|
|
||
| const MockFormDropdownMenu = defineComponent({ | ||
| name: 'FormDropdownMenu', | ||
| props: { | ||
| items: { type: Array as () => FormDropdownItem[], default: () => [] }, | ||
| isSelected: { type: Function, default: undefined }, | ||
| filterOptions: { type: Array, default: () => [] }, | ||
| sortOptions: { type: Array, default: () => [] }, | ||
| maxSelectable: { type: Number, default: 1 }, | ||
| disabled: { type: Boolean, default: false }, | ||
| showOwnershipFilter: { type: Boolean, default: false }, | ||
| ownershipOptions: { type: Array, default: () => [] }, | ||
| showBaseModelFilter: { type: Boolean, default: false }, | ||
| baseModelOptions: { type: Array, default: () => [] } | ||
| }, | ||
| setup() { | ||
| return () => h('div', { class: 'mock-menu' }) | ||
| } | ||
| }) | ||
|
|
||
| function mountDropdown(items: FormDropdownItem[]) { | ||
| return mount(FormDropdown, { | ||
| props: { items }, | ||
| global: { | ||
| plugins: [PrimeVue, i18n], | ||
| stubs: { | ||
| FormDropdownInput: true, | ||
| Popover: { template: '<div><slot /></div>' }, | ||
| FormDropdownMenu: MockFormDropdownMenu | ||
| } | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| function getMenuItems( | ||
| wrapper: ReturnType<typeof mountDropdown> | ||
| ): FormDropdownItem[] { | ||
| return wrapper | ||
| .findComponent(MockFormDropdownMenu) | ||
| .props('items') as FormDropdownItem[] | ||
| } | ||
|
|
||
| describe('FormDropdown', () => { | ||
| describe('filteredItems updates when items prop changes', () => { | ||
| it('updates displayed items when items prop changes', async () => { | ||
| const wrapper = mountDropdown([ | ||
| createItem('input-0', 'video1.mp4'), | ||
| createItem('input-1', 'video2.mp4') | ||
| ]) | ||
| await flushPromises() | ||
|
|
||
| expect(getMenuItems(wrapper)).toHaveLength(2) | ||
|
|
||
| await wrapper.setProps({ | ||
| items: [ | ||
| createItem('output-0', 'rendered1.mp4'), | ||
| createItem('output-1', 'rendered2.mp4') | ||
| ] | ||
| }) | ||
| await flushPromises() | ||
|
|
||
| const menuItems = getMenuItems(wrapper) | ||
| expect(menuItems).toHaveLength(2) | ||
| expect(menuItems[0].name).toBe('rendered1.mp4') | ||
| }) | ||
|
|
||
| it('updates when items change but IDs stay the same', async () => { | ||
| const wrapper = mountDropdown([createItem('1', 'alpha')]) | ||
| await flushPromises() | ||
|
|
||
| await wrapper.setProps({ items: [createItem('1', 'beta')] }) | ||
| await flushPromises() | ||
|
|
||
| expect(getMenuItems(wrapper)[0].name).toBe('beta') | ||
| }) | ||
|
|
||
| it('updates when switching between empty and non-empty items', async () => { | ||
| const wrapper = mountDropdown([]) | ||
| await flushPromises() | ||
|
|
||
| expect(getMenuItems(wrapper)).toHaveLength(0) | ||
|
|
||
| await wrapper.setProps({ items: [createItem('1', 'video.mp4')] }) | ||
| await flushPromises() | ||
|
|
||
| expect(getMenuItems(wrapper)).toHaveLength(1) | ||
| expect(getMenuItems(wrapper)[0].name).toBe('video.mp4') | ||
|
|
||
| await wrapper.setProps({ items: [] }) | ||
| await flushPromises() | ||
|
|
||
| expect(getMenuItems(wrapper)).toHaveLength(0) | ||
| }) | ||
| }) | ||
| }) | ||
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
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
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.