Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions app/components/Viewer/TreeObject.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@
return
}
const { added, removed } = compareSelections(current, previous)

added.forEach((item) => {
dataStyleStore.setVisibility(item.id, true)
})

for (const item of added) {
await dataStyleStore.setVisibility(item.id, true)
}
for (const item of removed) {
await dataStyleStore.setVisibility(item.id, false)
}
Expand Down
1 change: 1 addition & 0 deletions app/composables/project_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export function useProjectManager() {
await viewerStore.request(
viewer_schemas.opengeodeweb_viewer.viewer.reset_visualization,
{},
undefined,
)

treeviewStore.clear()
Expand Down
16 changes: 12 additions & 4 deletions app/stores/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { appMode } from "@ogw_front/utils/app_mode"
import { viewer_call } from "../../internal/utils/viewer_call"
import { useInfraStore } from "@ogw_front/stores/infra"

const request_timeout = 10 * 1000

export const useViewerStore = defineStore("viewer", {
state: () => ({
default_local_port: "1234",
Expand Down Expand Up @@ -117,9 +119,14 @@ export const useViewerStore = defineStore("viewer", {
connectImageStream(validClient.getConnection().getSession())
viewerStore.client = validClient
clientToConnect.endBusy()
viewer_call(viewerStore, {
schema: schemas.opengeodeweb_viewer.viewer.reset_visualization,
})
viewer_call(
viewerStore,
{
schema:
schemas.opengeodeweb_viewer.viewer.reset_visualization,
},
{ timeout: undefined },
)
viewerStore.status = Status.CONNECTED
resolve()
})
Expand Down Expand Up @@ -148,7 +155,7 @@ export const useViewerStore = defineStore("viewer", {
await this.ws_connect()
console.log("[VIEWER] Viewer connected successfully")
},
request(schema, params = {}, callbacks = {}) {
request(schema, params = {}, callbacks = {}, timeout = request_timeout) {
console.log("[VIEWER] Request:", schema.$id)

return viewer_call(
Expand All @@ -163,6 +170,7 @@ export const useViewerStore = defineStore("viewer", {
}
},
},
timeout,
)
},
},
Expand Down
1 change: 0 additions & 1 deletion app/utils/default_styles.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Global variables

const points_defaultVisibility = true
const edges_defaultVisibility = true
const cells_defaultVisibility = true
Expand Down
18 changes: 16 additions & 2 deletions internal/utils/viewer_call.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { useFeedbackStore } from "@ogw_front/stores/feedback"
export function viewer_call(
microservice,
{ schema, params = {} },
{ request_error_function, response_function, response_error_function } = {},
{
request_error_function,
response_function,
response_error_function,
timeout,
} = {},
) {
const feedbackStore = useFeedbackStore()

Expand All @@ -20,12 +25,13 @@ export function viewer_call(

const client = microservice.client

return new Promise((resolve, reject) => {
const promise = new Promise((resolve, reject) => {
if (!client.getConnection) {
resolve()
return
}
microservice.start_request()

client
.getConnection()
.getSession()
Expand Down Expand Up @@ -60,6 +66,14 @@ export function viewer_call(
microservice.stop_request()
})
})
if (timeout !== undefined && timeout > 0) {
const timeoutPromise = setTimeout(() => {
reject(`${schema.$id}: Timed out after ${timeout}ms, ${schema} ${params}`)
}, timeout)
return Promise.race([promise, timeoutPromise])
} else {
return promise
}
}

export default viewer_call
1 change: 0 additions & 1 deletion tests/integration/microservices/back/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
# pip-compile --output-file=tests/integration/microservices/back/requirements.txt tests/integration/microservices/back/requirements.in
#

opengeodeweb-back==6.*,>=6.1.0rc2
1 change: 0 additions & 1 deletion tests/integration/microservices/viewer/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
# pip-compile --output-file=tests/integration/microservices/viewer/requirements.txt tests/integration/microservices/viewer/requirements.in
#

opengeodeweb-viewer==1.*,>=1.15.0
27 changes: 16 additions & 11 deletions tests/integration/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@ import {
// Local constants
const data_folder = path.join("tests", "integration", "data")

async function setupIntegrationTests(file_name, geode_object) {
const pinia = createTestingPinia({
stubActions: false,
createSpy: vi.fn,
})
setActivePinia(pinia)
async function runMicroservices() {
const geodeStore = useGeodeStore()
// const hybridViewerStore = useHybridViewerStore()
const infraStore = useInfraStore()
const viewerStore = useViewerStore()
infraStore.app_mode = appMode.BROWSER
Expand Down Expand Up @@ -61,11 +55,22 @@ async function setupIntegrationTests(file_name, geode_object) {
geodeStore.default_local_port = back_port
viewerStore.default_local_port = viewer_port
console.log("after ports")

return { back_port, viewer_port, project_folder_path }
}

async function setupIntegrationTests(file_name, geode_object) {
const pinia = createTestingPinia({
stubActions: false,
createSpy: vi.fn,
})
setActivePinia(pinia)
const viewerStore = useViewerStore()

const { back_port, viewer_port, project_folder_path } =
await runMicroservices()
await viewerStore.ws_connect()
// await hybridViewerStore.initHybridViewer()
console.log("after hybridViewerStore.initHybridViewer")

// await viewerStore.ws_connect()
const id = await importFile(file_name, geode_object)
expect(viewerStore.status).toBe(Status.CONNECTED)
console.log("end of setupIntegrationTests")
Expand All @@ -91,4 +96,4 @@ afterAll(() => {
delete global.WebSocket
})

export { setupIntegrationTests }
export { runMicroservices, setupIntegrationTests }
9 changes: 9 additions & 0 deletions tests/integration/stores/data_style/mesh/cells.nuxt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,13 @@ describe("Mesh cells", () => {
}
})
})

test("Cells apply default style", async () => {
const dataStyleStore = useDataStyleStore()
const viewerStore = useViewerStore()
const result = dataStyleStore.applyMeshCellsStyle(id)
expect(result).toBeInstanceOf(Promise)
await result
expect(viewerStore.status).toBe(Status.CONNECTED)
})
})
8 changes: 8 additions & 0 deletions tests/integration/stores/data_style/mesh/edges.nuxt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,13 @@ describe("Mesh edges", () => {
expect(viewerStore.status).toBe(Status.CONNECTED)
}
})
test("Edges apply style", async () => {
const dataStyleStore = useDataStyleStore()
const viewerStore = useViewerStore()
const result = dataStyleStore.applyMeshEdgesStyle(id)
expect(result).toBeInstanceOf(Promise)
await result
expect(viewerStore.status).toBe(Status.CONNECTED)
})
})
})
9 changes: 9 additions & 0 deletions tests/integration/stores/data_style/mesh/points.nuxt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,13 @@ describe("Mesh points", () => {
expect(viewerStore.status).toBe(Status.CONNECTED)
})
})

