This repository has been archived by the owner on Nov 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(viz): Use metadata.name as flow identifier
Currently, the UI creates the flows IDs in two places: 1. Upon syncing the code through the useFlowsStore.setFlowsWrapper() method 2. Upon creating a new flow when using the New Flow button For the .1, since the UI doesn't have a previous ID because we're starting from the source code, the UI creates an ID using the DSL name and the position index, i.e. "Camel Route-1". For the .2, the UI uses a service to generate an ID with the word "route-####" while "####" it's a 4 digits random number. In this commit, the UI leverages the IFlowsWrapper.flows[0].metadata.name property as an ID for each flow, this way, whenever a sync happens, the IDs will be the same. fixes: KaotoIO/vscode-kaoto#280 fixes: #1910
- Loading branch information
Showing
24 changed files
with
805 additions
and
584 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
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
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 |
---|---|---|
@@ -1,39 +1,49 @@ | ||
import { AlertProvider } from '../layout'; | ||
import { SettingsModal } from './SettingsModal'; | ||
import { fireEvent, screen } from '@testing-library/dom'; | ||
import { render } from '@testing-library/react'; | ||
import { fireEvent } from '@testing-library/dom'; | ||
import { act, render } from '@testing-library/react'; | ||
|
||
describe('SettingsModal.tsx', () => { | ||
test('component renders if open', () => { | ||
render( | ||
<AlertProvider> | ||
<SettingsModal handleCloseModal={jest.fn()} isModalOpen={true} /> | ||
</AlertProvider> | ||
test('component renders if open', async () => { | ||
const wrapper = await act(async () => | ||
render( | ||
<AlertProvider> | ||
<SettingsModal handleCloseModal={jest.fn()} isModalOpen={true} /> | ||
</AlertProvider>, | ||
), | ||
); | ||
const element = screen.queryByTestId('settings-modal'); | ||
const element = wrapper.queryByTestId('settings-modal'); | ||
expect(element).toBeInTheDocument(); | ||
}); | ||
|
||
test('component does not render if closed', () => { | ||
render( | ||
<AlertProvider> | ||
<SettingsModal handleCloseModal={jest.fn()} isModalOpen={false} /> | ||
</AlertProvider> | ||
test('component does not render if closed', async () => { | ||
const wrapper = await act(async () => | ||
render( | ||
<AlertProvider> | ||
<SettingsModal handleCloseModal={jest.fn()} isModalOpen={false} /> | ||
</AlertProvider>, | ||
), | ||
); | ||
const element = screen.queryByTestId('settings-modal'); | ||
const element = wrapper.queryByTestId('settings-modal'); | ||
expect(element).not.toBeInTheDocument(); | ||
}); | ||
|
||
test('handleCloseModal is called', () => { | ||
test('handleCloseModal is called', async () => { | ||
const mockClose = jest.fn(); | ||
|
||
render( | ||
<AlertProvider> | ||
<SettingsModal handleCloseModal={mockClose} isModalOpen={true} /> | ||
</AlertProvider> | ||
const wrapper = await act(async () => | ||
render( | ||
<AlertProvider> | ||
<SettingsModal handleCloseModal={mockClose} isModalOpen={true} /> | ||
</AlertProvider>, | ||
), | ||
); | ||
const saveButton = screen.getByTestId('settings-modal--save'); | ||
fireEvent.click(saveButton); | ||
|
||
await act(async () => { | ||
const saveButton = wrapper.getByTestId('settings-modal--save'); | ||
fireEvent.click(saveButton); | ||
}); | ||
|
||
expect(mockClose).toHaveBeenCalled(); | ||
}); | ||
}); |
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
Oops, something went wrong.