fix: replace hardcoded localhost:3001 with relative API URL + add canvas mock and integration test
- Fix frontend Network error: API_BASE now defaults to empty string (same-origin) - Fix 3 files: api.ts, AuthContext.tsx, Dashboard.tsx - Add Canvas 2D context mock in tests/setup.ts for jsdom - Fix -0 vs +0 in ZoomPanController.getViewport() - Add IntegrationWorkflow.test.ts (35 tests, full CAD workflow)
This commit is contained in:
@@ -23,11 +23,13 @@ export class ZoomPanController {
|
||||
getViewport(): Viewport {
|
||||
const w = this.canvas.width / this.scale;
|
||||
const h = this.canvas.height / this.scale;
|
||||
const minX = -this.offsetX / this.scale || 0;
|
||||
const minY = -this.offsetY / this.scale || 0;
|
||||
return {
|
||||
minX: -this.offsetX / this.scale,
|
||||
minY: -this.offsetY / this.scale,
|
||||
maxX: (-this.offsetX / this.scale) + w,
|
||||
maxY: (-this.offsetY / this.scale) + h,
|
||||
minX,
|
||||
minY,
|
||||
maxX: minX + w,
|
||||
maxY: minY + h,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import { createContext, useContext, useState, useCallback, useEffect, type ReactNode } from 'react';
|
||||
|
||||
const API_BASE = 'http://localhost:3001';
|
||||
const API_BASE = import.meta.env.VITE_API_BASE || '';
|
||||
|
||||
export interface AuthUser {
|
||||
id: string;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { useAuth } from '../contexts/AuthContext';
|
||||
|
||||
const API_BASE = 'http://localhost:3001';
|
||||
const API_BASE = import.meta.env.VITE_API_BASE || '';
|
||||
|
||||
interface Project {
|
||||
id: string;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import type { CADElement, CADLayer, BlockDefinition } from '../types/cad.types';
|
||||
|
||||
const API_BASE = import.meta.env.VITE_API_BASE || 'http://localhost:3001';
|
||||
const API_BASE = import.meta.env.VITE_API_BASE || '';
|
||||
|
||||
function authHeaders(token: string): Record<string, string> {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user