Chapter 2: Feedback

Overview

Alright! Now, we get to build more sophisticated functionality! But, before we dive in, we’ll review where we left off. Then, we’ll render a dialog, create a form, and handle our first events. Along the way, we’ll refactor for cleaner code, explore schemas, and implement permissions.

Training

Pre-requisites

  1. Understanding of the previous chapter, building a dashboard and adding a card with images and buttons.

Concepts Covered in This Chapter

  1. Mercury - Event-handling and communication via Mercury.
  2. Tests - TDD by the 3 laws!
  3. Views - The visual representation of your skill provided by the Heartwood Skill.
  4. Events - Custom event creation and handling.
  5. Schemas - Data validation and normalization through schemas.
  6. Permissions - Controlling access with permission contracts.
  7. Listeners - Listening for backend events and responding appropriately.
  8. Errors - Handling and displaying errors effectively.

Tools Used in This Chapter

  1. spruce-cli - The Spruce Command Line Interface (CLI) is a tool that enables you create, build, and test your skills.
  2. vscode - A free code editor that works on Windows, macOS, and Linux.
  3. Development Theatre - The runtime that executes your skills.

Commands Used in This Chapter

Assertions

  1. vcAssert.rendersDialogue

    • Description: Asserts that a dialogue box is rendered on the view controller.
  2. formAssert.formRendersField

    • Description: Asserts that a specific field is rendered in the form.
  3. assert.isFalse

    • Description: Verifies that a specific condition or value is false.
  4. formAssert.fieldRendersAs

    • Description: Ensures that a form field is rendered as a specific type, e.g., a text area.
  5. assert.isEqual

    • Description: Checks that two values are equal.
  6. assert.renders.alert

    • Description: Confirms that an alert is displayed on the view.
  7. form.cardRenderedForm

    • Description: Asserts that a card renders a form.
  8. form assert.field.renders

    • Description: Verifies that a specific form field is rendered.

Events

  1. eventFaker.on

    • Description: Sets up a listener for a specified event to verify its behavior in tests.
  2. eventFaker.makeEventThrow

    • Description: Simulates an event throwing an error for testing purposes.
  3. client.emit

    • Description: Emits an event to a backend API.
  4. client.emitAndFlattenResponses

    • Description: Emits an event and simplifies the response structure, commonly used when responses contain nested data.

Forms

  1. formVC.getValue

    • Description: Retrieves the value of a specific field from the form.
  2. formVc.setValue

    • Description: Sets a value for a specific field in the form.

Views

  1. controller.Factory

    • Description: Creates a new instance of a controller for use in the application.
  2. this.controller.card

    • Description: Initializes a card view controller encapsulating the necessary view components.
  3. this.render.in.dialogue

    • Description: Renders a dialogue box with specific options and content.
  4. build.form

    • Description: Builds a form object with fields, sections, and schema definitions.

Listeners and Permissions

  1. this.connect.to.API

    • Description: Establishes a connection to the API for emitting or listening to events.
  2. buildPermissionReference

    • Description: Creates a reference for a permission contract, specifying roles and permissions.
  3. permissions.sync

    • Description: Synchronizes the permissions configuration to ensure it reflects the latest changes.

Terminal and CLI Commands

  1. spruce watch.views

    • Description: Watches for changes in views and rebuilds them automatically during development.
  2. spruce create.view

    • Description: Generates a new view controller file using the CLI.
  3. spruce sync.events

    • Description: Synchronizes the events configuration, ensuring event types and handlers are up-to-date.
  4. spruce sync.permissions

    • Description: Updates permission contracts and related configurations.

Schemas

  1. spruce create.schema
    • Description: Constructs a schema definition, including fields, types, and validation rules.

Test Doubles

  1. SpyFeedbackCard
    • Description: Defines a protected method used as a test case in the test framework.

Something Missing?

Request Documentation Enhancement

Now What?

Your Family Values
It looks like you are using Internet Explorer. While the basic content is available, this is no longer a supported browser by the manufacturer, and no attention is being given to having IE work well here.