-
Notifications
You must be signed in to change notification settings - Fork 672
fix: layer editor UX and review follow-ups #14941
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
jtydhr88
wants to merge
4
commits into
main
Choose a base branch
from
fix/layer-editor-review-nits
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 all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
23c2f8f
fix: layer editor UX and review follow-ups
jtydhr88 7eb23f7
fix: address coderabbit review on the layer editor UX batch
jtydhr88 b1fb868
fix: address the multi-agent review on the layer editor UX batch
jtydhr88 eb4b556
fix: size the layer editor canvas from the backend document canvas
jtydhr88 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
103 changes: 103 additions & 0 deletions
103
src/renderer/extensions/compositor/components/WidgetCompositor.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,103 @@ | ||
| import { render, screen } from '@testing-library/vue' | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest' | ||
| import { ref } from 'vue' | ||
| import { createI18n } from 'vue-i18n' | ||
|
|
||
| import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' | ||
| import { toNodeId } from '@/types/nodeId' | ||
|
|
||
| import { | ||
| clearCompositorLayers, | ||
| setCompositorLayers | ||
| } from '../composables/useCompositorLayers' | ||
| import WidgetCompositor from './WidgetCompositor.vue' | ||
|
|
||
| const { getNodeById } = vi.hoisted(() => ({ | ||
| getNodeById: vi.fn<() => unknown>(() => undefined) | ||
| })) | ||
|
|
||
| vi.mock('@/scripts/app', () => ({ | ||
| app: { canvas: { graph: { getNodeById } } } | ||
| })) | ||
| vi.mock('@/stores/nodeOutputStore', () => ({ | ||
| useNodeOutputStore: () => ({ | ||
| getNodeImageUrls: () => undefined, | ||
| nodeOutputs: {}, | ||
| nodePreviewImages: {} | ||
| }) | ||
| })) | ||
| vi.mock( | ||
| '@/renderer/extensions/compositor/composables/useCompositorEditor', | ||
| () => ({ | ||
| useCompositorEditor: () => ({ openCompositorEditor: vi.fn() }) | ||
| }) | ||
| ) | ||
| vi.mock( | ||
| '@/renderer/extensions/compositor/composables/useCompositorPsdDownload', | ||
| () => ({ | ||
| useCompositorPsdDownload: () => ({ | ||
| exporting: ref(false), | ||
| downloadPsd: vi.fn() | ||
| }) | ||
| }) | ||
| ) | ||
| const i18n = createI18n({ | ||
| legacy: false, | ||
| locale: 'en', | ||
| messages: { | ||
| en: { | ||
| compositor: { | ||
| empty: 'Run the workflow to generate a composite', | ||
| open: 'Open Compositor', | ||
| runWorkflowFirst: 'Run the workflow once to load input images', | ||
| downloadPsd: 'Download PSD' | ||
| } | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| const nodeId = toNodeId(9) | ||
| const graphNode = { id: nodeId, graph: null } as unknown as LGraphNode | ||
|
|
||
| function renderWidget() { | ||
| return render(WidgetCompositor, { | ||
| props: { nodeId }, | ||
| global: { | ||
| plugins: [i18n], | ||
| stubs: { | ||
| Button: { template: '<button v-bind="$attrs"><slot /></button>' } | ||
| } | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| describe('WidgetCompositor', () => { | ||
| beforeEach(() => { | ||
| vi.clearAllMocks() | ||
|
Check warning on line 76 in src/renderer/extensions/compositor/components/WidgetCompositor.test.ts
|
||
| clearCompositorLayers(graphNode) | ||
| getNodeById.mockReturnValue(undefined) | ||
| }) | ||
|
|
||
| it('renders the empty state when the node is not in the graph (search preview)', () => { | ||
| renderWidget() | ||
|
|
||
| expect(screen.getByTestId('compositor-empty').textContent).toContain( | ||
| 'Run the workflow to generate a composite' | ||
| ) | ||
| const open = screen.getByTestId('compositor-open-button') | ||
| expect(open.textContent).toContain('Open Compositor') | ||
| expect(open.hasAttribute('disabled')).toBe(true) | ||
| }) | ||
|
|
||
| it('enables opening once the graph node exists with cached layers', () => { | ||
| getNodeById.mockReturnValue(graphNode) | ||
| setCompositorLayers(graphNode, [ | ||
| { filename: 'a.png', subfolder: '', type: 'temp' } | ||
| ]) | ||
|
|
||
| renderWidget() | ||
|
|
||
| const open = screen.getByTestId('compositor-open-button') | ||
| expect(open.hasAttribute('disabled')).toBe(false) | ||
| }) | ||
| }) | ||
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.
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.