Repository navigation
Test every control, service and shipped extension against its wire contract - #86
Merged
Merged
Conversation
This was referenced Nov 16, 2026
…area controls ControlRegistry::TYPE_MAP still held the names older Flet clients used: "c" for DataCell and DataColumn, "r" for DataRow, "windowDragArea" and "dropdownoption". A control built as Ruflet::Control.new(type: "datarow") takes its wire type from that map, so it sent a type no current client renders, while ControlFactory.build sent "DataRow" from the class's WIRE. Make the six entries agree with their classes.
ControlContractCoverageTest enumerates every name ControlFactory resolves (CLASS_MAP: controls, platform contracts and services) plus the extensions Ruflet ships, and fails for any class without a spec in test/support/control_contracts. Its exceptions list is empty. Each spec states the wire type, every registered alias, the props the control cannot be built without and any prop or event sent under another key. From it, the family test files generate three tests per class: - the wire type (`_c`), that every alias builds the same class and type, that TYPE_MAP agrees for an untyped Ruflet::Control, and that the Ruflet.* helper builds it; - that each KEYWORDS prop, set on its own, reaches the patch under its Ruby wire key; - that each on_* keyword flags the event on the wire and that the handler runs once, with the control, when the client sends the event for the mounted control. Props and events come from the class's KEYWORDS, so a keyword added later is tested without editing the spec. 263 classes (107 Material, 24 Cupertino, 80 shared, 25 platform contracts, 26 services, 1 extension) under 459 names: 6,707 props and 654 events.
AdamMusa
force-pushed
the
test/control-contracts
branch
from
November 16, 2026 06:28
1ff176a to
7bcd125
Compare
This was referenced Nov 17, 2026
The comment claimed no current client rendered the old names. Only "windowDragArea" failed to render (the engine matches "WindowDragArea" only and shows "Unknown control" otherwise). DataTable and Dropdown read their rows, cells, columns and options by slot without checking the type, so for the other five only `_c` changes.
51 classes (video, web_view, map and its layers, the ads, charts, color pickers, data_table2, lottie, rive, code_editor) have no constructor keywords and pass any prop through, so their props and events tests checked nothing: VideoControl could drop every prop and still pass. Specs can now list props: and events: to test besides the constructor keywords. Each open-schema Material spec lists the names the engine's renderer for it reads (ruflet-engine codex/engine-initialization f44e7df): 458 props and 77 events. Every open-schema class is also checked with one prop and one event no renderer reads, and the coverage test requires props: for every open-schema spec except map_layer, which has no engine renderer. Also describe where the props come from correctly: the constructor keywords, i.e. KEYWORDS or, without that constant, the constructor's keyword parameters.
This was referenced Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the release-readiness test pass. This PR adds a wire-contract test for every control, service and shipped extension in
ruflet_core. Invoke methods,PageAPIs,ruflet_server,ruflet_railsandruflet_recordfollow in separate PRs.What's tested
ControlContractCoverageTestenumerates every nameControlFactoryresolves, plus the extensions Ruflet ships. That coversCLASS_MAP, which mergesRufletControls,PlatformControlContractsandRufletServices. The test fails for any class without a spec intest/support/control_contracts/. Its exceptions list is empty.Each spec states the wire type, every alias the factory registers, the props the control can't be built without, and any prop or event sent under a different key. From that, each class gets three generated tests:
test_<type>_wire_type_and_names_c; each alias builds the same class and wire type;TYPE_MAPagrees for an untypedRuflet::Control; theRuflet.*helper builds ittest_<type>_props_serialize_under_ruby_keystest_<type>_events_attach_and_dispatchon_*flags the event on the wire, and the handler runs once with the control when the client sends the event to the mounted controlProps and events come from
ControlFactory.constructor_keywords. That is the class'sKEYWORDS, or its constructor's keyword parameters when it has noKEYWORDSconstant (40 classes, for example badge, banner, divider and tab; 12 more have neither and are open-schema). A keyword added later is tested without editing the spec.Open-schema classes. 51 classes have no constructor keywords and pass any prop through: video, web_view, map with its layers, markers and attributions, the three ads, lottie, rive, code_editor, the six color pickers, data_table2/data_row2/data_column2, and every chart class plus chart_axis and chart_axis_label. For these:
props:andevents:the names the engine's renderer reads (ruflet-enginecodex/engine-initializationf44e7df). That is 458 props and 77 events over 50 classes.map_layerlists none, because the engine has no MapLayer renderer;props:(map_layeris the one listed exception).The lists are copied from the engine source. A rename in the engine does not fail here.
Coverage
The renames the specs record are the deliberate ones:
dropdown_m2's Material 2 spellings (DropdownControl::MATERIAL2_RENAMES),cupertino_switch's*_thumb_image→*_thumb_image_src, and the service registry's_services.Behavior changes
ControlRegistry::TYPE_MAPstill held old Flet wire names.Ruflet::Control.new(type: ...)for these six types therefore sent a different_cfrom the class-built control. The fix is its own commit (d0158cc). Its regression test,test/untyped_control_wire_type_test.rb, fails 6 of 6 on main.type:_con main_cnowwindowdragareawindowDragAreaWindowDragAreadatarowrDataRowdatacellcDataCelldatacolumncDataColumnoptiondropdownoptionOptiondropdownoptiondropdownoptionDropdownOptionThe underscore spellings change the same way, because
Control#wire_typelooks upTYPE_MAP[type.delete("_")]:window_drag_area,data_row,data_cell,data_columnanddropdown_option.windowdragareanow renders. The engine matches only"WindowDragArea"(ruflet_core_extension.dart). ForwindowDragAreait showed "Unknown control" (control_widget.dart:40)._cchanges. DataTable and Dropdown read rows, cells, columns and options by slot without checking_c, so these rendered before and render the same now.Ruflet::Controlinstances change. Controls built by the factory, theRuflet.*helpers or the DSL use the class'sWIREand do not change. The factory builds an untypedControlonly for a name it does not register, so an unregistered spelling that strips to one of these keys changes too:ControlFactory.build("window_dragarea")sendsWindowDragArea(main:windowDragArea). No code inpackages/passes such a name itself; app code that passes one to the factory, through the DSL orruflet_rails, gets the new_c.The commit message of d0158cc calls the old names "a type no current client renders". That is true only of
windowDragArea. The test's comment is corrected in b4ec646; history is not rewritten.Verified on 3074b71 (main caa4ca9 merged in)
ruflet_core, one process per file: 198 files, 1887 runs, 0 failures, 1 skip, on Ruby 4.0.5 and on 3.4.5 (CI's). All files in one process on 4.0.5: 1887 runs, 0 failures, 1 skip. The skip isdsl_presented_controls_test, which needsRUFLET_ENGINE_ROOT. That file is unchanged.ruflet_server: 13 files, 49 runs, 0 failures.ruby test/compat/compat.rb --jobs 4checked 234 goldens, exit 0.compat_goldens_test.rb: 242 runs, 0 failures.material_control_registry.rbplanted,untyped_control_wire_type_test.rbfails 6 of 6.volume: 1 failure.KEYWORDSschema that lacksvolume: 1 failure.on_*handlers: 3 failures.initial_center: 1 failure.icon_deferral,scoped_helper,ruflet_gem,ruflet_record_gem, and the in-process page exchange.Ruflet::Control.new(type:)sends the class's wire type for all six types above.compat_testat line 67 (mruby has noSystemExit) andregexp_testat line 132 (OnigRegexppassed toString#partition). Neither touches anything this PR changes.Gate: final head 465a92d (main c444cbd merged in, #77 and #88)
The merge touches nothing the PR changed.
git diff c444cbd5 465a92d6equalsgit diff caa4ca95 3074b71b.ruflet_core, one process per file: 201 files, 2006 runs, 0 failures, 1 skip (dsl_presented_controls_test), on Ruby 4.0.5 and 3.4.5. Run on fbc9869f (main a309af5 merged in), whoseruflet_coreandruflet_servertrees are identical to 465a92d.ruflet_server: 13 files, 49 runs, 0 failures (same tree).packages/ruflet, one process per file on 465a92d: 20 files, 606 runs, 0 failures.compat.rb --jobs 4checked 290 goldens, exit 0.compat_goldens_test.rb: 298 runs, 0 failures.No template or CLI change, so apps built with published gems that fetch template main are unaffected. No files from #82 are touched.