-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(editor): Change tooltip for workflow with execute workflow trigger (
- Loading branch information
1 parent
60cdf0b
commit dcd6038
Showing
3 changed files
with
102 additions
and
2 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
packages/editor-ui/src/components/WorkflowActivator.test.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,82 @@ | ||
import { describe, it, expect, vi } from 'vitest'; | ||
import WorkflowActivator from '@/components/WorkflowActivator.vue'; | ||
import userEvent from '@testing-library/user-event'; | ||
|
||
import { useWorkflowsStore } from '@/stores/workflows.store'; | ||
|
||
import { createTestingPinia } from '@pinia/testing'; | ||
import { createComponentRenderer } from '@/__tests__/render'; | ||
import { mockedStore } from '@/__tests__/utils'; | ||
import { EXECUTE_WORKFLOW_TRIGGER_NODE_TYPE } from '@/constants'; | ||
|
||
const renderComponent = createComponentRenderer(WorkflowActivator); | ||
let mockWorkflowsStore: ReturnType<typeof mockedStore<typeof useWorkflowsStore>>; | ||
|
||
describe('WorkflowActivator', () => { | ||
beforeEach(() => { | ||
createTestingPinia(); | ||
|
||
mockWorkflowsStore = mockedStore(useWorkflowsStore); | ||
}); | ||
|
||
afterEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
it('renders correctly', () => { | ||
const renderOptions = { | ||
props: { | ||
workflowActive: false, | ||
workflowId: '1', | ||
workflowPermissions: { update: true }, | ||
}, | ||
}; | ||
|
||
const { getByTestId, getByRole } = renderComponent(renderOptions); | ||
expect(getByTestId('workflow-activator-status')).toBeInTheDocument(); | ||
expect(getByRole('switch')).toBeInTheDocument(); | ||
}); | ||
|
||
it('display an inactive tooltip when there are no nodes available', async () => { | ||
mockWorkflowsStore.workflowId = '1'; | ||
|
||
const { getByTestId, getByRole } = renderComponent({ | ||
props: { | ||
workflowActive: false, | ||
workflowId: '1', | ||
workflowPermissions: { update: true }, | ||
}, | ||
}); | ||
|
||
await userEvent.hover(getByRole('switch')); | ||
expect(getByRole('tooltip')).toBeInTheDocument(); | ||
|
||
expect(getByRole('tooltip')).toHaveTextContent( | ||
'This workflow has no trigger nodes that require activation', | ||
); | ||
expect(getByTestId('workflow-activator-status')).toHaveTextContent('Inactive'); | ||
}); | ||
|
||
it('display an inactive tooltip when only execute workflow trigger is available', async () => { | ||
mockWorkflowsStore.workflowId = '1'; | ||
mockWorkflowsStore.workflowTriggerNodes = [ | ||
{ type: EXECUTE_WORKFLOW_TRIGGER_NODE_TYPE, disabled: false } as never, | ||
]; | ||
|
||
const { getByTestId, getByRole } = renderComponent({ | ||
props: { | ||
workflowActive: false, | ||
workflowId: '1', | ||
workflowPermissions: { update: true }, | ||
}, | ||
}); | ||
|
||
await userEvent.hover(getByRole('switch')); | ||
expect(getByRole('tooltip')).toBeInTheDocument(); | ||
|
||
expect(getByRole('tooltip')).toHaveTextContent( | ||
"Execute Workflow Trigger' doesn't require activation as it is triggered by another workflow", | ||
); | ||
expect(getByTestId('workflow-activator-status')).toHaveTextContent('Inactive'); | ||
}); | ||
}); |
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