merge: combine all features from both codebases - mobile dashboard + layer panel + notifications + shares + all fixes

This commit is contained in:
Leopoldadmin
2026-07-04 16:43:55 +02:00
parent 0606dbb501
commit be62470b53
79 changed files with 9562 additions and 3132 deletions
+35
View File
@@ -11,6 +11,7 @@ describe('Drawings API', () => {
let db: SqliteAdapter;
let projectId: string;
let createdDrawingId: string;
let authToken: string;
beforeAll(async () => {
db = new SqliteAdapter(':memory:');
@@ -18,10 +19,18 @@ describe('Drawings API', () => {
app = await createServer({ db, port: 0 });
await app.ready();
const regRes = await app.inject({
method: 'POST',
url: '/api/auth/register',
payload: { email: 'admin-test@example.com', password: 'Password123!', name: 'Admin Test', role: 'admin' },
});
authToken = JSON.parse(regRes.body).session.token;
// Create a project first (drawings belong to projects)
const projectRes = await app.inject({
method: 'POST',
url: '/api/projects',
headers: { authorization: `Bearer ${authToken}` },
payload: { name: 'Drawings Test Project' },
});
projectId = JSON.parse(projectRes.body).id;
@@ -32,6 +41,18 @@ describe('Drawings API', () => {
db.close();
});
// ─── Auth Check ──────────────────────────────────────
describe('Authentication', () => {
it('should return 401 without authorization header', async () => {
const response = await app.inject({
method: 'GET',
url: `/api/projects/${projectId}/drawings`,
});
expect(response.statusCode).toBe(401);
});
});
// ─── Create ─────────────────────────────────────────
describe('POST /api/projects/:projectId/drawings', () => {
@@ -39,6 +60,7 @@ describe('Drawings API', () => {
const response = await app.inject({
method: 'POST',
url: `/api/projects/${projectId}/drawings`,
headers: { authorization: `Bearer ${authToken}` },
payload: { name: 'Ground Floor' },
});
expect(response.statusCode).toBe(201);
@@ -53,6 +75,7 @@ describe('Drawings API', () => {
const response = await app.inject({
method: 'POST',
url: `/api/projects/${projectId}/drawings`,
headers: { authorization: `Bearer ${authToken}` },
payload: {},
});
expect(response.statusCode).toBe(201);
@@ -69,6 +92,7 @@ describe('Drawings API', () => {
const response = await app.inject({
method: 'GET',
url: `/api/projects/${projectId}/drawings`,
headers: { authorization: `Bearer ${authToken}` },
});
expect(response.statusCode).toBe(200);
const body = JSON.parse(response.body);
@@ -81,6 +105,7 @@ describe('Drawings API', () => {
const projRes = await app.inject({
method: 'POST',
url: '/api/projects',
headers: { authorization: `Bearer ${authToken}` },
payload: { name: 'Empty Project' },
});
const emptyProjId = JSON.parse(projRes.body).id;
@@ -88,6 +113,7 @@ describe('Drawings API', () => {
const response = await app.inject({
method: 'GET',
url: `/api/projects/${emptyProjId}/drawings`,
headers: { authorization: `Bearer ${authToken}` },
});
expect(response.statusCode).toBe(200);
const body = JSON.parse(response.body);
@@ -103,6 +129,7 @@ describe('Drawings API', () => {
const response = await app.inject({
method: 'GET',
url: `/api/drawings/${createdDrawingId}`,
headers: { authorization: `Bearer ${authToken}` },
});
expect(response.statusCode).toBe(200);
const body = JSON.parse(response.body);
@@ -114,6 +141,7 @@ describe('Drawings API', () => {
const response = await app.inject({
method: 'GET',
url: '/api/drawings/non-existent-id',
headers: { authorization: `Bearer ${authToken}` },
});
expect(response.statusCode).toBe(404);
});
@@ -126,6 +154,7 @@ describe('Drawings API', () => {
const response = await app.inject({
method: 'PATCH',
url: `/api/drawings/${createdDrawingId}`,
headers: { authorization: `Bearer ${authToken}` },
payload: { name: 'First Floor' },
});
expect(response.statusCode).toBe(200);
@@ -137,6 +166,7 @@ describe('Drawings API', () => {
const response = await app.inject({
method: 'PATCH',
url: `/api/drawings/${createdDrawingId}`,
headers: { authorization: `Bearer ${authToken}` },
payload: { data_json: '{"layers":[]}' },
});
expect(response.statusCode).toBe(200);
@@ -148,6 +178,7 @@ describe('Drawings API', () => {
const response = await app.inject({
method: 'PATCH',
url: '/api/drawings/non-existent-id',
headers: { authorization: `Bearer ${authToken}` },
payload: { name: 'New Name' },
});
expect(response.statusCode).toBe(404);
@@ -162,6 +193,7 @@ describe('Drawings API', () => {
const createRes = await app.inject({
method: 'POST',
url: `/api/projects/${projectId}/drawings`,
headers: { authorization: `Bearer ${authToken}` },
payload: { name: 'To Be Deleted' },
});
const drawingId = JSON.parse(createRes.body).id;
@@ -169,6 +201,7 @@ describe('Drawings API', () => {
const response = await app.inject({
method: 'DELETE',
url: `/api/drawings/${drawingId}`,
headers: { authorization: `Bearer ${authToken}` },
});
expect(response.statusCode).toBe(204);
@@ -176,6 +209,7 @@ describe('Drawings API', () => {
const getRes = await app.inject({
method: 'GET',
url: `/api/drawings/${drawingId}`,
headers: { authorization: `Bearer ${authToken}` },
});
expect(getRes.statusCode).toBe(404);
});
@@ -184,6 +218,7 @@ describe('Drawings API', () => {
const response = await app.inject({
method: 'DELETE',
url: '/api/drawings/non-existent-id',
headers: { authorization: `Bearer ${authToken}` },
});
expect(response.statusCode).toBe(404);
});