Skip to content

Commit

Permalink
WIP compile OK, some tests fail
Browse files Browse the repository at this point in the history
  • Loading branch information
sdumetz committed Oct 22, 2023
1 parent ec50d3c commit e989506
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 15 deletions.
7 changes: 4 additions & 3 deletions source/server/integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from "fs/promises";
import path from "path";
import { fileURLToPath } from 'url';
import {tmpdir} from "os";

import request from "supertest";
Expand All @@ -9,7 +10,7 @@ import User from "./auth/User.js";
import { Element, xml2js } from "xml-js";
import UserManager from "./auth/UserManager.js";


const thisDir = path.dirname(fileURLToPath(import.meta.url));

describe("Web Server Integration", function(){
let vfs :Vfs, userManager :UserManager, user :User, admin :User;
Expand Down Expand Up @@ -71,7 +72,7 @@ describe("Web Server Integration", function(){
});

it("can create a new scene", async function(){
let content = await fs.readFile(path.join(__dirname, "__test_fixtures/cube.glb"));
let content = await fs.readFile(path.join(thisDir, "__test_fixtures/cube.glb"));
let r = await this.agent.post("/api/v1/scenes/bar")
.set("Content-Type", "application/octet-stream")
.send(content)
Expand All @@ -84,7 +85,7 @@ describe("Web Server Integration", function(){
});

it("can upload a glb model in an existing scene", async function(){
let content = await fs.readFile(path.join(__dirname, "__test_fixtures/cube.glb"));
let content = await fs.readFile(path.join(thisDir, "__test_fixtures/cube.glb"));
await this.agent.put("/scenes/foo/models/baz.glb")
.send(content)
.expect(201);
Expand Down
2 changes: 1 addition & 1 deletion source/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "module",
"scripts": {
"start": "ROOT_DIR=\"$(pwd)/../..\" node ./dist/server/index.js",
"test": "mocha",
"test": "NODE_NO_WARNINGS=1 mocha",
"build": "tsc -b ."
},
"nodemonConfig": {
Expand Down
5 changes: 3 additions & 2 deletions source/server/routes/api/v1/scenes/scene/post.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from "fs/promises";
import path from "path";
import { fileURLToPath } from 'url';
import {tmpdir} from "os";
import timers from 'timers/promises';

Expand All @@ -11,12 +12,12 @@ import express, { Application } from "express";
import wrap from "../../../../../utils/wrapAsync.js";
import Vfs from "../../../../../vfs/index.js";


const thisDir = path.dirname(fileURLToPath(import.meta.url));

describe("POST /api/v1/scenes/:scene", function(){
let vfs:Vfs, app: Application, data:Buffer;
this.beforeEach(async function(){
data = await fs.readFile(path.join(__dirname, "../../../../../__test_fixtures/cube.glb"));
data = await fs.readFile(path.join(thisDir, "../../../../../__test_fixtures/cube.glb"));
this.dir = await fs.mkdtemp(path.join(tmpdir(), `scenes-integration`));
vfs = await Vfs.Open(this.dir,{createDirs: true});
app = express();
Expand Down
9 changes: 6 additions & 3 deletions source/server/utils/glTF.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { expect } from "chai";
import fs from "fs/promises";
import path from "path";
import { fileURLToPath } from 'url';
import { parse_glb, parse_glTF } from "./glTF.js";

const thisFile = fileURLToPath(import.meta.url);
const thisDir = path.dirname(thisFile);
describe("parse_glb()", function(){

it("parse a glb file to extract data", async function(){
let d = await parse_glb(path.resolve(__dirname, "../__test_fixtures/cube.glb" ));
let d = await parse_glb(path.resolve(thisDir, "../__test_fixtures/cube.glb" ));
expect(d).to.deep.equal({
meshes:[{
numFaces: 6*2 /*it takes two triangles to make a square and 6 squares for a cube */,
Expand All @@ -25,14 +28,14 @@ describe("parse_glb()", function(){
})
});
it("throw an error for invalid files", async function(){
await expect(parse_glb( __filename)).to.be.rejectedWith("bad magic number");
await expect(parse_glb( thisFile)).to.be.rejectedWith("bad magic number");
})
});


describe("parse_gltf()", function(){
it("handles morph targets", async function(){
let data = await fs.readFile(path.resolve(__dirname, "../__test_fixtures/morph.gltf" ), {encoding: "utf8"});
let data = await fs.readFile(path.resolve(thisDir, "../__test_fixtures/morph.gltf" ), {encoding: "utf8"});
let gltf = JSON.parse(data);
let res = parse_glTF(gltf);
expect(res).to.deep.equal({
Expand Down
10 changes: 5 additions & 5 deletions source/server/utils/schema/document.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* limitations under the License.
*/

import { Index } from "../../server/utils/schema/types";
import { Index } from "./types.ts";

import { EUnitType, TUnitType, Vector3, Quaternion, Matrix4, ColorRGB } from "./common";
import { IMeta } from "./meta";
import { IModel } from "./model";
import { ISetup } from "./setup";
import { EUnitType, TUnitType, Vector3, Quaternion, Matrix4, ColorRGB } from "./common.ts";
import { IMeta } from "./meta.ts";
import { IModel } from "./model.ts";
import { ISetup } from "./setup.ts";

////////////////////////////////////////////////////////////////////////////////

Expand Down
2 changes: 1 addition & 1 deletion source/server/utils/schema/edit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ref from "./default.svx.json";
import ref from "./default.svx.json" assert { type: "json" };

import {IDocument, INode, IScene} from "./document.js";
import { IAsset, IBoundingBox, IDerivative, IModel, TDerivativeQuality, TDerivativeUsage } from "./model.js";
Expand Down

0 comments on commit e989506

Please sign in to comment.