Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -71,7 +90,7 @@ jobs:
run: pnpm run build

e2e:
name: E2E Tests
name: E2E Test
runs-on: ubuntu-latest
needs: [build]
steps:
Expand Down
9 changes: 9 additions & 0 deletions cypress.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { mount } from "cypress/react";

declare global {
namespace Cypress {
interface Chainable {
mount: typeof mount;
}
}
}
11 changes: 0 additions & 11 deletions cypress/component/ChatTitle.cy.tsx

This file was deleted.

40 changes: 3 additions & 37 deletions cypress/support/component.ts
Original file line number Diff line number Diff line change
@@ -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 <reference path="./component" /> 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(<MyComponent />)
// 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";
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions src/components/atoms/APINotFound/APINotFound.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { mount } from "cypress/react";
import { APINotFound } from "./APINotFound";
import { StoreProvider } from "@/store/StoreProvider";

describe("<APINotFound />", () => {
it("renders", () => {
// see: https://on.cypress.io/mounting-react
mount(
<StoreProvider>
<APINotFound />
</StoreProvider>
);
});
});
8 changes: 8 additions & 0 deletions src/components/atoms/ChatTitle/ChatTitle.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { mount } from "cypress/react";
import { ChatTitle } from "./ChatTitle";

describe("<ChatTitle />", () => {
it("renders", () => {
mount(<ChatTitle />);
});
});
19 changes: 19 additions & 0 deletions src/components/atoms/ResultWrapper/ResultWrapper.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { mount } from "cypress/react";
import { ResultWrapper } from "./ResultWrapper";

describe("<ResultWrapper />", () => {
it("renders", () => {
// see: https://on.cypress.io/mounting-react
mount(
<ResultWrapper
id="api-1"
timestamp={1640995200000}
pinnedIds={new Set()}
responseMatches={{}}
togglePin={() => {}}
>
<div>Test</div>
</ResultWrapper>
);
});
});
29 changes: 29 additions & 0 deletions src/components/molecules/CatFacts/CatFacts.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { mount } from "cypress/react";
import { CatFacts } from "./CatFacts";

describe("<CatFacts />", () => {
it("renders", () => {
mount(
<CatFacts
response={{
id: "api-1",
apiId: "api-1",
timestamp: 1640995200000,
data: {
id: 1,
fact: "Cats are amazing animals",
},
}}
searchTerm={"cat"}
hasMatches={true}
matches={[
{
path: "fact",
value: "Cats are amazing animals",
matchedText: "cat",
},
]}
/>
);
});
});
4 changes: 2 additions & 2 deletions src/utils/highlight.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export interface HighlightMatch {
export type HighlightMatch = {
path: string;
value: string;
matchedText: string;
}
};

export function findMatches(
obj: unknown,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
"noUncheckedSideEffectImports": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src"]
"include": ["src", "cypress.d.ts"]
}
Loading