refactor: update import paths to use absolute paths for better clarity and maintainability
This commit is contained in:
parent
decb28dc19
commit
74aea1677b
11 changed files with 30 additions and 21 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
||||
import { AutodraftSettings } from '../AutodraftSettings';
|
||||
import { AutodraftSettings } from '~/components/AutodraftSettings';
|
||||
|
||||
// Mock fetch
|
||||
global.fetch = vi.fn();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { describe, it, expect } from "vitest";
|
||||
import { calculateDraftEligibility, getEligibilitySummary } from "../draft-eligibility";
|
||||
import { calculateDraftEligibility, getEligibilitySummary } from "~/lib/draft-eligibility";
|
||||
|
||||
// Helper to create test data
|
||||
const createSport = (id: string, name: string) => ({ id, name });
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { describe, it, expect } from 'vitest';
|
||||
import { cn } from '../utils';
|
||||
import { cn } from '~/lib/utils';
|
||||
|
||||
describe('Utils', () => {
|
||||
describe('cn (className merger)', () => {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { getAuth } from "@clerk/react-router/server";
|
||||
import { database } from "../../../database/context";
|
||||
import * as schema from "../../../database/schema";
|
||||
import { database } from "~/database/context";
|
||||
import * as schema from "~/database/schema";
|
||||
import { eq, and } from "drizzle-orm";
|
||||
import { getSocketIO } from "../../../server/socket";
|
||||
import { getSocketIO } from "~/server/socket";
|
||||
|
||||
export async function action(args: any) {
|
||||
const { request } = args;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { action } from "../../api/autodraft.update";
|
||||
import { action } from "~/routes/api/autodraft.update";
|
||||
|
||||
// Mock dependencies
|
||||
vi.mock("../../../../database/context");
|
||||
vi.mock("../../../../server/socket", () => ({
|
||||
vi.mock("~/database/context");
|
||||
vi.mock("~/server/socket", () => ({
|
||||
getSocketIO: vi.fn(),
|
||||
}));
|
||||
vi.mock("@clerk/react-router/server", () => ({
|
||||
|
|
@ -27,7 +27,7 @@ describe("Autodraft Settings API", () => {
|
|||
emit: vi.fn(),
|
||||
};
|
||||
|
||||
const socketModule = await import("../../../../server/socket");
|
||||
const socketModule = await import("~/server/socket");
|
||||
vi.mocked(socketModule.getSocketIO).mockReturnValue(mockSocketIO);
|
||||
|
||||
// Mock database
|
||||
|
|
@ -48,7 +48,7 @@ describe("Autodraft Settings API", () => {
|
|||
values: vi.fn().mockReturnThis(),
|
||||
};
|
||||
|
||||
const { database } = await import("../../../../database/context");
|
||||
const { database } = await import("~/database/context");
|
||||
vi.mocked(database).mockReturnValue(mockDb);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ import express from "express";
|
|||
import postgres from "postgres";
|
||||
import { RouterContextProvider } from "react-router";
|
||||
|
||||
import { DatabaseContext } from "../database/context";
|
||||
import * as schema from "../database/schema";
|
||||
import { expressValueContext } from "../app/contexts/express";
|
||||
import { DatabaseContext } from "~/database/context";
|
||||
import * as schema from "~/database/schema";
|
||||
import { expressValueContext } from "~/contexts/express";
|
||||
|
||||
export const app = express();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { drizzle } from "drizzle-orm/postgres-js";
|
||||
import postgres from "postgres";
|
||||
import * as schema from "../database/schema";
|
||||
import * as schema from "~/database/schema";
|
||||
import { eq, and, desc, asc, inArray, notInArray } from "drizzle-orm";
|
||||
import { getSocketIO } from "./socket";
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,10 @@
|
|||
"noEmit": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./app/*"]
|
||||
"~/*": ["./app/*"],
|
||||
"@/*": ["./app/*"],
|
||||
"~/database/*": ["./database/*"],
|
||||
"~/server/*": ["./server/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@
|
|||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"~/*": ["./app/*"],
|
||||
"~/database/*": ["./database/*"]
|
||||
"@/*": ["./app/*"],
|
||||
"~/database/*": ["./database/*"],
|
||||
"~/server/*": ["./server/*"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
"paths": {
|
||||
"@/*": ["./app/*"],
|
||||
"~/database/*": ["./database/*"],
|
||||
"~/server/*": ["./server/*"],
|
||||
"~/*": ["./app/*"]
|
||||
},
|
||||
"esModuleInterop": true,
|
||||
|
|
|
|||
|
|
@ -24,9 +24,12 @@ export default defineConfig({
|
|||
},
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'~': path.resolve(__dirname, './app'),
|
||||
'app': path.resolve(__dirname, './app'),
|
||||
},
|
||||
alias: [
|
||||
{ find: /^~\/database\/(.*)$/, replacement: path.resolve(__dirname, './database/$1') },
|
||||
{ find: /^~\/server\/(.*)$/, replacement: path.resolve(__dirname, './server/$1') },
|
||||
{ find: /^~\/(.*)$/, replacement: path.resolve(__dirname, './app/$1') },
|
||||
{ find: /^@\/(.*)$/, replacement: path.resolve(__dirname, './app/$1') },
|
||||
{ find: 'app', replacement: path.resolve(__dirname, './app') },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue