Skip to content

Commit

Permalink
Merge branch '10.0-release' into zachw/config-file-false-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachJW34 committed Mar 18, 2022
2 parents 84bfdcc + 9aa60f3 commit e836b3f
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 5 deletions.
58 changes: 54 additions & 4 deletions packages/app/cypress/e2e/settings.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ describe('App: Settings', () => {
cy.findByText('Project Settings').click()
cy.get('[data-cy="file-match-indicator"]').contains('2 Matches')
cy.get('[data-cy="spec-pattern"]').contains('**/*.cy.{js,jsx,ts,tsx}')

cy.get('[data-cy="settings-specPatterns"').within(() => {
cy.validateExternalLink({
name: 'Learn more.',
href: 'https://on.cypress.io/test-type-options',
})
})
})

it('shows the Spec Patterns section (edited specPattern value)', () => {
Expand All @@ -125,10 +132,53 @@ describe('App: Settings', () => {
cy.findByText('Settings').click()
cy.findByText('Project Settings').click()
cy.get('[data-cy="settings-experiments"]').within(() => {
cy.get('[data-cy="experiment-experimentalFetchPolyfill"]')
cy.get('[data-cy="experiment-experimentalInteractiveRunEvents"]')
cy.get('[data-cy="experiment-experimentalSessionSupport"]')
cy.get('[data-cy="experiment-experimentalSourceRewriting"]')
cy.validateExternalLink({
name: 'Learn more.',
href: 'https://on.cypress.io/experiments',
})

cy.get('[data-cy="experiment-experimentalFetchPolyfill"]').within(() => {
cy.validateExternalLink({
name: 'cy.intercept()',
href: 'https://on.cypress.io/intercept',
})
})

cy.get('[data-cy="experiment-experimentalInteractiveRunEvents"]').within(() => {
cy.validateExternalLink({
name: 'before:run',
href: 'https://on.cypress.io/before-run',
})

cy.validateExternalLink({
name: 'after:run',
href: 'https://on.cypress.io/after-run',
})

cy.validateExternalLink({
name: 'before:spec',
href: 'https://on.cypress.io/before-spec',
})

cy.validateExternalLink({
name: 'after:spec',
href: 'https://on.cypress.io/after-spec',
})
})

cy.get('[data-cy="experiment-experimentalSessionSupport"]').within(() => {
cy.validateExternalLink({
name: 'cy.session()',
href: 'https://on.cypress.io/session',
})
})

cy.get('[data-cy="experiment-experimentalSourceRewriting"]').within(() => {
cy.validateExternalLink({
name: '#5273',
href: 'https://github.com/cypress-io/cypress/issues/5273',
})
})
})
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ExternalLink_OpenExternalDocument } from '../../generated/graphql'
import UseMarkdownExample from './UseMarkdownExample.vue'

describe('useMarkdown', () => {
Expand Down Expand Up @@ -30,6 +31,10 @@ const heres = {
}
\`\`\`
[Simple Link](www.test.com)
[\`Code Link\`](www.code.com)
`

cy.mount(<UseMarkdownExample
Expand All @@ -39,5 +44,24 @@ const heres = {

cy.get('ul').should('have.class', 'list-disc')
cy.get('code').first().should('have.class', 'bg-pink-200').and('have.class', 'text-pink-600')

const openExternalStub = cy.stub()

cy.stubMutationResolver(ExternalLink_OpenExternalDocument, (defineResult, { url }) => {
openExternalStub(url)

return defineResult({
openExternal: true,
})
})

cy.contains('a', 'Simple Link').click()
cy.wrap(openExternalStub).should('have.been.calledWith', 'www.test.com')

cy.contains('a', 'Code Link').within(() => {
cy.get('code').click()
})

cy.wrap(openExternalStub).should('have.been.calledWith', 'www.code.com')
})
})
9 changes: 8 additions & 1 deletion packages/frontend-shared/src/composables/useMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,15 @@ export const useMarkdown = (target: Ref<HTMLElement>, text: MaybeRef<string>, op

whenever(target, () => {
useEventListener(target, 'click', (e: MouseEvent) => {
const link = (e.target as HTMLElement).closest('a[href]')

if (!link) {
return
}

e.preventDefault()
const url = (e.target as HTMLElement).getAttribute('href')

const url = link.getAttribute('href')

if (url) {
open(url)
Expand Down

0 comments on commit e836b3f

Please sign in to comment.