Skip to content

Commit a5c3aa8

Browse files
emmaling27Convex, Inc.
authored and
Convex, Inc.
committed
Test child component is unmounted (#28861)
GitOrigin-RevId: eed936c09fe0973b10033e35f8b8a93835420e73
1 parent 51fe85d commit a5c3aa8

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

crates/application/src/tests/components.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,3 +366,21 @@ async fn test_data_exists_in_unmounted_components(rt: TestRuntime) -> anyhow::Re
366366
assert_eq!(count, 1);
367367
Ok(())
368368
}
369+
370+
#[convex_macro::test_runtime]
371+
async fn test_descendents_unmounted(rt: TestRuntime) -> anyhow::Result<()> {
372+
let application = Application::new_for_tests(&rt).await?;
373+
unmount_component(&application).await?;
374+
let mut tx = application.begin(Identity::system()).await?;
375+
let mut components_model = BootstrapComponentsModel::new(&mut tx);
376+
let env_vars_child_component = ComponentPath::deserialize(Some("envVars/component"))?;
377+
let (_, component_id) = components_model
378+
.component_path_to_ids(env_vars_child_component)
379+
.await?;
380+
let metadata = components_model
381+
.load_component(component_id)
382+
.await?
383+
.unwrap();
384+
assert!(matches!(metadata.state, ComponentState::Unmounted));
385+
Ok(())
386+
}

npm-packages/component-tests/projects/mounted/convex/_generated/server.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,14 @@ export declare const app: {
162162
url: FunctionReference<"action", "internal", any, any>;
163163
};
164164
};
165+
envVars: {
166+
messages: {
167+
envVarAction: FunctionReference<"action", "internal", any, any>;
168+
envVarQuery: FunctionReference<"query", "internal", any, any>;
169+
hello: FunctionReference<"action", "internal", any, any>;
170+
systemEnvVarAction: FunctionReference<"action", "internal", any, any>;
171+
systemEnvVarQuery: FunctionReference<"query", "internal", any, any>;
172+
url: FunctionReference<"action", "internal", any, any>;
173+
};
174+
};
165175
};

npm-packages/component-tests/projects/mounted/convex/app.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// @ts-ignore
33
import { defineApp } from "convex/server";
44
import component from "../../../component/component.config";
5+
import envVars from "../../../envVars/component.config";
56

67
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
78
// @ts-ignore
@@ -10,6 +11,7 @@ const app = defineApp();
1011
const c = app.install(component, {
1112
args: { name: process.env.NAME, url: process.env.CONVEX_CLOUD_URL },
1213
});
14+
app.install(envVars, {});
1315
app.mount({ mounted: c.exports });
1416

1517
export default app;

0 commit comments

Comments
 (0)