From 9c540138c0ae49c0c23743bd7f62aef92ae529bb Mon Sep 17 00:00:00 2001 From: Cacie Prins Date: Mon, 23 Oct 2023 15:02:47 -0400 Subject: [PATCH] Revert "improve typescript usage when appending experimental retry options to experiments in Experimenets.vue" This reverts commit b459aba882a16e64caf2b6d4f9326c875106cdd2. --- .../app/src/settings/project/Experiments.vue | 33 ++++++++----------- .../src/settings/project/projectSettings.ts | 6 ++-- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/packages/app/src/settings/project/Experiments.vue b/packages/app/src/settings/project/Experiments.vue index 426a78e68375..b86489197e18 100644 --- a/packages/app/src/settings/project/Experiments.vue +++ b/packages/app/src/settings/project/Experiments.vue @@ -39,7 +39,7 @@ import SettingsSection from '../SettingsSection.vue' import ExternalLink from '@cy/gql-components/ExternalLink.vue' import type { ExperimentsFragment } from '../../generated/graphql' import { useI18n } from '@cy/i18n' -import type { CypressResolvedConfig, CypressConfigEntry } from './projectSettings' +import type { CypressResolvedConfig } from './projectSettings' const { t } = useI18n() gql` @@ -55,31 +55,24 @@ const props = defineProps<{ const localExperiments = computed(() => { // get experiments out of the config - const cfg = (props.gql?.config || []) as CypressResolvedConfig - - const experimentalConfigurations = cfg.filter((item) => item.field.startsWith('experimental')) + const experimentalConfigurations = props.gql?.config ? (props.gql.config as CypressResolvedConfig).filter((item) => item.field.startsWith('experimental')) : [] // get experimental retry properties on the 'retries' config object. Mutate the experimentalConfigurations array as to not have side effects with props.gql.config // TODO: remove this once experimentalRetries becomes GA. This is to be treated as a one off as supported nested experiments inside config is rare. - // const { value: { experimentalStrategy, experimentalOptions, from } } - const retryConfig = cfg.find((item) => item.field === 'retries') - - if (retryConfig) { - const { value: { experimentalStrategy, experimentalOptions, from } } = retryConfig as CypressConfigEntry & { value: Record } + const { value: { experimentalStrategy, experimentalOptions, from } } = props.gql?.config.find((item) => item.field === 'retries') - experimentalConfigurations.push({ - field: 'retries.experimentalStrategy', - from, - value: experimentalStrategy, - }) + experimentalConfigurations.push({ + field: 'retries.experimentalStrategy', + from, + value: experimentalStrategy, + }) - experimentalConfigurations.push({ - field: 'retries.experimentalOptions', - from, - value: experimentalOptions, - }) + experimentalConfigurations.push({ + field: 'retries.experimentalOptions', + from, + value: experimentalOptions, + }) // end TODO removal - } return experimentalConfigurations.map((configItem) => { return { diff --git a/packages/app/src/settings/project/projectSettings.ts b/packages/app/src/settings/project/projectSettings.ts index 18cd7e4935c5..317d5cc33bc7 100644 --- a/packages/app/src/settings/project/projectSettings.ts +++ b/packages/app/src/settings/project/projectSettings.ts @@ -15,10 +15,8 @@ export interface Experiment { key: string } -export type CypressConfigEntry = { +export type CypressResolvedConfig = Array<{ field: string from: 'default'| 'config' | 'plugin' | 'env' value: string | number | boolean | Record | Array -} - -export type CypressResolvedConfig = Array +}>