Fluffy.Expect (Fluffy v0.1.1)

Copy Markdown View Source

Typed locator, active-page, and captured-result assertion values executed by Fluffy.expect/2.

Active page expectations live on Fluffy.Page.

The module intentionally keeps a flat Elixir API while preserving Playwright's target and matcher concepts internally.

Every expectation constructor accepts the shared timeout option:

  • :timeout (non_neg_integer/0) - Maximum time in milliseconds to wait for the operation.

checked/2 additionally accepts:

  • :timeout (non_neg_integer/0) - Maximum time in milliseconds to wait for the operation.

  • :checked (boolean/0) - Set to false to expect an unchecked control.

  • :indeterminate (boolean/0) - Expect the browser-owned indeterminate state.

Summary

Locator assertions

checked(locator, options \\ [])

@spec checked(Fluffy.Locator.t(), [checked_option()]) :: t()

Expects a checkbox or radio to have Playwright's checked state.

The default is checked. Pass checked: false for unchecked, or indeterminate: true for the browser-owned mixed state. The indeterminate state requires Playwright because it is a DOM property rather than HTML state available to the Static or LiveView drivers.

count(locator, expected, options \\ [])

@spec count(Fluffy.Locator.t(), non_neg_integer(), [option()]) :: t()

disabled(locator, options \\ [])

@spec disabled(Fluffy.Locator.t(), [option()]) :: t()

editable(locator, options \\ [])

@spec editable(Fluffy.Locator.t(), [option()]) :: t()

enabled(locator, options \\ [])

@spec enabled(Fluffy.Locator.t(), [option()]) :: t()

focused(locator, options \\ [])

@spec focused(Fluffy.Locator.t(), [option()]) :: t()

value(locator, expected, options \\ [])

@spec value(Fluffy.Locator.t(), String.t(), [option()]) :: t()

values(locator, expected, options \\ [])

@spec values(Fluffy.Locator.t(), [term()], [option()]) :: t()

visible(locator, options \\ [])

@spec visible(Fluffy.Locator.t(), [option()]) :: t()

Downloads

download_content(key, expected, options \\ [])

@spec download_content(term(), String.t(), [option()]) :: t()

download_content_type(key, expected, options \\ [])

@spec download_content_type(term(), String.t(), [option()]) :: t()

download_size(key, expected, options \\ [])

@spec download_size(term(), non_neg_integer(), [option()]) :: t()

download_suggested_filename(key, expected, options \\ [])

@spec download_suggested_filename(term(), String.t(), [option()]) :: t()

download_url(key, expected, options \\ [])

@spec download_url(term(), String.t(), [option()]) :: t()

Dialogs

dialog_action(key, expected, options \\ [])

@spec dialog_action(term(), term(), [option()]) :: t()

dialog_default_value(key, expected, options \\ [])

@spec dialog_default_value(term(), String.t(), [option()]) :: t()

dialog_message(key, expected, options \\ [])

@spec dialog_message(term(), String.t(), [option()]) :: t()

dialog_prompt_text(key, expected, options \\ [])

@spec dialog_prompt_text(term(), term(), [option()]) :: t()

dialog_type(key, expected, options \\ [])

@spec dialog_type(term(), term(), [option()]) :: t()

Requests

request_headers(key, expected, options \\ [])

@spec request_headers(term(), map(), [option()]) :: t()

request_method(key, expected, options \\ [])

@spec request_method(term(), String.t(), [option()]) :: t()

request_page(key, expected, options \\ [])

@spec request_page(term(), term(), [option()]) :: t()

request_post_data(key, expected, options \\ [])

@spec request_post_data(term(), String.t(), [option()]) :: t()

request_resource_type(key, expected, options \\ [])

@spec request_resource_type(term(), String.t(), [option()]) :: t()

request_url(key, expected, options \\ [])

@spec request_url(term(), String.t(), [option()]) :: t()

Responses

response_headers(key, expected, options \\ [])

@spec response_headers(term(), map(), [option()]) :: t()

response_method(key, expected, options \\ [])

@spec response_method(term(), String.t(), [option()]) :: t()

response_page(key, expected, options \\ [])

@spec response_page(term(), term(), [option()]) :: t()

response_post_data(key, expected, options \\ [])

@spec response_post_data(term(), String.t(), [option()]) :: t()

response_resource_type(key, expected, options \\ [])

@spec response_resource_type(term(), String.t(), [option()]) :: t()

response_status(key, expected, options \\ [])

@spec response_status(term(), integer(), [option()]) :: t()

response_status_text(key, expected, options \\ [])

@spec response_status_text(term(), String.t(), [option()]) :: t()

response_url(key, expected, options \\ [])

@spec response_url(term(), String.t(), [option()]) :: t()

Types

checked_option()

@type checked_option() ::
  {:timeout, non_neg_integer()}
  | {:checked, boolean()}
  | {:indeterminate, boolean()}

kind()

@type kind() ::
  :checked
  | :count
  | :disabled
  | :editable
  | :enabled
  | :focused
  | :opener
  | :status
  | :title
  | :url
  | :value
  | :values
  | :visible
  | :download_content
  | :download_content_type
  | :download_size
  | :download_suggested_filename
  | :download_url
  | :dialog_action
  | :dialog_default_value
  | :dialog_message
  | :dialog_prompt_text
  | :dialog_type
  | :navigation_from_url
  | :navigation_status
  | :navigation_url
  | :request_headers
  | :request_method
  | :request_page
  | :request_post_data
  | :request_resource_type
  | :request_url
  | :response_headers
  | :response_method
  | :response_page
  | :response_post_data
  | :response_resource_type
  | :response_status
  | :response_status_text
  | :response_url

option()

@type option() :: {:timeout, non_neg_integer()}

t()

@type t() :: %Fluffy.Expect{
  expected: term(),
  kind: kind(),
  negated?: boolean(),
  options: keyword(),
  target: target()
}

target()

@type target() ::
  {:locator, Fluffy.Locator.t()}
  | :page
  | {:download, term()}
  | {:dialog, term()}
  | {:navigation, term()}
  | {:request, term()}
  | {:response, term()}