diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index d2f0b38..e74d25e 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -51,10 +51,29 @@ jobs: name: coverage-report path: coverage/ + component: + name: Component Test + runs-on: ubuntu-latest + needs: [lint, test] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + - name: Install dependencies + run: | + corepack enable + corepack prepare pnpm@latest --activate + pnpm install + - name: Run Cypress Component tests + run: pnpm run cy:component + build: name: Build runs-on: ubuntu-latest - needs: [lint, test] + needs: [lint, test, component] steps: - name: Checkout repository uses: actions/checkout@v4 @@ -71,7 +90,7 @@ jobs: run: pnpm run build e2e: - name: E2E Tests + name: E2E Test runs-on: ubuntu-latest needs: [build] steps: diff --git a/cypress.d.ts b/cypress.d.ts new file mode 100644 index 0000000..7c9d4cc --- /dev/null +++ b/cypress.d.ts @@ -0,0 +1,9 @@ +import { mount } from "cypress/react"; + +declare global { + namespace Cypress { + interface Chainable { + mount: typeof mount; + } + } +} diff --git a/cypress/component/ChatTitle.cy.tsx b/cypress/component/ChatTitle.cy.tsx deleted file mode 100644 index f69722c..0000000 --- a/cypress/component/ChatTitle.cy.tsx +++ /dev/null @@ -1,11 +0,0 @@ -/// - -import React from "react"; -import { ChatTitle } from "../../src/components/atoms/ChatTitle/ChatTitle"; - -describe("", () => { - it("renders", () => { - // see: https://on.cypress.io/mounting-react - cy.mount(); - }); -}); diff --git a/cypress/support/component.ts b/cypress/support/component.ts index 02b32e8..34b659d 100644 --- a/cypress/support/component.ts +++ b/cypress/support/component.ts @@ -1,37 +1,3 @@ -// *********************************************************** -// This example support/component.ts 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"; - -import { mount } from "cypress/react"; - -// Augment the Cypress namespace to include type definitions for -// your custom command. -// Alternatively, can be defined in cypress/support/component.d.ts -// with a at the top of your spec. -declare global { - // eslint-disable-next-line @typescript-eslint/no-namespace - namespace Cypress { - interface Chainable { - mount: typeof mount; - } - } -} - -Cypress.Commands.add("mount", mount); - -// Example use: -// cy.mount() +// cypress/support/component.ts +// This file is required for Cypress component testing setup. You can add custom commands or imports here if needed. +import "../../src/index.css"; diff --git a/package.json b/package.json index 959e567..3c9f279 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "test:coverage": "vitest --coverage.enabled --coverage.reportsDirectory ./coverage", "cy:open": "cypress open", "cy:run": "cypress run", - "cy:start": "concurrently \"pnpm run dev\" \"cypress run\"" + "cy:start": "concurrently \"pnpm run dev\" \"cypress run\"", + "cy:component": "cypress run --component" }, "dependencies": { "@reduxjs/toolkit": "^2.8.2", diff --git a/src/components/atoms/APINotFound/APINotFound.cy.tsx b/src/components/atoms/APINotFound/APINotFound.cy.tsx new file mode 100644 index 0000000..952e66e --- /dev/null +++ b/src/components/atoms/APINotFound/APINotFound.cy.tsx @@ -0,0 +1,14 @@ +import { mount } from "cypress/react"; +import { APINotFound } from "./APINotFound"; +import { StoreProvider } from "@/store/StoreProvider"; + +describe("", () => { + it("renders", () => { + // see: https://on.cypress.io/mounting-react + mount( + + + + ); + }); +}); diff --git a/src/components/atoms/ChatTitle/ChatTitle.cy.tsx b/src/components/atoms/ChatTitle/ChatTitle.cy.tsx new file mode 100644 index 0000000..802d087 --- /dev/null +++ b/src/components/atoms/ChatTitle/ChatTitle.cy.tsx @@ -0,0 +1,8 @@ +import { mount } from "cypress/react"; +import { ChatTitle } from "./ChatTitle"; + +describe("", () => { + it("renders", () => { + mount(); + }); +}); diff --git a/src/components/atoms/ResultWrapper/ResultWrapper.cy.tsx b/src/components/atoms/ResultWrapper/ResultWrapper.cy.tsx new file mode 100644 index 0000000..c161c32 --- /dev/null +++ b/src/components/atoms/ResultWrapper/ResultWrapper.cy.tsx @@ -0,0 +1,19 @@ +import { mount } from "cypress/react"; +import { ResultWrapper } from "./ResultWrapper"; + +describe("", () => { + it("renders", () => { + // see: https://on.cypress.io/mounting-react + mount( + {}} + > +
Test
+
+ ); + }); +}); diff --git a/src/components/molecules/CatFacts/CatFacts.cy.tsx b/src/components/molecules/CatFacts/CatFacts.cy.tsx new file mode 100644 index 0000000..f79abca --- /dev/null +++ b/src/components/molecules/CatFacts/CatFacts.cy.tsx @@ -0,0 +1,29 @@ +import { mount } from "cypress/react"; +import { CatFacts } from "./CatFacts"; + +describe("", () => { + it("renders", () => { + mount( + + ); + }); +}); diff --git a/src/utils/highlight.ts b/src/utils/highlight.ts index 9f725c0..bf5985f 100644 --- a/src/utils/highlight.ts +++ b/src/utils/highlight.ts @@ -1,8 +1,8 @@ -export interface HighlightMatch { +export type HighlightMatch = { path: string; value: string; matchedText: string; -} +}; export function findMatches( obj: unknown, diff --git a/tsconfig.app.json b/tsconfig.app.json index 15e8ff4..8ad3312 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -29,5 +29,5 @@ "noUncheckedSideEffectImports": true, "forceConsistentCasingInFileNames": true }, - "include": ["src"] + "include": ["src", "cypress.d.ts"] }