forge
Explore
Log in

Don't you dare go Hollow

The settings page earns its own guards

Browse files at this commit

a2e172e18c7bd7cf6347beca671a2aded741ee81Ahmet Kaan GümüşParent: 5178f3f
  • test
    • the settings page earns its own guards
Show full message
✅ test(ui): the settings page earns its own guards

Pins the settings page's own organising rule (PROJECT rows open only
.edith-writing doors, EDITOR rows never do) as a source-scan test, and
closes three gaps the feature's own commit left red: modal() reads
settings_open with no mount_for entry, the default-stroke count did
not move for its new binding, and the export-busy oracle test never
learned Settings joins Theme/Fullscreen/SubtitleStyle as safe during
an export (oracle.rs already allowed it -- only the test lagged).
Corrects the settings page's own doc comment, which overstated that
the proxy switches are never written into a project: they mirror into
it once one is open, same as inspector.rs's legacy row already did,
with only the subtitle font staying config-file-only.
crates/app/src/keymap.rsmodified+1 -1
@@ -1500,7 +1500,7 @@ mod tests {
1500 #[test]1500 #[test]
1501 fn every_default_stroke_reaches_its_action() {1501 fn every_default_stroke_reaches_its_action() {
1502 let k = Keymap::defaults();1502 let k = Keymap::defaults();
1503- assert_eq!(k.entries().len(), 73);1503+ assert_eq!(k.entries().len(), 74);
1504 // The cut odometer: bare walks one, `<`/`>` (what shift+,/shift+.1504 // The cut odometer: bare walks one, `<`/`>` (what shift+,/shift+.
1505 // actually type) strides ten.1505 // actually type) strides ten.
1506 assert_eq!(k.lookup(".", false), Some(ActionId::WalkCutNext));1506 assert_eq!(k.lookup(".", false), Some(ActionId::WalkCutNext));
crates/app/src/tests/cards.rsmodified+1 -0
@@ -75,6 +75,7 @@ fn every_modal_field_has_a_mounted_surface_somewhere_in_the_darkroom() {
75 "silence_open" => "silence_card(",75 "silence_open" => "silence_card(",
76 "mix_open" => "mix_card(",76 "mix_open" => "mix_card(",
77 "subtitle_style_open" => "subtitle_style_card(",77 "subtitle_style_open" => "subtitle_style_card(",
78+ "settings_open" => "settings_stance::render(",
78 other => panic!(79 other => panic!(
79 "Player::modal() now reads `self.{other}` with no entry in this test's \80 "Player::modal() now reads `self.{other}` with no entry in this test's \
80 mount_for map -- add one naming the function that mounts its surface in \81 mount_for map -- add one naming the function that mounts its surface in \
crates/app/src/tests/editing.rsmodified+2 -1
@@ -903,7 +903,8 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() {
903 let allowed = action == ActionId::CancelExport903 let allowed = action == ActionId::CancelExport
904 || action == ActionId::Theme904 || action == ActionId::Theme
905 || action == ActionId::Fullscreen905 || action == ActionId::Fullscreen
906- || action == ActionId::SubtitleStyle;906+ || action == ActionId::SubtitleStyle
907+ || action == ActionId::Settings;
907 assert_eq!(908 assert_eq!(
908 whole(action, busy).yes(),909 whole(action, busy).yes(),
909 allowed,910 allowed,
crates/app/src/tests/layout.rsmodified+45 -0
@@ -1922,3 +1922,48 @@ fn every_darkroom_menu_sizes_its_list_against_the_floor_room_not_the_raw_viewpor
1922 assert!(sizings > 0, "{file} no longer opens any menu -- update this guard");1922 assert!(sizings > 0, "{file} no longer opens any menu -- update this guard");
1923 }1923 }
1924 }1924 }
1925+
1926+/// The settings page's own organising rule: PROJECT rows open only the
1927+/// doors that write into the `.edith` file ([`Player::open_picker`],
1928+/// [`Player::open_mix`]), and EDITOR rows open only the doors that do not
1929+/// ([`Player::toggle_proxies`], [`Player::toggle_auto_proxies`],
1930+/// [`Player::open_subtitle_style`]) -- never the config-file writers
1931+/// (`ui::dock_stance::config_path`/`ui::theme::config_path`/
1932+/// `keymap::Keymap::config_path`) directly, which every editor-side row
1933+/// already routes around through its own opener. A row wired to the wrong
1934+/// section's opener is exactly the regression a page organised around two
1935+/// headings invites; this pins each half to its own doors so the two lists
1936+/// cannot cross.
1937+#[test]
1938+fn settings_project_and_editor_sections_open_disjoint_doors() {
1939+ let source = src_text("ui/settings_stance.rs");
1940+ let project_start = source.find("fn project_section(").expect("the project section");
1941+ let editor_start = source.find("fn editor_section(").expect("the editor section");
1942+ let render_start = source.find("pub(crate) fn render(").expect("the page's render fn");
1943+ assert!(project_start < editor_start && editor_start < render_start, "the three fns moved; this scan is blind");
1944+ let project_body = &source[project_start..editor_start];
1945+ let editor_body = &source[editor_start..render_start];
1946+
1947+ for door in ["open_picker(", "open_mix("] {
1948+ assert!(project_body.contains(door), "PROJECT section no longer opens {door} -- update this guard");
1949+ assert!(
1950+ !editor_body.contains(door),
1951+ "EDITOR section opens {door}, a project-file door -- that value belongs in PROJECT, not here"
1952+ );
1953+ }
1954+ for door in ["toggle_proxies(", "toggle_auto_proxies(", "open_subtitle_style("] {
1955+ assert!(editor_body.contains(door), "EDITOR section no longer opens {door} -- update this guard");
1956+ assert!(
1957+ !project_body.contains(door),
1958+ "PROJECT section opens {door}, an editor-only door -- that value belongs in EDITOR, not here"
1959+ );
1960+ }
1961+ // Neither section writes a config file straight from a row: both go
1962+ // through an opener, which is the one place a config-file write (the
1963+ // subtitle style card's Save, this window's next project load) is
1964+ // allowed to live.
1965+ for path_fn in ["dock_stance::config_path", "theme::config_path", "Keymap::config_path"] {
1966+ assert!(!project_body.contains(path_fn), "PROJECT section touches {path_fn} directly");
1967+ assert!(!editor_body.contains(path_fn), "EDITOR section touches {path_fn} directly");
1968+ }
1969+}
crates/app/src/ui/settings_stance.rsmodified+12 -4
@@ -5,9 +5,14 @@
5 //! - PROJECT: anything that changes the rendered output or is stored in the5 //! - PROJECT: anything that changes the rendered output or is stored in the
6 //! `.edith` file -- resolution, fps, sample-rate, the HDR tonemap, the mix.6 //! `.edith` file -- resolution, fps, sample-rate, the HDR tonemap, the mix.
7 //! - EDITOR: anything about this machine, this person, this window --7 //! - EDITOR: anything about this machine, this person, this window --
8-//! proxies/auto-proxies (this window's decode/import policy) and the8+//! proxies/auto-proxies (this window's decode/import policy, mirrored into
9-//! subtitle font (a reading preference, kept in `~/.config/edith` like the9+//! the project like the resolution row above it once one is open --
10-//! theme beside it, per [`crate::load_subtitle_style`]).10+//! [`engine::PlaybackSession::set_proxies`] -- but with a window-level
11+//! default, `false`/`true`, that answers before any project is, exactly as
12+//! [`inspector.rs`]'s own legacy row already does) and the subtitle font
13+//! (a reading preference, kept in `~/.config/edith` like the theme beside
14+//! it, per [`crate::load_subtitle_style`], and never written into a
15+//! project at all).
11 //!16 //!
12 //! Every row here reuses an opener or a picker this editor already has17 //! Every row here reuses an opener or a picker this editor already has
13 //! ([`Player::open_picker`], [`Player::open_mix`], [`Player::open_subtitle_style`],18 //! ([`Player::open_picker`], [`Player::open_mix`], [`Player::open_subtitle_style`],
@@ -165,7 +170,10 @@ fn project_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElemen
165 }170 }
166 171
167 /// EDITOR: this window's own decode/import policy and this person's own172 /// EDITOR: this window's own decode/import policy and this person's own
168-/// reading preference -- never written into the `.edith` file.173+/// reading preference. The subtitle font never touches the `.edith` file;
174+/// the proxy switches do mirror into it once a project is open (they are
175+/// project state too), but default from the window rather than a project
176+/// pick, which is what keeps them answerable with nothing open.
169 fn editor_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {177 fn editor_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {
170 div()178 div()
171 .flex_none()179 .flex_none()