Skip to content

Commit

Permalink
Merge branch 'develop' into update-v8-snapshot-cache-on-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanthemanuel authored Jun 5, 2023
2 parents 7406580 + d77341e commit 56bd0ae
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 11 deletions.
7 changes: 6 additions & 1 deletion cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ _Released 06/06/2023 (PENDING)_

## 12.13.0

_Pending_

**Bugfixes:**
- Make Git-related messages on the [Runs page](https://docs.cypress.io/guides/core-concepts/cypress-app#Runs) remain dismissed. Addresses [#26808](https://github.com/cypress-io/cypress/issues/26808)

_Released 05/23/2023_

**Features:**

- Adds Git-related messages for the [Runs page](https://docs.cypress.io/guides/core-concepts/cypress-app#Runs) and [Debug page](https://docs.cypress.io/guides/cloud/runs#Debug) when users aren't using Git or there are no recorded runs for the current branch. Fixes [#26680](https://github.com/cypress-io/cypress/issues/26680).
- Add Git-related messages for the [Runs page](https://docs.cypress.io/guides/core-concepts/cypress-app#Runs) and [Debug page](https://docs.cypress.io/guides/cloud/runs#Debug) when users aren't using Git or there are no recorded runs for the current branch. Addresses [#26680](https://github.com/cypress-io/cypress/issues/26680).

**Bugfixes:**

Expand Down
52 changes: 51 additions & 1 deletion packages/app/src/runs/RunsContainer.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,28 @@ describe('<RunsContainer />', { keystrokeDelay: 0 }, () => {
})

cy.get('h3').contains(defaultMessages.runs.empty.gitRepositoryNotDetected)
cy.get('p').contains(defaultMessages.runs.empty.ensureGitSetupCorrectly)
cy.contains(defaultMessages.runs.empty.ensureGitSetupCorrectly)
})

it('dismisses the alert', () => {
const userProjectStatusStore = useUserProjectStatusStore()

userProjectStatusStore.setProjectFlag('isUsingGit', false)
userProjectStatusStore.setUserFlag('isLoggedIn', true)

cy.mountFragment(RunsContainerFragmentDoc, {
onResult: (result) => {
result.cloudViewer = cloudViewer
},
render (gqlVal) {
return <RunsContainer gql={gqlVal} online />
},
})

cy.get('h3').contains(defaultMessages.runs.empty.gitRepositoryNotDetected)
cy.contains(defaultMessages.runs.empty.ensureGitSetupCorrectly)
cy.get('[data-cy=alert-suffix-icon]').click()
cy.get('[data-cy=alert-header]').should('not.exist')
})
})

Expand Down Expand Up @@ -175,5 +196,34 @@ describe('<RunsContainer />', { keystrokeDelay: 0 }, () => {
// The utm_source will be Binary%3A+App in production`open` mode but we assert using Binary%3A+Launchpad as this is the value in CI
cy.contains(defaultMessages.links.learnMoreButton).should('have.attr', 'href', 'https://on.cypress.io/git-info?utm_source=Binary%3A+Launchpad&utm_medium=Runs+Tab&utm_campaign=No+Runs+Found')
})

