diff --git a/app/api/create-ingest/CreateIngestRoute.test.ts b/__tests__/api/CreateIngestRoute.test.ts similarity index 96% rename from app/api/create-ingest/CreateIngestRoute.test.ts rename to __tests__/api/CreateIngestRoute.test.ts index 565bc4b..b66797c 100644 --- a/app/api/create-ingest/CreateIngestRoute.test.ts +++ b/__tests__/api/CreateIngestRoute.test.ts @@ -1,11 +1,11 @@ import { describe, expect, it, vi } from 'vitest'; import { POST, PUT } from '@/app/api/create-ingest/route'; -import UpdatePR from '@/utils/UpdatePR'; import { NextRequest } from 'next/server'; -import CreatePR from '@/utils/CreatePR'; +import UpdatePR from '@/utils/githubUtils/UpdatePR'; +import CreatePR from '@/utils/githubUtils/CreatePR'; -vi.mock('@/utils/UpdatePR'); -vi.mock('@/utils/CreatePR'); +vi.mock('@/utils/githubUtils/UpdatePR'); +vi.mock('@/utils/githubUtils/CreatePR'); describe('POST /create-ingest', () => { it('returns GitHub URL on successful PR creation', async () => { diff --git a/app/api/list-ingests/ListIngestsRoute.test.ts b/__tests__/api/ListIngestsRoute.test.ts similarity index 96% rename from app/api/list-ingests/ListIngestsRoute.test.ts rename to __tests__/api/ListIngestsRoute.test.ts index ad566e2..98d0768 100644 --- a/app/api/list-ingests/ListIngestsRoute.test.ts +++ b/__tests__/api/ListIngestsRoute.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it, vi } from 'vitest'; import { GET } from '@/app/api/list-ingests/route'; -import ListPRs from '@/utils/ListPRs'; +import ListPRs from '@/utils/githubUtils/ListPRs'; import { NextRequest } from 'next/server'; import { Endpoints } from '@octokit/types'; @@ -12,7 +12,7 @@ type SimplifiedPullRequest = Pick & { }; // Mock implementation -vi.mock('@/utils/ListPRs', () => { +vi.mock('@/utils/githubUtils/ListPRs', () => { const mockPRs: SimplifiedPullRequest[] = [ { id: 1, diff --git a/app/api/retrieve-ingest/RetrieveIngestRoute.test.ts b/__tests__/api/RetrieveIngestRoute.test.ts similarity index 96% rename from app/api/retrieve-ingest/RetrieveIngestRoute.test.ts rename to __tests__/api/RetrieveIngestRoute.test.ts index 1087266..6564883 100644 --- a/app/api/retrieve-ingest/RetrieveIngestRoute.test.ts +++ b/__tests__/api/RetrieveIngestRoute.test.ts @@ -1,10 +1,10 @@ import { describe, expect, it, vi, beforeEach } from 'vitest'; import { GET } from '@/app/api/retrieve-ingest/route'; -import RetrieveJSON from '@/utils/RetrieveJSON'; +import RetrieveJSON from '@/utils/githubUtils/RetrieveJSON'; import { NextRequest } from 'next/server'; // Mock implementation -vi.mock('@/utils/RetrieveJSON', () => { +vi.mock('@/utils/githubUtils/RetrieveJSON', () => { return { default: vi.fn(), }; diff --git a/components/ErrorModal.test.tsx b/__tests__/components/ErrorModal.test.tsx similarity index 98% rename from components/ErrorModal.test.tsx rename to __tests__/components/ErrorModal.test.tsx index b9421bb..7c41364 100644 --- a/components/ErrorModal.test.tsx +++ b/__tests__/components/ErrorModal.test.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { cleanup, render, screen } from '@testing-library/react'; import { describe, it, expect, vi, afterEach } from 'vitest'; -import ErrorModal from './ErrorModal'; +import ErrorModal from '@/components/ErrorModal'; // Mock StyledModal vi.mock('@/components/StyledModal', () => ({ diff --git a/components/SuccessModal.test.tsx b/__tests__/components/SuccessModal.test.tsx similarity index 95% rename from components/SuccessModal.test.tsx rename to __tests__/components/SuccessModal.test.tsx index 04e194e..836f3e4 100644 --- a/components/SuccessModal.test.tsx +++ b/__tests__/components/SuccessModal.test.tsx @@ -1,11 +1,11 @@ import React from 'react'; import { render, screen, fireEvent, cleanup } from '@testing-library/react'; import { describe, it, vi, expect, afterEach } from 'vitest'; -import SuccessModal from './SuccessModal'; +import SuccessModal from '@/components/SuccessModal'; // Mock StyledModal -vi.mock('./StyledModal', () => ({ +vi.mock('@/components/StyledModal', () => ({ __esModule: true, default: vi.fn(({ children, okText, onOk }) => (
diff --git a/middleware.test.ts b/__tests__/middleware.test.ts similarity index 98% rename from middleware.test.ts rename to __tests__/middleware.test.ts index 4949642..6daa489 100644 --- a/middleware.test.ts +++ b/__tests__/middleware.test.ts @@ -1,6 +1,6 @@ import { describe, it, expect, vi } from 'vitest'; import { NextRequest } from 'next/server'; -import { middleware } from './middleware'; +import { middleware } from '@/middleware'; import { runWithAmplifyServerContext } from '@/utils/amplify-server-util'; import { fetchAuthSession } from 'aws-amplify/auth/server'; diff --git a/app/page.test.tsx b/__tests__/page.test.tsx similarity index 94% rename from app/page.test.tsx rename to __tests__/page.test.tsx index 5065ff8..a5ab1f0 100644 --- a/app/page.test.tsx +++ b/__tests__/page.test.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; import { describe, it, expect, beforeAll } from 'vitest'; -import Home from './page'; +import Home from '@/app/page'; import { Amplify } from 'aws-amplify'; import { config } from '@/utils/aws-exports'; diff --git a/app/create-ingest/CreateIngestModals.test.tsx b/__tests__/pages/CreateIngestModals.test.tsx similarity index 100% rename from app/create-ingest/CreateIngestModals.test.tsx rename to __tests__/pages/CreateIngestModals.test.tsx diff --git a/app/create-ingest/CreateIngestPage.test.tsx b/__tests__/pages/CreateIngestPage.test.tsx similarity index 91% rename from app/create-ingest/CreateIngestPage.test.tsx rename to __tests__/pages/CreateIngestPage.test.tsx index 9cdb169..9d7eded 100644 --- a/app/create-ingest/CreateIngestPage.test.tsx +++ b/__tests__/pages/CreateIngestPage.test.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; import { describe, it, expect, beforeAll } from 'vitest'; -import CreateIngest from './page'; +import CreateIngest from '@/app/create-ingest/page'; import { Amplify } from 'aws-amplify'; import { config } from '@/utils/aws-exports'; diff --git a/app/edit-ingest/EditIngestPage.test.tsx b/__tests__/pages/EditIngestPage.test.tsx similarity index 97% rename from app/edit-ingest/EditIngestPage.test.tsx rename to __tests__/pages/EditIngestPage.test.tsx index da7e404..3053fb3 100644 --- a/app/edit-ingest/EditIngestPage.test.tsx +++ b/__tests__/pages/EditIngestPage.test.tsx @@ -7,7 +7,7 @@ import { setupServer } from 'msw/node'; import { handlers } from '@/__mocks__/handlers'; import { http, HttpResponse } from 'msw'; -import EditIngest from './page'; +import EditIngest from '@/app/edit-ingest/page'; global.window.getComputedStyle = vi.fn().mockImplementation(() => ({ getPropertyValue: vi.fn(), @@ -79,6 +79,6 @@ describe('Edit Ingest Page', () => { const modalTitle = screen.getByText(/Collection Updated/i); expect(modalTitle).toBeInTheDocument(); }); - }); + }, 10000); }); diff --git a/utils/CreatePR.test.ts b/__tests__/utils/CreatePR.test.ts similarity index 93% rename from utils/CreatePR.test.ts rename to __tests__/utils/CreatePR.test.ts index ae2f7ed..3a231c7 100644 --- a/utils/CreatePR.test.ts +++ b/__tests__/utils/CreatePR.test.ts @@ -1,12 +1,12 @@ import { describe, it, expect, vi, beforeEach, beforeAll, afterAll, Mock } from 'vitest'; -import CreatePR from './CreatePR'; -import { createOctokit } from './OctokitFactory'; -import GetGithubToken from './GetGithubToken'; +import CreatePR from '@/utils/githubUtils/CreatePR'; +import { createOctokit } from '@/utils/githubUtils/OctokitFactory'; +import GetGithubToken from '@/utils/githubUtils/GetGithubToken'; import { RequestError } from '@octokit/request-error'; -vi.mock('./OctokitFactory'); -vi.mock('./GetGithubToken'); -vi.mock('./FormatFilename', () => ({ +vi.mock('@/utils/githubUtils/OctokitFactory'); +vi.mock('@/utils/githubUtils/GetGithubToken'); +vi.mock('@/utils/FormatFilename', () => ({ formatFilename: (name: string) => name.replace(/\s+/g, '-').toLowerCase(), })); diff --git a/utils/FormatFilename.test.ts b/__tests__/utils/FormatFilename.test.ts similarity index 94% rename from utils/FormatFilename.test.ts rename to __tests__/utils/FormatFilename.test.ts index 6718327..ed9ec93 100644 --- a/utils/FormatFilename.test.ts +++ b/__tests__/utils/FormatFilename.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest'; -import { formatFilename } from './FormatFilename'; +import { formatFilename } from '@/utils/FormatFilename'; describe('formatFilename', () => { it('removes non-alphanumeric characters except dash and underscore', () => { diff --git a/utils/GetGithubToken.test.ts b/__tests__/utils/GetGithubToken.test.ts similarity index 97% rename from utils/GetGithubToken.test.ts rename to __tests__/utils/GetGithubToken.test.ts index d745500..0c91f6b 100644 --- a/utils/GetGithubToken.test.ts +++ b/__tests__/utils/GetGithubToken.test.ts @@ -1,6 +1,6 @@ import { describe, it, expect, vi, beforeEach, Mock } from 'vitest'; -import GetGithubToken from './GetGithubToken'; +import GetGithubToken from '@/utils/githubUtils/GetGithubToken'; import { Octokit } from '@octokit/rest'; vi.mock('@octokit/rest', () => ({ diff --git a/utils/ListPRs.test.ts b/__tests__/utils/ListPRs.test.ts similarity index 94% rename from utils/ListPRs.test.ts rename to __tests__/utils/ListPRs.test.ts index 5d8ec23..475122f 100644 --- a/utils/ListPRs.test.ts +++ b/__tests__/utils/ListPRs.test.ts @@ -1,9 +1,9 @@ import { describe, it, expect, vi } from 'vitest'; import { Octokit } from '@octokit/rest'; -import ListPRs from './ListPRs'; -import GetGithubToken from './GetGithubToken'; +import ListPRs from '@/utils/githubUtils/ListPRs'; +import GetGithubToken from '@/utils/githubUtils/GetGithubToken'; -vi.mock('./GetGithubToken', () => ({ +vi.mock('@/utils/githubUtils/GetGithubToken', () => ({ default: vi.fn(), })); diff --git a/utils/RetrieveJSON.test.ts b/__tests__/utils/RetrieveJSON.test.ts similarity index 93% rename from utils/RetrieveJSON.test.ts rename to __tests__/utils/RetrieveJSON.test.ts index 72cba98..1395d8f 100644 --- a/utils/RetrieveJSON.test.ts +++ b/__tests__/utils/RetrieveJSON.test.ts @@ -1,13 +1,13 @@ import { describe, it, expect, vi, beforeEach, Mock } from 'vitest'; -import RetrieveJSON from './RetrieveJSON'; -import GetGithubToken from './GetGithubToken'; +import RetrieveJSON from '@/utils/githubUtils/RetrieveJSON'; +import GetGithubToken from '@/utils/githubUtils/GetGithubToken'; import { Octokit } from '@octokit/rest'; vi.mock('@octokit/rest', () => ({ Octokit: vi.fn(), })); -vi.mock('./GetGithubToken'); +vi.mock('@/utils/githubUtils/GetGithubToken'); describe('RetrieveJSON', () => { const mockGetContent = vi.fn(); diff --git a/utils/UpdatePR.test.ts b/__tests__/utils/UpdatePR.test.ts similarity index 95% rename from utils/UpdatePR.test.ts rename to __tests__/utils/UpdatePR.test.ts index df1bbae..408bd5f 100644 --- a/utils/UpdatePR.test.ts +++ b/__tests__/utils/UpdatePR.test.ts @@ -1,13 +1,13 @@ import { describe, it, expect, vi, beforeEach, Mock } from 'vitest'; -import UpdatePR from './UpdatePR'; -import GetGithubToken from './GetGithubToken'; +import UpdatePR from '@/utils/githubUtils/UpdatePR'; +import GetGithubToken from '@/utils/githubUtils/GetGithubToken'; import { Octokit } from '@octokit/rest'; vi.mock('@octokit/rest', () => ({ Octokit: vi.fn(), })); -vi.mock('./GetGithubToken'); +vi.mock('@/utils/githubUtils/GetGithubToken'); describe('UpdatePR', () => { const mockCreateOrUpdateFileContents = vi.fn(); diff --git a/app/api/create-ingest/route.ts b/app/api/create-ingest/route.ts index 2bb6390..37eb596 100644 --- a/app/api/create-ingest/route.ts +++ b/app/api/create-ingest/route.ts @@ -1,5 +1,5 @@ -import CreatePR from '@/utils/CreatePR'; -import UpdatePR from '@/utils/UpdatePR'; +import CreatePR from '@/utils/githubUtils/CreatePR'; +import UpdatePR from '@/utils/githubUtils/UpdatePR'; import { NextRequest, NextResponse } from 'next/server'; export async function POST(request: NextRequest) { diff --git a/app/api/list-ingests/route.ts b/app/api/list-ingests/route.ts index 4f64def..77b2db1 100644 --- a/app/api/list-ingests/route.ts +++ b/app/api/list-ingests/route.ts @@ -1,4 +1,4 @@ -import ListPRs from '@/utils/ListPRs'; +import ListPRs from '@/utils/githubUtils/ListPRs'; import { NextRequest, NextResponse } from 'next/server'; export async function GET(request: NextRequest) { diff --git a/app/api/retrieve-ingest/route.ts b/app/api/retrieve-ingest/route.ts index 4ea11d0..4471bc9 100644 --- a/app/api/retrieve-ingest/route.ts +++ b/app/api/retrieve-ingest/route.ts @@ -1,4 +1,4 @@ -import RetrieveJSON from '@/utils/RetrieveJSON'; +import RetrieveJSON from '@/utils/githubUtils/RetrieveJSON'; import { NextRequest, NextResponse } from 'next/server'; export async function GET(request: NextRequest) { diff --git a/components/IngestCreationForm.tsx b/components/IngestCreationForm.tsx index d047e7b..52649bb 100644 --- a/components/IngestCreationForm.tsx +++ b/components/IngestCreationForm.tsx @@ -3,7 +3,7 @@ import { useState } from 'react'; import { Status } from '@/types/global'; -import IngestForm from './IngestForm'; +import IngestForm from '@/components/IngestForm'; import uiSchema from '@/FormSchemas/uischema.json'; function IngestCreationForm({ diff --git a/components/IngestForm.tsx b/components/IngestForm.tsx index 8f2e288..63d5328 100644 --- a/components/IngestForm.tsx +++ b/components/IngestForm.tsx @@ -8,7 +8,7 @@ import { Theme as AntDTheme } from '@rjsf/antd'; import validator from '@rjsf/validator-ajv8'; import { JSONSchema7 } from 'json-schema'; -import ObjectFieldTemplate from '../ObjectFieldTemplate'; +import ObjectFieldTemplate from '@/utils/ObjectFieldTemplate'; import jsonSchema from '@/FormSchemas/jsonschema.json'; import { RJSFSchema, UiSchema } from '@rjsf/utils'; diff --git a/components/SuccessModal.tsx b/components/SuccessModal.tsx index d16ae45..32f65b9 100644 --- a/components/SuccessModal.tsx +++ b/components/SuccessModal.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import StyledModal from './StyledModal'; +import StyledModal from '@/components/StyledModal'; import { Status } from '@/types/global'; type SuccessModalProps = diff --git a/tsconfig.json b/tsconfig.json index caeae2e..8959de1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -29,7 +29,6 @@ "**/*.tsx", ".next/types/**/*.ts", "./types/global.d.ts", - "./jest-setup.ts" ], "exclude": ["node_modules"] } diff --git a/ObjectFieldTemplate.tsx b/utils/ObjectFieldTemplate.tsx similarity index 100% rename from ObjectFieldTemplate.tsx rename to utils/ObjectFieldTemplate.tsx diff --git a/utils/CreatePR.ts b/utils/githubUtils/CreatePR.ts similarity index 97% rename from utils/CreatePR.ts rename to utils/githubUtils/CreatePR.ts index 206d320..d5c4649 100644 --- a/utils/CreatePR.ts +++ b/utils/githubUtils/CreatePR.ts @@ -1,6 +1,6 @@ import { createOctokit } from './OctokitFactory'; import { RequestError } from '@octokit/request-error'; -import { formatFilename } from './FormatFilename'; +import { formatFilename } from '@/utils/FormatFilename'; import GetGithubToken from './GetGithubToken'; interface Data { diff --git a/utils/GetGithubToken.ts b/utils/githubUtils/GetGithubToken.ts similarity index 100% rename from utils/GetGithubToken.ts rename to utils/githubUtils/GetGithubToken.ts diff --git a/utils/ListPRs.ts b/utils/githubUtils/ListPRs.ts similarity index 93% rename from utils/ListPRs.ts rename to utils/githubUtils/ListPRs.ts index e88dd1d..75499fc 100644 --- a/utils/ListPRs.ts +++ b/utils/githubUtils/ListPRs.ts @@ -1,6 +1,6 @@ import { Octokit } from '@octokit/rest'; import { Endpoints } from '@octokit/types'; -import GetGithubToken from './GetGithubToken'; +import GetGithubToken from '@/utils/githubUtils/GetGithubToken'; const base = process.env.TARGET_BRANCH ||'main'; const prefix = 'Ingest Request for '; diff --git a/utils/OctokitFactory.ts b/utils/githubUtils/OctokitFactory.ts similarity index 100% rename from utils/OctokitFactory.ts rename to utils/githubUtils/OctokitFactory.ts diff --git a/utils/RetrieveJSON.ts b/utils/githubUtils/RetrieveJSON.ts similarity index 95% rename from utils/RetrieveJSON.ts rename to utils/githubUtils/RetrieveJSON.ts index eb48271..48a1a58 100644 --- a/utils/RetrieveJSON.ts +++ b/utils/githubUtils/RetrieveJSON.ts @@ -1,5 +1,5 @@ import { Octokit } from '@octokit/rest'; -import GetGithubToken from './GetGithubToken'; +import GetGithubToken from '@/utils/githubUtils/GetGithubToken'; const targetPath = 'ingestion-data/staging/dataset-config'; diff --git a/utils/UpdatePR.ts b/utils/githubUtils/UpdatePR.ts similarity index 93% rename from utils/UpdatePR.ts rename to utils/githubUtils/UpdatePR.ts index 4cdbafb..45b877b 100644 --- a/utils/UpdatePR.ts +++ b/utils/githubUtils/UpdatePR.ts @@ -1,5 +1,5 @@ import { Octokit } from '@octokit/rest'; -import GetGithubToken from './GetGithubToken'; +import GetGithubToken from '@/utils/githubUtils/GetGithubToken'; const UpdatePR = async ( ref: string,