diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index d1132af..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: tests -on: - push: - branches: - - main - - renovate/* - pull_request: -jobs: - tests: - name: Tests - runs-on: docker - container: - image: ghcr.io/di0ik/forgejo_runner_container:main@sha256:672aee9a5dfc35531db3a218ad9486eb5c5d7d9ac10bdcba13110470c10403ee - steps: - - name: Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - - - name: Enable corepack - run: corepack enable - - - name: Cypress run - uses: cypress-io/github-action@v6 - with: - build: yarn run build - start: yarn start - component: true diff --git a/cypress.config.ts b/cypress.config.ts index d2013c5..768b87a 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -1,6 +1,12 @@ import { defineConfig } from 'cypress'; export default defineConfig({ + e2e: { + setupNodeEvents(on, config) { + // implement node event listeners here + }, + }, + component: { devServer: { framework: 'next', diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 59717f5..95857ae 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -35,28 +35,3 @@ // } // } // } - -Cypress.Commands.add('getBySel', (selector, ...args) => { - return cy.get(`[data-cy=${selector}]`, ...args); -}); - -Cypress.Commands.add('getBySelLike', (selector, ...args) => { - return cy.get(`[data-cy*=${selector}]`, ...args); -}); - -declare global { - namespace Cypress { - interface Chainable { - getBySel( - selector: string, - ...args: any[] - ): Chainable>; - getBySelLike( - selector: string, - ...args: any[] - ): Chainable>; - } - } -} - -export {}; diff --git a/cypress/support/component.ts b/cypress/support/component.ts index b1f1c92..23fbccc 100644 --- a/cypress/support/component.ts +++ b/cypress/support/component.ts @@ -13,8 +13,6 @@ // https://on.cypress.io/configuration // *********************************************************** -import '@/app/globals.css'; - // Import commands.js using ES2015 syntax: import './commands'; diff --git a/package.json b/package.json index a9fa0b1..e3bcfc4 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "lint": "next lint", "format": "prettier --write .", "cypress:open": "cypress open", - "cypress:run": "cypress run" + "cypress:run": "cypress run", + "test": "start-server-and-test " }, "dependencies": { "@fortawesome/fontawesome-svg-core": "^6.7.2", diff --git a/src/components/icon-button.cy.tsx b/src/components/icon-button.cy.tsx deleted file mode 100644 index b5a1ff0..0000000 --- a/src/components/icon-button.cy.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unused-expressions */ -import React from 'react'; -import { IconButton } from './icon-button'; -import { faOpenid } from '@fortawesome/free-brands-svg-icons'; - -describe('', () => { - it('renders', () => { - cy.mount(Button); - }); - - it('is clickable', () => { - const onClick = cy.stub(); - cy.mount( - - Button - , - ); - cy.getBySel('icon-button') - .click() - .then(() => { - expect(onClick).to.be.calledOnce; - }); - }); -}); diff --git a/src/components/user/theme-picker.cy.tsx b/src/components/user/theme-picker.cy.tsx deleted file mode 100644 index 23dc01b..0000000 --- a/src/components/user/theme-picker.cy.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import React from 'react'; -import { ThemePicker } from '@/components/user/theme-picker'; -import { ThemeProvider } from '../theme-provider'; - -describe('', () => { - it('renders', () => { - cy.mount(); - }); - - it('toggle open and close', () => { - cy.mount(); - cy.getBySel('theme-picker').click(); - cy.getBySel('theme-picker-content').should('exist'); - cy.get('html').click(); - cy.getBySel('theme-picker-content').should('not.exist'); - }); - - it('enable dark mode', () => { - cy.mount( - - - , - ); - - cy.getBySel('theme-picker').click(); - cy.getBySel('dark-theme').click(); - cy.get('html').should('have.attr', 'data-theme', 'dark'); - }); - - it('enable light mode', () => { - cy.mount( - - - , - ); - - cy.getBySel('theme-picker').click(); - cy.getBySel('light-theme').click(); - cy.get('html').should('have.attr', 'data-theme', 'light'); - }); -}); diff --git a/src/components/user/theme-picker.tsx b/src/components/user/theme-picker.tsx index 3ceca4c..5341c3c 100644 --- a/src/components/user/theme-picker.tsx +++ b/src/components/user/theme-picker.tsx @@ -18,26 +18,20 @@ export function ThemePicker() { return ( - - - setTheme('light')} - data-cy='light-theme' - > + + setTheme('light')}> Light - setTheme('dark')} data-cy='dark-theme'> + setTheme('dark')}> Dark - setTheme('system')} - data-cy='system-theme' - > + setTheme('system')}> System diff --git a/tsconfig.json b/tsconfig.json index 6bd88b8..c133409 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,8 +20,7 @@ ], "paths": { "@/*": ["./src/*"] - }, - "types": ["node", "cypress"] + } }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "exclude": ["node_modules"]