Skip to content

Commit

Permalink
test: add minor tests for markviews
Browse files Browse the repository at this point in the history
  • Loading branch information
nperez0111 committed Jan 10, 2025
1 parent e715aa9 commit f7c2a98
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 3 deletions.
4 changes: 2 additions & 2 deletions demos/src/GuideMarkViews/ReactComponent/React/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export default (props: MarkViewRendererProps) => {
const [count, setCount] = React.useState(0)

return (
<span className="content">
<span className="content" data-test-id="mark-view">
<MarkViewContent />
<label contentEditable={false}>
React component::
React component:
<button
onClick={() => {
setCount(count + 1)
Expand Down
32 changes: 32 additions & 0 deletions demos/src/GuideMarkViews/ReactComponent/React/index.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/// <reference types="cypress" />

context('/src/GuideMarkViews/ReactComponent/React/', () => {
before(() => {
cy.visit('/src/GuideMarkViews/ReactComponent/React/')
})

beforeEach(() => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.setContent('<p>Example Text</p><react-component>Mark View Text</react-component>')
})
cy.get('.tiptap').type('{selectall}')
})

it('should show the markview', () => {
cy.get('.tiptap').find('[data-test-id="mark-view"]').should('exist')
})

it('should allow clicking the button', () => {
cy.get('.tiptap')
.find('[data-test-id="mark-view"] button')
.should('contain', 'This button has been clicked 0 times.')
cy.get('.tiptap')
.find('[data-test-id="mark-view"] button')
.click()
.then(() => {
cy.get('.tiptap')
.find('[data-test-id="mark-view"] button')
.should('contain', 'This button has been clicked 1 times.')
})
})
})
2 changes: 1 addition & 1 deletion demos/src/GuideMarkViews/VueComponent/Vue/Component.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<span class="vue-component">
<span className="content" data-test-id="mark-view">
<mark-view-content />
<label contenteditable="false"
>Vue Component::
Expand Down
32 changes: 32 additions & 0 deletions demos/src/GuideMarkViews/VueComponent/Vue/index.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/// <reference types="cypress" />

context('/src/GuideMarkViews/VueComponent/Vue/', () => {
before(() => {
cy.visit('/src/GuideMarkViews/VueComponent/Vue/')
})

beforeEach(() => {
cy.get('.tiptap').then(([{ editor }]) => {
editor.commands.setContent('<p>Example Text</p><vue-component>Mark View Text</vue-component>')
})
cy.get('.tiptap').type('{selectall}')
})

it('should show the markview', () => {
cy.get('.tiptap').find('[data-test-id="mark-view"]').should('exist')
})

it('should allow clicking the button', () => {
cy.get('.tiptap')
.find('[data-test-id="mark-view"] button')
.should('contain', 'This button has been clicked 0 times.')
cy.get('.tiptap')
.find('[data-test-id="mark-view"] button')
.click()
.then(() => {
cy.get('.tiptap')
.find('[data-test-id="mark-view"] button')
.should('contain', 'This button has been clicked 1 times.')
})
})
})

0 comments on commit f7c2a98

Please sign in to comment.