From a5c3aa8ec2403ca89eb65f49c3c07a179fc21e1c Mon Sep 17 00:00:00 2001 From: Emma Forman Ling Date: Mon, 12 Aug 2024 17:14:58 -0700 Subject: [PATCH] Test child component is unmounted (#28861) GitOrigin-RevId: eed936c09fe0973b10033e35f8b8a93835420e73 --- crates/application/src/tests/components.rs | 18 ++++++++++++++++++ .../mounted/convex/_generated/server.d.ts | 10 ++++++++++ .../projects/mounted/convex/app.config.ts | 2 ++ 3 files changed, 30 insertions(+) diff --git a/crates/application/src/tests/components.rs b/crates/application/src/tests/components.rs index 666e1557..9200e9e9 100644 --- a/crates/application/src/tests/components.rs +++ b/crates/application/src/tests/components.rs @@ -366,3 +366,21 @@ async fn test_data_exists_in_unmounted_components(rt: TestRuntime) -> anyhow::Re assert_eq!(count, 1); Ok(()) } + +#[convex_macro::test_runtime] +async fn test_descendents_unmounted(rt: TestRuntime) -> anyhow::Result<()> { + let application = Application::new_for_tests(&rt).await?; + unmount_component(&application).await?; + let mut tx = application.begin(Identity::system()).await?; + let mut components_model = BootstrapComponentsModel::new(&mut tx); + let env_vars_child_component = ComponentPath::deserialize(Some("envVars/component"))?; + let (_, component_id) = components_model + .component_path_to_ids(env_vars_child_component) + .await?; + let metadata = components_model + .load_component(component_id) + .await? + .unwrap(); + assert!(matches!(metadata.state, ComponentState::Unmounted)); + Ok(()) +} diff --git a/npm-packages/component-tests/projects/mounted/convex/_generated/server.d.ts b/npm-packages/component-tests/projects/mounted/convex/_generated/server.d.ts index 22b7eacb..ab5f801c 100644 --- a/npm-packages/component-tests/projects/mounted/convex/_generated/server.d.ts +++ b/npm-packages/component-tests/projects/mounted/convex/_generated/server.d.ts @@ -162,4 +162,14 @@ export declare const app: { url: FunctionReference<"action", "internal", any, any>; }; }; + envVars: { + messages: { + envVarAction: FunctionReference<"action", "internal", any, any>; + envVarQuery: FunctionReference<"query", "internal", any, any>; + hello: FunctionReference<"action", "internal", any, any>; + systemEnvVarAction: FunctionReference<"action", "internal", any, any>; + systemEnvVarQuery: FunctionReference<"query", "internal", any, any>; + url: FunctionReference<"action", "internal", any, any>; + }; + }; }; diff --git a/npm-packages/component-tests/projects/mounted/convex/app.config.ts b/npm-packages/component-tests/projects/mounted/convex/app.config.ts index 7d59a799..ac833fb2 100644 --- a/npm-packages/component-tests/projects/mounted/convex/app.config.ts +++ b/npm-packages/component-tests/projects/mounted/convex/app.config.ts @@ -2,6 +2,7 @@ // @ts-ignore import { defineApp } from "convex/server"; import component from "../../../component/component.config"; +import envVars from "../../../envVars/component.config"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore @@ -10,6 +11,7 @@ const app = defineApp(); const c = app.install(component, { args: { name: process.env.NAME, url: process.env.CONVEX_CLOUD_URL }, }); +app.install(envVars, {}); app.mount({ mounted: c.exports }); export default app;