forked from PostHog/posthog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e): convert cypress to typescript (PostHog#13513)
- Loading branch information
1 parent
540c4aa
commit 7414ae0
Showing
36 changed files
with
62 additions
and
44 deletions.
There are no files selected for viewing
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
4 changes: 3 additions & 1 deletion
4
cypress/support/accessibility.js → cypress/support/accessibility.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
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 |
---|---|---|
@@ -1,12 +1,3 @@ | ||
const patternHandler = {} | ||
|
||
Cypress.Commands.add('interceptLazy', (pattern, handler) => { | ||
patternHandler[pattern] = handler | ||
return cy.intercept(pattern, (req) => { | ||
req.reply(patternHandler[pattern]()) | ||
}) | ||
}) | ||
|
||
Cypress.Commands.add('login', () => { | ||
// This function isn't used for every test anymore | ||
cy.get('[data-attr=login-email]').type('[email protected]').should('have.value', '[email protected]').blur() | ||
|
@@ -19,14 +10,6 @@ Cypress.Commands.add('login', () => { | |
cy.location('pathname').should('not.eq', '/login') // Wait until login request fully completes | ||
}) | ||
|
||
Cypress.Commands.add('overrideInterceptLazy', (pattern, handler) => { | ||
patternHandler[pattern] = handler | ||
}) | ||
|
||
Cypress.Commands.add('map', { prevSubject: true }, (subject, method) => { | ||
return method(subject) | ||
}) | ||
|
||
Cypress.Commands.add('clickNavMenu', (name) => { | ||
cy.get(`[data-attr="menu-item-${name}"]`).click() | ||
}) |
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
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,21 @@ | ||
/// <reference types="cypress" /> | ||
|
||
declare global { | ||
// eslint-disable-next-line @typescript-eslint/no-namespace | ||
namespace Cypress { | ||
interface Chainable { | ||
/** | ||
* Custom command to login to PostHog | ||
*/ | ||
login(): Chainable<Element> | ||
|
||
/** | ||
* Custom command to click a navigation menu item | ||
* @example cy.clickNavMenu('dashboards') | ||
*/ | ||
clickNavMenu(name: string): Chainable<Element> | ||
} | ||
} | ||
} | ||
|
||
export {} |
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
export function randomString(prefix = ''): string { | ||
const uuid = (): number => Cypress._.random(0, 1e6) | ||
return `${prefix}${uuid()}` | ||
} |
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,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": "../frontend", | ||
"paths": { | ||
"lib/*": ["src/lib/*"], | ||
"scenes/*": ["src/scenes/*"] | ||
}, | ||
"target": "es5", | ||
"lib": ["es5", "dom"], | ||
"types": ["cypress", "node"] | ||
} | ||
} |