diff --git a/.gitignore b/.gitignore index dcb79d4b..4dce1a07 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,5 @@ venv .pytest_cache __snapshots__ coverage +*.db # package-lock.json \ No newline at end of file diff --git a/components/Viewer/Options/TextureItem.vue b/components/Viewer/Options/TextureItem.vue index 588f7cbe..8f1d5757 100644 --- a/components/Viewer/Options/TextureItem.vue +++ b/components/Viewer/Options/TextureItem.vue @@ -42,15 +42,15 @@ const props = defineProps({ id: { type: String, required: true }, + texture_id: { type: String, required: true }, texture_name: { type: String, required: true }, - texture_file_name: { type: String, required: true }, }) const texture_name = ref("") texture_name.value = props.texture_name - const texture_file_name = ref("") - texture_file_name.value = props.texture_file_name + const texture_id = ref("") + texture_id.value = props.texture_id const texture_coordinates = ref([]) @@ -86,7 +86,7 @@ }, { response_function: async (response) => { - texture_file_name.value = response._data.viewable_file_name + texture_id.value = response._data.id }, }, ) @@ -97,8 +97,8 @@ emit("update_value", { key: "texture_name", value }) }) - watch(texture_file_name, (value) => { - emit("update_value", { key: "texture_file_name", value }) + watch(texture_id, (value) => { + emit("update_value", { key: "id", value }) }) diff --git a/components/Viewer/Options/TexturesSelector.vue b/components/Viewer/Options/TexturesSelector.vue index 66ec8517..1dac4b9a 100644 --- a/components/Viewer/Options/TexturesSelector.vue +++ b/components/Viewer/Options/TexturesSelector.vue @@ -18,7 +18,7 @@ @@ -30,9 +30,7 @@ icon="mdi-plus" v-tooltip:bottom="'Add a texture'" size="20" - @click=" - internal_textures.push({ texture_name: '', texture_file_name: '' }) - " + @click="internal_textures.push({ texture_name: '', id: '' })" /> @@ -51,16 +49,16 @@ if (textures.value != null) { internal_textures.value = textures.value } else { - internal_textures.value = [{ texture_name: "", texture_file_name: "" }] + internal_textures.value = [{ id: "", texture_name: "" }] } }) function update_value_event($event, index) { internal_textures.value[index][$event.key] = $event.value const filtered = internal_textures.value.filter((texture) => { - return texture.texture_name != "" && texture.texture_file_name != "" + return texture.texture_name !== "" && texture.id !== "" }) - if (filtered.length != 0) { + if (filtered.length !== 0) { textures.value = filtered } } diff --git a/stores/data_base.js b/stores/data_base.js index 5026ac8c..ef5d8924 100644 --- a/stores/data_base.js +++ b/stores/data_base.js @@ -42,10 +42,10 @@ export const useDataBaseStore = defineStore("dataBase", () => { } /** Actions **/ - async function registerObject(id, file_name, viewer_object) { + async function registerObject(id, viewer_object) { return viewer_call({ schema: viewer_schemas.opengeodeweb_viewer.generic.register, - params: { id, file_name, viewer_object }, + params: { id, viewer_object }, }) } async function addItem( @@ -76,14 +76,11 @@ export const useDataBaseStore = defineStore("dataBase", () => { } async function fetchMeshComponents(id) { - const { native_filename, geode_object } = itemMetaDatas(id) await api_fetch( { schema: back_schemas.opengeodeweb_back.models.mesh_components, params: { id, - filename: native_filename, - geode_object, }, }, { diff --git a/tests/integration/data/uploads/test.og_edc2d b/tests/integration/data/uploads/test.og_edc2d new file mode 100644 index 00000000..362c7b35 Binary files /dev/null and b/tests/integration/data/uploads/test.og_edc2d differ diff --git a/tests/integration/microservices/back/requirements.txt b/tests/integration/microservices/back/requirements.txt index d6bd0620..bd3a3ef5 100644 --- a/tests/integration/microservices/back/requirements.txt +++ b/tests/integration/microservices/back/requirements.txt @@ -5,4 +5,3 @@ # pip-compile --output-file=tests/integration/microservices/back/requirements.txt tests/integration/microservices/back/requirements.in # -opengeodeweb-back==5.*,>=5.10.3rc16 diff --git a/tests/integration/microservices/viewer/requirements.txt b/tests/integration/microservices/viewer/requirements.txt index 254b17b8..4d097394 100644 --- a/tests/integration/microservices/viewer/requirements.txt +++ b/tests/integration/microservices/viewer/requirements.txt @@ -5,4 +5,3 @@ # pip-compile --output-file=tests/integration/microservices/viewer/requirements.txt tests/integration/microservices/viewer/requirements.in # -opengeodeweb-viewer==1.*,>=1.11.3rc7 diff --git a/tests/integration/stores/DataStyle/mesh/Edges.nuxt.test.js b/tests/integration/stores/DataStyle/mesh/Edges.nuxt.test.js index 97441eb8..ca4b8ff6 100644 --- a/tests/integration/stores/DataStyle/mesh/Edges.nuxt.test.js +++ b/tests/integration/stores/DataStyle/mesh/Edges.nuxt.test.js @@ -1,4 +1,5 @@ import path from "path" +import fs from "fs" import { setActivePinia } from "pinia" import { createTestingPinia } from "@pinia/testing" @@ -17,19 +18,25 @@ import { import { executable_name, executable_path, - kill_viewer, run_viewer, + run_back, + kill_viewer, + kill_back, } from "@ogw_f/utils/local" import Status from "@ogw_f/utils/status" +import { api_fetch } from "@ogw_f/composables/api_fetch" import * as composables from "@ogw_f/composables/viewer_call" import { useDataStyleStore } from "@ogw_f/stores/data_style" import { useDataBaseStore } from "@ogw_f/stores/data_base" import { useViewerStore } from "@ogw_f/stores/viewer" import { useInfraStore } from "@ogw_f/stores/infra" +import { useGeodeStore } from "@ogw_f/stores/geode" import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" +import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json" +import appMode from "@ogw_f/utils/app_mode" import { WebSocket } from "ws" const mesh_edges_schemas = viewer_schemas.opengeodeweb_viewer.mesh.edges @@ -45,18 +52,50 @@ vi.stubGlobal("navigator", { }, }) +let foldersBeforeTests = new Set() +const data_folder_path = path.join(__dirname, "..", "..", "..", "data") + +function getCurrentFolders(dataFolderPath) { + if (!fs.existsSync(dataFolderPath)) { + return new Set() + } + const entries = fs.readdirSync(dataFolderPath) + const folders = new Set() + for (const entry of entries) { + const entryPath = path.join(dataFolderPath, entry) + if (fs.statSync(entryPath).isDirectory()) { + folders.add(entry) + } + } + return folders +} + +function cleanupCreatedFolders(dataFolderPath, foldersBeforeTests) { + if (!fs.existsSync(dataFolderPath)) { + return + } + const currentFolders = getCurrentFolders(dataFolderPath) + for (const folder of currentFolders) { + if (!foldersBeforeTests.has(folder)) { + const folderPath = path.join(dataFolderPath, folder) + fs.rmSync(folderPath, { recursive: true, force: true }) + } + } +} + beforeAll(() => { global.WebSocket = WebSocket + foldersBeforeTests = getCurrentFolders(data_folder_path) }) afterAll(() => { delete global.WebSocket + cleanupCreatedFolders(data_folder_path, foldersBeforeTests) }) -const id = "fake_id" -const file_name = "edged_curve.vtp" +let id = "fake_id" +const file_name = "test.og_edc2d" const geode_object = "EdgedCurve2D" -const object_type = "mesh" beforeEach(async () => { const pinia = createTestingPinia({ @@ -66,32 +105,71 @@ beforeEach(async () => { setActivePinia(pinia) const dataStyleStore = useDataStyleStore() const dataBaseStore = useDataBaseStore() + const geodeStore = useGeodeStore() const viewerStore = useViewerStore() const infraStore = useInfraStore() - infraStore.app_mode = appMode.appMode.BROWSER + infraStore.app_mode = appMode.BROWSER + + if (!fs.existsSync(data_folder_path)) { + fs.mkdirSync(data_folder_path, { recursive: true }) + } + + const back_path = path.join( + executable_path(path.join("tests", "integration", "microservices", "back")), + executable_name("opengeodeweb-back"), + ) const viewer_path = path.join( executable_path( path.join("tests", "integration", "microservices", "viewer"), ), - executable_name("opengeodeweb_viewer"), + executable_name("opengeodeweb-viewer"), ) - const viewer_port = await run_viewer(viewer_path, { + + const back_promise = run_back(back_path, { + port: 5000, + data_folder_path, + }) + + const viewer_promise = run_viewer(viewer_path, { port: 1234, - data_folder_path: path.join(__dirname, "..", "..", "..", "data"), + data_folder_path, }) + + const [back_port, viewer_port] = await Promise.all([ + back_promise, + viewer_promise, + ]) + console.log("Viewer path:", viewer_path) + geodeStore.default_local_port = back_port viewerStore.default_local_port = viewer_port await viewerStore.ws_connect() - await dataBaseStore.registerObject(id, file_name, object_type) - await dataStyleStore.addDataStyle(id, geode_object, object_type) + console.log("schema", back_schemas.opengeodeweb_back.save_viewable_file) + + const response = await api_fetch({ + schema: back_schemas.opengeodeweb_back.save_viewable_file, + params: { + input_geode_object: geode_object, + filename: file_name, + }, + }) + id = response.data.value.id + + await dataBaseStore.registerObject(id, "mesh") + await dataStyleStore.addDataStyle(id, geode_object, "mesh") + expect(viewerStore.status).toBe(Status.CONNECTED) }, 15000) -describe("Mesh edges", () => { - afterEach(async () => { - const viewerStore = useViewerStore() - await kill_viewer(viewerStore.default_local_port) - }) +afterEach(async () => { + const viewerStore = useViewerStore() + const geodeStore = useGeodeStore() + await Promise.all([ + kill_viewer(viewerStore.default_local_port), + kill_back(geodeStore.default_local_port), + ]) +}) +describe("Mesh edges", () => { describe("Edges visibility", () => { test("test visibility true", async () => { const dataStyleStore = useDataStyleStore()