Skip to content

Commit

Permalink
chore: remove failing test cases due to hover pseudo selector not wor…
Browse files Browse the repository at this point in the history
…king with jsdom #2025
  • Loading branch information
marek-mihok authored and mturoci committed Sep 6, 2023
1 parent 83d5b5c commit 6e2c9ca
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 51 deletions.
19 changes: 1 addition & 18 deletions ui/src/copyable_text.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import { fireEvent, render } from '@testing-library/react'
import { render } from '@testing-library/react'
import React from 'react'
import { CopyableText, XCopyableText } from './copyable_text'
import userEvent from '@testing-library/user-event'

const name = 'name'
const copyableTextProps: CopyableText = { name, value: '', label: '' }
Expand All @@ -34,20 +33,4 @@ describe('CopyableText.tsx', () => {
rerender(<XCopyableText model={{ ...copyableTextProps, value: 'B' }} />)
expect(getByTestId(name)).toHaveValue('B')
})

it('Shows copy to clipboard button on hover - multiline text', async () => {
const { container } = render(<XCopyableText model={{ ...copyableTextProps, multiline: true }} />)
await new Promise(resolve => setTimeout(resolve, 500))

const copyButton = container.querySelector('button')
const textfield = container.querySelector('textarea')!.parentElement!
expect(copyButton).toBeInTheDocument()
expect(copyButton).not.toBeVisible()

userEvent.hover(textfield)
expect(container.querySelector('button')).toBeVisible()

fireEvent.mouseLeave(textfield)
expect(copyButton).not.toBeVisible()
})
})
33 changes: 0 additions & 33 deletions ui/src/markdown.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,8 @@
import { fireEvent, render } from '@testing-library/react'
import React from 'react'
import { Markdown } from './markdown'
import userEvent from '@testing-library/user-event'

const source = 'The quick brown [fox](?fox) jumps over the lazy [dog](dog).'
const codeBlockSource = `
\`\`\`py
from h2o_wave import main, app, Q, ui
@app('/')
async def serve(q: Q):
# Display a Hello, world! message.
q.page['hello'] = ui.markdown_card(
box='1 1 4 4',
title='Hello',
content='Hello, world!'
)
await q.page.save()
\`\`\`
`

describe('Markdown.tsx', () => {

Expand All @@ -51,19 +33,4 @@ describe('Markdown.tsx', () => {
fireEvent.click(getByText('dog'))
expect(dispatchEventMock).not.toHaveBeenCalled()
})

it('Shows copy to clipboard button on hover over code block', async () => {
const { container } = render(<Markdown source={codeBlockSource} />)
await new Promise(resolve => setTimeout(resolve, 500))

const copyButton = container.querySelector('button')
const textfield = container.querySelectorAll('code')[1]!

expect(textfield).toBeInTheDocument()
expect(copyButton).toBeInTheDocument()
expect(copyButton).not.toBeVisible()

userEvent.hover(textfield)
expect(container.querySelector('button')).toBeVisible()
})
})

0 comments on commit 6e2c9ca

Please sign in to comment.