-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
E2E testing for interactive code snippets (#948)
* e2e testing for generated code snippets * Parcel ts-utils
- Loading branch information
1 parent
9b7acd4
commit db0851c
Showing
3 changed files
with
40 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/website/cypress/e2e/code-snippets/code-snippets.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/// <reference types="cypress" /> | ||
|
||
describe('code snippet interactions', () => { | ||
beforeEach(() => { | ||
cy.visit('http://localhost:8000/course/fundamentals-v4/07-interfaces-and-type-aliases/').waitForRouteChange() | ||
}) | ||
|
||
it('Code snippet is found', () => { | ||
// Code snippet found | ||
cy.get('.post-body > .shiki.twoslash.lsp:nth-child(6)').should('exist').should('contain.text', 'function printAmount') | ||
}) | ||
|
||
it('"Popover" tooltips from ^? are present', () => { | ||
cy.get('.post-body > .shiki.twoslash.lsp:nth-child(6) :nth-child(10) > .popover').should('contain.text', 'currency: string') | ||
}) | ||
|
||
it('Hover tooltips work', () => { | ||
cy.get('.post-body > .shiki.twoslash.lsp:nth-child(6) data-lsp[lsp="function printAmount(amt: Amount): void"]') | ||
.should('exist').trigger('mouseover') | ||
cy.get('#twoslash-mouse-hover-info').should('contain.text', "function printAmount(amt: Amount): void") | ||
}) | ||
it('Rendered errors work', () => { | ||
cy.get('.post-body > .shiki.twoslash.lsp:nth-child(15)').should('exist').should('contain.text', 'type Amount') | ||
cy.get('.post-body > .shiki.twoslash.lsp:nth-child(15) code > span.error:nth-child(2)') | ||
.should('exist') | ||
.should('contain.text', 'Duplicate identifier') | ||
|
||
}) | ||
it('Code complete for |^ works', () => { | ||
cy.get('.post-body > .shiki.twoslash.lsp:nth-child(21)').should('exist').should('contain.text', 'newYearsEve') | ||
cy.get('.post-body > .shiki.twoslash.lsp:nth-child(21) .inline-completions').should('exist').should('contain.text', 'getDay') | ||
}) | ||
it('Code highlighting works', () => { | ||
cy.get('.post-body > .shiki.twoslash.lsp:nth-child(49)').should('exist').should('contain.text', 'jumpToHeight') | ||
cy.get('.post-body > .shiki.twoslash.lsp:nth-child(49) .highlight').should('exist').should('contain.text', 'string') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters