-
Notifications
You must be signed in to change notification settings - Fork 86
fix(pou): show return type selector for graphical function POUs #954
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
emerson-d-lopes
wants to merge
2
commits into
Autonomy-Logic:development
Choose a base branch
from
emerson-d-lopes:bugfix/gh-696-function-return-type-graphical
base: development
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.
+67
−3
Open
Changes from all commits
Commits
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
64 changes: 64 additions & 0 deletions
64
...frontend/components/_organisms/variables-editor/__tests__/return-type-visibility.test.tsx
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,64 @@ | ||
| import { render, screen } from '@testing-library/react' | ||
|
|
||
| // The variables code editor pulls in Monaco, which cannot run in jsdom. | ||
| vi.mock('@root/frontend/components/_organisms/variables-code-editor', () => ({ | ||
| VariablesCodeEditor: () => <div data-testid='variables-code-editor' />, | ||
| })) | ||
|
|
||
| import { useOpenPLCStore } from '../../../../store' | ||
| import { VariablesEditor } from '../index' | ||
|
|
||
| const createPou = ( | ||
| name: string, | ||
| type: 'program' | 'function' | 'function-block', | ||
| language: 'st' | 'fbd' | 'ld' | 'sfc', | ||
| ) => { | ||
| const result = useOpenPLCStore.getState().pouActions.create({ type, name, language }) | ||
| expect(result.ok).toBe(true) | ||
| } | ||
|
|
||
| // https://github.com/Autonomy-Logic/openplc-editor/issues/696 | ||
| describe('VariablesEditor return type selector', () => { | ||
| it('shows the return type selector for a function written in FBD', () => { | ||
| createPou('FbdFunction', 'function', 'fbd') | ||
| render(<VariablesEditor name='FbdFunction' />) | ||
| expect(screen.getByText('Return type :')).toBeTruthy() | ||
| }) | ||
|
|
||
| it('shows the return type selector for a function written in LD', () => { | ||
| createPou('LdFunction', 'function', 'ld') | ||
| render(<VariablesEditor name='LdFunction' />) | ||
| expect(screen.getByText('Return type :')).toBeTruthy() | ||
| }) | ||
|
|
||
| it('shows the return type selector for a function written in SFC', () => { | ||
| createPou('SfcFunction', 'function', 'sfc') | ||
| render(<VariablesEditor name='SfcFunction' />) | ||
| expect(screen.getByText('Return type :')).toBeTruthy() | ||
| }) | ||
|
|
||
| it('associates the return type label with its select trigger', () => { | ||
| createPou('LabeledFunction', 'function', 'fbd') | ||
| render(<VariablesEditor name='LabeledFunction' />) | ||
| const trigger = screen.getByLabelText('Return type :') | ||
| expect(trigger.id).toBe('return-type') | ||
| }) | ||
|
|
||
| it('shows the return type selector for a function written in ST', () => { | ||
| createPou('StFunction', 'function', 'st') | ||
| render(<VariablesEditor name='StFunction' />) | ||
| expect(screen.getByText('Return type :')).toBeTruthy() | ||
| }) | ||
|
|
||
| it('does not show the return type selector for an FBD program', () => { | ||
| createPou('FbdProgram', 'program', 'fbd') | ||
| render(<VariablesEditor name='FbdProgram' />) | ||
| expect(screen.queryByText('Return type :')).toBeNull() | ||
| }) | ||
|
|
||
| it('does not show the return type selector for an FBD function block', () => { | ||
| createPou('FbdBlock', 'function-block', 'fbd') | ||
| render(<VariablesEditor name='FbdBlock' />) | ||
| expect(screen.queryByText('Return type :')).toBeNull() | ||
| }) | ||
| }) |
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
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.