docs: add cypress test
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
FROM node:lts-slim
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV CYPRESS_INSTALL_BINARY=0
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY / ./
|
||||
@@ -9,5 +12,4 @@ RUN npm install -g pnpm
|
||||
RUN pnpm install --unsafe-perm --frozen-lockfile
|
||||
RUN pnpm run build -C packages/docs
|
||||
|
||||
ENV NODE_ENV=production
|
||||
CMD [ "pnpm", "-C", "packages/docs", "start" ]
|
||||
|
||||
@@ -16,11 +16,12 @@ export function MainNavigation() {
|
||||
<AppLink {...link} key={link.to} className={linkClass} />
|
||||
))}
|
||||
</div>
|
||||
<div className="md:hidden" id="main-navigation-popover">
|
||||
<div className="md:hidden">
|
||||
<PopoverMenu>
|
||||
{mainLinks.map((link) => (
|
||||
<AppLink
|
||||
{...link}
|
||||
role="menuitem"
|
||||
key={link.to}
|
||||
className={PopoverMenu.itemClass}
|
||||
/>
|
||||
@@ -29,6 +30,7 @@ export function MainNavigation() {
|
||||
{guideLinks.map(({ link }) => (
|
||||
<AppLink
|
||||
{...link}
|
||||
role="menuitem"
|
||||
key={link.to}
|
||||
className={PopoverMenu.itemClass}
|
||||
/>
|
||||
|
||||
@@ -10,6 +10,7 @@ export function PopoverMenu({ children }: { children: React.ReactNode }) {
|
||||
<MenuAlt4Icon className="w-6" />
|
||||
</button>
|
||||
<div
|
||||
role="menu"
|
||||
className={`
|
||||
w-48 max-h-[calc(100vh-4rem)]
|
||||
absolute right-0 top-[calc(100%+8px)]
|
||||
|
||||
3
packages/docs/cypress.json
Normal file
3
packages/docs/cypress.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"baseUrl": "http://localhost:3000/"
|
||||
}
|
||||
5
packages/docs/cypress/fixtures/example.json
Normal file
5
packages/docs/cypress/fixtures/example.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "Using fixtures to represent data",
|
||||
"email": "hello@cypress.io",
|
||||
"body": "Fixtures are a great way to mock data for responses to routes"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
describe("main popover menu", () => {
|
||||
it("should toggle on button click", () => {
|
||||
cy.viewport(480, 720)
|
||||
cy.visit("/")
|
||||
cy.findByRole("button", { name: "Menu" }).click()
|
||||
cy.findByRole("menu").should("be.visible")
|
||||
cy.findByRole("button", { name: "Menu" }).click()
|
||||
cy.findByRole("menu").should("not.exist")
|
||||
})
|
||||
})
|
||||
22
packages/docs/cypress/plugins/index.js
Normal file
22
packages/docs/cypress/plugins/index.js
Normal file
@@ -0,0 +1,22 @@
|
||||
/// <reference types="cypress" />
|
||||
// ***********************************************************
|
||||
// This example plugins/index.js can be used to load plugins
|
||||
//
|
||||
// You can change the location of this file or turn off loading
|
||||
// the plugins file with the 'pluginsFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/plugins-guide
|
||||
// ***********************************************************
|
||||
|
||||
// This function is called when a project is opened or re-opened (e.g. due to
|
||||
// the project's config changing)
|
||||
|
||||
/**
|
||||
* @type {Cypress.PluginConfig}
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
module.exports = (on, config) => {
|
||||
// `on` is used to hook into various events Cypress emits
|
||||
// `config` is the resolved Cypress config
|
||||
}
|
||||
26
packages/docs/cypress/support/commands.js
Normal file
26
packages/docs/cypress/support/commands.js
Normal file
@@ -0,0 +1,26 @@
|
||||
// ***********************************************
|
||||
// This example commands.js shows you how to
|
||||
// create various custom commands and overwrite
|
||||
// existing commands.
|
||||
//
|
||||
// For more comprehensive examples of custom
|
||||
// commands please read more here:
|
||||
// https://on.cypress.io/custom-commands
|
||||
// ***********************************************
|
||||
//
|
||||
//
|
||||
// -- This is a parent command --
|
||||
// Cypress.Commands.add('login', (email, password) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a child command --
|
||||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a dual command --
|
||||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
||||
import "@testing-library/cypress/add-commands"
|
||||
20
packages/docs/cypress/support/index.js
Normal file
20
packages/docs/cypress/support/index.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// ***********************************************************
|
||||
// This example support/index.js is processed and
|
||||
// loaded automatically before your test files.
|
||||
//
|
||||
// This is a great place to put global configuration and
|
||||
// behavior that modifies Cypress.
|
||||
//
|
||||
// You can change the location of this file or turn off
|
||||
// automatically serving support files with the
|
||||
// 'supportFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/configuration
|
||||
// ***********************************************************
|
||||
|
||||
// Import commands.js using ES2015 syntax:
|
||||
import './commands'
|
||||
|
||||
// Alternatively you can use CommonJS syntax:
|
||||
// require('./commands')
|
||||
6
packages/docs/cypress/tsconfig.json
Normal file
6
packages/docs/cypress/tsconfig.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"types": ["cypress", "@testing-library/cypress"]
|
||||
}
|
||||
}
|
||||
BIN
packages/docs/cypress/videos/mobile-popover-menu.test.ts.mp4
Normal file
BIN
packages/docs/cypress/videos/mobile-popover-menu.test.ts.mp4
Normal file
Binary file not shown.
@@ -4,6 +4,8 @@
|
||||
"scripts": {
|
||||
"prepare": "remix setup node",
|
||||
"dev": "concurrently 'typedoc --watch' 'remix dev'",
|
||||
"test": "pnpm build && pnpm start & wait-on http-get://localhost:3000 && cypress run",
|
||||
"test-dev": "pnpm dev & wait-on http-get://localhost:3000 && cypress open",
|
||||
"build": "typedoc && remix build",
|
||||
"start": "remix-serve build",
|
||||
"typecheck": "tsc --noEmit"
|
||||
@@ -28,14 +30,17 @@
|
||||
"devDependencies": {
|
||||
"@remix-run/dev": "^1.1.1",
|
||||
"@remix-run/node": "^1.1.1",
|
||||
"@testing-library/cypress": "^8.0.2",
|
||||
"@types/node": "*",
|
||||
"@types/react": "^17.0.38",
|
||||
"@types/react-dom": "^17.0.11",
|
||||
"@types/tailwindcss": "^3.0.2",
|
||||
"concurrently": "^7.0.0",
|
||||
"cypress": "^9.2.0",
|
||||
"rehype-prism-plus": "^1.2.2",
|
||||
"typedoc": "^0.22.10",
|
||||
"typescript": "^4.5.4"
|
||||
"typescript": "^4.5.4",
|
||||
"wait-on": "^6.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
|
||||
653
pnpm-lock.yaml
generated
653
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user