esm migration for solid-react

main
Jackson Morgan 4 months ago
parent ba748f08e2
commit 5769b1aab2
  1. 11
      packages/solid-react/package.json
  2. 7
      packages/solid-react/test-server/runServer.ts
  3. 44
      packages/solid-react/test-server/solidServer.helper.ts
  4. 35
      packages/solid-react/test/Solid-Integration.test.tsx
  5. 2
      packages/solid-react/test/configs/components-config/unauthenticatedServer.json
  6. 0
      packages/solid-react/test/configs/solid-css-seed.json
  7. 0
      packages/solid-react/test/configs/template/wac/.acl.hbs
  8. 0
      packages/solid-react/test/configs/template/wac/link-query/main-profile.ttl
  9. 0
      packages/solid-react/test/configs/template/wac/link-query/other-profile.ttl
  10. 0
      packages/solid-react/test/configs/template/wac/link-query/third-profile.ttl
  11. 0
      packages/solid-react/test/configs/template/wac/profile/card.acl.hbs
  12. 42
      packages/solid-react/test/fileData.ts
  13. 3
      packages/test-solid-server/src/setupTestServer.ts

@ -18,13 +18,10 @@
"build": "rimraf dist && npm run build:cjs && npm run build:esm", "build": "rimraf dist && npm run build:cjs && npm run build:esm",
"build:cjs": "tsc --project tsconfig.cjs.json", "build:cjs": "tsc --project tsconfig.cjs.json",
"build:esm": "tsc --project tsconfig.esm.json", "build:esm": "tsc --project tsconfig.esm.json",
"test": "npm run test:integration", "test": "vitest run --coverage",
"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",
"start-test-server": "ts-node ./test-server/runServer.ts",
"start-integration-test": "vitest run --coverage --sequence.concurrent"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -43,8 +40,6 @@
"@rdfjs/types": "^1.0.1", "@rdfjs/types": "^1.0.1",
"@testing-library/react": "^14.1.2", "@testing-library/react": "^14.1.2",
"start-server-and-test": "^2.0.3", "start-server-and-test": "^2.0.3",
"ts-node": "^10.9.2",
"tsx": "^4.19.4",
"whatwg-fetch": "^3.6.20" "whatwg-fetch": "^3.6.20"
}, },
"dependencies": { "dependencies": {
@ -63,4 +58,4 @@
"access": "public" "access": "public"
}, },
"gitHead": "0287cd6371f06630763568dec5e41653f7b8583e" "gitHead": "0287cd6371f06630763568dec5e41653f7b8583e"
} }

@ -1,7 +0,0 @@
import { createApp } from "./solidServer.helper.js";
async function run() {
const app = await createApp();
await app.start();
}
run();

@ -1,44 +0,0 @@
// Taken from https://github.com/comunica/comunica/blob/b237be4265c353a62a876187d9e21e3bc05123a3/engines/query-sparql/test/QuerySparql-solid-test.ts#L9
import * as path from "path";
import type { App } 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> {
if (process.env.SERVER) {
return {
start: () => {},
stop: () => {},
} as App;
}
const appRunner = new AppRunner();
return appRunner.create({
loaderProperties: {
mainModulePath: resolveModulePath(""),
typeChecking: false,
},
config: path.join(
__dirname,
"configs",
"components-config",
"unauthenticatedServer.json",
),
variableBindings: {},
shorthand: {
port: 3_002,
loggingLevel: "off",
seedConfig: path.join(__dirname, "configs", "solid-css-seed.json"),
},
});
}
export interface ISecretData {
id: string;
secret: string;
}

