Skip to content

Commit

Permalink
test: add cypress test for markdown links that they are build correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
ResuBaka committed Aug 11, 2022
1 parent 53885d2 commit 8230222
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
13 changes: 13 additions & 0 deletions examples/vue3/cypress/integration/markdown-links.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// <reference types="cypress" />

describe('Markdown links', () => {
it('should be just #welcome and not contain attribute target="_blank"', () => {
cy.visit('/story/src-components-markdownlinks-story-vue?variantId=_default')
cy.get('#link-to-welcome').should('have.attr', 'href', '#welcome').should('not.have.attr', 'target')
})

it('should have target="_blank" set when they external', () => {
cy.visit('/story/src-components-markdownlinks-story-vue?variantId=_default')
cy.get('#link-to-history').should('have.attr', 'href', 'https://histoire.dev/').should('have.attr', 'target', '_blank')
})
})
2 changes: 1 addition & 1 deletion examples/vue3/cypress/integration/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('Search', () => {
cy.visit('/')
cy.get('[data-test-id="search-btn"]').click()
cy.get('[data-test-id="search-modal"] input').type('welcome')
cy.get('[data-test-id="search-item"]').should('have.length', 1)
cy.get('[data-test-id="search-item"]').should('have.length', 2)
cy.get('[data-test-id="search-item"]').contains('Introduction')
})
})
2 changes: 1 addition & 1 deletion examples/vue3/cypress/integration/stories-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('Stories list', () => {
it('should display the stories', () => {
cy.clearLocalStorage()
cy.visit('/')
cy.get('[data-test-id="story-list-item"]').should('have.length', 23)
cy.get('[data-test-id="story-list-item"]').should('have.length', 24)
cy.get('[data-test-id="story-list-item"]').contains('🐱 Meow')
cy.get('[data-test-id="story-list-item"]').contains('BaseButton')
.contains('3') // Variants count
Expand Down
15 changes: 15 additions & 0 deletions examples/vue3/src/components/MarkdownLinks.story.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<template>
<Story
group="top"
docs-only
icon="carbon:bookmark"
/>
</template>

<docs lang="md">
[Link to welcome header](#welcome){id="link-to-welcome"}

# Welcome

This is just a link to [Histoire.dev](https://histoire.dev/){id="link-to-history"}.
</docs>

0 comments on commit 8230222

Please sign in to comment.