Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for profiles without options #96

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ window.profileList = [
slug: "custom",
},
{
slug: "build-custom-environment",
description: "Dynamic Image building + unlisted choice",
display_name: "Build custom environment",
profile_options: {
Expand All @@ -220,4 +221,15 @@ window.profileList = [
},
},
},
{
slug: "empty-options",
description: "Profile with empty options",
display_name: "Empty Options",
profile_options: {},
},
{
slug: "no-options",
description: "Profile with no options",
display_name: "No Options",
},
];
18 changes: 18 additions & 0 deletions src/ProfileForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,22 @@ describe("Profile form with URL Params", () => {
expect(screen.getByLabelText("Repository").value).toEqual("org/repo");
expect(screen.getByLabelText("Git Ref").value).toEqual("v1.0");
});

test("no-option profiles are rendered", () => {
render(
<SpawnerFormProvider>
<ProfileForm />
</SpawnerFormProvider>,
);

const empty = screen.queryByRole("radio", {
name: "Empty Options Profile with empty options",
});
expect(empty).toBeInTheDocument();

const noObject = screen.queryByRole("radio", {
name: "No Options Profile with no options",
});
expect(noObject).toBeInTheDocument();
});
});
3 changes: 3 additions & 0 deletions src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ export const SpawnerFormContext = createContext();

function isDynamicImageProfile(profile) {
const { profile_options } = profile;

if (!profile_options) return false;

return Object.entries(profile_options).some(([key, option]) =>
hasDynamicImageBuilding(key, option),
);
Expand Down
Loading