-
Notifications
You must be signed in to change notification settings - Fork 1
fix(w-div): scan a className on any whitespace, not a single space #180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+111
−5
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:fluttersdk_wind/fluttersdk_wind.dart'; | ||
|
|
||
| /// The composition helpers scan a child's raw `className` for tokens, and this | ||
| /// project's own convention writes any className with 3+ concerns as a | ||
| /// triple-quoted string with one concern per line (`.claude/rules/widgets.md`). | ||
| /// | ||
| /// A scan that splits on a single space therefore sees `flex-1\n` rather than | ||
| /// `flex-1` for every token that ends a line, and misses it. Each helper fails | ||
| /// differently when that happens, so each gets its own case here: the wrap is | ||
| /// applied twice, or applied where it should not be, or skipped where it should | ||
| /// not be. | ||
| void main() { | ||
| setUp(() { | ||
| WindParser.clearCache(); | ||
| }); | ||
|
|
||
| /// Pumps [child] inside a fixed-width Wind surface. | ||
| Future<void> pumpAt(WidgetTester tester, double width, Widget child) { | ||
| return tester.pumpWidget( | ||
| MaterialApp( | ||
| home: WindTheme( | ||
| data: WindThemeData(), | ||
| child: Align( | ||
| alignment: Alignment.topLeft, | ||
| child: SizedBox(width: width, child: child), | ||
| ), | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| testWidgets( | ||
| 'a multi-line flex-1 child is not wrapped a second time', | ||
| (tester) async { | ||
| // `_selfWrapsInFlex` guards against exactly this: the child already | ||
| // carries its own Expanded, so a parent Flexible on top of it throws | ||
| // "Incorrect use of ParentDataWidget". `overflow-hidden` wraps | ||
| // unconditionally, which is the shortest route to the double wrap. | ||
| await pumpAt( | ||
| tester, | ||
| 400, | ||
| const WDiv( | ||
| className: 'flex flex-row items-center overflow-hidden', | ||
| children: [ | ||
| WDiv( | ||
| className: ''' | ||
| flex-1 | ||
| bg-white dark:bg-gray-800 | ||
| ''', | ||
| child: SizedBox(height: 20), | ||
| ), | ||
| WDiv(child: SizedBox(width: 24, height: 24)), | ||
| ], | ||
| ), | ||
| ); | ||
|
|
||
| expect(tester.takeException(), isNull); | ||
| }, | ||
| ); | ||
|
|
||
| testWidgets( | ||
| 'a multi-line shrink-0 child keeps its intrinsic width', | ||
| (tester) async { | ||
| // `shrink-0` is the caller saying "never shrink me". Missing the token | ||
| // wraps the child in a Flexible, whose share in a crowded row is smaller | ||
| // than the width it asked for. | ||
| await pumpAt( | ||
| tester, | ||
| 100, | ||
| const WDiv( | ||
| className: 'flex flex-row items-center overflow-hidden', | ||
| children: [ | ||
| WDiv( | ||
| key: Key('fixed'), | ||
| className: ''' | ||
| w-24 shrink-0 | ||
| bg-white dark:bg-gray-800 | ||
| ''', | ||
| child: SizedBox(height: 20), | ||
| ), | ||
| WText('Very Long Value Text That Cannot Fit', className: 'text-sm'), | ||
| ], | ||
| ), | ||
| ); | ||
|
|
||
| expect(tester.getSize(find.byKey(const Key('fixed'))).width, 96); | ||
| }, | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.