-
Notifications
You must be signed in to change notification settings - Fork 31.1k
refactor(editor): Migrate header WorkflowDetails to composition api (no-changelog) #9186
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
alexgrozav
merged 11 commits into
master
from
n8n-7345-migrate-workflowdetails-to-composition-api
Apr 29, 2024
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2912cdb
refactor: migrate header WorkflowDetails to composition api
alexgrozav 9c0ccc7
test: add WorkflowDetails.vue tests
alexgrozav 9754f5d
chore: remove unused import
alexgrozav 0d178ba
fix: rename IActionDropdownItem type name to ActionDropdownItem
alexgrozav eaa554b
fix: fix tag text alignment
alexgrozav b044d34
fix: update tags padding
alexgrozav 5c9e85e
Merge branch 'master' into n8n-7345-migrate-workflowdetails-to-compos…
alexgrozav 3032059
fix: fix workflow watcher
alexgrozav cdbe6e7
fix: fix event bus naming
alexgrozav e6eb249
chore: remove console.log
alexgrozav b93e7ac
fix: fix condition for displaying workflow details
alexgrozav 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,11 @@ | ||
import type { KeyboardShortcut } from '@/types/keyboardshortcut'; | ||
|
||
export interface ActionDropdownItem { | ||
id: string; | ||
label: string; | ||
icon?: string; | ||
divided?: boolean; | ||
disabled?: boolean; | ||
shortcut?: KeyboardShortcut; | ||
customClass?: string; | ||
} |
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
115 changes: 115 additions & 0 deletions
115
packages/editor-ui/src/components/MainHeader/WorkflowDetails.spec.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 WorkflowDetails from '@/components/MainHeader/WorkflowDetails.vue'; | ||
import { createComponentRenderer } from '@/__tests__/render'; | ||
import { STORES } from '@/constants'; | ||
import { createTestingPinia } from '@pinia/testing'; | ||
import { fireEvent } from '@testing-library/vue'; | ||
|
||
vi.mock('vue-router', async () => { | ||
const actual = await import('vue-router'); | ||
|
||
return { | ||
...actual, | ||
useRoute: () => ({ | ||
value: { | ||
params: { | ||
id: '1', | ||
}, | ||
}, | ||
}), | ||
}; | ||
}); | ||
|
||
const initialState = { | ||
[STORES.SETTINGS]: { | ||
settings: { | ||
enterprise: { | ||
sharing: true, | ||
}, | ||
}, | ||
areTagsEnabled: true, | ||
}, | ||
[STORES.TAGS]: { | ||
tags: { | ||
1: { | ||
id: '1', | ||
name: 'tag1', | ||
}, | ||
2: { | ||
id: '2', | ||
name: 'tag2', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
const renderComponent = createComponentRenderer(WorkflowDetails, { | ||
pinia: createTestingPinia({ initialState }), | ||
}); | ||
|
||
describe('WorkflowDetails', () => { | ||
it('renders workflow name and tags', async () => { | ||
const workflow = { | ||
id: '1', | ||
name: 'Test Workflow', | ||
tags: ['1', '2'], | ||
}; | ||
|
||
const { getByTestId, getByText } = renderComponent({ | ||
props: { | ||
workflow, | ||
readOnly: false, | ||
}, | ||
}); | ||
|
||
const workflowName = getByTestId('workflow-name-input'); | ||
const workflowNameInput = workflowName.querySelector('input'); | ||
|
||
expect(workflowNameInput).toHaveValue('Test Workflow'); | ||
expect(getByText('tag1')).toBeInTheDocument(); | ||
expect(getByText('tag2')).toBeInTheDocument(); | ||
}); | ||
|
||
it('calls save function on save button click', async () => { | ||
const onSaveButtonClick = vi.fn(); | ||
const { getByTestId } = renderComponent({ | ||
props: { | ||
workflow: { | ||
id: '1', | ||
name: 'Test Workflow', | ||
tags: [], | ||
}, | ||
readOnly: false, | ||
}, | ||
global: { | ||
mocks: { | ||
onSaveButtonClick, | ||
}, | ||
}, | ||
}); | ||
|
||
await fireEvent.click(getByTestId('workflow-save-button')); | ||
expect(onSaveButtonClick).toHaveBeenCalled(); | ||
}); | ||
|
||
it('opens share modal on share button click', async () => { | ||
const onShareButtonClick = vi.fn(); | ||
const { getByTestId } = renderComponent({ | ||
props: { | ||
workflow: { | ||
id: '1', | ||
name: 'Test Workflow', | ||
tags: [], | ||
}, | ||
readOnly: false, | ||
}, | ||
global: { | ||
mocks: { | ||
onShareButtonClick, | ||
}, | ||
}, | ||
}); | ||
|
||
await fireEvent.click(getByTestId('workflow-share-button')); | ||
expect(onShareButtonClick).toHaveBeenCalled(); | ||
}); | ||
}); |
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.