Repository navigation
Names step buttons and checks them at start - #279
Merged
Merged
Conversation
The returnable step type's config key for its buttons was called outcomes, the block type vocabulary's word for the ways a block can finish, while the step declares one outcome, done. The key is now buttons, the type is at version 2, and migrate_config/2 renames the key in a version 1 block as it resolves. The moduledoc says why the type declares no outcomes/1: a step finishing with a button's outcome would be unconsumed by the sequence that holds it. Journey start now refuses a Path whose step disagrees with the screen it names, as steps_disagree: a configured button or response the screen does not carry, or a button or question on the screen the step does not configure. One test per refusal, each with a sabotage note. The patron registration steps, the branch onboarding and its three setups move to buttons at version 2. No card or signup fixture carries the type. Refs: se-9p2o
The step's moduledoc said that declaring one outcome per button would leave a step unconsumed by the core.sequence holding it. That is not so: a sequence advances on a child's done event whichever final the child enters, and never reads an outcome name. The paragraph now rests the rename on the vocabulary alone, says that declaring outcomes/1 was the other open answer, and why the rename was taken instead. The test helper the refusal tests and the version 1 start test share is named start/1, since it starts as well as refuses. Refs: se-9p2o
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.
What
The returnable step type (
myapp.step,StatifierExamples.Signup.ReturnableStep) said its buttons under a config key namedoutcomes, the block type vocabulary's word for the ways a block can finish, while the step declares nooutcomes/1and finishes asdonewhichever button was pressed. Nothing checked that a step's configured buttons and responses agree with the screen it names.buttons. The type moves to version 2 (current_version/0), andmigrate_config/2renamesoutcomestobuttonsin a version 1 block as it resolves. The moduledoc's "One outcome,done" section says why:outcomesis the block type vocabulary's word for the ways a block can finish, and this list is the screen's buttons. Declaringoutcomes/1with one outcome per button was the other open answer, and would have let a Path route on the button; the rename was taken on the same vocabulary ground, since a step's buttons are how the reader leaves its screen and a Path reads what was answered fromresponses.StatifierExamples.Signup.Journey.start/2answers{:error, {:steps_disagree, disagreements}}for a Path with amyapp.stepthat disagrees with the screen it names, each disagreement{block_id, reason, name}. The reasons are a configured button the screen does not carry, a button on the screen the step does not configure, a configured response with no question of that key, and a question on the screen the step does not configure. A version 1 step is read through the migration, so itsoutcomescount as its buttons.myapp.stepblock in them is now attype_version2 withbuttons. No card or signup fixture carries the type, so none moves.Tests
One test per refusal in
ReturnableStepTest, plus a test that a version 1 step starts, and a test of the version and the migration. The validation test and the setups' agreement test readbuttons. Each new test carries a sabotage note. Every mutation was applied, killed on an assertion and restored byte-equal before the next.Gate
Full
mix qualitygreen on the committed tree: format, compile with warnings as errors, unused dependencies, credo, dialyzer, and the suite with 88.2% coverage.Provenance
The choice between renaming the key and declaring
outcomes/1was engineering. The rename was taken on the vocabulary ground above. A second commit corrects the moduledoc, which first claimed that a step with a non-doneoutcome would stall its sequence; a sequence advances on a child's done event whichever final the child enters, so that reason did not hold and is gone. The same commit names the shared test helperstart/1. The reverse checks (a button or question on the screen the step does not configure) follow the bead's description: such a press has no transition and such an answer is never recorded.