Skip to content

Commit

Permalink
Test child component is unmounted (#28861)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: eed936c09fe0973b10033e35f8b8a93835420e73
  • Loading branch information
emmaling27 authored and Convex, Inc. committed Aug 13, 2024
1 parent 51fe85d commit a5c3aa8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
18 changes: 18 additions & 0 deletions crates/application/src/tests/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
};
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

0 comments on commit a5c3aa8

Please sign in to comment.