-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(editor): Migrate header WorkflowDetails to composition api (…
…no-changelog) (#9186)
- Loading branch information
1 parent
442aaba
commit 1c261f8
Showing
11 changed files
with
716 additions
and
595 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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.