Before converting react server to the shared library

main
Jackson Morgan 4 months ago
parent 7b03667727
commit ba748f08e2
  1. 1619
      package-lock.json
  2. 4
      package.json
  3. 3
      packages/solid-react/babel.config.js
  4. 17
      packages/solid-react/jest.config.js
  5. 8
      packages/solid-react/jest.setup.ts
  6. 28
      packages/solid-react/package.json
  7. 2
      packages/solid-react/test-server/configs/components-config/unauthenticatedServer.json
  8. 0
      packages/solid-react/test-server/configs/solid-css-seed.json
  9. 0
      packages/solid-react/test-server/configs/template/wac/.acl.hbs
  10. 0
      packages/solid-react/test-server/configs/template/wac/link-query/main-profile.ttl
  11. 0
      packages/solid-react/test-server/configs/template/wac/link-query/other-profile.ttl
  12. 0
      packages/solid-react/test-server/configs/template/wac/link-query/third-profile.ttl
  13. 0
      packages/solid-react/test-server/configs/template/wac/profile/card.acl.hbs
  14. 0
      packages/solid-react/test-server/runServer.ts
  15. 5
      packages/solid-react/test-server/solidServer.helper.ts
  16. 2
      packages/solid-react/test/.ldo/solidProfile.shapeTypes.ts
  17. 5
      packages/solid-react/test/Solid-Integration.test.tsx
  18. 12
      packages/solid-react/test/setUpServer.ts
  19. 8
      packages/solid-react/tsconfig.build.json
  20. 10
      packages/solid-react/tsconfig.cjs.json
  21. 11
      packages/solid-react/tsconfig.esm.json
  22. 12
      packages/solid-react/vitest.config.js

1619
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -13,15 +13,19 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/preset-env": "^7.26.9", "@babel/preset-env": "^7.26.9",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^14.6.1",
"@types/jest": "^27.5.2", "@types/jest": "^27.5.2",
"@types/node": "^20.5.7", "@types/node": "^20.5.7",
"@typescript-eslint/eslint-plugin": "^6.5.0", "@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0", "@typescript-eslint/parser": "^6.5.0",
"@vitejs/plugin-react": "^4.4.1",
"eslint": "^8.48.0", "eslint": "^8.48.0",
"eslint-config-prettier": "^9.0.0", "eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0", "eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-react": "^7.33.2", "eslint-plugin-react": "^7.33.2",
"jest": "^29.7.0", "jest": "^29.7.0",
"jsdom": "^26.1.0",
"lerna": "^7.2.0", "lerna": "^7.2.0",
"prettier": "3.0.3", "prettier": "3.0.3",
"ts-jest": "^29.3.0", "ts-jest": "^29.3.0",

@ -1,3 +0,0 @@
module.exports = {
presets: [["@babel/preset-env", { targets: { node: "current" } }]],
};

@ -1,17 +0,0 @@
const sharedConfig = require("../../jest.config.js");
module.exports = {
...sharedConfig,
rootDir: "./",
testEnvironment: "jsdom",
transform: {
"^.+\\.(ts|tsx)$": "ts-jest",
"^.+\\.(js|jsx)$": "babel-jest",
},
transformIgnorePatterns: ["/node_modules/(?!(jose)/)"],
globals: {
"ts-jest": {
isolatedModules: true,
},
},
setupFiles: ["<rootDir>/jest.setup.ts"],
};

@ -1,8 +0,0 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import "@inrupt/jest-jsdom-polyfills";
jest.mock("undici", () => {
return {
fetch: global.fetch,
};
});

