From 030ee39e8f8a1631dbc2cd04f2b7b447810210f2 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Wed, 4 Dec 2024 10:18:38 -0500 Subject: [PATCH 1/3] feat(eventtemplates): support preset event template type --- .../Shared/Components/SelectTemplateSelectorForm.tsx | 11 ++++++++++- src/app/Shared/Services/api.types.ts | 2 +- src/test/Events/EventTemplates.test.tsx | 9 ++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/app/Shared/Components/SelectTemplateSelectorForm.tsx b/src/app/Shared/Components/SelectTemplateSelectorForm.tsx index be9a81139..a4d1813ba 100644 --- a/src/app/Shared/Components/SelectTemplateSelectorForm.tsx +++ b/src/app/Shared/Components/SelectTemplateSelectorForm.tsx @@ -58,7 +58,7 @@ export const SelectTemplateSelectorForm: React.FC t.type === 'CUSTOM') .map((t) => ({ @@ -66,6 +66,15 @@ export const SelectTemplateSelectorForm: React.FC t.type === 'PRESET') + .map((t) => ({ + value: `${t.name},${t.type}`, + label: t.name, + })), + }, ] as TemplateSelectionGroup[], [templates], ); diff --git a/src/app/Shared/Services/api.types.ts b/src/app/Shared/Services/api.types.ts index 735e7f173..94da94a9e 100644 --- a/src/app/Shared/Services/api.types.ts +++ b/src/app/Shared/Services/api.types.ts @@ -347,7 +347,7 @@ export interface EventType { options: { [key: string]: OptionDescriptor }[]; } -export type TemplateType = 'TARGET' | 'CUSTOM'; +export type TemplateType = 'TARGET' | 'CUSTOM' | 'PRESET'; export interface EventTemplate { name: string; diff --git a/src/test/Events/EventTemplates.test.tsx b/src/test/Events/EventTemplates.test.tsx index bd3dae83d..f33228978 100644 --- a/src/test/Events/EventTemplates.test.tsx +++ b/src/test/Events/EventTemplates.test.tsx @@ -44,6 +44,13 @@ const mockCustomEventTemplate: EventTemplate = { const mockAnotherTemplate = { ...mockCustomEventTemplate, name: 'anotherEventTemplate' }; +const mockPresetEventTemplate: EventTemplate = { + name: 'presetEventTemplate', + description: 'Some Description', + provider: 'Cryostat', + type: 'PRESET', +}; + const mockCreateTemplateNotification = { meta: { category: 'TemplateCreated', @@ -73,7 +80,7 @@ jest.spyOn(defaultServices.api, 'addCustomEventTemplate').mockReturnValue(of(tru jest.spyOn(defaultServices.api, 'deleteCustomEventTemplate').mockReturnValue(of(true)); jest.spyOn(defaultServices.api, 'downloadTemplate').mockReturnValue(void 0); -jest.spyOn(defaultServices.api, 'getTargetEventTemplates').mockReturnValue(of([mockCustomEventTemplate])); +jest.spyOn(defaultServices.api, 'getTargetEventTemplates').mockReturnValue(of([mockCustomEventTemplate, mockPresetEventTemplate])); jest.spyOn(defaultServices.target, 'target').mockReturnValue(of(mockTarget)); jest.spyOn(defaultServices.target, 'authFailure').mockReturnValue(of()); From 65676e1e98daa8ffb96ea46a92011256a2272adf Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Wed, 4 Dec 2024 11:17:42 -0500 Subject: [PATCH 2/3] tests and snapshots --- ...TargetsArchivedRecordingsTable.test.tsx.snap | 6 +++--- .../CustomRecordingForm.test.tsx.snap | 17 ++++++++++++++--- src/test/Events/EventTemplates.test.tsx | 9 +-------- .../__snapshots__/EventTypes.test.tsx.snap | 10 +++++----- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/test/Archives/__snapshots__/AllTargetsArchivedRecordingsTable.test.tsx.snap b/src/test/Archives/__snapshots__/AllTargetsArchivedRecordingsTable.test.tsx.snap index 8080a1a9c..c3af605e4 100644 --- a/src/test/Archives/__snapshots__/AllTargetsArchivedRecordingsTable.test.tsx.snap +++ b/src/test/Archives/__snapshots__/AllTargetsArchivedRecordingsTable.test.tsx.snap @@ -310,7 +310,7 @@ exports[` renders correctly 1`] = ` aria-disabled={false} aria-label={null} className="pf-v5-c-button pf-m-plain" - data-ouia-component-id="OUIA-Generated-Button-plain-2" + data-ouia-component-id="OUIA-Generated-Button-plain-1" data-ouia-component-type="PF5/Button" data-ouia-safe={true} disabled={false} @@ -391,7 +391,7 @@ exports[` renders correctly 1`] = ` aria-label="Details" aria-labelledby="simple-node1 expand-toggle1" className="pf-v5-c-button pf-m-plain" - data-ouia-component-id="OUIA-Generated-Button-plain-3" + data-ouia-component-id="OUIA-Generated-Button-plain-2" data-ouia-component-type="PF5/Button" data-ouia-safe={true} disabled={false} @@ -442,7 +442,7 @@ exports[` renders correctly 1`] = ` aria-disabled={false} aria-label={null} className="pf-v5-c-button pf-m-plain" - data-ouia-component-id="OUIA-Generated-Button-plain-4" + data-ouia-component-id="OUIA-Generated-Button-plain-2" data-ouia-component-type="PF5/Button" data-ouia-safe={true} disabled={false} diff --git a/src/test/CreateRecording/__snapshots__/CustomRecordingForm.test.tsx.snap b/src/test/CreateRecording/__snapshots__/CustomRecordingForm.test.tsx.snap index 74b5890c8..a9062718d 100644 --- a/src/test/CreateRecording/__snapshots__/CustomRecordingForm.test.tsx.snap +++ b/src/test/CreateRecording/__snapshots__/CustomRecordingForm.test.tsx.snap @@ -383,7 +383,7 @@ exports[` renders correctly 1`] = ` + + + renders correctly 1`] = ` >