Skip to content

Commit

Permalink
improve typescript usage when appending experimental retry options to…
Browse files Browse the repository at this point in the history
… experiments in Experimenets.vue
  • Loading branch information
cacieprins committed Oct 23, 2023
1 parent 711b548 commit b459aba
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
33 changes: 20 additions & 13 deletions packages/app/src/settings/project/Experiments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 } from './projectSettings'
import type { CypressResolvedConfig, CypressConfigEntry } from './projectSettings'
const { t } = useI18n()
gql`
Expand All @@ -55,24 +55,31 @@ const props = defineProps<{
const localExperiments = computed(() => {
// get experiments out of the config
const experimentalConfigurations = props.gql?.config ? (props.gql.config as CypressResolvedConfig).filter((item) => item.field.startsWith('experimental')) : []
const cfg = (props.gql?.config || []) as CypressResolvedConfig
const experimentalConfigurations = cfg.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 } } = props.gql?.config.find((item) => item.field === 'retries')
// const { value: { experimentalStrategy, experimentalOptions, from } }
const retryConfig = cfg.find((item) => item.field === 'retries')
experimentalConfigurations.push({
field: 'retries.experimentalStrategy',
from,
value: experimentalStrategy,
})
if (retryConfig) {
const { value: { experimentalStrategy, experimentalOptions, from } } = retryConfig as CypressConfigEntry & { value: Record<string, string> }
experimentalConfigurations.push({
field: 'retries.experimentalOptions',
from,
value: experimentalOptions,
})
experimentalConfigurations.push({
field: 'retries.experimentalStrategy',
from,
value: experimentalStrategy,
})
experimentalConfigurations.push({
field: 'retries.experimentalOptions',
from,
value: experimentalOptions,
})
// end TODO removal
}
return experimentalConfigurations.map((configItem) => {
return {
Expand Down
6 changes: 4 additions & 2 deletions packages/app/src/settings/project/projectSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ export interface Experiment {
key: string
}

export type CypressResolvedConfig = Array<{
export type CypressConfigEntry = {
field: string
from: 'default'| 'config' | 'plugin' | 'env'
value: string | number | boolean | Record<string, string> | Array<string>
}>
}

export type CypressResolvedConfig = Array<CypressConfigEntry>

5 comments on commit b459aba

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b459aba Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.4.0/linux-arm64/feature/experimental-retries-b459aba882a16e64caf2b6d4f9326c875106cdd2/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b459aba Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.4.0/linux-x64/feature/experimental-retries-b459aba882a16e64caf2b6d4f9326c875106cdd2/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b459aba Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.4.0/darwin-x64/feature/experimental-retries-b459aba882a16e64caf2b6d4f9326c875106cdd2/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b459aba Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.4.0/darwin-arm64/feature/experimental-retries-b459aba882a16e64caf2b6d4f9326c875106cdd2/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b459aba Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.4.0/win32-x64/feature/experimental-retries-b459aba882a16e64caf2b6d4f9326c875106cdd2/cypress.tgz

Please sign in to comment.