-
-
Notifications
You must be signed in to change notification settings - Fork 727
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: copy feature alert when change requests enabled in any env (#4964)
Adds an alert if change requests are enabled in any env and you try to copy a feature. Currently the functionality was disabled but with no explanation Closes # [SR-79](https://linear.app/unleash/issue/SR-79/when-change-request-is-enable-the-copy-functionality-its-disabled-but) <img width="1138" alt="Screenshot 2023-10-09 at 12 32 52" src="https://github.com/Unleash/unleash/assets/104830839/e900e4b8-8d26-46d7-8622-0ad592704d03"> --------- Signed-off-by: andreas-unleash <[email protected]>
- Loading branch information
1 parent
71431c7
commit 8821dbc
Showing
3 changed files
with
105 additions
and
29 deletions.
There are no files selected for viewing
27 changes: 0 additions & 27 deletions
27
frontend/src/component/feature/CopyFeature/CopyFeature.module.scss
This file was deleted.
Oops, something went wrong.
88 changes: 88 additions & 0 deletions
88
frontend/src/component/feature/CopyFeature/CopyFeature.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,88 @@ | ||
import { render } from 'utils/testRenderer'; | ||
import { CopyFeatureToggle } from './CopyFeature'; | ||
import { Route, Routes } from 'react-router-dom'; | ||
import { screen } from '@testing-library/react'; | ||
import { CREATE_FEATURE } from 'component/providers/AccessProvider/permissions'; | ||
import { testServerRoute, testServerSetup } from 'utils/testServer'; | ||
|
||
const server = testServerSetup(); | ||
|
||
const setupServerRoutes = (changeRequestsEnabled = true) => { | ||
testServerRoute(server, '/api/admin/ui-config', { | ||
environment: 'Open Source', | ||
flags: { | ||
changeRequests: true, | ||
}, | ||
versionInfo: { | ||
current: { oss: '4.18.0-beta.5', enterprise: '4.17.0-beta.1' }, | ||
}, | ||
disablePasswordAuth: false, | ||
}); | ||
|
||
testServerRoute( | ||
server, | ||
'/api/admin/projects/default/change-requests/config', | ||
[ | ||
{ | ||
environment: 'development', | ||
type: 'development', | ||
requiredApprovals: null, | ||
changeRequestEnabled: false, | ||
}, | ||
{ | ||
environment: 'production', | ||
type: 'production', | ||
requiredApprovals: 1, | ||
changeRequestEnabled: changeRequestsEnabled, | ||
}, | ||
], | ||
); | ||
|
||
testServerRoute( | ||
server, | ||
'/api/admin/projects/default/features/someFeature', | ||
{ name: 'someFeature' }, | ||
); | ||
}; | ||
test('should render an alert when change request is enabled in any env when copying feature', async () => { | ||
setupServerRoutes(); | ||
render( | ||
<Routes> | ||
<Route | ||
path={ | ||
'/projects/:projectId/features/:featureId/strategies/copy' | ||
} | ||
element={<CopyFeatureToggle />} | ||
/> | ||
</Routes>, | ||
{ | ||
route: '/projects/default/features/someFeature/strategies/copy', | ||
permissions: [{ permission: CREATE_FEATURE }], | ||
}, | ||
); | ||
|
||
await screen.findByText( | ||
'Copy functionality is disabled for this project because change request is enabled for at least one environment in this project.', | ||
); | ||
}); | ||
|
||
test('should not render an alert when change request is disabled when copying feature', async () => { | ||
setupServerRoutes(false); | ||
render( | ||
<Routes> | ||
<Route | ||
path={'projects/:projectId/features/:featureId/strategies/copy'} | ||
element={<CopyFeatureToggle />} | ||
/> | ||
</Routes>, | ||
{ | ||
route: '/projects/default/features/someFeature/strategies/copy', | ||
permissions: [{ permission: CREATE_FEATURE }], | ||
}, | ||
); | ||
|
||
const alert = screen.queryByText( | ||
'Copy functionality is disabled for this project because change request is enabled for at least one environment in this project.', | ||
); | ||
expect(alert).not.toBeInTheDocument(); | ||
}); |
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