Skip to content

Commit

Permalink
chore: End a/b campaigns for aci smart banners (#25504)
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-plummer authored Jan 25, 2023
1 parent fe1fe7f commit f1f2c73
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 32 deletions.
26 changes: 15 additions & 11 deletions packages/app/src/specs/SpecsListBanners.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ import ConnectIcon from '~icons/cy/chain-link_x16.svg'
import WarningIcon from '~icons/cy/warning_x16.svg'
import RefreshIcon from '~icons/cy/action-restart_x16'
import { useRoute } from 'vue-router'
import { computed, reactive, ref, watch } from 'vue'
import { computed, reactive, ref, watch, Ref } from 'vue'
import RequestAccessButton from './RequestAccessButton.vue'
import { gql, useSubscription } from '@urql/vue'
import { SpecsListBannersFragment, SpecsListBanners_CheckCloudOrgMembershipDocument } from '../generated/graphql'
import { AllowedState, BannerIds } from '@packages/types'
import { LoginBanner, CreateOrganizationBanner, ConnectProjectBanner, RecordBanner } from './banners'
import { useLoginConnectStore } from '@packages/frontend-shared/src/store/login-connect-store'
import { usePromptManager } from '@packages/frontend-shared/src/gql-components/composables/usePromptManager'
import { CohortConfig, useCohorts } from '@packages/frontend-shared/src/gql-components/composables/useCohorts'
import { CohortConfig, CohortOption, useCohorts } from '@packages/frontend-shared/src/gql-components/composables/useCohorts'
const route = useRoute()
const { t } = useI18n()
Expand Down Expand Up @@ -248,27 +248,31 @@ watch(cloudData, () => {
},
{ immediate: true })
const bannerCohortOptions = {
type BannerKeys = keyof typeof BannerIds
type BannerId = typeof BannerIds[BannerKeys]
type BannerCohortOptions = Partial<Record<BannerId, CohortOption[]>>
const bannerCohortOptions: BannerCohortOptions = {
[BannerIds.ACI_082022_LOGIN]: [
{ cohort: 'A', value: t('specPage.banners.login.contentA') },
{ cohort: 'B', value: t('specPage.banners.login.contentB') },
// Campaign ended in v12.4.0, see GH issue #24472
{ cohort: '', value: t('specPage.banners.login.content') },
],
[BannerIds.ACI_082022_CREATE_ORG]: [
{ cohort: 'A', value: t('specPage.banners.createOrganization.titleA') },
{ cohort: 'B', value: t('specPage.banners.createOrganization.titleB') },
// Campaign ended in v12.4.0, see GH issue #24472
{ cohort: '', value: t('specPage.banners.createOrganization.title') },
],
[BannerIds.ACI_082022_CONNECT_PROJECT]: [
{ cohort: 'A', value: t('specPage.banners.connectProject.contentA') },
{ cohort: 'B', value: t('specPage.banners.connectProject.contentB') },
// Campaign ended in v12.4.0, see GH issue #24472
{ cohort: '', value: t('specPage.banners.connectProject.content') },
],
}
const cohortBuilder = useCohorts()
const getCohortForBanner = (bannerId: string) => {
const getCohortForBanner = (bannerId: BannerId): Ref<CohortOption | undefined> => {
const cohortConfig: CohortConfig = {
name: bannerId,
options: bannerCohortOptions[bannerId],
options: bannerCohortOptions[bannerId] || [],
}
return cohortBuilder.getCohort(cohortConfig)
Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/specs/banners/ConnectProjectBanner.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import ConnectProjectBanner from './ConnectProjectBanner.vue'
import { TrackedBanner_RecordBannerSeenDocument } from '../../generated/graphql'

describe('<ConnectProjectBanner />', () => {
const cohortOption = { cohort: 'A', value: defaultMessages.specPage.banners.connectProject.contentA }
const cohortOption = { cohort: '', value: defaultMessages.specPage.banners.connectProject.content }

it('should render expected content', () => {
cy.mount({ render: () => <ConnectProjectBanner hasBannerBeenShown={true} cohortOption={cohortOption}/> })

cy.contains(defaultMessages.specPage.banners.connectProject.title).should('be.visible')
cy.contains(defaultMessages.specPage.banners.connectProject.contentA).should('be.visible')
cy.contains(defaultMessages.specPage.banners.connectProject.content).should('be.visible')
cy.contains(defaultMessages.specPage.banners.connectProject.buttonLabel).should('be.visible')

cy.percySnapshot()
Expand All @@ -33,7 +33,7 @@ describe('<ConnectProjectBanner />', () => {
campaign: 'Create project',
medium: 'Specs Create Project Banner',
messageId: Cypress.sinon.match.string,
cohort: 'A',
cohort: null,
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import CreateOrganizationBanner from './CreateOrganizationBanner.vue'
import { TrackedBanner_RecordBannerSeenDocument } from '../../generated/graphql'

describe('<CreateOrganizationBanner />', () => {
const cohortOption = { cohort: 'A', value: defaultMessages.specPage.banners.createOrganization.titleA }
const cohortOption = { cohort: '', value: defaultMessages.specPage.banners.createOrganization.title }

it('should render expected content', () => {
const linkHref = 'http://dummy.cypress.io/organizations/create'
Expand All @@ -16,7 +16,7 @@ describe('<CreateOrganizationBanner />', () => {

cy.mount({ render: () => <CreateOrganizationBanner hasBannerBeenShown={true} cohortOption={cohortOption}/> })

cy.contains(defaultMessages.specPage.banners.createOrganization.titleA).should('be.visible')
cy.contains(defaultMessages.specPage.banners.createOrganization.title).should('be.visible')
cy.contains(defaultMessages.specPage.banners.createOrganization.content).should('be.visible')
cy.contains(defaultMessages.specPage.banners.createOrganization.buttonLabel).should('be.visible')

Expand Down Expand Up @@ -45,7 +45,7 @@ describe('<CreateOrganizationBanner />', () => {
campaign: 'Set up your organization',
medium: 'Specs Create Organization Banner',
messageId: Cypress.sinon.match.string,
cohort: 'A',
cohort: null,
})
})

Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/specs/banners/LoginBanner.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import LoginBanner from './LoginBanner.vue'
import { TrackedBanner_RecordBannerSeenDocument } from '../../generated/graphql'

describe('<LoginBanner />', () => {
const cohortOption = { cohort: 'A', value: defaultMessages.specPage.banners.login.contentA }
const cohortOption = { cohort: '', value: defaultMessages.specPage.banners.login.content }

it('should render expected content', () => {
cy.mount({ render: () => <LoginBanner hasBannerBeenShown={true} cohortOption={cohortOption}/> })

cy.contains(defaultMessages.specPage.banners.login.title).should('be.visible')
cy.contains(defaultMessages.specPage.banners.login.contentA).should('be.visible')
cy.contains(defaultMessages.specPage.banners.login.content).should('be.visible')
cy.contains(defaultMessages.specPage.banners.login.buttonLabel).should('be.visible')

cy.percySnapshot()
Expand All @@ -33,7 +33,7 @@ describe('<LoginBanner />', () => {
campaign: 'Log In',
medium: 'Specs Login Banner',
messageId: Cypress.sinon.match.string,
cohort: cohortOption.cohort,
cohort: null,
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,22 @@ export const useCohorts = () => {
const getCohort = (config: CohortConfig) => {
const cohortOptionSelected = ref<CohortOption>()

const cohortIds = config.options.map((option) => option.cohort)
const { name, options } = config

const fetchCohort = async () => {
const cohortSelected = await determineCohort(config.name, cohortIds)
// If an experiment has been ended it will have <= 1 cohort option. In this case, bypass selecting & persisting a cohort
if (!options || options.length <= 1) {
cohortOptionSelected.value = options?.[0]
} else {
const cohortIds = options.map((option) => option.cohort)

cohortOptionSelected.value = config.options.find((option) => option.cohort === cohortSelected.data?.determineCohort?.cohort)
}
const fetchCohort = async () => {
const cohortSelected = await determineCohort(name, cohortIds)

cohortOptionSelected.value = options.find((option) => option.cohort === cohortSelected.data?.determineCohort?.cohort)
}

fetchCohort()
fetchCohort()
}

return cohortOptionSelected
}
Expand Down
9 changes: 3 additions & 6 deletions packages/frontend-shared/src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,20 +199,17 @@
"banners": {
"login": {
"title": "Optimize and record your CI test runs with Cypress Cloud",
"contentA": "Parallelize your tests in CI and visualize every error by watching full video recordings of each test you run.",
"contentB": "When you configure Cypress to record tests to Cypress Cloud, you'll see data from your latest recorded runs in the Cypress app. This increased visibility into your test history allows you to debug your tests faster and more effectively, all within your local workflow.",
"content": "When you configure Cypress to record tests to Cypress Cloud, you'll see data from your latest recorded runs in the Cypress app. This increased visibility into your test history allows you to debug your tests faster and more effectively, all within your local workflow.",
"buttonLabel": "Get started with Cypress Cloud"
},
"createOrganization": {
"titleA": "Finish setting up Cypress Cloud",
"titleB": "Create or join an organization",
"title": "Finish setting up Cypress Cloud",
"content": "Join or create an organization in Cypress Cloud to access your projects and recorded test runs.",
"buttonLabel": "Set up your organization"
},
"connectProject": {
"title": "Connect your project to Cypress Cloud",
"contentA": "View recorded test runs directly in the Cypress app to monitor, run, and fix tests locally.",
"contentB": "Bring your recorded test results into your local development workflow to monitor, run, and fix tests all in the Cypress app.",
"content": "Bring your recorded test results into your local development workflow to monitor, run, and fix tests all in the Cypress app.",
"buttonLabel": "Connect your project"
},
"record": {
Expand Down

5 comments on commit f1f2c73

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f1f2c73 Jan 25, 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/12.4.1/linux-arm64/develop-f1f2c730153faecbffca82797de4a6d00fca92d3/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f1f2c73 Jan 25, 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/12.4.1/linux-x64/develop-f1f2c730153faecbffca82797de4a6d00fca92d3/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f1f2c73 Jan 25, 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/12.4.1/darwin-arm64/develop-f1f2c730153faecbffca82797de4a6d00fca92d3/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f1f2c73 Jan 25, 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/12.4.1/darwin-x64/develop-f1f2c730153faecbffca82797de4a6d00fca92d3/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f1f2c73 Jan 25, 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/12.4.1/win32-x64/develop-f1f2c730153faecbffca82797de4a6d00fca92d3/cypress.tgz

Please sign in to comment.