-
Notifications
You must be signed in to change notification settings - Fork 0
Basic testing done with github actions #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f8de2df
Basic testing done with github actions
sushilparajuli 0692dbc
jest setup and main components testing added
sushilparajuli 1047b7f
Cypress for end-to-end testing and github workflow updated
sushilparajuli 7f6162f
fix e2e workflow issue
sushilparajuli 2c51162
homepage e2e coverage done
sushilparajuli 64e625f
removed spinner logic as we are passing fallback
sushilparajuli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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,83 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, master, feature/*] | ||
| pull_request: | ||
| branches: [main, master] | ||
|
|
||
| jobs: | ||
| server-tests: | ||
| name: Server tests | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| working-directory: server/market-trading-service | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Use Node.js 20 | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "20" | ||
|
|
||
| - name: Cache server node modules | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: server/market-trading-service/node_modules | ||
| key: ${{ runner.os }}-server-${{ hashFiles('server/market-trading-service/package-lock.json') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-server- | ||
|
|
||
| - name: Install server dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Run server tests | ||
| run: npm test --silent | ||
|
|
||
| client-tests: | ||
| name: Client tests (conditional) | ||
| runs-on: ubuntu-latest | ||
| needs: server-tests | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Detect client test script | ||
| id: detect_client_tests | ||
| run: | | ||
| set -e | ||
| PKG=client/trading-dashboard/package.json | ||
| if [ -f "$PKG" ] && grep -q '"test"' "$PKG"; then | ||
| echo "has_tests=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "has_tests=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Use Node.js 20 | ||
| if: steps.detect_client_tests.outputs.has_tests == 'true' | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "20" | ||
|
|
||
| - name: Cache client node modules | ||
| if: steps.detect_client_tests.outputs.has_tests == 'true' | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: client/trading-dashboard/node_modules | ||
| key: ${{ runner.os }}-client-${{ hashFiles('client/trading-dashboard/package-lock.json') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-client- | ||
|
|
||
| - name: Install client dependencies | ||
| if: steps.detect_client_tests.outputs.has_tests == 'true' | ||
| run: | | ||
| cd client/trading-dashboard | ||
| npm ci | ||
|
|
||
| - name: Run client tests | ||
| if: steps.detect_client_tests.outputs.has_tests == 'true' | ||
| run: | | ||
| cd client/trading-dashboard | ||
| npm test --silent |
This file contains hidden or 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,44 @@ | ||
| name: E2E (Cypress) | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, master, feature/*] | ||
| pull_request: | ||
| branches: [main, master] | ||
|
|
||
| jobs: | ||
| cypress-run: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node 20 | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "20" | ||
|
|
||
| - name: Start client & run Cypress (no backend) | ||
| uses: cypress-io/github-action@v6 | ||
| with: | ||
| working-directory: client/trading-dashboard | ||
| build: npm run build | ||
| start: npm start | ||
| wait-on: "http://localhost:3000" | ||
| wait-on-timeout: 120 | ||
| browser: chrome | ||
| spec: cypress/e2e/**/*.cy.ts | ||
| env: | ||
| # Point to an unreachable host so fetch fails and client falls back to MOCK_TICKERS | ||
| NEXT_PUBLIC_MARKET_TRADING_URL: http://127.0.0.1:59999 | ||
| CYPRESS_BASE_URL: http://localhost:3000 | ||
|
|
||
| - name: Upload Cypress videos/screenshots (if failed) | ||
| if: failure() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: cypress-artifacts | ||
| path: | | ||
| client/trading-dashboard/cypress/videos/** | ||
| client/trading-dashboard/cypress/screenshots/** |
This file contains hidden or 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,2 +1,56 @@ | ||
| # multi-bank-coding-challenge | ||
| Full Stack real-time trading dashboard | ||
|
|
||
| Full-stack real-time trading dashboard used for the Multi Bank coding challenge. This repository contains two main projects and supporting documentation. | ||
|
|
||
| Project layout | ||
|
|
||
| - `client/trading-dashboard` — Next.js frontend (UI, E2E + unit tests). See: `client/trading-dashboard/README.md` and `client/trading-dashboard/README.md` for developer instructions. | ||
| - `server/market-trading-service` — Node + TypeScript microservice that simulates market data and exposes a small REST API. See: `server/market-trading-service/README.md`. | ||
| - `docs/` — architecture and project-scope documentation. | ||
| - `docker-compose.yml` & `README.DOCKER.md` — Docker setup for running both services together. | ||
|
|
||
| Quick start (recommended: Docker) | ||
|
|
||
| 1. From the repository root, build and start both services with docker-compose: | ||
|
|
||
| ```bash | ||
| docker-compose build | ||
| docker-compose up | ||
| ``` | ||
|
|
||
| This will start: | ||
|
|
||
| - Frontend: http://localhost:3000 | ||
| - Backend API: http://localhost:3005 (health endpoint: `/health`) | ||
|
|
||
| Local development (without Docker) | ||
|
|
||
| - Frontend: | ||
|
|
||
| ```bash | ||
| cd client/trading-dashboard | ||
| npm install | ||
| npm run dev | ||
| ``` | ||
|
|
||
| - Backend: | ||
|
|
||
| ```bash | ||
| cd server/market-trading-service | ||
| npm install | ||
| npm run dev | ||
| ``` | ||
|
|
||
| Tests | ||
|
|
||
| - Frontend unit tests: run in `client/trading-dashboard` with `npm run test` (Jest) | ||
| - Frontend E2E: run Cypress after starting the frontend (see `client/trading-dashboard/cypress.config.ts`) | ||
|
|
||
| Notes | ||
|
|
||
| - Each subproject includes its own README with more detailed developer and testing instructions. If you plan to contribute, please follow the subproject README before opening a PR. | ||
| - If you want CI/CD integration, I can add GitHub Actions workflows that run unit tests and optional Cypress E2E tests. | ||
|
|
||
| License | ||
|
|
||
| This project is available under the repository LICENSE file. |
This file contains hidden or 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,32 @@ | ||
| import { render, screen } from "@testing-library/react"; | ||
| import Index from "../page"; | ||
| // IMPORTANT: mock child components BEFORE importing the page so the page uses the mocked versions. | ||
| jest.mock("@/components/Hero", () => ({ | ||
| __esModule: true, | ||
| default: () => <div data-testid="hero">Hero Component</div>, | ||
| })); | ||
|
|
||
| jest.mock("@/components/TickerGrid", () => ({ | ||
| __esModule: true, | ||
| default: () => <div data-testid="ticker-grid">TickerGrid Component</div>, | ||
| })); | ||
|
|
||
| jest.mock("@/components/NewsFeed", () => ({ | ||
| __esModule: true, | ||
| default: () => <div data-testid="news-feed">NewsFeed Component</div>, | ||
| })); | ||
|
|
||
| describe("Homepage (Index)", () => { | ||
| it("renders all main sections: Hero, TickerGrid, and NewsFeed", () => { | ||
| render(<Index />); | ||
| expect(screen.getByTestId("hero")).toBeInTheDocument(); | ||
| expect(screen.getByTestId("ticker-grid")).toBeInTheDocument(); | ||
| expect(screen.getByTestId("news-feed")).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("has correct layout structure with min-h-screen and bg-background", () => { | ||
| const { container } = render(<Index />); | ||
| const mainDiv = container.querySelector(".min-h-screen.bg-background"); | ||
| expect(mainDiv).toBeInTheDocument(); | ||
| }); | ||
| }); |
This file contains hidden or 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,54 @@ | ||
| "use client"; | ||
| import { useEffect } from "react"; | ||
| import Link from "next/link"; | ||
| import { usePathname } from "next/navigation"; | ||
| import { AlertTriangle, Home } from "lucide-react"; | ||
|
|
||
| const NotFound = () => { | ||
| const pathname = usePathname(); | ||
|
|
||
| // Log the error to the console for debugging purposes | ||
| useEffect(() => { | ||
| console.error( | ||
| `404 Not Found: User attempted to access a non-existent route: ${pathname}` | ||
| ); | ||
| }, [pathname]); | ||
|
|
||
| return ( | ||
| <div className="flex min-h-screen items-center justify-center bg-gray-900"> | ||
| <div className="mx-4 w-full max-w-md rounded-2xl p-8 text-center shadow-xl bg-gray-800/60 dark:backdrop-blur-sm"> | ||
| <div className="mb-6 flex justify-center"> | ||
| <AlertTriangle | ||
| aria-label="Warning: Page not found" | ||
| className="h-16 w-16 text-yellow-500" | ||
| /> | ||
| </div> | ||
|
|
||
| <h1 className="bg-gradient-to-r from-purple-500 to-pink-500 bg-clip-text text-8xl font-extrabold text-transparent"> | ||
| 404 | ||
| </h1> | ||
|
|
||
| <h2 className="mt-4 text-2xl font-bold text-gray-100"> | ||
| Page Not Found | ||
| </h2> | ||
|
|
||
| <p className="mt-2 text-gray-500 dark:text-gray-400"> | ||
| Sorry, the page you are looking for doesn't exist or has been | ||
| moved. | ||
| </p> | ||
|
|
||
| <div className="mt-8"> | ||
| <Link | ||
| href="/" | ||
| className="inline-flex items-center gap-2 rounded-lg bg-blue-600 px-6 py-3 font-semibold text-white shadow-md transition-all duration-300 hover:bg-blue-700 hover:shadow-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800" | ||
| > | ||
| <Home className="h-5 w-5" /> | ||
| Return to Homepage | ||
| </Link> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default NotFound; | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix formatting issues and standardize dark mode handling.
Multiple className strings contain double spaces and inconsistent dark mode class usage:
bg-gray-900,bg-gray-800/60), but some elements conditionally applydark:prefix classes. Either commit to a dark-only theme or implement proper light/dark mode support consistently across all elements.clsxorcnhelper for better readability.Example fixes:
Also applies to: 28-28, 32-32, 36-36, 44-44
🤖 Prompt for AI Agents