diff --git a/frontend/.eslintrc b/frontend/.eslintrc index 9ae61fd1a8..cca83da5be 100755 --- a/frontend/.eslintrc +++ b/frontend/.eslintrc @@ -77,6 +77,7 @@ "always", { "exceptAfterSingleLine": false } ], + "@typescript-eslint/method-signature-style": "error", "@typescript-eslint/naming-convention": [ "error", { diff --git a/frontend/src/__tests__/cypress/cypress/support/commands/application.ts b/frontend/src/__tests__/cypress/cypress/support/commands/application.ts index 9a28f5a2ac..080703bf1b 100644 --- a/frontend/src/__tests__/cypress/cypress/support/commands/application.ts +++ b/frontend/src/__tests__/cypress/cypress/support/commands/application.ts @@ -11,17 +11,17 @@ declare global { * @param url the URL to visit * @param credentials login credentials */ - visitWithLogin( + visitWithLogin: ( url: string, credentials?: { username: string; password: string; provider?: string }, - ): Cypress.Chainable; + ) => Cypress.Chainable; /** * Find a patternfly kebab toggle button. * * @param isDropdownToggle - True to indicate that it is a dropdown toggle instead of table kebab actions */ - findKebab(isDropdownToggle?: boolean): Cypress.Chainable; + findKebab: (isDropdownToggle?: boolean) => Cypress.Chainable; /** * Finds a patternfly kebab toggle button, opens the menu, and finds the action. @@ -29,51 +29,61 @@ declare global { * @param name the name of the action in the kebeb menu * @param isDropdownToggle - True to indicate that it is a dropdown toggle instead of table kebab actions */ - findKebabAction(name: string | RegExp, isDropdownToggle?: boolean): Cypress.Chainable; + findKebabAction: ( + name: string | RegExp, + isDropdownToggle?: boolean, + ) => Cypress.Chainable; /** * Finds a patternfly dropdown item by first opening the dropdown if not already opened. * * @param name the name of the item */ - findDropdownItem(name: string | RegExp): Cypress.Chainable; + findDropdownItem: (name: string | RegExp) => Cypress.Chainable; /** * Finds a patternfly dropdown item by data-testid, first opening the dropdown if not already opened. * * @param testId the name of the item */ - findDropdownItemByTestId(testId: string): Cypress.Chainable; + findDropdownItemByTestId: (testId: string) => Cypress.Chainable; /** * Finds a patternfly select option by first opening the select menu if not already opened. * * @param name the name of the option */ - findSelectOption(name: string | RegExp): Cypress.Chainable; + findSelectOption: (name: string | RegExp) => Cypress.Chainable; /** * Shortcut to first clear the previous value and then type text into DOM element. * * @see https://on.cypress.io/type */ - fill( + fill: ( text: string, options?: Partial | undefined, - ): Cypress.Chainable; + ) => Cypress.Chainable; /** * Returns a PF Switch label for clickable actions. * * @param dataId - the data test id you provided to the PF Switch */ - pfSwitch(dataId: string): Cypress.Chainable; + pfSwitch: (dataId: string) => Cypress.Chainable; /** * Returns a PF Switch input behind the checkbox to compare .should('be.checked') like ops * * @param dataId */ - pfSwitchValue(dataId: string): Cypress.Chainable; + pfSwitchValue: (dataId: string) => Cypress.Chainable; + + /** + * The bottom two functions, findByTestId and findAllByTestId have the disabled rule + * method-signature-style because they are overwrites. + * Thus, we cannot change it to use the property signature for functions. + * https://typescript-eslint.io/rules/method-signature-style/ + */ /** * Overwrite `findByTestId` to support an array of Matchers. @@ -85,6 +95,7 @@ declare global { * cy.findByTestId(['card', 'my-id']); * cy.findByTestId('card my-id'); */ + // eslint-disable-next-line @typescript-eslint/method-signature-style findByTestId(id: Matcher | Matcher[], options?: MatcherOptions): Chainable; /** @@ -97,6 +108,7 @@ declare global { * cy.findAllByTestId(['card']); * cy.findAllByTestId('card my-id'); */ + // eslint-disable-next-line @typescript-eslint/method-signature-style findAllByTestId(id: Matcher | Matcher[], options?: MatcherOptions): Chainable; } } diff --git a/frontend/src/__tests__/cypress/cypress/support/commands/axe.ts b/frontend/src/__tests__/cypress/cypress/support/commands/axe.ts index 6267afa9ef..f719986485 100644 --- a/frontend/src/__tests__/cypress/cypress/support/commands/axe.ts +++ b/frontend/src/__tests__/cypress/cypress/support/commands/axe.ts @@ -4,7 +4,7 @@ import 'cypress-axe'; declare global { namespace Cypress { interface Chainable { - testA11y(context?: Parameters[0]): void; + testA11y: (context?: Parameters[0]) => void; } } } diff --git a/frontend/src/__tests__/cypress/cypress/support/commands/intercept-snapshots.ts b/frontend/src/__tests__/cypress/cypress/support/commands/intercept-snapshots.ts index 6cbc432b45..e04fd6bb58 100644 --- a/frontend/src/__tests__/cypress/cypress/support/commands/intercept-snapshots.ts +++ b/frontend/src/__tests__/cypress/cypress/support/commands/intercept-snapshots.ts @@ -7,8 +7,8 @@ declare global { namespace Cypress { interface Chainable { interceptSnapshot: InterceptSnapshot; - waitSnapshot(alias: string): Chainable; - readSnapshot(path: string): Cypress.Chainable<{ [key: string]: Snapshot }>; + waitSnapshot: (alias: string) => Chainable; + readSnapshot: (path: string) => Cypress.Chainable<{ [key: string]: Snapshot }>; } } } diff --git a/frontend/src/__tests__/cypress/cypress/support/commands/k8s.ts b/frontend/src/__tests__/cypress/cypress/support/commands/k8s.ts index e17d2ca88f..717ec7b98e 100644 --- a/frontend/src/__tests__/cypress/cypress/support/commands/k8s.ts +++ b/frontend/src/__tests__/cypress/cypress/support/commands/k8s.ts @@ -35,16 +35,16 @@ declare global { * By default all the URL will include the namespace but not the name of the provided resource. * This results in the default behavior tailored to listing resources. */ - wsK8s( + wsK8s: ( type: 'ADDED' | 'DELETED' | 'MODIFIED', modelOrOptions: K8sModelCommon | WsOptions, resource: K, - ): Cypress.Chainable; + ) => Cypress.Chainable; /** * Simplified variant of equivalent function for GET method. */ - interceptK8s( + interceptK8s: (( modelOrOptions: K8sModelCommon | K8sOptions, response?: | K @@ -53,29 +53,28 @@ declare global { | string | GenericStaticResponse | RouteHandlerController, - ): Chainable; - - /** - * Intercept command for K8s resource. - * Provides equivalent functionality to `cy.intercept` where the URL is constructed from the given model and options. - * - * The default URL will include the name and namespace extracted from the supplied resource. - * This can be overridden by supplying options. - * - * If a payload other than a K8s resource is supplied, ensure that the appropriate options include the resource - * name and namespace, if required. - */ - interceptK8s( - method: 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT', - modelOrOptions: K8sModelCommon | K8sOptions, - response?: - | K - | K8sStatus - | Patch[] - | string - | GenericStaticResponse - | RouteHandlerController, - ): Chainable; + ) => Chainable) & + /** + * Intercept command for K8s resource. + * Provides equivalent functionality to `cy.intercept` where the URL is constructed from the given model and options. + * + * The default URL will include the name and namespace extracted from the supplied resource. + * This can be overridden by supplying options. + * + * If a payload other than a K8s resource is supplied, ensure that the appropriate options include the resource + * name and namespace, if required. + */ + (( + method: 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT', + modelOrOptions: K8sModelCommon | K8sOptions, + response?: + | K + | K8sStatus + | Patch[] + | string + | GenericStaticResponse + | RouteHandlerController, + ) => Chainable); /** * Intercept command for listing K8s resources. @@ -87,13 +86,13 @@ declare global { * If a payload other than a list containing at least one K8s resource is supplied, ensure that the appropriate * options include the resource name and namespace, if required. */ - interceptK8sList( + interceptK8sList: ( modelOrOptions: K8sModelCommon | K8sOptions, resource: | K8sResourceListResult | GenericStaticResponse | K8sStatus> | RouteHandlerController, - ): Chainable; + ) => Chainable; } } } diff --git a/frontend/src/__tests__/cypress/cypress/support/commands/odh.ts b/frontend/src/__tests__/cypress/cypress/support/commands/odh.ts index 0f29cdf747..57e836e84e 100644 --- a/frontend/src/__tests__/cypress/cypress/support/commands/odh.ts +++ b/frontend/src/__tests__/cypress/cypress/support/commands/odh.ts @@ -65,483 +65,404 @@ type Options = { path?: Replacement; query?: Query; times?: number } | null; declare global { namespace Cypress { interface Chainable { - interceptOdh( + interceptOdh: (( type: 'POST /api/accelerator-profiles', response?: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'DELETE /api/accelerator-profiles/:name', - options: { path: { name: string } }, - response?: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'PUT /api/accelerator-profiles/:name', - options: { path: { name: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/groups-config', - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'PUT /api/groups-config', - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/components', - options: { - query?: { - installed: 'true' | 'false'; - }; - } | null, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/docs', - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/quickstarts', - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/dsc/status', - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/status', - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/status/openshift-ai-notebooks/allowedUsers', - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/status/openshift-ai-notebooks/allowedUsers', - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/rolebindings/opendatahub/openshift-ai-notebooks-image-pullers', - response: OdhResponse>, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/config', - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/dsci/status', - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/dashboardConfig/opendatahub/odh-dashboard-config', - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/cluster-settings', - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'PUT /api/cluster-settings', - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/namespaces/:namespace/:context', - options: { - path: { - namespace: string; - context: '0' | '1' | '2' | '*'; - }; - }, - response: OdhResponse<{ applied: boolean }>, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/templates/:namespace', - options: { path: { namespace: string }; query?: { labelSelector: string } }, - response: OdhResponse>, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/templates/:namespace/:name', - options: { path: { namespace: string; name: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'POST /api/templates/', - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'DELETE /api/templates/:namespace/:name', - options: { path: { namespace: string; name: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'PATCH /api/templates/:namespace/:name', - options: { path: { namespace: string; name: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'POST /api/servingRuntimes/', - options: { query: { dryRun: 'All' } } | null, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/images/byon', - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/images/:type', - options: { path: { type: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'DELETE /api/images/:image', - options: { path: { image: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'PUT /api/images/:image', - options: { path: { image: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'POST /api/images', - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'POST /api/notebooks', - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'PATCH /api/notebooks', - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/notebooks/openshift-ai-notebooks/:username/status', - options: { - path: { username: string }; - }, - response: OdhResponse, - ): Cypress.Chainable; - interceptOdh( - type: 'POST /api/prometheus/pvc', - response: OdhResponse<{ code: number; response: PrometheusQueryResponse }>, - ): Cypress.Chainable; - - interceptOdh( - type: 'POST /api/prometheus/query', - response: OdhResponse<{ code: number; response: PrometheusQueryResponse }>, - ): Cypress.Chainable; - - interceptOdh( - type: 'POST /api/prometheus/serving', - response: OdhResponse<{ code: number; response: PrometheusQueryRangeResponse }>, - ): Cypress.Chainable; - - interceptOdh( - type: 'POST /api/prometheus/bias', - response: OdhResponse<{ code: number; response: PrometheusQueryRangeResponse }>, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/service/trustyai/:namespace/trustyai-service/metrics/all/requests', - options: { - path: { namespace: string }; - query?: { type: string }; - }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/service/trustyai/:namespace/trustyai-service/metrics/spd/requests', - options: { - path: { namespace: string }; - }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'POST /api/service/trustyai/:namespace/trustyai-service/metrics/spd/request', - options: { - path: { namespace: string }; - }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'DELETE /api/service/trustyai/:namespace/trustyai-service/metrics/spd/request', - options: { - path: { namespace: string }; - }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/service/trustyai/:namespace/trustyai-service/metrics/dir/requests', - options: { - path: { namespace: string }; - }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'POST /api/service/trustyai/:namespace/trustyai-service/metrics/dir/request', - options: { - path: { namespace: string }; - }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'DELETE /api/service/trustyai/:namespace/trustyai-service/metrics/dir/request', - options: { - path: { namespace: string }; - }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/service/modelregistry/:serviceName/api/model_registry/:apiVersion/registered_models', - options: { path: { serviceName: string; apiVersion: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/service/modelregistry/:serviceName/api/model_registry/:apiVersion/registered_models/:registeredModelId/versions', - options: { path: { serviceName: string; apiVersion: string; registeredModelId: number } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/service/modelregistry/:serviceName/api/model_registry/:apiVersion/registered_models/:registeredModelId', - options: { path: { serviceName: string; apiVersion: string; registeredModelId: number } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/service/modelregistry/:serviceName/api/model_registry/:apiVersion/model_versions/:modelVersionId', - options: { - path: { serviceName: string; apiVersion: string; modelVersionId: number }; - }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/service/modelregistry/:serviceName/api/model_registry/:apiVersion/model_versions/:modelVersionId/artifacts', - options: { path: { serviceName: string; apiVersion: string; modelVersionId: number } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'PATCH /api/service/modelregistry/:serviceName/api/model_registry/:apiVersion/model_versions/:modelVersionId', - options: { path: { serviceName: string; apiVersion: string; modelVersionId: number } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/:pipelineId/versions/:pipelineVersionId`, - options: { - path: { - namespace: string; - serviceName: string; - pipelineId: string; - pipelineVersionId: string; - }; - }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `DELETE /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/:pipelineId/versions/:pipelineVersionId`, - options: { - path: { - namespace: string; - serviceName: string; - pipelineId: string; - pipelineVersionId: string; - }; - times?: number; - }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/:pipelineId`, - options: { path: { namespace: string; serviceName: string; pipelineId: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `DELETE /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/:pipelineId`, - options: { - path: { namespace: string; serviceName: string; pipelineId: string }; - times?: number; - }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `POST /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/upload_version`, - options: { path: { namespace: string; serviceName: string }; times?: number }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `POST /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/:pipelineId/versions`, - options: { - path: { namespace: string; serviceName: string; pipelineId: string }; - times?: number; - }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/:pipelineId/versions`, - options: { path: { namespace: string; serviceName: string; pipelineId: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines`, - options: { - path: { namespace: string; serviceName: string }; - query?: { sort_by: string }; - }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `POST /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/recurringruns/:recurringRunId`, - options: { path: { namespace: string; serviceName: string; recurringRunId: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/recurringruns/:recurringRunId`, - options: { path: { namespace: string; serviceName: string; recurringRunId: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `DELETE /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/recurringruns/:recurringRunId`, - options: { path: { namespace: string; serviceName: string; recurringRunId: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `POST /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/create`, - options: { path: { namespace: string; serviceName: string }; times?: number }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `POST /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/upload`, - options: { path: { namespace: string; serviceName: string }; times?: number }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/runs`, - options: { path: { namespace: string; serviceName: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `POST /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/runs`, - options: { path: { namespace: string; serviceName: string }; times?: number }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `DELETE /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/runs/:runId`, - options: { path: { namespace: string; serviceName: string; runId: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/runs/:runId`, - options: { path: { namespace: string; serviceName: string; runId: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `POST /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/runs/:runId`, - options: { path: { namespace: string; serviceName: string; runId: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/experiments`, - options: { path: { namespace: string; serviceName: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `POST /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/experiments/:experimentId`, - options: { path: { namespace: string; serviceName: string; experimentId: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/experiments/:experimentId`, - options: { path: { namespace: string; serviceName: string; experimentId: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `POST /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/recurringruns`, - options: { path: { namespace: string; serviceName: string }; times?: number }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/recurringruns`, - options: { path: { namespace: string; serviceName: string } }, - response: OdhResponse, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/rolebindings/opendatahub/openshift-ai-notebooks-image-pullers', - response: OdhResponse>, - ): Cypress.Chainable; - - interceptOdh( - type: 'GET /api/notebooks/openshift-ai-notebooks/:username/status', - options: { - path: { username: string }; - }, - response: OdhResponse<{ notebook: NotebookKind; isRunning: boolean }>, - ): Cypress.Chainable; + ) => Cypress.Chainable) & + (( + type: 'DELETE /api/accelerator-profiles/:name', + options: { path: { name: string } }, + response?: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'PUT /api/accelerator-profiles/:name', + options: { path: { name: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/groups-config', + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'PUT /api/groups-config', + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/components', + options: { + query?: { + installed: 'true' | 'false'; + }; + } | null, + response: OdhResponse, + ) => Cypress.Chainable) & + ((type: 'GET /api/docs', response: OdhResponse) => Cypress.Chainable) & + (( + type: 'GET /api/quickstarts', + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/dsc/status', + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/status', + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/status/openshift-ai-notebooks/allowedUsers', + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/status/openshift-ai-notebooks/allowedUsers', + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/rolebindings/opendatahub/openshift-ai-notebooks-image-pullers', + response: OdhResponse>, + ) => Cypress.Chainable) & + (( + type: 'GET /api/config', + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/dsci/status', + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/dashboardConfig/opendatahub/odh-dashboard-config', + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/cluster-settings', + response: OdhResponse, + ) => Cypress.Chainable) & + ((type: 'PUT /api/cluster-settings', response: OdhResponse) => Cypress.Chainable) & + (( + type: 'GET /api/namespaces/:namespace/:context', + options: { + path: { + namespace: string; + context: '0' | '1' | '2' | '*'; + }; + }, + response: OdhResponse<{ applied: boolean }>, + ) => Cypress.Chainable) & + (( + type: 'GET /api/templates/:namespace', + options: { path: { namespace: string }; query?: { labelSelector: string } }, + response: OdhResponse>, + ) => Cypress.Chainable) & + (( + type: 'GET /api/templates/:namespace/:name', + options: { path: { namespace: string; name: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'POST /api/templates/', + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'DELETE /api/templates/:namespace/:name', + options: { path: { namespace: string; name: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'PATCH /api/templates/:namespace/:name', + options: { path: { namespace: string; name: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'POST /api/servingRuntimes/', + options: { query: { dryRun: 'All' } } | null, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/images/byon', + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/images/:type', + options: { path: { type: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'DELETE /api/images/:image', + options: { path: { image: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'PUT /api/images/:image', + options: { path: { image: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'POST /api/images', + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'POST /api/notebooks', + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'PATCH /api/notebooks', + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/notebooks/openshift-ai-notebooks/:username/status', + options: { + path: { username: string }; + }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'POST /api/prometheus/pvc', + response: OdhResponse<{ code: number; response: PrometheusQueryResponse }>, + ) => Cypress.Chainable) & + (( + type: 'POST /api/prometheus/query', + response: OdhResponse<{ code: number; response: PrometheusQueryResponse }>, + ) => Cypress.Chainable) & + (( + type: 'POST /api/prometheus/serving', + response: OdhResponse<{ code: number; response: PrometheusQueryRangeResponse }>, + ) => Cypress.Chainable) & + (( + type: 'POST /api/prometheus/bias', + response: OdhResponse<{ code: number; response: PrometheusQueryRangeResponse }>, + ) => Cypress.Chainable) & + (( + type: 'GET /api/service/trustyai/:namespace/trustyai-service/metrics/all/requests', + options: { + path: { namespace: string }; + query?: { type: string }; + }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/service/trustyai/:namespace/trustyai-service/metrics/spd/requests', + options: { + path: { namespace: string }; + }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'POST /api/service/trustyai/:namespace/trustyai-service/metrics/spd/request', + options: { + path: { namespace: string }; + }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'DELETE /api/service/trustyai/:namespace/trustyai-service/metrics/spd/request', + options: { + path: { namespace: string }; + }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/service/trustyai/:namespace/trustyai-service/metrics/dir/requests', + options: { + path: { namespace: string }; + }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'POST /api/service/trustyai/:namespace/trustyai-service/metrics/dir/request', + options: { + path: { namespace: string }; + }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'DELETE /api/service/trustyai/:namespace/trustyai-service/metrics/dir/request', + options: { + path: { namespace: string }; + }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/service/modelregistry/:serviceName/api/model_registry/:apiVersion/registered_models', + options: { path: { serviceName: string; apiVersion: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/service/modelregistry/:serviceName/api/model_registry/:apiVersion/registered_models/:registeredModelId/versions', + options: { path: { serviceName: string; apiVersion: string; registeredModelId: number } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/service/modelregistry/:serviceName/api/model_registry/:apiVersion/registered_models/:registeredModelId', + options: { path: { serviceName: string; apiVersion: string; registeredModelId: number } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/service/modelregistry/:serviceName/api/model_registry/:apiVersion/model_versions/:modelVersionId', + options: { + path: { serviceName: string; apiVersion: string; modelVersionId: number }; + }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/service/modelregistry/:serviceName/api/model_registry/:apiVersion/model_versions/:modelVersionId/artifacts', + options: { path: { serviceName: string; apiVersion: string; modelVersionId: number } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'PATCH /api/service/modelregistry/:serviceName/api/model_registry/:apiVersion/model_versions/:modelVersionId', + options: { path: { serviceName: string; apiVersion: string; modelVersionId: number } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/:pipelineId/versions/:pipelineVersionId`, + options: { + path: { + namespace: string; + serviceName: string; + pipelineId: string; + pipelineVersionId: string; + }; + }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `DELETE /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/:pipelineId/versions/:pipelineVersionId`, + options: { + path: { + namespace: string; + serviceName: string; + pipelineId: string; + pipelineVersionId: string; + }; + times?: number; + }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/:pipelineId`, + options: { path: { namespace: string; serviceName: string; pipelineId: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `DELETE /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/:pipelineId`, + options: { + path: { namespace: string; serviceName: string; pipelineId: string }; + times?: number; + }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `POST /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/upload_version`, + options: { path: { namespace: string; serviceName: string }; times?: number }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `POST /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/:pipelineId/versions`, + options: { + path: { namespace: string; serviceName: string; pipelineId: string }; + times?: number; + }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/:pipelineId/versions`, + options: { path: { namespace: string; serviceName: string; pipelineId: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines`, + options: { + path: { namespace: string; serviceName: string }; + query?: { sort_by: string }; + }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `POST /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/recurringruns/:recurringRunId`, + options: { path: { namespace: string; serviceName: string; recurringRunId: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/recurringruns/:recurringRunId`, + options: { path: { namespace: string; serviceName: string; recurringRunId: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `DELETE /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/recurringruns/:recurringRunId`, + options: { path: { namespace: string; serviceName: string; recurringRunId: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `POST /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/create`, + options: { path: { namespace: string; serviceName: string }; times?: number }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `POST /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/pipelines/upload`, + options: { path: { namespace: string; serviceName: string }; times?: number }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/runs`, + options: { path: { namespace: string; serviceName: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `POST /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/runs`, + options: { path: { namespace: string; serviceName: string }; times?: number }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `DELETE /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/runs/:runId`, + options: { path: { namespace: string; serviceName: string; runId: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/runs/:runId`, + options: { path: { namespace: string; serviceName: string; runId: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `POST /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/runs/:runId`, + options: { path: { namespace: string; serviceName: string; runId: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/experiments`, + options: { path: { namespace: string; serviceName: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `POST /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/experiments/:experimentId`, + options: { path: { namespace: string; serviceName: string; experimentId: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/experiments/:experimentId`, + options: { path: { namespace: string; serviceName: string; experimentId: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `POST /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/recurringruns`, + options: { path: { namespace: string; serviceName: string }; times?: number }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: `GET /api/service/pipelines/:namespace/:serviceName/apis/v2beta1/recurringruns`, + options: { path: { namespace: string; serviceName: string } }, + response: OdhResponse, + ) => Cypress.Chainable) & + (( + type: 'GET /api/rolebindings/opendatahub/openshift-ai-notebooks-image-pullers', + response: OdhResponse>, + ) => Cypress.Chainable) & + (( + type: 'GET /api/notebooks/openshift-ai-notebooks/:username/status', + options: { + path: { username: string }; + }, + response: OdhResponse<{ notebook: NotebookKind; isRunning: boolean }>, + ) => Cypress.Chainable); } } } diff --git a/frontend/src/__tests__/cypress/cypress/support/websockets.ts b/frontend/src/__tests__/cypress/cypress/support/websockets.ts index 325cd857b4..aa1ac506ce 100644 --- a/frontend/src/__tests__/cypress/cypress/support/websockets.ts +++ b/frontend/src/__tests__/cypress/cypress/support/websockets.ts @@ -7,10 +7,10 @@ declare global { /** * Send data to through websockets to all matching connections. */ - wsSend( + wsSend: ( matcher: string | { pathname: string; searchParams?: URLSearchParams }, data: string | object, - ): void; + ) => void; } } } diff --git a/frontend/src/__tests__/unit/jest.d.ts b/frontend/src/__tests__/unit/jest.d.ts index 3a99872fcf..5decfa3cf0 100644 --- a/frontend/src/__tests__/unit/jest.d.ts +++ b/frontend/src/__tests__/unit/jest.d.ts @@ -1,13 +1,13 @@ declare namespace jest { interface Expect { - isIdentityEqual(expected: T): T; + isIdentityEqual: (expected: T) => T; } interface Matchers { - hookToBe(expected: unknown): R; - hookToStrictEqual(expected: unknown): R; - hookToHaveUpdateCount(expected: number): R; - hookToBeStable< + hookToBe: (expected: unknown) => R; + hookToStrictEqual: (expected: unknown) => R; + hookToHaveUpdateCount: (expected: number) => R; + hookToBeStable: < V extends T extends Pick< import('~/__tests__/unit/testUtils/hooks').RenderHookResultExt< infer Result, @@ -20,10 +20,10 @@ declare namespace jest { : never, >( expected?: V, - ): R; + ) => R; } interface Expect { - isIdentityEqual(expected: unknown): AsymmetricMatcher; + isIdentityEqual: (expected: unknown) => AsymmetricMatcher; } } diff --git a/frontend/src/concepts/pipelines/content/createRun/contentSections/ParamsSection/types.ts b/frontend/src/concepts/pipelines/content/createRun/contentSections/ParamsSection/types.ts index 2fb5abce13..106756f8f7 100644 --- a/frontend/src/concepts/pipelines/content/createRun/contentSections/ParamsSection/types.ts +++ b/frontend/src/concepts/pipelines/content/createRun/contentSections/ParamsSection/types.ts @@ -3,5 +3,5 @@ import { RuntimeConfigParamValue } from '~/concepts/pipelines/kfTypes'; export type InputParamProps = { id: string; value: RuntimeConfigParamValue; - onChange(event: React.ChangeEvent | null, value: RuntimeConfigParamValue): void; + onChange: (event: React.ChangeEvent | null, value: string | number | boolean) => void; };