Skip to content

Commit

Permalink
chore: protocol/mount before async (#27511)
Browse files Browse the repository at this point in the history
Co-authored-by: David Kasper <dave.m.kasper@gmail.com>
  • Loading branch information
lmiller1990 and dkasper-was-taken committed Aug 10, 2023
1 parent 421c7a3 commit d27e249
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 26 deletions.
2 changes: 1 addition & 1 deletion npm/mount-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function setupHooks (optionalCallback?: Function) {
})

// @ts-ignore
Cypress.on('test:before:run', () => {
Cypress.on('test:before:after:run:async', () => {
optionalCallback?.()
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ import { computed } from 'vue'
import { gql, useMutation } from '@urql/vue'
import { allBrowsersIcons } from '@packages/frontend-shared/src/assets/browserLogos'
import Tooltip from '../../components/Tooltip.vue'
import sortBrowsers from '@packages/frontend-shared/src/utils/sortBrowsers'
const { t } = useI18n()
Expand Down Expand Up @@ -129,11 +128,7 @@ const props = withDefaults(defineProps <{
})
const browsers = computed(() => {
if (!props.gql.browsers) {
return undefined
}
return sortBrowsers([...props.gql.browsers])
return (props.gql.browsers ?? []).slice().sort((a, b) => a.displayName > b.displayName ? 1 : -1)
})
const setBrowser = useMutation(VerticalBrowserListItems_SetBrowserDocument)
Expand Down
3 changes: 0 additions & 3 deletions packages/frontend-shared/src/utils/sortBrowsers.ts

This file was deleted.

11 changes: 4 additions & 7 deletions packages/launchpad/src/setup/OpenBrowserList.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,10 @@ describe('<OpenBrowserList />', () => {

cy.contains('button', defaultMessages.openBrowser.running.replace('{browser}', 'Electron')).should('be.disabled')
cy.contains('button', defaultMessages.openBrowser.focus).should('not.exist')
cy.get('[aria-checked="true"]').contains('Electron')
})

// TODO: fix flaky test https://github.com/cypress-io/cypress/issues/23099
it('throws when activeBrowser is null', { retries: 15 }, (done) => {
cy.once('uncaught:exception', (err) => {
expect(err.message).to.include('Missing activeBrowser in selectedBrowserId')
done()
})

it('throws when activeBrowser is null', () => {
cy.mountFragment(OpenBrowserListFragmentDoc, {
onResult: (res) => {
res.activeBrowser = null
Expand All @@ -150,5 +145,7 @@ describe('<OpenBrowserList />', () => {
</div>)
},
})

cy.get('[aria-checked="true"]').should('not.exist')
})
})
12 changes: 3 additions & 9 deletions packages/launchpad/src/setup/OpenBrowserList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ import ArrowRightIcon from '~icons/cy/arrow-right_x16'
import StatusRunningIcon from '~icons/cy/status-running_x16'
import { RadioGroup, RadioGroupOption, RadioGroupLabel } from '@headlessui/vue'
import Tooltip from '@packages/frontend-shared/src/components/Tooltip.vue'
import sortBrowsers from '@packages/frontend-shared/src/utils/sortBrowsers'
import type { OpenBrowserListFragment } from '../generated/graphql'
import { OpenBrowserList_SetBrowserDocument, OpenBrowserList_BrowserStatusChangeDocument } from '../generated/graphql'
Expand Down Expand Up @@ -228,21 +227,16 @@ const emit = defineEmits<{
const { t } = useI18n()
const browsers = computed(() => {
if (!props.gql.browsers) {
return undefined
}
return sortBrowsers([...props.gql.browsers])
// Need to slice(). `sort()` mutates, and props are supposed to be `readonly`.
return (props.gql.browsers ?? []).slice().sort((a, b) => a.displayName > b.displayName ? 1 : -1)
})
const setBrowser = useMutation(OpenBrowserList_SetBrowserDocument)
const selectedBrowserId = computed({
get: () => {
// NOTE: The activeBrowser is set during project initialization. It should always be defined.
if (!props.gql.activeBrowser) throw new Error('Missing activeBrowser in selectedBrowserId')
return props.gql.activeBrowser.id
return props.gql.activeBrowser?.id
},
set (browserId) {
if (browserId) {
Expand Down

5 comments on commit d27e249

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d27e249 Aug 10, 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.0.0/linux-x64/release/13.0.0-d27e2494fa0733643538168c9f894b7c9c0c9148/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d27e249 Aug 10, 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.0.0/linux-arm64/release/13.0.0-d27e2494fa0733643538168c9f894b7c9c0c9148/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d27e249 Aug 10, 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.0.0/darwin-x64/release/13.0.0-d27e2494fa0733643538168c9f894b7c9c0c9148/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d27e249 Aug 10, 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.0.0/win32-x64/release/13.0.0-d27e2494fa0733643538168c9f894b7c9c0c9148/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on d27e249 Aug 10, 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.0.0/darwin-arm64/release/13.0.0-d27e2494fa0733643538168c9f894b7c9c0c9148/cypress.tgz

Please sign in to comment.