Skip to content

Commit

Permalink
Merge branch 'master' into vb/fix-support-i3s-token
Browse files Browse the repository at this point in the history
  • Loading branch information
belom88 committed Oct 24, 2023
2 parents c8b71c8 + 5f67a61 commit e2882ec
Show file tree
Hide file tree
Showing 11 changed files with 239 additions and 151 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ProjectCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jobs:
Tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: "14.x"
node-version: 18

- name: Install dependencies
run: yarn
Expand All @@ -26,11 +26,11 @@ jobs:
Linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: "14.x"
node-version: 18

- name: Install dependencies
run: yarn
Expand Down
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This is the dockerfile for the AWS amplify image compatible with NodeJS v18
FROM node:18-slim

RUN apt-get update
RUN apt-get install git -y
RUN apt-get install openssh-client -y
RUN apt-get install curl -y

CMD ["/bin/bash"]
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/react-fontawesome": "^0.1.17",
"@hyperjump/json-schema": "^0.23.2",
"@loaders.gl/3d-tiles": "^4.0.0-beta.2",
"@loaders.gl/core": "^4.0.0-beta.2",
"@loaders.gl/i3s": "^4.0.0-beta.2",
"@loaders.gl/loader-utils": "^4.0.0-beta.2",
"@loaders.gl/tiles": "^4.0.0-beta.2",
"@loaders.gl/3d-tiles": "^4.0.0-beta.7",
"@loaders.gl/core": "^4.0.0-beta.7",
"@loaders.gl/i3s": "^4.0.0-beta.7",
"@loaders.gl/tiles": "^4.0.0-beta.7",
"@luma.gl/core": "^8.5.14",
"@math.gl/proj4": "^3.6.3",
"@probe.gl/stats": "^4.0.4",
Expand Down Expand Up @@ -87,6 +86,10 @@
"webpack-dev-server": "^4.7.4"
},
"resolutions": {
"@loaders.gl/tiles": "^4.0.0-beta.2"
"@loaders.gl/tiles": "^4.0.0-beta.7"
},
"volta": {
"node": "18.18.2",
"yarn": "1.22.19"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import userEvent from "@testing-library/user-event";
import { renderWithThemeProviders } from "../../../utils/testing-utils/render-with-theme";
import { AttributeStats } from "./attribute-stats";

import { load } from "@loaders.gl/core";
import { fetchFile } from "@loaders.gl/core";
import { capitalize } from "../../../utils/format/capitalize";
import { setupStore } from "../../../redux/store";
import { setColorsByAttrubute } from "../../../redux/slices/colors-by-attribute-slice";
Expand All @@ -14,7 +14,7 @@ jest.mock("../histogram", () => ({
HistogramChart: jest.fn().mockImplementation(() => <div>HistogramChart</div>),
}));

const loadMock = load as unknown as jest.Mocked<any>;
const fetchMock = fetchFile as unknown as jest.Mocked<any>;

const stats = {
totalValuesCount: 1,
Expand Down Expand Up @@ -46,10 +46,6 @@ function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}

jest.mock("@loaders.gl/loader-utils", () => ({
JSONLoader: jest.fn(),
}));

jest.mock("../../toogle-switch/toggle-switch", () => ({
ToggleSwitch: jest
.fn()
Expand All @@ -64,7 +60,7 @@ jest.mock("../../loading-spinner/loading-spinner", () => ({

describe("Attribute Stats Error test", () => {
it("Should no render Attribute Stats if loading statistics error", async () => {
loadMock.mockImplementationOnce(
fetchMock.mockImplementationOnce(
() =>
new Promise((resolve, reject) =>
setTimeout(() => {
Expand Down Expand Up @@ -109,11 +105,16 @@ describe("Attribute Stats Error test", () => {

describe("AttributeStats", () => {
beforeEach(() => {
loadMock.mockImplementationOnce(
fetchMock.mockImplementationOnce(
() =>
new Promise((resolve) =>
setTimeout(() => {
resolve({ stats });
resolve({
text: async () =>
JSON.stringify({
stats,
}),
});
}, 50)
)
);
Expand Down Expand Up @@ -189,7 +190,7 @@ describe("AttributeStats", () => {
);
});

expect(loadMock).toHaveBeenCalledTimes(1);
expect(fetchMock).toHaveBeenCalledTimes(1);
});

it("Should render colorize block", async () => {
Expand Down
24 changes: 19 additions & 5 deletions src/redux/slices/attribute-stats-map-slice.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { load } from "@loaders.gl/core";
import { fetchFile } from "@loaders.gl/core";
import { setupStore } from "../store";
import {
getAttributeStatsInfo,
Expand All @@ -16,7 +16,7 @@ describe("slice: attribute-stats-map", () => {
});

it("Should handle `getAttributeStatsInfo.rejected` action", async () => {
(load as unknown as jest.Mock<any>).mockRejectedValue("Error");
(fetchFile as unknown as jest.Mock<any>).mockRejectedValue("Error");

const store = setupStore();
const state = store.getState();
Expand All @@ -28,8 +28,15 @@ describe("slice: attribute-stats-map", () => {
});

it("Should handle `getAttributeStatsInfo.fulfilled` action for non-empty stats", async () => {
(load as unknown as jest.Mock<any>).mockReturnValue(
Promise.resolve({ stats })
(fetchFile as unknown as jest.Mock<any>).mockReturnValue(
new Promise((resolve) => {
resolve({
text: async () =>
JSON.stringify({
stats,
}),
});
})
);

const store = setupStore();
Expand All @@ -42,7 +49,14 @@ describe("slice: attribute-stats-map", () => {
});

it("Should handle `getAttributeStatsInfo.fulfilled` action for empty stats", async () => {
(load as unknown as jest.Mock<any>).mockReturnValue(Promise.resolve({}));
(fetchFile as unknown as jest.Mock<any>).mockReturnValue(
new Promise((resolve) => {
resolve({
text: async () =>
JSON.stringify({}),
});
})
);

const store = setupStore();
const state = store.getState();
Expand Down
6 changes: 3 additions & 3 deletions src/redux/slices/attribute-stats-map-slice.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { StatsInfo } from "@loaders.gl/i3s";

import { fetchFile } from "@loaders.gl/core";
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
import { RootState } from "../store";
import { load } from "@loaders.gl/core";
import { JSONLoader } from "@loaders.gl/loader-utils";

// Define a type for the slice state
interface statisitcsMapState {
Expand Down Expand Up @@ -36,7 +35,8 @@ export const getAttributeStatsInfo = createAsyncThunk<
string
>("getAttributeStatsInfo", async (statAttributeUrl) => {
let stats: StatsInfo | null = null;
const data = await load(statAttributeUrl, JSONLoader);
const dataResponse = await fetchFile(statAttributeUrl);
const data = JSON.parse(await dataResponse.text());
stats = (data?.stats as StatsInfo) || null;
return { stats, statAttributeUrl };
});
Expand Down
3 changes: 2 additions & 1 deletion src/test/tileset-header-stub.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SceneLayer3D } from "@loaders.gl/i3s";
import { getTileHeader } from "./tile-header-stub";

export const getTilesetJson = (): SceneLayer3D => {
const i3sProperties: SceneLayer3D = {
Expand Down Expand Up @@ -859,7 +860,7 @@ export const getTilesetHeader = () => {
nodesInNodePages: 0,
textureLoaderOptions: {},
},
root: {},
root: getTileHeader(),
basePath:
"https://tiles.arcgis.com/tiles/z2tnIkrLQ2BRzr6P/arcgis/rest/services/SanFrancisco_3DObjects_1_7/SceneServer/layers/0",
type: "I3S",
Expand Down
4 changes: 2 additions & 2 deletions src/utils/debug/build-minimap-data.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe("Build Minimap Data", () => {
const expectedResult = [
{
coordinates: new Vector3([
63.43494882292201, 53.48500010847735, -6364361.246505878,
63.43494882292201, 53.48500010847735, -6364361.246505877,
]),
radius: 10,
},
Expand All @@ -70,7 +70,7 @@ describe("Build Minimap Data", () => {
const expectedResult = [
{
coordinates: new Vector3([
63.43494882292201, 53.48500010847735, -6364361.246505878,
63.43494882292201, 53.48500010847735, -6364361.246505877,
]),
radius: 10,
},
Expand Down
13 changes: 13 additions & 0 deletions webpack.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ const LOADERS_LINK_ALIASES = {
__dirname,
"../loaders.gl/modules/textures/src"
),
"@loaders.gl/compression": path.resolve(
__dirname,
"../loaders.gl/modules/compression/src"
),
"@loaders.gl/worker-threads": path.resolve(
__dirname,
"../loaders.gl/modules/worker-threads/src"
),
};

const LUMA_LINK_ALIASES = {
Expand Down Expand Up @@ -99,6 +107,11 @@ module.exports = (env) => {
historyApiFallback: true,
},
module: {
parser: {
javascript: {
exportsPresence: "warn",
},
},
rules: [
{
test: [/\.(js)$/],
Expand Down
5 changes: 5 additions & 0 deletions webpack.prod.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ module.exports = {
path: path.resolve(__dirname, "build"),
},
module: {
parser: {
javascript: {
exportsPresence: "warn",
},
},
rules: [
{
test: [/\.(js)$/],
Expand Down
Loading

0 comments on commit e2882ec

Please sign in to comment.