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
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# MongoDB connection string
MONGO_DB_URL=

# Secret key for JWT token signing
TOKEN_SECRET=

# SMTP configuration for sending emails
SMTP_USER=
SMTP_PASS=

# Domain URL for email verification links
domain=http://localhost:3000
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run: npm install

- name: Run tests
run: npx jest --coverage --reporters=jest-junit
run: npx jest --coverage --reporters=default --reporters=jest-junit --verbose

- name: Upload results to Codecov
uses: codecov/codecov-action@v5
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

# testing
/coverage
junit.xml

# next.js
/.next/
Expand All @@ -31,7 +32,7 @@ yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*
.env

# vercel
.vercel
Expand Down
11 changes: 10 additions & 1 deletion app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface Device {
color: string; // Named color
brightness: number;
powered: boolean;
connected?: boolean; // Connection status
}

interface User {
Expand All @@ -40,7 +41,7 @@ export default function Dashboard() {
const [devices, setDevices] = useState<Device[]>([]);
const [selectedDeviceId, setSelectedDeviceId] = useState<string>("");
const [selectedDevice, setSelectedDevice] = useState<Device | null>(null);
const [editValues, setEditValues] = useState<Omit<Device, "_id">>({
const [editValues, setEditValues] = useState<Omit<Device, "_id" | "connected">>({
name: "",
color: colors[0].name,
brightness: 100,
Expand Down Expand Up @@ -293,6 +294,14 @@ const colorsList = useMemo(() => colors, []);

{selectedDevice && (
<div className="mt-6 bg-blue-100 p-4 text-left rounded-lg shadow">
{/* Connection Status */}
<div className="flex items-center gap-2 mb-4 pb-3 border-b border-gray-300">
<div className={`w-3 h-3 rounded-full ${selectedDevice.connected ? 'bg-green-500' : 'bg-red-500'}`} />
<span className="text-sm font-semibold">
{selectedDevice.connected ? 'Connected' : 'Disconnected'}
</span>
</div>

{/* Device Name */}
<label className="block mb-2">Name</label>
<input
Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

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

5 changes: 5 additions & 0 deletions tests/account/account.api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ jest.mock("@/dbConfig", () => ({
disconnect: async () => {}, // no-op
}));

// βœ… Mock sendEmail to prevent actual email sending in tests
jest.mock("@/app/helpers/mailer", () => ({
sendEmail: jest.fn().mockResolvedValue(true),
}));

import User from "@/server/mongodb/models/accountSchema";
import bcrypt from "bcryptjs";
import { POST as deviceHandler } from "@/app/api/users/devices/route";
Expand Down
3 changes: 3 additions & 0 deletions tests/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ beforeAll(async () => {
// Set test DB URL
process.env.MONGO_DB_URL = mongo.getUri();

// Set TOKEN_SECRET for JWT signing in tests
process.env.TOKEN_SECRET = "test-secret-key-for-jwt-signing";

// Connect mongoose directly
await mongoose.connect(process.env.MONGO_DB_URL);
console.log("βœ… Connected to in-memory MongoDB");
Expand Down