Skip to content

Commit

Permalink
Merge v2.1.9
Browse files Browse the repository at this point in the history
- `ElementExtension`:
  - added `dispatchChangeEvent`.
- Added `SelectElementExtension`:
  - `selectIndex`.
- `BonesUITestRunner`:
  - Fix copy of `build` directory when it's already populated.
  - Improved console logging.
- `UITestChain`:
  - Added `selectIndex`, `where`.
- `UITestChainNode`:
  - Added `elementAs`.
- Added `TestNodeExtension` (on `dart:html.Node`):
  - `simplify`.
  • Loading branch information
gmpassos authored Jan 30, 2023
2 parents 11301e9 + b55e5dd commit 764125d
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 64 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 2.1.9

- `ElementExtension`:
- added `dispatchChangeEvent`.
- Added `SelectElementExtension`:
- `selectIndex`.
- `BonesUITestRunner`:
- Fix copy of `build` directory when it's already populated.
- Improved console logging.
- `UITestChain`:
- Added `selectIndex`, `where`.
- `UITestChainNode`:
- Added `elementAs`.
- Added `TestNodeExtension` (on `dart:html.Node`):
- `simplify`.

## 2.1.8

- `UITestChain`:
Expand Down
2 changes: 1 addition & 1 deletion lib/src/bones_ui.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class BonesUI {
static const String version = '2.1.8';
static const String version = '2.1.9';
}
11 changes: 11 additions & 0 deletions lib/src/bones_ui_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ extension ElementExtension on Element {
var value = elementValue;
return value == null || value.trim().isEmpty;
}

bool dispatchChangeEvent() => dispatchEvent(Event('change'));
}

extension IterableElementExtension<E extends Element> on Iterable<E> {
Expand All @@ -87,3 +89,12 @@ extension IterableElementExtension<E extends Element> on Iterable<E> {
/// Returns a [List] of values of this [Iterable] of [Element]s.
List<String?> get elementsValues => map((e) => e.elementValue).toList();
}

extension SelectElementExtension on SelectElement {
/// Selects an [index] and triggers the `change` event.
/// See [dispatchChangeEvent] and [selectedIndex].
bool selectIndex(int index) {
selectedIndex = index;
return dispatchChangeEvent();
}
}
28 changes: 19 additions & 9 deletions lib/src/bones_ui_test_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,6 @@ class BonesUITestRunner {
var jsonReportFile = File(jsonReportFilePath);
if (!jsonReportFile.existsSync()) return false;

print('** JSON REPORT: ${jsonReportFile.path}');

var jsonReport = jsonReportFile.readAsStringSync();

var lines = jsonReport.split(RegExp(r'}\n'));
Expand Down Expand Up @@ -344,13 +342,17 @@ class BonesUITestRunner {
}).toList();

if (documentLogs.isNotEmpty) {
printBox([
'LOG DIRECTORY: ${logDir.path}',
'» JSON report: ${jsonReportFile.path}',
'» Document logs: ${documentLogs.length}',
]);

var logBuildDir = Directory(pack_path.join(logDir.path, 'build'));
logBuildDir.createSync();

print('-- COPYING: ${bonesUICompileDir.path} -> ${logBuildDir.path}');
_copyPathSync(bonesUICompileDir.path, logBuildDir.path);

print('** DOCUMENT LOGS: ${documentLogs.length}');
_copyPathSync(bonesUICompileDir.path, logBuildDir.path,
clearIfExists: true);

for (var e in documentLogs) {
var id = e.id.trim().replaceAll(RegExp(r'\W+'), '_');
Expand Down Expand Up @@ -381,15 +383,15 @@ class BonesUITestRunner {
var f = File(fPath);
f.writeAsStringSync(content);

print(' -- $e >> $fPath');
print(' -- $e\n >> $fPath');
}
}

return true;
}

/// Copies a directory respecting relative links.
void _copyPathSync(String from, String to) {
void _copyPathSync(String from, String to, {bool clearIfExists = false}) {
if (pack_path.canonicalize(from) == pack_path.canonicalize(to)) {
return;
}
Expand All @@ -398,7 +400,15 @@ class BonesUITestRunner {
throw ArgumentError('Cannot copy from $from to $to');
}

Directory(to).createSync(recursive: true);
var toDir = Directory(to);

if (clearIfExists && toDir.existsSync()) {
print('-- CLEARING DIRECTORY: $to');
toDir.deleteSync(recursive: true);
}

print('-- COPYING: $from -> $to');
toDir.createSync(recursive: true);

var dirList = Directory(from).listSync(recursive: true, followLinks: false);

Expand Down
Loading

0 comments on commit 764125d

Please sign in to comment.