@ -2,18 +2,29 @@
"name": "@ldo/solid-react", "name": "@ldo/solid-react",
"version": "1.0.0-alpha.9", "version": "1.0.0-alpha.9",
"description": "A React library for LDO and Solid", "description": "A React library for LDO and Solid",
"main": "dist/index.js", "type": "module",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"./package.json": "./package.json"
},
"scripts": { "scripts": {
"build": "tsc --project tsconfig.build.json", "build": "rimraf dist && npm run build:cjs && npm run build:esm",
"watch": "tsc --project tsconfig.build.json --watch", "build:cjs": "tsc --project tsconfig.cjs.json",
"build:esm": "tsc --project tsconfig.esm.json",
"test": "npm run test:integration", "test": "npm run test:integration",
"test:watch": "jest --watch",
"prepublishOnly": "npm run test && npm run build", "prepublishOnly": "npm run test && npm run build",
"build:ldo": "ldo build --input src/shapes --output src/ldo", "build:ldo": "ldo build --input src/shapes --output src/ldo",
"lint": "eslint src/** --fix --no-error-on-unmatched-pattern", "lint": "eslint src/** --fix --no-error-on-unmatched-pattern",
"test:integration": "start-server-and-test start-test-server http://localhost:3002 start-integration-test", "test:integration": "start-server-and-test start-test-server http://localhost:3002 start-integration-test",
"start-test-server": "ts-node ./test/test-server/runServer.ts", "start-test-server": "ts-node ./test-server/runServer.ts",
"start-integration-test": "jest --coverage" "start-integration-test": "vitest run --coverage --sequence.concurrent"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -28,15 +39,12 @@
"devDependencies": { "devDependencies": {
"@babel/core": "^7.26.10", "@babel/core": "^7.26.10",
"@babel/preset-env": "^7.26.9", "@babel/preset-env": "^7.26.9",
"@inrupt/jest-jsdom-polyfills": "^3.2.6",
"@ldo/rdf-utils": "^1.0.0-alpha.9", "@ldo/rdf-utils": "^1.0.0-alpha.9",
"@rdfjs/types": "^1.0.1", "@rdfjs/types": "^1.0.1",
"@testing-library/react": "^14.1.2", "@testing-library/react": "^14.1.2",
"babel-jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"start-server-and-test": "^2.0.3", "start-server-and-test": "^2.0.3",
"ts-jest": "^29.3.0",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"tsx": "^4.19.4",
"whatwg-fetch": "^3.6.20" "whatwg-fetch": "^3.6.20"
}, },
"dependencies": { "dependencies": {

@ -45,7 +45,7 @@
}, },
"overrideParameters": { "overrideParameters": {
"@type": "StaticFolderGenerator", "@type": "StaticFolderGenerator",
"templateFolder": "./test/test-server/configs/template" "templateFolder": "./test-server/configs/template"
} }
} }
] ]

