//! Matrix coverage for `create m:n relationship from to //! [as ]` (C4 / ADR-0045). Exercises the full typing surface — //! completion candidates, ambient hint, highlighting, and parse state — //! at each stage, so a regression in any of those surfaces is caught. use crate::typing_surface::*; use rdbms_playground::input_render::InputState; #[test] fn after_create_offers_table_and_m2n() { let schema = schema_multi_table(); let a = assess_at_end("create ", &schema); assert!(matches!(a.state, InputState::IncompleteAtEof)); // `create` branches to `table` (create table) or the `m:n` composite. assert_candidate_present(&a, &["table", "m:n"]); crate::snap!("after_create", a); } #[test] fn m2n_relationship_keyword_sequence_is_incomplete() { let schema = schema_multi_table(); let a = assess_at_end("create m:n relationship ", &schema); assert!(matches!(a.state, InputState::IncompleteAtEof)); assert_candidate_present(&a, &["from"]); crate::snap!("after_relationship_keyword", a); } #[test] fn after_from_offers_table_names() { let schema = schema_multi_table(); let a = assess_at_end("create m:n relationship from ", &schema); assert!(matches!(a.state, InputState::IncompleteAtEof)); assert_candidate_present(&a, &["Customers", "Orders"]); crate::snap!("after_from", a); } #[test] fn after_to_offers_table_names() { let schema = schema_multi_table(); let a = assess_at_end("create m:n relationship from Customers to ", &schema); assert!(matches!(a.state, InputState::IncompleteAtEof)); assert_candidate_present(&a, &["Customers", "Orders"]); crate::snap!("after_to", a); } #[test] fn complete_create_m2n_parses() { let schema = schema_multi_table(); let a = assess_at_end("create m:n relationship from Customers to Orders", &schema); assert!(matches!(a.state, InputState::Valid)); assert_eq!(a.parse_result.as_deref(), Ok("CreateM2nRelationship")); crate::snap!("complete", a); } #[test] fn create_m2n_with_as_name_parses() { let schema = schema_multi_table(); let a = assess_at_end( "create m:n relationship from Customers to Orders as CustomerOrders", &schema, ); assert!(matches!(a.state, InputState::Valid)); assert_eq!(a.parse_result.as_deref(), Ok("CreateM2nRelationship")); crate::snap!("with_as_name", a); } #[test] fn after_as_keyword_is_incomplete() { let schema = schema_multi_table(); let a = assess_at_end("create m:n relationship from Customers to Orders as ", &schema); assert!(matches!(a.state, InputState::IncompleteAtEof)); crate::snap!("after_as", a); }