it('dismisses the alert', () => {
const { setUserFlag, setProjectFlag, cloudStatusMatches } = useUserProjectStatusStore()

setUserFlag('isLoggedIn', true)
setUserFlag('isMemberOfOrganization', true)
setProjectFlag('isProjectConnected', true)
setProjectFlag('hasNoRecordedRuns', true)
setProjectFlag('hasNonExampleSpec', true)
setProjectFlag('isConfigLoaded', true)
setProjectFlag('isUsingGit', true)

expect(cloudStatusMatches('needsRecordedRun')).equals(true)
cy.mountFragment(RunsContainerFragmentDoc, {
onResult: (result) => {
result.cloudViewer = cloudViewer
},
render (gqlVal) {
return <RunsContainer gql={gqlVal} online />
},
})

cy.get('h3').contains(defaultMessages.runs.empty.noRunsFoundForBranch)
cy.get('p').contains(defaultMessages.runs.empty.noRunsForBranchMessage)
// The utm_source will be Binary%3A+App in production`open` mode but we assert using Binary%3A+Launchpad as this is the value in CI
cy.contains(defaultMessages.links.learnMoreButton).should('have.attr', 'href', 'https://on.cypress.io/git-info?utm_source=Binary%3A+Launchpad&utm_medium=Runs+Tab&utm_campaign=No+Runs+Found')
cy.get('[data-cy=alert-suffix-icon]').click()
cy.get('[data-cy=alert-header]').should('not.exist')
})
})
})
37 changes: 31 additions & 6 deletions packages/app/src/runs/RunsContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,39 @@
data-cy="runs"
class="flex flex-col pb-[24px] gap-[16px]"
>
<Warning
<TrackedBanner
v-if="userProjectStatusStore.cloudStatusMatches('needsRecordedRun') && userProjectStatusStore.project.isUsingGit"
:title="t('runs.empty.noRunsFoundForBranch')"
:message="noRunsForBranchMessage"
/>
:banner-id="ACI_052023_NO_RUNS_FOUND_FOR_BRANCH"
dismissible
status="warning"
:has-banner-been-shown="false"
:event-data="undefined"
>
<div
ref="markdownTarget"
class="warning-markdown"
v-html="markdown"
/>
</TrackedBanner>
<Warning
v-if="!online"
:title="t('launchpadErrors.noInternet.header')"
:message="t('launchpadErrors.noInternet.message')"
:dismissible="false"
class="mx-auto mb-[24px]"
/>
<Warning
<TrackedBanner
v-if="!userProjectStatusStore.project.isUsingGit"
:title="t('runs.empty.gitRepositoryNotDetected')"
:message="t('runs.empty.ensureGitSetupCorrectly')"
/>
:banner-id="ACI_052023_GIT_NOT_DETECTED"
:has-banner-been-shown="false"
status="warning"
dismissible
:event-data="undefined"
>
{{ t('runs.empty.ensureGitSetupCorrectly') }}
</TrackedBanner>
<RunCard
v-for="run of currentProject?.cloudProject?.runs?.nodes"
:key="run.id"
Expand All @@ -69,9 +85,16 @@ import { useUserProjectStatusStore } from '@packages/frontend-shared/src/store/u
import { RUNS_PROMO_CAMPAIGNS, RUNS_TAB_MEDIUM } from './utils/constants'
import { getUrlWithParams } from '@packages/frontend-shared/src/utils/getUrlWithParams'
import { getUtmSource } from '@packages/frontend-shared/src/utils/getUtmSource'
import TrackedBanner from '../specs/banners/TrackedBanner.vue'
import { BannerIds } from '@packages/types/src'
import { useMarkdown } from '@packages/frontend-shared/src/composables/useMarkdown'
const { t } = useI18n()
const markdownTarget = ref()
const { ACI_052023_GIT_NOT_DETECTED, ACI_052023_NO_RUNS_FOUND_FOR_BRANCH } = BannerIds
const emit = defineEmits<{
(e: 'reExecuteRunsQuery'): void
}>()
Expand Down Expand Up @@ -220,6 +243,8 @@ const noRunsForBranchMessage = computed(() => {
return `${message} ${link}`
})
const { markdown } = useMarkdown(markdownTarget, noRunsForBranchMessage.value, { classes: { code: ['bg-warning-200'] } })
const userProjectStatusStore = useUserProjectStatusStore()
watch(() => userProjectStatusStore.project.isProjectConnected, (newVal, oldVal) => {
Expand Down
10 changes: 10 additions & 0 deletions packages/app/src/specs/banners/TrackedBanner.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,15 @@ describe('<TrackedBanner />', () => {
cy.get('@recordEvent').should('not.have.been.called')
})
})

