Skip to content

Commit

Permalink
fix(kcodeblock): updated copy button data-test-id [KHCP-14752] (#2577)
Browse files Browse the repository at this point in the history
* fix(kcodeblock): updated copy button data-test-id [KHCP-14752]

* fix: removed length check

* test: updated kcodeblock test case [KHCP-14752]

* fix: removed id check

* fix: reverted docs changes

---------

Co-authored-by: Maksym Portianoi <[email protected]>
  • Loading branch information
afrzhussain and portikM authored Jan 20, 2025
1 parent a6ce5c3 commit 63bd9da
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/KCodeBlock/KCodeBlock.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ describe('KCodeBlock', () => {
renderComponent({ id: 'code-block' })

cy.get('.line').should('have.length', 5)
cy.get('[data-testid="code-block-copy-button"]').should('exist')
cy.get('[data-testid="code-block-copy-button-code-block"]').should('exist')
cy.get('[data-testid="highlighted-code-block"]').contains(code)
})

it('has no copy button when props.showCopyButton is false', () => {
renderComponent({ id: 'code-block', showCopyButton: false })

cy.get('[data-testid="code-block-copy-button"]').should('not.exist')
cy.get('[data-testid="code-block-copy-button-code-block"]').should('not.exist')
})

it('can be searched to highlight matching lines', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/KCodeBlock/KCodeBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
:aria-label="`Copy (${ALT_SHORTCUT_LABEL}+C)`"
class="code-block-copy-button"
:copy-tooltip="`Copy (${ALT_SHORTCUT_LABEL}+C)`"
data-testid="code-block-copy-button"
:data-testid="`code-block-copy-button-${id}`"
:theme="theme"
@click="copyCode"
>
Expand Down

0 comments on commit 63bd9da

Please sign in to comment.