6. Finish and test the app

Your development computer

Choose the computer you’ll build on. Your choice applies throughout these six lessons.

Add navigation buttons and automated tests to the app from lesson 5. Retain Cargo.toml, Day.toml, build.rs, and src/main.rs. Replace the UI and catalog with the versions below.

1. Complete the catalog

Replace resource/locales/en/app.ftl. The unused alert messages are removed:

Write resource/locales/en/app.ftl:

app_title = Session counter
counter_value = Count: { $count }
add_one = Add one
reset_count = Reset
session_hint = Add one after each session. Reset when you start a new day.
nav_counter = Counter
nav_summary = Summary
summary_value = Sessions completed: { $count }
summary_hint = This count lasts until you quit the app.
show_summary = Show summary
back_to_counter = Back to counter

2. Complete the UI

Replace src/lib.rs:

Write src/lib.rs:

use day::prelude::*;

day::resources!();
day::day_start!(options: res::window_options(), root);

pub fn root() -> impl Piece {
    let count = Signal::new(0i64);
    let section = Signal::new("counter".to_string());

    nav(section)
        .style(NavStyle::Sidebar)
        .title(res::str::app_title())
        .item("counter", res::str::nav_counter(), move || {
            counter_page(count)
        })
        .item("summary", res::str::nav_summary(), move || {
            summary_page(count)
        })
        .grow(Dimension::Both)
}

fn counter_page(count: Signal<i64>) -> impl Piece {
    column((
        label(res::str::counter_value(count)).id(id!(counter_label)),
        row((
            button(res::str::add_one())
                .action(move || count.update(|n| *n = n.saturating_add(1)))
                .id(id!(increment_button)),
            button(res::str::reset_count())
                .action(move || count.set(0))
                .id(id!(reset_button)),
        ))
        .spacing(Space::M),
        label(res::str::session_hint()),
        nav_link(res::str::show_summary(), "summary").id(id!(summary_button)),
    ))
    .spacing(Space::M)
    .padding(Space::L)
    .grow(Dimension::Both)
}

fn summary_page(count: Signal<i64>) -> impl Piece {
    column((
        label(res::str::summary_value(count)).id(id!(summary_label)),
        label(res::str::summary_hint()),
        nav_link(res::str::back_to_counter(), "counter").id(id!(counter_button)),
    ))
    .spacing(Space::M)
    .padding(Space::L)
    .grow(Dimension::Both)
}

nav_link creates a button that selects a route key. These buttons and the sidebar update the same navigation state. This app switches peer sections; it does not push pages onto a back stack. All UI text uses generated Fluent accessors.

3. Run the finished app

macOS

day launch -t macos-appkit

Windows

day launch -t windows-winui

Linux

day launch -t linux-gtk

Add two sessions and press Show summary; expect Sessions completed: 2. Press Back to counter, reset, and reopen the summary; expect zero. The in-memory count resets when the app exits.

macOS

Quit with Command-Q before continuing.

Windows

Close the app window before continuing.

Linux

Close the app window before continuing.

4. Automate the walkthrough

Create the script directory:

macOS

mkdir -p dayscript

Windows

New-Item -ItemType Directory -Force -Path dayscript

Linux

mkdir -p dayscript

Create dayscript/session-counter.yaml:

Write dayscript/session-counter.yaml:

name: session-counter
on_failure: stop
flow:
  - wait_for: { id: increment_button }
  - assert_text: { id: counter_label, key: counter_value, args: { count: 0 } }
  - tap: { id: increment_button }
  - tap: { id: increment_button }
  - assert_text: { id: counter_label, key: counter_value, args: { count: 2 } }
  - tap: { id: summary_button }
  - assert_route: { route: summary }
  - assert_text: { id: summary_label, key: summary_value, args: { count: 2 } }
  - tap: { id: counter_button }
  - assert_route: { route: counter }
  - assert_text: { id: counter_label, key: counter_value, args: { count: 2 } }
  - tap: { id: reset_button }
  - assert_text: { id: counter_label, key: counter_value, args: { count: 0 } }
  - tap: { id: summary_button }
  - assert_text: { id: summary_label, key: summary_value, args: { count: 0 } }

Dayscript is Day’s YAML UI automation format. IDs locate controls; message keys and arguments specify expected localized text. assert_route checks navigation; on_failure: stop stops at the first failed assertion.

Run from the app directory:

macOS

day launch -t macos-appkit --locale en --script dayscript/session-counter.yaml

Windows

day launch -t windows-winui --locale en --script dayscript/session-counter.yaml

Linux

day launch -t linux-gtk --locale en --script dayscript/session-counter.yaml

Expect 15 passing steps and exit status zero. Assertion failures return status 5. Scripted taps test Day’s event dispatch; test physical mouse and keyboard input separately.

Troubleshooting

SymptomCheck and recovery
Script cannot find an IDMatch YAML IDs to id!(...), save both files, and rerun without --skip-build.
Initial count is not zeroLaunch a new app instance.
Navigation failsMatch nav_link keys to .item keys, not translated labels.
Text assertion failsCheck arguments against the count; use matching final catalog and Rust files.

Next steps

See other platforms, localization, state, and navigation.