test("Points apply default style", async () => {
const dataStyleStore = useDataStyleStore()
const viewerStore = useViewerStore()
const result = dataStyleStore.applyMeshPointsStyle(id)
expect(result).toBeInstanceOf(Promise)
await result
expect(viewerStore.status).toBe(Status.CONNECTED)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,13 @@ describe("Mesh polygons", () => {
}
})
})

test("Polygons apply default style", async () => {
const dataStyleStore = useDataStyleStore()
const viewerStore = useViewerStore()
const result = dataStyleStore.applyMeshPolygonsStyle(id)
expect(result).toBeInstanceOf(Promise)
await result
expect(viewerStore.status).toBe(Status.CONNECTED)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,13 @@ describe("Mesh polyhedra", () => {
)
expect(viewerStore.status).toBe(Status.CONNECTED)
})

test("Polyhedra apply default style", async () => {
const dataStyleStore = useDataStyleStore()
const viewerStore = useViewerStore()
const result = dataStyleStore.applyMeshPolyhedraStyle(id)
expect(result).toBeInstanceOf(Promise)
await result
expect(viewerStore.status).toBe(Status.CONNECTED)
})
})
63 changes: 38 additions & 25 deletions tests/integration/stores/data_style/model/blocks.nuxt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,29 +74,42 @@ describe("Model blocks", () => {
})
})

