diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..4cd3353 --- /dev/null +++ b/.env.example @@ -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 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index aeaa18b..cb1a45c 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -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 diff --git a/.gitignore b/.gitignore index 5ef6a52..5887273 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ # testing /coverage +junit.xml # next.js /.next/ @@ -31,7 +32,7 @@ yarn-error.log* .pnpm-debug.log* # env files (can opt-in for committing if needed) -.env* +.env # vercel .vercel diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx index daeb7eb..a12728c 100644 --- a/app/dashboard/page.tsx +++ b/app/dashboard/page.tsx @@ -25,6 +25,7 @@ interface Device { color: string; // Named color brightness: number; powered: boolean; + connected?: boolean; // Connection status } interface User { @@ -40,7 +41,7 @@ export default function Dashboard() { const [devices, setDevices] = useState([]); const [selectedDeviceId, setSelectedDeviceId] = useState(""); const [selectedDevice, setSelectedDevice] = useState(null); - const [editValues, setEditValues] = useState>({ + const [editValues, setEditValues] = useState>({ name: "", color: colors[0].name, brightness: 100, @@ -293,6 +294,14 @@ const colorsList = useMemo(() => colors, []); {selectedDevice && (
+ {/* Connection Status */} +
+
+ + {selectedDevice.connected ? 'Connected' : 'Disconnected'} + +
+ {/* Device Name */} =0.10.0" } @@ -8528,6 +8539,7 @@ "version": "19.0.0", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.0.0.tgz", "integrity": "sha512-4GV5sHFG0e/0AD4X+ySy6UJd3jVl1iNsNHdpad0qhABJ11twS3TTBnseqsKurKcsNqCEFeGL3uLpVChpIO3QfQ==", + "peer": true, "dependencies": { "scheduler": "^0.25.0" }, @@ -9892,6 +9904,7 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", "dev": true, + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/tests/account/account.api.test.ts b/tests/account/account.api.test.ts index 836d140..7600f16 100644 --- a/tests/account/account.api.test.ts +++ b/tests/account/account.api.test.ts @@ -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"; diff --git a/tests/setup.ts b/tests/setup.ts index 6e6dded..0e1cadc 100644 --- a/tests/setup.ts +++ b/tests/setup.ts @@ -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");