@ -1,15 +1,22 @@
import React, { useCallback, useEffect, useState } from "react"; import React, { useCallback, useEffect, useState } from "react";
import type { FunctionComponent } from "react"; import type { FunctionComponent } from "react";
import { render, screen, fireEvent, act } from "@testing-library/react";
import { import {
render,
screen,
fireEvent,
act,
cleanup,
} from "@testing-library/react";
import {
fileData,
MAIN_PROFILE_SUBJECT, MAIN_PROFILE_SUBJECT,
MAIN_PROFILE_URI, MAIN_PROFILE_URI,
SAMPLE_BINARY_URI, SAMPLE_BINARY_URI,
SAMPLE_DATA_URI, SAMPLE_DATA_URI,
SERVER_DOMAIN, SERVER_DOMAIN,
setUpServer, setUpServerFiles,
THIRD_PROFILE_SUBJECT, THIRD_PROFILE_SUBJECT,
} from "./setUpServer.js"; } from "./fileData.js";
import { UnauthenticatedSolidLdoProvider } from "../src/UnauthenticatedSolidLdoProvider.js"; import { UnauthenticatedSolidLdoProvider } from "../src/UnauthenticatedSolidLdoProvider.js";
import { import {
dataset, dataset,
@ -28,16 +35,32 @@ 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"; import { describe, vi, afterEach, expect, it } from "vitest";
import { setupServer } from "@ldo/test-solid-server";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
// Use an increased timeout, since the CSS server takes too much setup time. // eslint-disable-next-line @typescript-eslint/ban-ts-comment
vi.setConfig({ testTimeout: 40_000 }); // @ts-ignore
const __dirname = dirname(fileURLToPath(import.meta.url));
describe("Integration Tests", () => { describe("Integration Tests", () => {
setUpServer(); setupServer(
3002,
fileData,
join(
__dirname,
"configs",
"components-config",
"unauthenticatedServer.json",
),
true,
);
setUpServerFiles();
afterEach(() => { afterEach(() => {
dataset.forgetAllResources(); dataset.forgetAllResources();
dataset.deleteMatches(undefined, undefined, undefined, undefined); dataset.deleteMatches(undefined, undefined, undefined, undefined);
cleanup();
}); });
/** /**

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

@ -1,4 +1,5 @@
import type { SolidContainerUri, SolidLeafUri } from "@ldo/connected-solid"; import type { SolidContainerUri, SolidLeafUri } from "@ldo/connected-solid";
import type { ResourceInfo } from "@ldo/test-solid-server";
import fetch from "cross-fetch"; import fetch from "cross-fetch";
import type { MockedFunction } from "vitest"; import type { MockedFunction } from "vitest";
import { beforeAll, beforeEach, afterEach, vi } from "vitest"; import { beforeAll, beforeEach, afterEach, vi } from "vitest";
@ -74,7 +75,46 @@ export interface SetUpServerReturn {
>; >;
} }
export function setUpServer(): SetUpServerReturn { export const fileData: ResourceInfo = {
slug: TEST_CONTAINER_SLUG,
isContainer: true,
contains: [
{
slug: "sample.ttl",
isContainer: false,
mimeType: "text/turtle",
data: EXAMPLE_POST_TTL,
},
{
slug: "sample.txt",
isContainer: false,
mimeType: "text/plain",
data: `some text.`,
},
{
slug: "sample2.ttl",
isContainer: false,
mimeType: "text/turtle",
shouldNotInit: true,
data: "",
},
{
slug: "sample2.txt",
isContainer: false,
mimeType: "text/plain",
shouldNotInit: true,
data: "",
},
{
slug: "sampleContainer/",
isContainer: true,
shouldNotInit: true,
contains: [],
},
],
};
export function setUpServerFiles(): SetUpServerReturn {
// Ignore to build s // Ignore to build s
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore // @ts-ignore

@ -22,6 +22,7 @@ export function setupServer(
port: number, port: number,
resourceInfo: ResourceInfo, resourceInfo: ResourceInfo,
customConfigPath?: string, customConfigPath?: string,
skipAuthentication?: boolean,
) { ) {
const data: { const data: {
app: App; app: App;
@ -45,7 +46,7 @@ export function setupServer(
// Start up the server // Start up the server
data.app = await createApp(port, customConfigPath); data.app = await createApp(port, customConfigPath);
await data.app.start(); await data.app.start();
data.authFetch = await generateAuthFetch(port); data.authFetch = skipAuthentication ? fetch : await generateAuthFetch(port);
}); });
afterAll(async () => { afterAll(async () => {

Loading…
Cancel
Save