@ -3,6 +3,11 @@
import * as path from "path"; import * as path from "path";
import type { App } from "@solid/community-server"; import type { App } from "@solid/community-server";
import { AppRunner, resolveModulePath } from "@solid/community-server"; import { AppRunner, resolveModulePath } from "@solid/community-server";
import { fileURLToPath } from "url";
import { dirname } from "path";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
export async function createApp(): Promise<App> { export async function createApp(): Promise<App> {
if (process.env.SERVER) { if (process.env.SERVER) {

@ -1,7 +1,7 @@
import { ShapeType } from "@ldo/ldo"; import { ShapeType } from "@ldo/ldo";
import { solidProfileSchema } from "./solidProfile.schema.js"; import { solidProfileSchema } from "./solidProfile.schema.js";
import { solidProfileContext } from "./solidProfile.context.js"; import { solidProfileContext } from "./solidProfile.context.js";
import { solidProfileSchema } from "./solidProfile.schema.js"; import { AddressShape, EmailShape, PhoneNumberShape, RSAPublicKeyShape, SolidProfileShape, TrustedAppShape } from "./solidProfile.typings.js";
/** /**
* ============================================================================= * =============================================================================

@ -27,9 +27,10 @@ import type { PostSh } from "./.ldo/post.typings.js";
import { SolidProfileShapeShapeType } from "./.ldo/solidProfile.shapeTypes.js"; import { SolidProfileShapeShapeType } from "./.ldo/solidProfile.shapeTypes.js";
import { changeData, commitData } from "@ldo/connected"; import { changeData, commitData } from "@ldo/connected";
import type { SolidProfileShape } from "./.ldo/solidProfile.typings.js"; import type { SolidProfileShape } from "./.ldo/solidProfile.typings.js";
import { describe, vi, afterEach, expect, it } from "vitest";
// Use an increased timeout, since the CSS server takes too much setup time. // Use an increased timeout, since the CSS server takes too much setup time.
jest.setTimeout(40_000); vi.setConfig({ testTimeout: 40_000 });
describe("Integration Tests", () => { describe("Integration Tests", () => {
setUpServer(); setUpServer();
@ -355,7 +356,7 @@ describe("Integration Tests", () => {
}); });
it("does not set a value if a value is attempted to be set", async () => { it("does not set a value if a value is attempted to be set", async () => {
const warn = jest.spyOn(console, "warn").mockImplementation(() => {}); const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
const UseSubjectTest: FunctionComponent = () => { const UseSubjectTest: FunctionComponent = () => {
const resource = useResource(SAMPLE_DATA_URI); const resource = useResource(SAMPLE_DATA_URI);
const post = useSubject(PostShShapeType, `${SAMPLE_DATA_URI}#Post1`); const post = useSubject(PostShShapeType, `${SAMPLE_DATA_URI}#Post1`);

@ -1,5 +1,7 @@
import type { SolidContainerUri, SolidLeafUri } from "@ldo/connected-solid"; import type { SolidContainerUri, SolidLeafUri } from "@ldo/connected-solid";
import fetch from "cross-fetch"; import fetch from "cross-fetch";
import type { MockedFunction } from "vitest";
import { beforeAll, beforeEach, afterEach, vi } from "vitest";
export const SERVER_DOMAIN = process.env.SERVER || "http://localhost:3002/"; export const SERVER_DOMAIN = process.env.SERVER || "http://localhost:3002/";
export const ROOT_ROUTE = process.env.ROOT_CONTAINER || "example/"; export const ROOT_ROUTE = process.env.ROOT_CONTAINER || "example/";
@ -64,9 +66,11 @@ export const TEST_CONTAINER_TTL = `@prefix dc: <http://purl.org/dc/terms/>.
export interface SetUpServerReturn { export interface SetUpServerReturn {
authFetch: typeof fetch; authFetch: typeof fetch;
fetchMock: jest.Mock< fetchMock: MockedFunction<
Promise<Response>, (
[input: RequestInfo | URL, init?: RequestInit | undefined] input: RequestInfo | URL,
init?: RequestInit | undefined,
) => Promise<Response>
>; >;
} }
@ -82,7 +86,7 @@ export function setUpServer(): SetUpServerReturn {
}); });
beforeEach(async () => { beforeEach(async () => {
s.fetchMock = jest.fn(s.authFetch); s.fetchMock = vi.fn(s.authFetch);
// Create a new document called sample.ttl // Create a new document called sample.ttl
await s.authFetch(ROOT_CONTAINER, { await s.authFetch(ROOT_CONTAINER, {
method: "POST", method: "POST",

@ -1,8 +0,0 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"lib": ["dom"]
},
"include": ["./src"]
}

@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.cjs.json",
"compilerOptions": {
"outDir": "./dist/cjs",
"rootDir": "./src"
},
"include": [
"src"
]
}

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.esm.json",
"compilerOptions": {
"outDir": "./dist/esm",
"rootDir": "./src",
"declarationDir": "./dist/types"
},
"include": [
"src"
]
}

@ -0,0 +1,12 @@
import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [react()],
test: {
environment: "jsdom",
coverage: {
provider: "istanbul",
},
},
});
Loading…
Cancel
Save