1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-19 00:15:43 +01:00

feat: keep parent selection in edit dependency dialogue (#6727)

This commit is contained in:
Mateusz Kwasniewski 2024-03-28 11:15:26 +01:00 committed by GitHub
parent 089bc4851e
commit 99935fec94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 4 deletions

View File

@ -81,13 +81,14 @@ test('Delete dependency', async () => {
});
});
test('Add dependency', async () => {
test('Edit dependency', async () => {
let closed = false;
setupApi();
render(
<AddDependencyDialogue
project='default'
featureId='child'
parentFeatureId='parentB'
showDependencyDialogue={true}
onClose={() => {
closed = true;
@ -95,7 +96,7 @@ test('Add dependency', async () => {
/>,
);
const removeDependency = await screen.findByText('Remove');
const removeDependency = await screen.findByText('Add');
await waitFor(() => {
expect(removeDependency).not.toBeDisabled();
@ -103,6 +104,7 @@ test('Add dependency', async () => {
// Open the dropdown by selecting the role.
const dropdown = screen.queryAllByRole('combobox')[0];
expect(dropdown.innerHTML).toBe('parentB');
userEvent.click(dropdown);
const parentAOption = await screen.findByText('parentA');

View File

@ -18,6 +18,7 @@ import { DependenciesUpgradeAlert } from './DependenciesUpgradeAlert';
interface IAddDependencyDialogueProps {
project: string;
featureId: string;
parentFeatureId?: string;
showDependencyDialogue: boolean;
onClose: () => void;
}
@ -161,10 +162,13 @@ const useManageDependency = (
export const AddDependencyDialogue = ({
project,
featureId,
parentFeatureId,
showDependencyDialogue,
onClose,
}: IAddDependencyDialogueProps) => {
const [parent, setParent] = useState(REMOVE_DEPENDENCY_OPTION.key);
const [parent, setParent] = useState(
parentFeatureId || REMOVE_DEPENDENCY_OPTION.key,
);
const handleClick = useManageDependency(
project,
featureId,

View File

@ -164,6 +164,7 @@ export const DependencyRow: FC<{ feature: IFeatureToggle }> = ({ feature }) => {
<AddDependencyDialogue
project={feature.project}
featureId={feature.name}
parentFeatureId={feature.dependencies[0]?.feature}
onClose={() => setShowDependencyDialogue(false)}
showDependencyDialogue={showDependencyDialogue}
/>

View File

@ -18,7 +18,7 @@ const setupApi = () => {
testServerRoute(
server,
'/api/admin/projects/default/features/feature/parents',
[],
['some_parent'],
);
testServerRoute(
server,
@ -243,6 +243,7 @@ test('delete dependency with change request', async () => {
});
test('edit dependency', async () => {
setupChangeRequestApi();
render(
<FeatureOverviewSidePanelDetails
feature={