# `Fluffy.Expect`
[🔗](https://github.com/ftes/fluffy/blob/v0.8.0/lib/fluffy/expect.ex#L1)

Typed locator and active-page assertion values executed by
`Fluffy.Expect.expect/2`.

Page constructors use target prefixes such as `page_to_have_url/2`.
Import this module to use `expect/2`, `not_/1`, and all constructors.
For ExUnit-style names, use `Fluffy.Assert`.

Assertion constructors use fluent `to_be_*` names for states and `to_have_*`
names for properties.

Every expectation constructor accepts the shared timeout option.

* `:timeout` (`t:non_neg_integer/0`) - Maximum time in milliseconds to wait for the operation. Playwright browser bookkeeping and navigation synchronization use the session timeout separately.

`to_be_checked/2` additionally accepts:

* `:timeout` (`t:non_neg_integer/0`) - Maximum time in milliseconds to wait for the operation. Playwright browser bookkeeping and navigation synchronization use the session timeout separately.

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

* `:indeterminate` (`t:boolean/0`) - Expect the browser-owned indeterminate state.

# `to_be_checked`

```elixir
@spec to_be_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.

# `to_be_disabled`

```elixir
@spec to_be_disabled(Fluffy.Locator.t(), [option()]) :: t()
```

# `to_be_editable`

```elixir
@spec to_be_editable(Fluffy.Locator.t(), [option()]) :: t()
```

# `to_be_enabled`

```elixir
@spec to_be_enabled(Fluffy.Locator.t(), [option()]) :: t()
```

# `to_be_focused`
*Playwright only* 

```elixir
@spec to_be_focused(Fluffy.Locator.t(), [option()]) :: t()
```

Asserts browser focus. Requires Playwright, including when negated.

# `to_be_visible`

```elixir
@spec to_be_visible(Fluffy.Locator.t(), [option()]) :: t()
```

# `to_have_count`

```elixir
@spec to_have_count(Fluffy.Locator.t(), non_neg_integer(), [option()]) :: t()
```

# `to_have_value`

```elixir
@spec to_have_value(Fluffy.Locator.t(), String.t(), [option()]) :: t()
```

# `to_have_values`

```elixir
@spec to_have_values(Fluffy.Locator.t(), [term()], [option()]) :: t()
```

# `checked_option`

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

# `kind`

```elixir
@type kind() ::
  :checked
  | :count
  | :disabled
  | :editable
  | :enabled
  | :focused
  | :opener
  | :status
  | :title
  | :url
  | :value
  | :values
  | :visible
```

# `option`

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

# `t`

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

# `target`

```elixir
@type target() :: {:locator, Fluffy.Locator.t()} | :page
```

# `expect`

```elixir
@spec expect(Fluffy.Session.t(), t(), [option()]) :: Fluffy.Session.t()
```

Executes an expectation and returns the unchanged or reconciled session.

# `expect_event`

Registers before the action, awaits a matching event, and optionally asserts on
its value. Action and assertion callbacks run once in the caller; their return
values are ignored. Returns the input session, retaining its page selection.

# `expect_event`

Expects an event with an assertion callback or wait options.

# `expect_event`

Expects an event with an assertion callback and wait options.

# `not_`

```elixir
@spec not_(t()) :: t()
```

Negates an expectation while preserving its target and options.

# `page_to_have_opener`

```elixir
@spec page_to_have_opener(Fluffy.Page.t() | nil, [option()]) :: t()
```

Expects the active page to have the given opener handle, or no opener with `nil`.

# `page_to_have_status`

```elixir
@spec page_to_have_status(non_neg_integer(), [option()]) :: t()
```

Expects the active page's normalized main-resource status.

# `page_to_have_title`

```elixir
@spec page_to_have_title(Fluffy.Page.title_expectation(), [option()]) :: t()
```

Expects the active page title to equal a string or match a regular expression.

Like Playwright's `toHaveTitle`, the assertion retries on Live and Playwright
pages and normalizes whitespace before matching.

## Options

* `:timeout` (`t:non_neg_integer/0`) - Maximum time in milliseconds to wait for the operation. Playwright browser bookkeeping and navigation synchronization use the session timeout separately.

# `page_to_have_url`

```elixir
@spec page_to_have_url(Fluffy.Page.url_expectation(), [option()]) :: t()
```

Expects the active page to have the requested URL.

A string matches the complete canonical absolute URL after resolving a
relative value against the session base URL. A regular expression matches
that complete serialized URL. A function receives a `%URI{}` and returns a boolean.
Keep predicates quick and nonblocking.

A keyword list selects structured components. `:path` and `:fragment` are
exact serialized component values; omit either to ignore it. `:fragment`
excludes the leading `#`, and `fragment: nil` requires no fragment.

`:query` is a map from decoded parameter names to one value or an ordered
list of repeated values. Ordering between distinct names is ignored while
repeated-value order is retained. Bare names and names with an empty value
both decode to `""`; `+` and `%20` both decode to a space. Exact mode is the
default. `query_mode: :subset` permits unrelated names but still requires
the complete ordered value list for each requested name.

## Structured components

* `:path` (`t:String.t/0`) - Serialized URL pathname to match exactly.

* `:query` - Decoded query names and their ordered value or values.

* `:query_mode` - Require the complete query or allow unrelated parameter names. The default value is `:exact`.

* `:fragment` - Serialized fragment without `#`; nil requires no fragment.

## Assertion options

* `:timeout` (`t:non_neg_integer/0`) - Maximum time in milliseconds to wait for the operation. Playwright browser bookkeeping and navigation synchronization use the session timeout separately.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
