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:
parent
089bc4851e
commit
99935fec94
@ -81,13 +81,14 @@ test('Delete dependency', async () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Add dependency', async () => {
|
test('Edit dependency', async () => {
|
||||||
let closed = false;
|
let closed = false;
|
||||||
setupApi();
|
setupApi();
|
||||||
render(
|
render(
|
||||||
<AddDependencyDialogue
|
<AddDependencyDialogue
|
||||||
project='default'
|
project='default'
|
||||||
featureId='child'
|
featureId='child'
|
||||||
|
parentFeatureId='parentB'
|
||||||
showDependencyDialogue={true}
|
showDependencyDialogue={true}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
closed = true;
|
closed = true;
|
||||||
@ -95,7 +96,7 @@ test('Add dependency', async () => {
|
|||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
|
||||||
const removeDependency = await screen.findByText('Remove');
|
const removeDependency = await screen.findByText('Add');
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(removeDependency).not.toBeDisabled();
|
expect(removeDependency).not.toBeDisabled();
|
||||||
@ -103,6 +104,7 @@ test('Add dependency', async () => {
|
|||||||
|
|
||||||
// Open the dropdown by selecting the role.
|
// Open the dropdown by selecting the role.
|
||||||
const dropdown = screen.queryAllByRole('combobox')[0];
|
const dropdown = screen.queryAllByRole('combobox')[0];
|
||||||
|
expect(dropdown.innerHTML).toBe('parentB');
|
||||||
userEvent.click(dropdown);
|
userEvent.click(dropdown);
|
||||||
|
|
||||||
const parentAOption = await screen.findByText('parentA');
|
const parentAOption = await screen.findByText('parentA');
|
||||||
|
@ -18,6 +18,7 @@ import { DependenciesUpgradeAlert } from './DependenciesUpgradeAlert';
|
|||||||
interface IAddDependencyDialogueProps {
|
interface IAddDependencyDialogueProps {
|
||||||
project: string;
|
project: string;
|
||||||
featureId: string;
|
featureId: string;
|
||||||
|
parentFeatureId?: string;
|
||||||
showDependencyDialogue: boolean;
|
showDependencyDialogue: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
}
|
}
|
||||||
@ -161,10 +162,13 @@ const useManageDependency = (
|
|||||||
export const AddDependencyDialogue = ({
|
export const AddDependencyDialogue = ({
|
||||||
project,
|
project,
|
||||||
featureId,
|
featureId,
|
||||||
|
parentFeatureId,
|
||||||
showDependencyDialogue,
|
showDependencyDialogue,
|
||||||
onClose,
|
onClose,
|
||||||
}: IAddDependencyDialogueProps) => {
|
}: IAddDependencyDialogueProps) => {
|
||||||
const [parent, setParent] = useState(REMOVE_DEPENDENCY_OPTION.key);
|
const [parent, setParent] = useState(
|
||||||
|
parentFeatureId || REMOVE_DEPENDENCY_OPTION.key,
|
||||||
|
);
|
||||||
const handleClick = useManageDependency(
|
const handleClick = useManageDependency(
|
||||||
project,
|
project,
|
||||||
featureId,
|
featureId,
|
||||||
|
@ -164,6 +164,7 @@ export const DependencyRow: FC<{ feature: IFeatureToggle }> = ({ feature }) => {
|
|||||||
<AddDependencyDialogue
|
<AddDependencyDialogue
|
||||||
project={feature.project}
|
project={feature.project}
|
||||||
featureId={feature.name}
|
featureId={feature.name}
|
||||||
|
parentFeatureId={feature.dependencies[0]?.feature}
|
||||||
onClose={() => setShowDependencyDialogue(false)}
|
onClose={() => setShowDependencyDialogue(false)}
|
||||||
showDependencyDialogue={showDependencyDialogue}
|
showDependencyDialogue={showDependencyDialogue}
|
||||||
/>
|
/>
|
||||||
|
@ -18,7 +18,7 @@ const setupApi = () => {
|
|||||||
testServerRoute(
|
testServerRoute(
|
||||||
server,
|
server,
|
||||||
'/api/admin/projects/default/features/feature/parents',
|
'/api/admin/projects/default/features/feature/parents',
|
||||||
[],
|
['some_parent'],
|
||||||
);
|
);
|
||||||
testServerRoute(
|
testServerRoute(
|
||||||
server,
|
server,
|
||||||
@ -243,6 +243,7 @@ test('delete dependency with change request', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('edit dependency', async () => {
|
test('edit dependency', async () => {
|
||||||
|
setupChangeRequestApi();
|
||||||
render(
|
render(
|
||||||
<FeatureOverviewSidePanelDetails
|
<FeatureOverviewSidePanelDetails
|
||||||
feature={
|
feature={
|
||||||
|
Loading…
Reference in New Issue
Block a user