From c35db859bbc11fa94a4169076e8c64dfd6a75fba Mon Sep 17 00:00:00 2001 From: Pascal Welsch Date: Mon, 25 Dec 2023 19:49:43 +0100 Subject: [PATCH] Prepare release 0.7.0 --- CHANGELOG.md | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ pubspec.yaml | 2 +- 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ade74f9f..021af8f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,72 @@ # Changelog +## 0.7.0 + +- New prop API with `hasWidgetProp()` makes it easy to filter and assert properties of Widgets. + This replaces the old `hasProp()` method which was based on way to complicated package:checks context. + ```dart + // Old ⛈️ + spotSingle().existsOnce().hasProp( + selector: (e) => e.context.nest( + () => ['Checkbox', 'value'], + (e) => Extracted.value((e.widget as Checkbox).value), + ), + match: (it) => it.equals(true), + ); + ``` + ```dart + // New ✨ + spotSingle().existsOnce().hasWidgetProp( + prop: widgetProp('value', (widget) => widget.value), + match: (value) => value.isTrue(), + ); + ``` + + The prop API is also available for `Element` and `RenderObject`. + +
+ + ``` + ├── Interface "NamedWidgetProp" added + ├── Interface "NamedElementProp" added + ├── Interface "NamedRenderObjectProp" added + ├── Function "widgetProp" added + ├── Function "elementProp" added + ├── Function "renderObjectProp" added + ├─┬ Class SelectorQueries + │ ├── Method "whereWidgetProp" added + │ ├── Method "whereElementProp" added + │ └── Method "whereRenderObjectProp" added + └─┬ Class WidgetMatcherExtensions + ├── Method "getWidgetProp" added + ├── Method "hasWidgetProp" added + ├── Method "getElementProp" added + ├── Method "hasElementProp" added + ├── Method "getRenderObjectProp" added + └── Method "hasRenderObjectProp" added + ``` +
+
+ +- Never miss asserting your `WidgetSelector`. + All methods returning a `WidgetSelector` are now annotated with `@useResult`. + This will cause a lint warning when you only define a `WidgetSelector` without asserting it. + ```dart + spot().withChild(spotIcon(Icons.add)); // warning, no assertion + + final plusFab = spot().withChild(spotIcon(Icons.add)); // ok, assigned + spot().withChild(spotIcon(Icons.add)).existsOnce(); // ok, asserted + ``` + +- It is now easy to directly access the Widget of a `SingleWidgetSelector` with `snapshotWidget()`. + It also works for the associated `Element` and `RenderObject`. Use `snapshotElement()` and `snapshotRenderObject()`. + + ```diff + -final checkbox = spotSingle().snapshot().widget; + +final checkbox = spotSingle().snapshotWidget(); + print(checkbox.checkColor); + ``` + ## 0.6.0 - Add matchers `.existsAtMostOnce()` and `.existsAtMostNTimes(x)` #19 - Add selector `.withParent(parent)`/`.withParents([...])` #21 diff --git a/pubspec.yaml b/pubspec.yaml index 9eceb2b2..887ae711 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: spot description: Chainable finders and better assertions for powerful widget tests. -version: 0.6.0 +version: 0.7.0 repository: https://github.com/passsy/spot issue_tracker: https://github.com/passsy/spot/issues