Skip to content

Commit

Permalink
Update frontend and backend ci (#17)
Browse files Browse the repository at this point in the history
* Update frontend and backend ci

* Fix import issue

* Fix import paths to include js extension

* Fix import path of reportWebVitals

* Use babel with jest

* Config jest for es modules

* Downgrade axios

* Update app.test

* Update tests

* Revert "Config jest for es modules"

This reverts commit 5316ede.

* Revert "Use babel with jest"

This reverts commit d3a95cb.
  • Loading branch information
eomielan authored Oct 27, 2024
1 parent 60e2ef4 commit 5b5256b
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 37 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: Backend CI

on:
push:
paths:
- 'backend/**'
branches:
- main
pull_request:
paths:
- 'backend/**'
branches:
- main

jobs:
build:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: Frontend CI

on:
push:
paths:
- 'frontend/**'
branches:
- main
pull_request:
paths:
- 'frontend/**'
branches:
- main

jobs:
build-and-test:
Expand Down
19 changes: 6 additions & 13 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
"name": "frontend",
"version": "0.1.0",
"private": true,
"type": "module",
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.7.7",
"axios": "^0.27.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.27.0",
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { BrowserRouter as Router, Routes, Route, Link } from "react-router-dom";
import SenderPage from "./components/SenderPage";
import ReceiverPage from "./components/ReceiverPage";
import SenderPage from "./components/SenderPage.js";
import ReceiverPage from "./components/ReceiverPage.js";
import styled from "styled-components";

const Container = styled.div`
Expand Down
35 changes: 29 additions & 6 deletions frontend/src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
import { render, screen } from '@testing-library/react';
import App from './App';
import React from "react";
import { render, screen } from "@testing-library/react";
import { MemoryRouter, Route, Routes } from "react-router-dom";
import SenderPage from "./components/SenderPage";
import ReceiverPage from "./components/ReceiverPage";

test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
describe("App Navigation", () => {
test("renders SenderPage when navigating to '/'", () => {
render(
<MemoryRouter initialEntries={["/"]}>
<Routes>
<Route path="/" element={<SenderPage />} />
</Routes>
</MemoryRouter>
);
const senderHeading = screen.getByText(/Sender Page/i);
expect(senderHeading).toBeInTheDocument();
});

test("renders ReceiverPage when navigating to '/receiver'", () => {
render(
<MemoryRouter initialEntries={["/receiver"]}>
<Routes>
<Route path="/receiver" element={<ReceiverPage />} />
</Routes>
</MemoryRouter>
);
const receiverHeading = screen.getByText(/Receiver Page/i);
expect(receiverHeading).toBeInTheDocument();
});
});
12 changes: 6 additions & 6 deletions frontend/src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import App from "./App.js";
import reportWebVitals from "./reportWebVitals.js";

const root = ReactDOM.createRoot(document.getElementById('root'));
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
<React.StrictMode>
<App />
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';
import "@testing-library/jest-dom";

0 comments on commit 5b5256b

Please sign in to comment.