Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/new strategy configuration general tab (#5628)
* Adds the new general tab settings behind a feature flag * Adds a test for the FlexibleStrategy component
- Loading branch information
1 parent
54316ca
commit c552f3a
Showing
7 changed files
with
251 additions
and
22 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
38 changes: 37 additions & 1 deletion
38
...egy/FeatureStrategyForm/FeatureStrategyEnabledDisabled/FeatureStrategyEnabledDisabled.tsx
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
63 changes: 63 additions & 0 deletions
63
frontend/src/component/feature/StrategyTypes/FlexibleStrategy/FlexibleStrategy.test.tsx
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,63 @@ | ||
import { useState } from 'react'; | ||
import { screen, fireEvent, within } from '@testing-library/react'; | ||
import FlexibleStrategy from './FlexibleStrategy'; | ||
import { render } from 'utils/testRenderer'; | ||
import { Route, Routes } from 'react-router-dom'; | ||
import { testServerSetup, testServerRoute } from 'utils/testServer'; | ||
|
||
const server = testServerSetup(); | ||
|
||
const setupApi = () => { | ||
testServerRoute(server, '/api/admin/projects/default', {}); | ||
}; | ||
|
||
test('manipulates the rollout slider', async () => { | ||
const Wrapper = () => { | ||
const [parameters, setParameters] = useState({ | ||
groupId: 'testid', | ||
rollout: '0', | ||
stickiness: 'default', | ||
}); | ||
|
||
const updateParameter = (parameter: string, value: string) => { | ||
setParameters((prevParameters) => ({ | ||
...prevParameters, | ||
[parameter]: value, | ||
})); | ||
}; | ||
|
||
return ( | ||
<Routes> | ||
<Route | ||
path='/projects/:projectId/features/:featureName' | ||
element={ | ||
<FlexibleStrategy | ||
parameters={parameters} | ||
updateParameter={updateParameter} | ||
context={{}} | ||
editable={true} | ||
/> | ||
} | ||
/> | ||
</Routes> | ||
); | ||
}; | ||
|
||
setupApi(); | ||
|
||
render(<Wrapper />, { | ||
route: '/projects/default/features/test', | ||
}); | ||
|
||
const slider = await screen.findByRole('slider', { name: /rollout/i }); | ||
const groupIdInput = await screen.getByLabelText('groupId'); | ||
|
||
expect(slider).toHaveValue('0'); | ||
expect(groupIdInput).toHaveValue('testid'); | ||
|
||
fireEvent.change(slider, { target: { value: '50' } }); | ||
fireEvent.change(groupIdInput, { target: { value: 'newGroupId' } }); | ||
|
||
expect(slider).toHaveValue('50'); | ||
expect(groupIdInput).toHaveValue('newGroupId'); | ||
}); |
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.