@serenity-js/web 3.0.0-rc.29 → 3.0.0-rc.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/lib/screenplay/interactions/Clear.d.ts +1 -1
- package/lib/screenplay/interactions/Clear.d.ts.map +1 -1
- package/lib/screenplay/interactions/Clear.js +15 -10
- package/lib/screenplay/interactions/Clear.js.map +1 -1
- package/lib/screenplay/models/BrowsingSession.js +3 -3
- package/lib/screenplay/models/BrowsingSession.js.map +1 -1
- package/package.json +4 -4
- package/src/screenplay/interactions/Clear.ts +21 -15
- package/src/screenplay/models/BrowsingSession.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.0.0-rc.30](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.29...v3.0.0-rc.30) (2022-10-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **web:** all web modules now correctly support handling iframe context for the current page ([bcb8672](https://github.com/serenity-js/serenity-js/commit/bcb86722dfcaa023613e63fb8bd2e14d6d546efd)), closes [#1310](https://github.com/serenity-js/serenity-js/issues/1310)
|
|
12
|
+
* **web:** corrected interaction to Clear to avoid issues with elements that have no value attribute ([37ae809](https://github.com/serenity-js/serenity-js/commit/37ae8092a36091db528024b99695905982ef8284)), closes [#1306](https://github.com/serenity-js/serenity-js/issues/1306)
|
|
13
|
+
* **web:** interaction to Clear now supports "contenteditable" elements ([d090458](https://github.com/serenity-js/serenity-js/commit/d090458845c23af59561d74421c16160ccc4ff64)), closes [#1306](https://github.com/serenity-js/serenity-js/issues/1306)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **web:** interaction to Clear works with "contenteditable" elements across all the web tools ([c53b00d](https://github.com/serenity-js/serenity-js/commit/c53b00dac512977c00e5eadc101e281997f8e0de)), closes [#1306](https://github.com/serenity-js/serenity-js/issues/1306)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
# [3.0.0-rc.29](https://github.com/serenity-js/serenity-js/compare/v3.0.0-rc.28...v3.0.0-rc.29) (2022-10-01)
|
|
7
25
|
|
|
8
26
|
**Note:** Version bump only for package @serenity-js/web
|
|
@@ -68,7 +68,7 @@ export declare class Clear extends PageElementInteraction {
|
|
|
68
68
|
* @inheritDoc
|
|
69
69
|
*/
|
|
70
70
|
performAs(actor: UsesAbilities & AnswersQuestions): Promise<void>;
|
|
71
|
-
private
|
|
71
|
+
private isClearable;
|
|
72
72
|
private capitaliseFirstLetter;
|
|
73
73
|
}
|
|
74
74
|
//# sourceMappingURL=Clear.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Clear.d.ts","sourceRoot":"","sources":["../../../src/screenplay/interactions/Clear.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAK,WAAW,EAAc,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE5G,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,qBAAa,KAAM,SAAQ,sBAAsB;IAcvB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAZ5C;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,WAAW;IAI9D,SAAS,aAA8B,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC;IAIrE;;OAEG;IACG,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"Clear.d.ts","sourceRoot":"","sources":["../../../src/screenplay/interactions/Clear.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAK,WAAW,EAAc,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE5G,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,qBAAa,KAAM,SAAQ,sBAAsB;IAcvB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAZ5C;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,WAAW;IAI9D,SAAS,aAA8B,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC;IAIrE;;OAEG;IACG,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;YAczD,WAAW;IAmBzB,OAAO,CAAC,qBAAqB;CAGhC"}
|
|
@@ -75,20 +75,25 @@ class Clear extends PageElementInteraction_1.PageElementInteraction {
|
|
|
75
75
|
*/
|
|
76
76
|
async performAs(actor) {
|
|
77
77
|
const element = await this.resolve(actor, this.field);
|
|
78
|
-
await this.
|
|
79
|
-
|
|
78
|
+
const isClearable = await this.isClearable(element);
|
|
79
|
+
if (!isClearable) {
|
|
80
|
+
throw new core_1.LogicError(this.capitaliseFirstLetter((0, core_1.d) `${this.field} doesn't seem like an element that could be cleared.`));
|
|
81
|
+
}
|
|
82
|
+
await element.clearValue();
|
|
80
83
|
}
|
|
81
|
-
async
|
|
82
|
-
|
|
84
|
+
async isClearable(element) {
|
|
85
|
+
const contentEditable = await element.attribute('contenteditable');
|
|
86
|
+
const hasContentEditableAttribute = contentEditable !== null && contentEditable !== undefined && contentEditable !== 'false'; // true or empty string mean content is editable
|
|
87
|
+
if (hasContentEditableAttribute) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
83
90
|
try {
|
|
84
91
|
const value = await element.value();
|
|
85
|
-
hasValueAttribute = value !== null && value !== undefined;
|
|
86
|
-
|
|
87
|
-
catch (error) {
|
|
88
|
-
threwError = error;
|
|
92
|
+
const hasValueAttribute = value !== null && value !== undefined;
|
|
93
|
+
return hasValueAttribute;
|
|
89
94
|
}
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
catch {
|
|
96
|
+
return false;
|
|
92
97
|
}
|
|
93
98
|
}
|
|
94
99
|
capitaliseFirstLetter(text) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Clear.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/Clear.ts"],"names":[],"mappings":";;;AAAA,4CAA4G;AAG5G,qEAAkE;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,MAAa,KAAM,SAAQ,+CAAsB;IAc7C,YAAuC,KAA8B;QACjE,KAAK,CAAC,IAAA,QAAC,EAAA,8BAA+B,KAAM,EAAE,CAAC,CAAC;QADb,UAAK,GAAL,KAAK,CAAyB;IAErE,CAAC;IAdD;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,KAA8B;QAC5C,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAMD;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,KAAuC;QACnD,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"Clear.js","sourceRoot":"","sources":["../../../src/screenplay/interactions/Clear.ts"],"names":[],"mappings":";;;AAAA,4CAA4G;AAG5G,qEAAkE;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,MAAa,KAA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AAC,IAAY;QACtC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;CACJ;AAzDD,sBAyDC"}
|
|
@@ -14,10 +14,10 @@ class BrowsingSession {
|
|
|
14
14
|
this.pages = new Map();
|
|
15
15
|
}
|
|
16
16
|
async closePagesOtherThan(pageOfInterest) {
|
|
17
|
-
for (const
|
|
18
|
-
if (page
|
|
17
|
+
for (const page of await this.allPages()) {
|
|
18
|
+
if (!page.id.equals(pageOfInterest.id)) {
|
|
19
19
|
await page.close();
|
|
20
|
-
this.pages.delete(
|
|
20
|
+
this.pages.delete(page.id);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
await this.changeCurrentPageTo(pageOfInterest);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowsingSession.js","sourceRoot":"","sources":["../../../src/screenplay/models/BrowsingSession.ts"],"names":[],"mappings":";;;AAIA;;;;;;;GAOG;AACH,MAAsB,eAAe;IAArC;QAEuB,UAAK,GAAkC,IAAI,GAAG,EAA4B,CAAC;IAoGlG,CAAC;IAlGG,KAAK,CAAC,mBAAmB,CAAC,cAAyB;QAC/C,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"BrowsingSession.js","sourceRoot":"","sources":["../../../src/screenplay/models/BrowsingSession.ts"],"names":[],"mappings":";;;AAIA;;;;;;;GAOG;AACH,MAAsB,eAAe;IAArC;QAEuB,UAAK,GAAkC,IAAI,GAAG,EAA4B,CAAC;IAoGlG,CAAC;IAlGG,KAAK,CAAC,mBAAmB,CAAC,cAAyB;QAC/C,KAAK,MAAM,IAAI,IAAI,MAAM,IAAI,CAAC,QAAQ,EAAE,EAAE;YACtC,IAAI,CAAE,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE;gBACrC,MAAM,IAAI,CAAC,KAAK,EAAE,C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AC,KAAK,CAAC,MAAM,EAAE,EAAE;YACpC,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;SACtB;QAED,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACnB,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;IACxC,CAAC;CACJ;AAtGD,0CAsGC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-js/web",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.30",
|
|
4
4
|
"description": "Serenity/JS Screenplay Pattern APIs for the Web",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jan Molak",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"npm": "^6 || ^7 || ^8"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@serenity-js/assertions": "3.0.0-rc.
|
|
48
|
-
"@serenity-js/core": "3.0.0-rc.
|
|
47
|
+
"@serenity-js/assertions": "3.0.0-rc.30",
|
|
48
|
+
"@serenity-js/core": "3.0.0-rc.30",
|
|
49
49
|
"tiny-types": "^1.19.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"ts-node": "^10.9.1",
|
|
58
58
|
"typescript": "^4.8.4"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "fa832ca71c7fb142db468a433a1c51a2bffe4667"
|
|
61
61
|
}
|
|
@@ -76,29 +76,35 @@ export class Clear extends PageElementInteraction {
|
|
|
76
76
|
* @inheritDoc
|
|
77
77
|
*/
|
|
78
78
|
async performAs(actor: UsesAbilities & AnswersQuestions): Promise<void> {
|
|
79
|
-
const element
|
|
79
|
+
const element = await this.resolve(actor, this.field);
|
|
80
80
|
|
|
81
|
-
await this.
|
|
81
|
+
const isClearable = await this.isClearable(element);
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
if (!isClearable) {
|
|
84
|
+
throw new LogicError(
|
|
85
|
+
this.capitaliseFirstLetter(d`${ this.field } doesn't seem like an element that could be cleared.`),
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
await element.clearValue();
|
|
84
90
|
}
|
|
85
91
|
|
|
86
|
-
private async
|
|
87
|
-
|
|
88
|
-
|
|
92
|
+
private async isClearable(element: PageElement): Promise<boolean> {
|
|
93
|
+
const contentEditable = await element.attribute('contenteditable');
|
|
94
|
+
const hasContentEditableAttribute = contentEditable !== null && contentEditable !== undefined && contentEditable !== 'false'; // true or empty string mean content is editable
|
|
95
|
+
|
|
96
|
+
if (hasContentEditableAttribute) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
89
99
|
|
|
90
100
|
try {
|
|
91
101
|
const value = await element.value();
|
|
92
|
-
hasValueAttribute = value !== null && value !== undefined;
|
|
93
|
-
} catch (error) {
|
|
94
|
-
threwError = error;
|
|
95
|
-
}
|
|
102
|
+
const hasValueAttribute = value !== null && value !== undefined;
|
|
96
103
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
);
|
|
104
|
+
return hasValueAttribute;
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return false;
|
|
102
108
|
}
|
|
103
109
|
}
|
|
104
110
|
|
|
@@ -15,10 +15,10 @@ export abstract class BrowsingSession<Page_Type extends Page> {
|
|
|
15
15
|
protected readonly pages: Map<CorrelationId, Page_Type> = new Map<CorrelationId, Page_Type>();
|
|
16
16
|
|
|
17
17
|
async closePagesOtherThan(pageOfInterest: Page_Type): Promise<void> {
|
|
18
|
-
for (const
|
|
19
|
-
if (page
|
|
18
|
+
for (const page of await this.allPages()) {
|
|
19
|
+
if (! page.id.equals(pageOfInterest.id)) {
|
|
20
20
|
await page.close();
|
|
21
|
-
this.pages.delete(
|
|
21
|
+
this.pages.delete(page.id);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|