// describe("Blocks color", () => {
// test("Color red", async () => {
// const dataStyleStore = useDataStyleStore()
// const viewerStore = useViewerStore()
// const dataStore = useDataStore()
// const block_ids = await dataStore.getBlocksGeodeIds(id)
// const block_viewer_ids = dataStore.getMeshComponentsViewerIds(id, block_ids)
// const color = { r: 255, g: 0, b: 0 }
// const spy = vi.spyOn(viewerStore, "request")
// await dataStyleStore.setModelBlocksColor(id, block_ids, color)
// expect(spy).toHaveBeenCalledWith(
// model_blocks_schemas.color,
// { id, block_ids: block_viewer_ids, color },
// {
// response_function: expect.any(Function),
// },
// )
// for (const block_id of block_ids) {
// expect(dataStyleStore.modelBlockColor(id, block_id)).toStrictEqual(
// color,
// )
// }
// expect(viewerStore.status).toBe(Status.CONNECTED)
// })
// })
describe("Blocks color", () => {
test("Color red", async () => {
const dataStyleStore = useDataStyleStore()
const viewerStore = useViewerStore()
const dataStore = useDataStore()
const block_ids = await dataStore.getBlocksGeodeIds(id)
const block_viewer_ids = await dataStore.getMeshComponentsViewerIds(
id,
block_ids,
)
const color = { r: 255, g: 0, b: 0 }
const spy = vi.spyOn(viewerStore, "request")
await dataStyleStore.setModelBlocksColor(id, block_ids, color)
expect(spy).toHaveBeenCalledWith(
model_blocks_schemas.color,
{ id, block_ids: block_viewer_ids, color },
{
response_function: expect.any(Function),
},
)
for (const block_id of block_ids) {
expect(dataStyleStore.modelBlockColor(id, block_id)).toStrictEqual(
color,
)
}
expect(viewerStore.status).toBe(Status.CONNECTED)
})
})
describe("Blocks style", () => {
test("Blocks apply style", async () => {
const dataStyleStore = useDataStyleStore()
const viewerStore = useViewerStore()
const result = dataStyleStore.applyModelBlocksStyle(id)
expect(result).toBeInstanceOf(Promise)
await result
expect(viewerStore.status).toBe(Status.CONNECTED)
})
})
})
11 changes: 11 additions & 0 deletions tests/integration/stores/data_style/model/corners.nuxt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,15 @@ describe("Model corners", () => {
expect(viewerStore.status).toBe(Status.CONNECTED)
})
})

describe("Corner style", () => {
test("Corners apply style", async () => {
const dataStyleStore = useDataStyleStore()
const viewerStore = useViewerStore()
const result = dataStyleStore.applyModelCornersStyle(id)
expect(result).toBeInstanceOf(Promise)
await result
expect(viewerStore.status).toBe(Status.CONNECTED)
})
})
})
10 changes: 10 additions & 0 deletions tests/integration/stores/data_style/model/edges.nuxt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,14 @@ describe("Model edges", () => {
expect(viewerStore.status).toBe(Status.CONNECTED)
})
})
describe("Edges style", () => {
test("Edges apply style", async () => {
const dataStyleStore = useDataStyleStore()
const viewerStore = useViewerStore()
const result = dataStyleStore.applyModelEdgesStyle(id)
expect(result).toBeInstanceOf(Promise)
await result
expect(viewerStore.status).toBe(Status.CONNECTED)
})
})
})
10 changes: 10 additions & 0 deletions tests/integration/stores/data_style/model/lines.nuxt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,14 @@ describe("Model lines", () => {
expect(viewerStore.status).toBe(Status.CONNECTED)
})
})
describe("Lines style", () => {
test("Lines apply style", async () => {
const dataStyleStore = useDataStyleStore()
const viewerStore = useViewerStore()
const result = dataStyleStore.applyModelLinesStyle(id)
expect(result).toBeInstanceOf(Promise)
await result
expect(viewerStore.status).toBe(Status.CONNECTED)
})
})
})
10 changes: 10 additions & 0 deletions tests/integration/stores/data_style/model/points.nuxt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,14 @@ describe("Model points", () => {
expect(viewerStore.status).toBe(Status.CONNECTED)
})
})
describe("Points style", () => {
test("Points apply style", async () => {
const dataStyleStore = useDataStyleStore()
const viewerStore = useViewerStore()
const result = dataStyleStore.applyModelPointsStyle(id)
expect(result).toBeInstanceOf(Promise)
await result
expect(viewerStore.status).toBe(Status.CONNECTED)
})
})
})
10 changes: 10 additions & 0 deletions tests/integration/stores/data_style/model/surfaces.nuxt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,14 @@ describe("Model surfaces", () => {
expect(viewerStore.status).toBe(Status.CONNECTED)
})
})
describe("Surfaces style", () => {
test("Surfaces apply style", async () => {
const dataStyleStore = useDataStyleStore()
const viewerStore = useViewerStore()
const result = dataStyleStore.applyModelSurfacesStyle(id)
expect(result).toBeInstanceOf(Promise)
await result
expect(viewerStore.status).toBe(Status.CONNECTED)
})
})
})
Loading
Loading