Skip to content

Commit

Permalink
feat: keep parent selection in edit dependency dialogue (#6727)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew committed Mar 28, 2024
1 parent 089bc48 commit 99935fe
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Expand Up @@ -81,28 +81,30 @@ 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;
}}
/>,
);

const removeDependency = await screen.findByText('Remove');
const removeDependency = await screen.findByText('Add');

await waitFor(() => {
expect(removeDependency).not.toBeDisabled();
});

// 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');
Expand Down
Expand Up @@ -18,6 +18,7 @@ import { DependenciesUpgradeAlert } from './DependenciesUpgradeAlert';
interface IAddDependencyDialogueProps {
project: string;
featureId: string;
parentFeatureId?: string;
showDependencyDialogue: boolean;
onClose: () => void;
}
Expand Down Expand Up @@ -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,
Expand Down
Expand Up @@ -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}
/>
Expand Down
Expand Up @@ -18,7 +18,7 @@ const setupApi = () => {
testServerRoute(
server,
'/api/admin/projects/default/features/feature/parents',
[],
['some_parent'],
);
testServerRoute(
server,
Expand Down Expand Up @@ -243,6 +243,7 @@ test('delete dependency with change request', async () => {
});

test('edit dependency', async () => {
setupChangeRequestApi();
render(
<FeatureOverviewSidePanelDetails
feature={
Expand Down

0 comments on commit 99935fe

Please sign in to comment.