| 
 | 1 | +// Node.js imports  | 
 | 2 | + | 
 | 3 | +// Third party imports  | 
 | 4 | +import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"  | 
 | 5 | +import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" with { type: "json" }  | 
 | 6 | + | 
 | 7 | +// Local imports  | 
 | 8 | +import Status from "~/utils/status"  | 
 | 9 | +import * as composables from "~/composables/viewer_call"  | 
 | 10 | +import { useDataStyleStore } from "~/stores/data_style"  | 
 | 11 | +import { useViewerStore } from "~/stores/viewer"  | 
 | 12 | +import { kill_back, kill_viewer } from "~/utils/local"  | 
 | 13 | +import { setupIntegrationTests } from "../../../setup.js"  | 
 | 14 | + | 
 | 15 | +// Local constants  | 
 | 16 | +const mesh_polygons_schemas = viewer_schemas.opengeodeweb_viewer.mesh.polygons  | 
 | 17 | +let id, back_port, viewer_port  | 
 | 18 | +const file_name = "test.og_psf3d"  | 
 | 19 | +const geode_object = "PolygonalSurface3D"  | 
 | 20 | +const object_type = "mesh"  | 
 | 21 | + | 
 | 22 | +beforeEach(async () => {  | 
 | 23 | +  ;({ id, back_port, viewer_port } = await setupIntegrationTests(  | 
 | 24 | +    file_name,  | 
 | 25 | +    geode_object,  | 
 | 26 | +    object_type,  | 
 | 27 | +  ))  | 
 | 28 | +  console.log("beforeEach points id", id)  | 
 | 29 | +}, 25000)  | 
 | 30 | + | 
 | 31 | +afterEach(async () => {  | 
 | 32 | +  await Promise.all([kill_back(back_port), kill_viewer(viewer_port)])  | 
 | 33 | +})  | 
 | 34 | + | 
 | 35 | +describe("Mesh polygons", () => {  | 
 | 36 | +  describe("Polygons visibility", () => {  | 
 | 37 | +    test("Visibility true", async () => {  | 
 | 38 | +      const dataStyleStore = useDataStyleStore()  | 
 | 39 | +      const viewerStore = useViewerStore()  | 
 | 40 | +      await dataStyleStore.setMeshPolygonsVisibility(id, true)  | 
 | 41 | +      expect(dataStyleStore.meshPolygonsVisibility(id)).toBe(true)  | 
 | 42 | +      expect(viewerStore.status).toBe(Status.CONNECTED)  | 
 | 43 | +    })  | 
 | 44 | +  })  | 
 | 45 | +  describe("Polygons active coloring", () => {  | 
 | 46 | +    test("test coloring", async () => {  | 
 | 47 | +      const dataStyleStore = useDataStyleStore()  | 
 | 48 | +      const viewerStore = useViewerStore()  | 
 | 49 | +      const coloringTypes = ["color"]  | 
 | 50 | +      for (let i = 0; i < coloringTypes.length; i++) {  | 
 | 51 | +        dataStyleStore.setMeshPolygonsActiveColoring(id, coloringTypes[i])  | 
 | 52 | +        expect(dataStyleStore.meshPolygonsActiveColoring(id)).toBe(  | 
 | 53 | +          coloringTypes[i],  | 
 | 54 | +        )  | 
 | 55 | +        expect(viewerStore.status).toBe(Status.CONNECTED)  | 
 | 56 | +      }  | 
 | 57 | +    })  | 
 | 58 | +  })  | 
 | 59 | +  describe("Polygons color", () => {  | 
 | 60 | +    test("test red", async () => {  | 
 | 61 | +      const dataStyleStore = useDataStyleStore()  | 
 | 62 | +      const viewerStore = useViewerStore()  | 
 | 63 | +      const color = { r: 255, g: 0, b: 0 }  | 
 | 64 | +      const spy = vi.spyOn(composables, "viewer_call")  | 
 | 65 | +      await dataStyleStore.setMeshPolygonsColor(id, color)  | 
 | 66 | +      expect(spy).toHaveBeenCalledWith(  | 
 | 67 | +        {  | 
 | 68 | +          schema: mesh_polygons_schemas.color,  | 
 | 69 | +          params: { id, color },  | 
 | 70 | +        },  | 
 | 71 | +        {  | 
 | 72 | +          response_function: expect.any(Function),  | 
 | 73 | +        },  | 
 | 74 | +      )  | 
 | 75 | +      expect(dataStyleStore.meshPolygonsColor(id)).toStrictEqual(color)  | 
 | 76 | +      expect(viewerStore.status).toBe(Status.CONNECTED)  | 
 | 77 | +    })  | 
 | 78 | +  })  | 
 | 79 | +})  | 
0 commit comments