Skip to content
Open
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
59 changes: 59 additions & 0 deletions Day19_overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# App Architecture and Endpoint Summary

## ✅ Project Setup (Local)

- Cloned from: [GitHub Repo](https://github.com/PoshikaM/express-react-fullstack.git)

- Dependencies installe with npm install or npm i

- Started using npm run dev, which concurrently launches:

- Frontend via webpack-dev-server

- Backend via nodemon using babel-node

## 🏗️ Application Architecture
### 📦 Frontend (/src/app)

- Tech Stack: React.js with Redux

- Core Components:

- Login.jsx / Signup.jsx: User authentication screens

- Dashboard.jsx: Primary app interface

- TaskList.jsx / TaskDetail.jsx: Manage and display tasks

- Navigation.jsx: Handles in-app navigation

### Backend (/src/server)
- Tech Stack: Express.js + MongoDB

- Files:

- server.js: Entry point and app config

- authenticate.js: Login logic & token handling

- communicate-db.js: CRUD operations with Mongo

- connect-db.js: Handles DB connection

- initialize-db.js: Seeds/sets up DB structure

## Environment Configuration
- Mongo URI: mongodb://localhost:27017/organizer

- Ports:

- Frontend: 8080

- Backend: 7777

## Tech Stack
- Frontend: React, Redux

- Backend: Express.js, MongoDB

- Tools: Webpack, Babel
130 changes: 130 additions & 0 deletions Test_Plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# 🧪 Fullstack App Testing Suite

This project includes comprehensive testing for the fullstack web application, covering integration tests, unit tests, UI automation using Selenium, and performance/load testing.

---

## 📂 Directory Structure
```
tests/
├── integration/
│ ├── auth.test.js
│ ├── inMemory.js
│ └── task.test.js
├── selenium-tests/
│ ├── loginAutomation.js
│ └── taskDetailAutomation.js
├── unit/
│ └── utility.test.js
└── performance/
└── loadtest.js
```


---

## 🛠️ Testing Tools & Libraries Used

| Tool | Purpose |
|-----------------|--------------------------------------------------------------|
| `jest` | JavaScript test runner used for unit and integration tests |
| `supertest` | HTTP assertions for API endpoint testing |
| `mongodb-memory-server` | Creates an ephemeral in-memory MongoDB instance for testing |
| `selenium-webdriver` + `chromedriver` | Browser automation for UI testing |
| `k6` | Performance and load testing tool |

---

## ✅ Test Categories

### 🔹 1. Integration Tests (`tests/integration/`)

#### `auth.test.js`
- Tests user creation and authentication routes using `supertest`.
- Validates response structure and status codes.

#### `inMemory.js`
- Connects to an in-memory MongoDB instance using `mongodb-memory-server`.
- Inserts and retrieves a user document to confirm DB operations work in isolation.

#### `task.test.js`
- Verifies `/task/new` and `/task/update` endpoints.
- Ensures task creation and update flows are functional.

---

### 🔹 2. Unit Tests (`tests/unit/`)

#### `utility.test.js`
- Unit test for `assembleUserState` utility function.
- Validates correct session and task data retrieval.
- Uses test fixtures for users, tasks, and comments in MongoDB.

---

### 🔹 3. UI Automation Tests (`tests/selenium-tests/`)

#### `loginAutomation.js`
- Automates login form interaction on the frontend using Selenium.
- Verifies if login is successful by checking for presence of dashboard header.

#### `taskDetailAutomation.js`
- Simulates a user interacting with a task detail page:
- Updates task name
- Toggles task completion status
- Changes task group
- Adds a comment
- Navigates back to dashboard
- Waits for each step using Selenium's `until` feature for reliability.

---

### 🔹 4. Load Testing (`tests/performance/loadtest.js`)

#### `loadtest.js`
- Uses [k6](https://k6.io/) to simulate concurrent user traffic:
- Gradually ramps up to 100 virtual users
- Measures response time performance
- Checks that homepage loads within 500ms for each request.

---

## 🧪 How to Run the Tests

### ✅ Unit & Integration Tests (Jest)
```bash
npm install
npm test
```

## ✅ Selenium UI Tests

Ensure you have Chrome installed and chromedriver is available in PATH.
```
node tests/selenium-tests/loginAutomation.js
node tests/selenium-tests/taskDetailAutomation.js
```

## ✅ Load Testing with k6
Install k6 from https://k6.io/docs/getting-started/installation/
```
k6 run tests/performance/loadtest.js
```

## 📌 Summary

- ✔️ End-to-end testing coverage across API, UI, DB, and performance layers.

- ⚙️ Simulated real-world browser usage via Selenium.

- 🧠 Isolated DB testing with no side effects using in-memory MongoDB.

- 📈 Scalable load simulation via k6 to ensure system stability under load.

## 📎 Notes

- All tests assume the application is running locally on http://localhost:8080/.

- For Selenium, ensure forms have accessible input field names (e.g., name="username").

- Load testing is read-only — no data is posted or mutated.
Loading