Skip to content

Commit

Permalink
Merge pull request #37 from Workiva/set-scope-to-body
Browse files Browse the repository at this point in the history
CPLAT-15997 Scope Queries to the Body Element
  • Loading branch information
rmconsole2-wf authored Nov 8, 2021
2 parents e0c3562 + 5f67ba4 commit 033034b
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 109 deletions.
2 changes: 1 addition & 1 deletion lib/src/react/render/render.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ RenderResult render(
/// {@category Queries}
@sealed
class RenderResult extends ScopedQueries {
RenderResult._(this._jsRenderResult, this._renderedElement) : super(() => _jsRenderResult.container);
RenderResult._(this._jsRenderResult, this._renderedElement) : super(() => _jsRenderResult.baseElement);

final JsRenderResult _jsRenderResult;

Expand Down
8 changes: 4 additions & 4 deletions test/unit/dom/queries/by_label_text_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('no form control was found associated to that label')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -105,7 +105,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('no form control was found associated to that label')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -121,7 +121,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('no form control was found associated to that label')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -138,7 +138,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('no form control was found associated to that label')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand Down
32 changes: 16 additions & 16 deletions test/unit/dom/queries/by_role_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void main() {
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an accessible element with the role "dialog"')),
hasToStringValue(contains('Here are the accessible roles:')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -124,7 +124,7 @@ void main() {
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an accessible element with the role "dialog"')),
hasToStringValue(contains('Here are the accessible roles:')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -141,7 +141,7 @@ void main() {
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an accessible element with the role "dialog"')),
hasToStringValue(contains('Here are the accessible roles:')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -159,7 +159,7 @@ void main() {
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an accessible element with the role "dialog"')),
hasToStringValue(contains('Here are the accessible roles:')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand Down Expand Up @@ -202,7 +202,7 @@ void main() {
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an accessible element with the role "option"')),
hasToStringValue(contains('Here are the accessible roles:')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -220,7 +220,7 @@ void main() {
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an accessible element with the role "option"')),
hasToStringValue(contains('Here are the accessible roles:')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -237,7 +237,7 @@ void main() {
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an accessible element with the role "option"')),
hasToStringValue(contains('Here are the accessible roles:')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -255,7 +255,7 @@ void main() {
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an accessible element with the role "option"')),
hasToStringValue(contains('Here are the accessible roles:')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand Down Expand Up @@ -498,7 +498,7 @@ void main() {
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an accessible element with the role "checkbox"')),
hasToStringValue(contains('Here are the accessible roles:')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -516,7 +516,7 @@ void main() {
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an accessible element with the role "checkbox"')),
hasToStringValue(contains('Here are the accessible roles:')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -533,7 +533,7 @@ void main() {
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an accessible element with the role "checkbox"')),
hasToStringValue(contains('Here are the accessible roles:')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -551,7 +551,7 @@ void main() {
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an accessible element with the role "checkbox"')),
hasToStringValue(contains('Here are the accessible roles:')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand Down Expand Up @@ -699,7 +699,7 @@ void main() {
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an accessible element with the role "switch"')),
hasToStringValue(contains('Here are the accessible roles:')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -717,7 +717,7 @@ void main() {
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an accessible element with the role "switch"')),
hasToStringValue(contains('Here are the accessible roles:')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -734,7 +734,7 @@ void main() {
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an accessible element with the role "switch"')),
hasToStringValue(contains('Here are the accessible roles:')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -752,7 +752,7 @@ void main() {
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an accessible element with the role "switch"')),
hasToStringValue(contains('Here are the accessible roles:')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand Down
40 changes: 20 additions & 20 deletions test/unit/dom/queries/by_testid_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Found multiple elements by: [$defaultTestIdKey="testId-2"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});

Expand All @@ -76,7 +76,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an element by: [$defaultTestIdKey="fail"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -96,7 +96,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an element by: [$defaultTestIdKey="fail"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -116,7 +116,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Found multiple elements by: [$defaultTestIdKey="testId-2"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});

Expand Down Expand Up @@ -154,7 +154,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Found multiple elements by: [$defaultTestIdKey="testId-2"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});

Expand All @@ -164,7 +164,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an element by: [$defaultTestIdKey="fail"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -184,7 +184,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an element by: [$defaultTestIdKey="fail"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -201,7 +201,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Found multiple elements by: [$defaultTestIdKey="estid-2"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -223,7 +223,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Found multiple elements by: [$defaultTestIdKey="estid-2"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -245,7 +245,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Found multiple elements by: [$defaultTestIdKey="estid-2"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand Down Expand Up @@ -290,7 +290,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Found multiple elements by: [$defaultTestIdKey="testId-3"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});

Expand All @@ -300,7 +300,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an element by: [$defaultTestIdKey="fail"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -324,7 +324,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an element by: [$defaultTestIdKey="fail"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -344,7 +344,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Found multiple elements by: [$defaultTestIdKey="testId-3"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});

Expand Down Expand Up @@ -386,7 +386,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Found multiple elements by: [$defaultTestIdKey="testId-2"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});

Expand All @@ -396,7 +396,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an element by: [$defaultTestIdKey="fail"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -420,7 +420,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Unable to find an element by: [$defaultTestIdKey="fail"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -437,7 +437,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Found multiple elements by: [$defaultTestIdKey="estid-2"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -461,7 +461,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Found multiple elements by: [$defaultTestIdKey="estid-2"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand All @@ -485,7 +485,7 @@ void main() {
throwsA(allOf(
isA<TestingLibraryElementError>(),
hasToStringValue(contains('Found multiple elements by: [$defaultTestIdKey="estid-2"]')),
hasToStringValue(contains(rtl.prettyDOM(view.container))),
hasToStringValue(contains(rtl.prettyDOM(view.baseElement))),
)));
});
});
Expand Down
Loading

0 comments on commit 033034b

Please sign in to comment.