context('when eventData is undefined', () => {
it('should not record event', () => {
cy.mount({
render: () => <TrackedBanner bannerId="test-banner" hasBannerBeenShown={false} eventData={undefined} />,
})

cy.get('@recordEvent').should('not.have.been.called')
})
})
})
})
2 changes: 1 addition & 1 deletion packages/app/src/specs/banners/TrackedBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type AlertComponentProps = InstanceType<typeof Alert>['$props']
interface TrackedBannerComponentProps extends AlertComponentProps {
bannerId: string
hasBannerBeenShown: boolean
eventData: EventData
eventData: EventData | undefined
}
gql`
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export const BannerIds = {
ACI_082022_CONNECT_PROJECT: 'aci_082022_connectProject',
ACI_082022_RECORD: 'aci_082022_record',
CT_052023_AVAILABLE: 'ct_052023_available',
ACI_052023_NO_RUNS_FOUND_FOR_BRANCH: 'aci_052023_noRunsFoundForBranch',
ACI_052023_GIT_NOT_DETECTED: 'aci_052023_gitNotDetected',
} as const

type BannerKeys = keyof typeof BannerIds
Expand Down
14 changes: 12 additions & 2 deletions scripts/circle-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,18 @@ async function checkCanaries () {

const circleEnv = await readCircleEnv()

if (Object.keys(circleEnv).length === 0) {
return console.warn('CircleCI env empty, assuming this is a contributor PR. Not checking for canary variables.')
// if the config contains only CIRCLE_OIDC_TOKEN, CIRCLE_OIDC_TOKEN_V2, CIRCLE_PLUGIN_TEST, treat the config as if it were empty
const containsOnlyAllowedEnvs = () => {
const circleEnvKeys = Object.keys(circleEnv)

return circleEnvKeys.length === 0 || (circleEnvKeys.length === 3 &&
circleEnvKeys.includes('CIRCLE_OIDC_TOKEN') &&
circleEnvKeys.includes('CIRCLE_OIDC_TOKEN_V2') &&
circleEnvKeys.includes('CIRCLE_PLUGIN_TEST'))
}

if (containsOnlyAllowedEnvs()) {
return console.warn('CircleCI env empty or contains only allowed envs, assuming this is a contributor PR. Not checking for canary variables.')
}

if (!circleEnv.MAIN_CANARY) throw new Error('Missing MAIN_CANARY.')
Expand Down
50 changes: 50 additions & 0 deletions scripts/unit/circle-env-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,56 @@ describe('circle-env', () => {
}
})
})

context('with circleEnv plus only omitted keys', () => {
it('passes', async () => {
sinon.stub(fs, 'readFile')
.withArgs('/foo.json').resolves(JSON.stringify({
Dispatched: { TaskInfo: { Environment: {
CIRCLE_OIDC_TOKEN: 'foo',
CIRCLE_OIDC_TOKEN_V2: 'bar',
CIRCLE_PLUGIN_TEST: 'baz',
} } },
}))

sinon.spy(console, 'warn')
await _checkCanaries()
expect(console.warn).to.be.calledWith('CircleCI env empty or contains only allowed envs, assuming this is a contributor PR. Not checking for canary variables.')
})

it('also passes', async () => {
sinon.stub(fs, 'readFile')
.withArgs('/foo.json').resolves(JSON.stringify({
Dispatched: { TaskInfo: { Environment: {
CIRCLE_OIDC_TOKEN: 'foo',
CIRCLE_OIDC_TOKEN_V2: 'bar',
CIRCLE_PLUGIN_TEST: 'baz',
MAIN_CANARY: 'qux',
CONTEXT_CANARY: 'quux',
} } },
}))

await _checkCanaries()
})

it('fails', async () => {
sinon.stub(fs, 'readFile')
.withArgs('/foo.json').resolves(JSON.stringify({
Dispatched: { TaskInfo: { Environment: {
CIRCLE_OIDC_TOKEN: 'foo',
CIRCLE_OIDC_TOKEN_V2: 'bar',
CIRCLE_PLUGIN_TEST: 'baz',
SOME_OTHER_VAR: 'quux',
} } },
}))

try {
await _checkCanaries()
} catch (e) {
expect(e.message).to.equal('Missing MAIN_CANARY.')
}
})
})
})

it('passes with canaries', async () => {
Expand Down

4 comments on commit 56bd0ae

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 56bd0ae Jun 5, 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.13.1/linux-arm64/update-v8-snapshot-cache-on-develop-56bd0ae28fbc1cccb289a54546f6183c07e30a0c/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 56bd0ae Jun 5, 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.13.1/linux-x64/update-v8-snapshot-cache-on-develop-56bd0ae28fbc1cccb289a54546f6183c07e30a0c/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 56bd0ae Jun 5, 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.13.1/darwin-x64/update-v8-snapshot-cache-on-develop-56bd0ae28fbc1cccb289a54546f6183c07e30a0c/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 56bd0ae Jun 5, 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.13.1/win32-x64/update-v8-snapshot-cache-on-develop-56bd0ae28fbc1cccb289a54546f6183c07e30a0c/cypress.tgz

Please sign in to comment.