-
Notifications
You must be signed in to change notification settings - Fork 17
OLS-3897: Fix agentic capabilities toggle when config is absent #209
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| import { describe, expect, test } from 'vitest'; | ||
| import { buildSuspendedPatch } from './agenticCapabilitiesUtils'; | ||
| import { | ||
| buildAgenticOLSConfig, | ||
| buildSuspendedPatch, | ||
| isNotFoundError, | ||
| } from './agenticCapabilitiesUtils'; | ||
|
|
||
| describe('buildSuspendedPatch', () => { | ||
| test('returns replace op setting suspended to true', () => { | ||
|
|
@@ -14,3 +18,34 @@ describe('buildSuspendedPatch', () => { | |
| ]); | ||
| }); | ||
| }); | ||
|
|
||
| describe('buildAgenticOLSConfig', () => { | ||
| test('builds a cluster config with the given suspended value', () => { | ||
| expect(buildAgenticOLSConfig(true)).toEqual({ | ||
| apiVersion: 'agentic.openshift.io/v1alpha1', | ||
| kind: 'AgenticOLSConfig', | ||
| metadata: { name: 'cluster' }, | ||
| spec: { suspended: true }, | ||
| }); | ||
| }); | ||
| }); | ||
|
Comment on lines
+22
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift Add component tests for the toggle behavior. These tests only validate Add component tests that mock the watch, access-review hooks, 🤖 Prompt for AI AgentsSources: Coding guidelines, Learnings |
||
|
|
||
| describe('isNotFoundError', () => { | ||
| test('is true for a 404 error', () => { | ||
| expect(isNotFoundError({ code: 404 })).toBe(true); | ||
| }); | ||
|
|
||
| test('is false for other error codes', () => { | ||
| expect(isNotFoundError({ code: 403 })).toBe(false); | ||
| expect(isNotFoundError({ code: 500 })).toBe(false); | ||
| }); | ||
|
|
||
| test('is false for errors without a code', () => { | ||
| expect(isNotFoundError(new Error('network down'))).toBe(false); | ||
| }); | ||
|
|
||
| test('is false when there is no error', () => { | ||
| expect(isNotFoundError(null)).toBe(false); | ||
| expect(isNotFoundError(undefined)).toBe(false); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,17 @@ | ||
| import { AgenticOLSConfig, AgenticOLSConfigModel } from '../../models/agenticrun'; | ||
|
|
||
| export const AGENTIC_OLS_CONFIG_NAME = 'cluster'; | ||
|
|
||
| export const isNotFoundError = (loadError: unknown): boolean => | ||
| (loadError as { code?: number } | null)?.code === 404; | ||
|
|
||
| export const buildSuspendedPatch = (suspended: boolean) => [ | ||
| { op: 'add' as const, path: '/spec/suspended', value: suspended }, | ||
| ]; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| export const buildAgenticOLSConfig = (suspended: boolean): AgenticOLSConfig => ({ | ||
| apiVersion: `${AgenticOLSConfigModel.apiGroup}/${AgenticOLSConfigModel.apiVersion}`, | ||
| kind: AgenticOLSConfigModel.kind, | ||
| metadata: { name: AGENTIC_OLS_CONFIG_NAME }, | ||
| spec: { suspended }, | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.