feat(smart-app): implement complete mobile app MVP

- App.tsx: full navigation (Auth stack + Main tabs with 5 screens)
- Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen
- HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors
- MapScreen: interactive map with layer toggles (6 layers)
- MarketplaceScreen: categories (6), products (5), search
- ChatScreen: AI chat with quick prompts (4), bot responses
- ProfileScreen: user info, stats, menu (9 items), logout
- AlertsScreen: alert list with severity, acknowledge
- SensorsScreen: sensor list with type filters (6 types), search
- ZonesScreen: zone cards with stats
- SettingsScreen: language picker (FR/EN/ES/DE), privacy, about
- Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n
- Hooks: useSensors, useAlerts, useNotifications, useLocation
- Components: Card, Button, LoadingSpinner, ErrorBoundary, Header
- Services: iotService, notificationService (with axios API client)
- Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN)
- Theme: colors.ts with full design system (Blue Ocean palette)
- Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
This commit is contained in:
Eric FELIXINE
2026-06-01 18:00:35 -04:00
parent 08ca495bde
commit e30ae8ed09
35578 changed files with 3703534 additions and 43 deletions

View File

@@ -0,0 +1,46 @@
const { AbortController } = require("../index.js");
describe("AbortController", function () {
it("should call abort handlers once", function () {
const controller = new AbortController();
const signal = controller.signal;
const handler = jest.fn();
expect(signal.onabort).toBeNull();
expect(signal.aborted).toBe(false);
expect(signal.reason).toBeUndefined();
signal.onabort = jest.fn();
signal.addEventListener("abort", handler);
controller.abort();
expect(signal.aborted).toBe(true);
expect(signal.reason).toEqual(new Error("AbortError"));
expect(handler).toBeCalledTimes(1);
expect(handler).toBeCalledWith({ type: "abort", target: signal });
expect(signal.onabort).toBeCalledTimes(1);
expect(signal.onabort).toBeCalledWith({ type: "abort", target: signal });
jest.clearAllMocks();
controller.abort();
expect(signal.aborted).toBe(true);
expect(signal.reason).toEqual(new Error("AbortError"));
expect(handler).not.toBeCalled();
expect(signal.onabort).not.toBeCalled();
});
it("should use custom abort reason", () => {
const controller = new AbortController();
const signal = controller.signal;
expect(signal.aborted).toBe(false);
expect(signal.reason).toBeUndefined();
const customReason = new Error("Custom Reason");
controller.abort(customReason);
expect(signal.aborted).toBe(true);
expect(signal.reason).toBe(customReason);
});
});

View File

@@ -0,0 +1,72 @@
const { AbortController, AbortSignal } = require("../index.js");
describe("AbortSignal", function () {
it("should implement EventTarget", function () {
const controller = new AbortController();
const signal = controller.signal;
const unusedHandler = jest.fn();
const handler = jest.fn();
const event = { type: "abort", target: signal };
signal.onabort = jest.fn();
signal.addEventListener("abort", handler);
signal.addEventListener("abort", unusedHandler);
signal.removeEventListener("abort", unusedHandler);
signal.dispatchEvent("abort", event);
expect(unusedHandler).not.toBeCalled();
expect(handler).toBeCalledTimes(1);
expect(handler).toBeCalledWith(event);
expect(signal.onabort).toBeCalledTimes(1);
expect(signal.onabort).toBeCalledWith(event);
jest.clearAllMocks();
signal.dispatchEvent("abort", event);
expect(unusedHandler).not.toBeCalled();
expect(handler).toBeCalledTimes(1);
expect(handler).toBeCalledWith(event);
expect(signal.onabort).toBeCalledTimes(1);
expect(signal.onabort).toBeCalledWith(event);
jest.clearAllMocks();
signal.dispatchEvent("unknown", event);
expect(unusedHandler).not.toBeCalled();
expect(handler).not.toBeCalled();
expect(signal.onabort).not.toBeCalled();
});
it("should implement throwIfAborted", function () {
const controller = new AbortController();
const signal = controller.signal;
expect(() => signal.throwIfAborted()).not.toThrowError();
controller.abort();
expect(() => signal.throwIfAborted()).toThrowError(new Error("AbortError"));
});
});
describe("Static methods", () => {
jest.useFakeTimers();
jest.spyOn(global, "setTimeout");
it("should implement abort", function () {
const signal = AbortSignal.abort();
expect(signal.aborted).toBe(true);
expect(signal.reason).toEqual(new Error("AbortError"));
});
it("should implement timeout", function () {
const signal = AbortSignal.timeout(1000);
expect(setTimeout).toHaveBeenCalledTimes(1);
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 1000);
expect(signal.aborted).toBe(false);
expect(signal.reason).toBeUndefined();
jest.runAllTimers();
expect(signal.aborted).toBe(true);
expect(signal.reason).toEqual(new Error("TimeoutError"));
});
});

View File

@@ -0,0 +1,19 @@
describe("AbortController in browser", function () {
// Mock AbortController
const mockedGlobalAbortController = jest.fn();
beforeAll(() => {
// Attach mocked AbortController to global
self.AbortController = mockedGlobalAbortController;
});
it("should call global abort controller", function () {
// Require module after global setup
const { AbortController } = require("../browser.js");
const controller = new AbortController();
expect(controller).toBeTruthy();
expect(mockedGlobalAbortController).toBeCalled();
});
});

View File

@@ -0,0 +1,27 @@
const { AbortController } = require("../index.js");
const fetch = require("node-fetch");
describe("node-fetch", function () {
it("should throw exception if aborted during the request", async function () {
expect.assertions(1);
try {
const controller = new AbortController();
const signal = controller.signal;
setTimeout(() => controller.abort(), 5);
await fetch("https://www.google.com/", { signal });
} catch (err) {
expect(err.name).toBe("AbortError");
}
});
it("should throw exception if passed an already aborted signal", async function () {
expect.assertions(1);
try {
const controller = new AbortController();
const signal = controller.signal;
controller.abort();
await fetch("https://www.google.com/", { signal });
} catch (err) {
expect(err.name).toBe("AbortError");
}
});
});

View File

@@ -0,0 +1,27 @@
const { AbortController } = require("../index.js");
const { fetch } = require("whatwg-fetch");
describe("node-fetch", function () {
it("should throw exception if aborted during the request", async function () {
expect.assertions(1);
try {
const controller = new AbortController();
const signal = controller.signal;
setTimeout(() => controller.abort(), 5);
await fetch("https://www.google.com/", { signal });
} catch (err) {
expect(err.name).toBe("AbortError");
}
});
it("should throw exception if passed an already aborted signal", async function () {
expect.assertions(1);
try {
const controller = new AbortController();
const signal = controller.signal;
controller.abort();
await fetch("https://www.google.com/", { signal });
} catch (err) {
expect(err.name).toBe("AbortError");
}
});
});