-
Notifications
You must be signed in to change notification settings - Fork 673
fix: show promoted advanced widgets on subgraph nodes #14647
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
Open
jaeone94
wants to merge
8
commits into
main
Choose a base branch
from
jaeone/fe-854-bug-promoted-advanced-inputs-do-not-appear-as-subgraph
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3cc5ad9
test: add failing coverage for promoted advanced widgets
jaeone94 736f2d8
fix: show promoted advanced widgets on subgraph nodes
jaeone94 0c9529e
fix: identify promoted widgets at the host boundary
jaeone94 faf8230
Merge commit '06d8968fc9' into jaeone/fe-854-bug-promoted-advanced-in…
jaeone94 60f98bd
fix: address promoted widget review feedback
jaeone94 a5af157
fix: address follow-up review feedback
jaeone94 a5301d5
test: avoid coupling advanced ring coverage to classes
jaeone94 65bef75
test: align widget test with shared Pinia setup
jaeone94 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| import { createTestingPinia } from '@pinia/testing' | ||
| import { render, screen } from '@testing-library/vue' | ||
| import { fromAny } from '@total-typescript/shoehorn' | ||
| import { setActivePinia } from 'pinia' | ||
| import { createI18n } from 'vue-i18n' | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| import type { VueNodeData } from '@/composables/graph/useGraphNodeManager' | ||
| import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' | ||
| import { LGraphEventMode } from '@/lib/litegraph/src/types/globalEnums' | ||
| import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets' | ||
| import { toNodeId } from '@/types/nodeId' | ||
| import type { WidgetId } from '@/types/widgetId' | ||
|
|
||
| import AppModeWidgetList from './AppModeWidgetList.vue' | ||
|
|
||
| const mocks = vi.hoisted(() => ({ | ||
| extractVueNodeData: vi.fn(), | ||
| resolvedInputs: { value: [] as unknown[] } | ||
| })) | ||
|
|
||
| vi.mock('@/components/builder/useResolvedSelectedInputs', () => ({ | ||
| useResolvedSelectedInputs: () => mocks.resolvedInputs | ||
| })) | ||
|
|
||
| vi.mock('@/composables/graph/useGraphNodeManager', () => ({ | ||
| extractVueNodeData: mocks.extractVueNodeData | ||
| })) | ||
|
|
||
| vi.mock('@/composables/maskeditor/useMaskEditor', () => ({ | ||
| useMaskEditor: () => ({ openMaskEditor: vi.fn() }) | ||
| })) | ||
|
|
||
| vi.mock('@/renderer/core/canvas/canvasStore', () => ({ | ||
| useCanvasStore: () => ({ | ||
| canvas: { graph: { rootGraph: { id: 'graph-test' } } } | ||
| }) | ||
| })) | ||
|
|
||
| vi.mock( | ||
| '@/renderer/extensions/vueNodes/composables/useNodeEventHandlers', | ||
| () => ({ | ||
| useNodeEventHandlers: () => ({ handleNodeRightClick: vi.fn() }) | ||
| }) | ||
| ) | ||
|
|
||
| vi.mock('@/renderer/extensions/vueNodes/composables/useNodeTooltips', () => ({ | ||
| useNodeTooltips: () => ({ | ||
| createTooltipConfig: () => ({}), | ||
| getWidgetTooltip: () => '' | ||
| }) | ||
| })) | ||
|
|
||
| vi.mock( | ||
| '@/renderer/extensions/vueNodes/widgets/registry/widgetRegistry', | ||
| () => ({ | ||
| getComponent: () => ({ | ||
| props: ['widget'], | ||
| template: '<div data-testid="advanced-widget-control" />' | ||
| }), | ||
| shouldExpand: () => false, | ||
| shouldRenderAsVue: () => true | ||
| }) | ||
| ) | ||
|
|
||
| vi.mock('@/scripts/app', () => ({ | ||
| app: { | ||
| isGraphReady: false, | ||
| rootGraph: { id: 'graph-test' } | ||
| } | ||
| })) | ||
|
|
||
| const i18n = createI18n({ | ||
| legacy: false, | ||
| locale: 'en', | ||
| messages: { | ||
| en: { | ||
| g: { remove: 'Remove', rename: 'Rename' } | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| describe('AppModeWidgetList', () => { | ||
| beforeEach(() => { | ||
| const widgetId = 'graph-test:1:max_shift' as WidgetId | ||
| const widget = fromAny<IBaseWidget, unknown>({ | ||
| label: 'Max shift', | ||
| name: 'max_shift', | ||
| widgetId | ||
| }) | ||
| const node = fromAny<LGraphNode, unknown>({ | ||
| id: toNodeId(1), | ||
| mode: LGraphEventMode.ALWAYS, | ||
| title: 'Subgraph', | ||
| type: 'SubgraphNode' | ||
| }) | ||
| const nodeData: VueNodeData = { | ||
| executing: false, | ||
| id: toNodeId(1), | ||
| inputs: [], | ||
| mode: LGraphEventMode.ALWAYS, | ||
| outputs: [], | ||
| selected: false, | ||
| title: 'Subgraph', | ||
| type: 'SubgraphNode', | ||
| widgets: [ | ||
| { | ||
| name: 'max_shift', | ||
| options: { advanced: true }, | ||
| slotMetadata: { | ||
| index: 0, | ||
| linked: false, | ||
| promoted: true, | ||
| type: 'FLOAT' | ||
| }, | ||
| type: 'number', | ||
| widgetId | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| mocks.resolvedInputs.value = [ | ||
| { | ||
| displayName: 'max_shift', | ||
| node, | ||
| status: 'resolved', | ||
| widget, | ||
| widgetId | ||
| } | ||
| ] | ||
| mocks.extractVueNodeData.mockReturnValue(nodeData) | ||
| }) | ||
|
|
||
| it('renders a selected promoted advanced widget', () => { | ||
| const pinia = createTestingPinia({ stubActions: false }) | ||
| setActivePinia(pinia) | ||
|
|
||
| render(AppModeWidgetList, { | ||
| global: { | ||
| directives: { tooltip: { mounted: () => {} } }, | ||
| plugins: [pinia, i18n], | ||
| stubs: { | ||
| Button: { template: '<button><slot /></button>' }, | ||
| DropZone: { template: '<div><slot /></div>' }, | ||
| InputSlot: true, | ||
| Popover: { template: '<div><slot name="button" /></div>' }, | ||
| WidgetDescription: true | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| expect(screen.getByTestId('advanced-widget-control')).toBeVisible() | ||
| }) | ||
| }) |
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
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.