Skip to content

Commit

Permalink
Merge v2.1.10
Browse files Browse the repository at this point in the history
- `bones_ui_test_tools.dart`:
  - `UITestChain` with `Iterable` `element`: - Added `elementsLength` `expectElementsLength`, `elementAt`, `first`, `firstOr`
  - Moved from extension to `UITestChain`:
    - `click`, `setValue` and `selectIndex`.
  - `_mergeStackStraces`: - Remove some bottom lines from `stack1` (after `TestFutureExtension.thenWithStackTrace`).
- `bones_ui_test_cli.dart`:
- `_DocumentLog`:
  - Now appending to the document `<title>` the logging `id`.
  • Loading branch information
gmpassos authored Jan 31, 2023
2 parents 764125d + 8729bd6 commit 79f0840
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 117 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 2.1.10

- `bones_ui_test_tools.dart`:
- `UITestChain` with `Iterable` `element`:
- Added `elementsLength` `expectElementsLength`, `elementAt`, `first`, `firstOr`
- Moved from extension to `UITestChain`:
- `click`, `setValue` and `selectIndex`.
- `_mergeStackStraces`:
- Remove some bottom lines from `stack1` (after `TestFutureExtension.thenWithStackTrace`).
- `bones_ui_test_cli.dart`:
- `_DocumentLog`:
- Now appending to the document `<title>` the logging `id`.

## 2.1.9

- `ElementExtension`:
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.9';
static const String version = '2.1.10';
}
33 changes: 31 additions & 2 deletions lib/src/bones_ui_test_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ class BonesUITestRunner {
var fPath = pack_path.join(documentsLogDir.path,
'document_log--$id--${e.time.millisecondsSinceEpoch}.html');

var content = e.contentWithBasePath(basePath);
var content = e.contentResolved(basePath: basePath, title: e.id);

var f = File(fPath);
f.writeAsStringSync(content);
Expand Down Expand Up @@ -901,9 +901,21 @@ class _DocumentLog {
decompressed: decompressed, testPath: testPath);
}

String contentWithBasePath(String basePath) {
String contentResolved({String? basePath, String? title}) {
var content = this.content;

if (basePath != null && basePath.isNotEmpty) {
content = _setContentBasePath(content, basePath);
}

if (title != null && title.trim().isNotEmpty) {
content = _setContentTitle(content, title);
}

return content;
}

String _setContentBasePath(String content, String basePath) {
var m = RegExp(r'<base\s+href="(.*?)"(.*?)>',
caseSensitive: false, dotAll: true)
.firstMatch(content);
Expand All @@ -917,7 +929,24 @@ class _DocumentLog {
content = content.replaceFirst(
RegExp(r'<head>'), '<head><base href="$basePath">');
}
return content;
}

String _setContentTitle(String content, String title) {
title = title.trim();

var m = RegExp(r'<title>(.*?)</title>', caseSensitive: false, dotAll: true)
.firstMatch(content);

if (m != null) {
var prevTitle = m.group(1) ?? '';

content = content.replaceFirst(
RegExp(r'<title>.*?</title>'), '<title>$prevTitle - $title</title>');
} else {
content = content.replaceFirst(
RegExp(r'<title>.*?</title>'), '<title>$title</title>');
}
return content;
}

Expand Down
Loading

0 comments on commit 79f0840

Please sign in to comment.