Merge branch 'jjs/presets-fe' into jjs/presets

This commit is contained in:
Sas Swart
2025-02-14 09:45:08 +00:00
3 changed files with 12 additions and 12 deletions

View File

@ -15,8 +15,6 @@ import (
) )
func TestTemplateVersionPresets(t *testing.T) { func TestTemplateVersionPresets(t *testing.T) {
// TODO (sasswart): Test case: what if a user tries to read presets or preset parameters from a different org?
t.Parallel() t.Parallel()
givenPreset := codersdk.Preset{ givenPreset := codersdk.Preset{

View File

@ -1,5 +1,7 @@
import { action } from "@storybook/addon-actions"; import { action } from "@storybook/addon-actions";
import type { Meta, StoryObj } from "@storybook/react"; import type { Meta, StoryObj } from "@storybook/react";
import { within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { chromatic } from "testHelpers/chromatic"; import { chromatic } from "testHelpers/chromatic";
import { import {
MockTemplate, MockTemplate,
@ -116,7 +118,7 @@ export const Parameters: Story = {
}, },
}; };
export const Presets: Story = { export const PresetsButNoneSelected: Story = {
args: { args: {
presets: [ presets: [
{ {
@ -148,6 +150,15 @@ export const Presets: Story = {
}, },
}; };
export const PresetSelected: Story = {
args: PresetsButNoneSelected.args,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await userEvent.click(canvas.getByLabelText("Preset"));
await userEvent.click(canvas.getByText("Preset 1"));
},
};
export const ExternalAuth: Story = { export const ExternalAuth: Story = {
args: { args: {
externalAuth: [ externalAuth: [

View File

@ -164,15 +164,6 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
); );
useEffect(() => { useEffect(() => {
// TODO (sasswart): test case: what if immutable parameters are used in the preset?
// TODO (sasswart): test case: what if presets are defined for a template version with no params?
// TODO (sasswart): test case: what if a non active version is selected?
// TODO (sasswart): test case: what if a preset is selected that has no parameters?
// TODO (sasswart): what if we have preset params and autofill params on the same param?
// TODO (sasswart): test case: if we move from preset to no preset, do we reset the params?
// If so, how should it behave? Reset to initial value? reset to last set value?
// TODO (sasswart): test case: rich parameters
const selectedPresetOption = presetOptions[selectedPresetIndex]; const selectedPresetOption = presetOptions[selectedPresetIndex];
let selectedPreset: TypesGen.Preset | undefined; let selectedPreset: TypesGen.Preset | undefined;
for (const preset of presets) { for (const preset of presets) {