@agnos-ui/page-objects 0.0.1-alpha.0
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/README.md +26 -0
- package/dist/lib/index.d.ts +225 -0
- package/dist/lib/index.js +1 -0
- package/dist/lib/index.mjs +347 -0
- package/dist/lib/tsdoc-metadata.json +11 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @agnos-ui/page-objects
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@agnos-ui/page-objects)
|
|
4
|
+
|
|
5
|
+
Page objects to be used when testing AgnosUI-based applications with Playwright.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install -D @agnos-ui/page-objects
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Here is a sample test using the `RatingPO`:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import {expect, test} from '@playwright/test';
|
|
19
|
+
import {RatingPO} from '@agnos-ui/page-objects';
|
|
20
|
+
|
|
21
|
+
test(`Click on rating star`, async ({page}) => {
|
|
22
|
+
const ratingPO = new RatingPO(page);
|
|
23
|
+
await ratingPO.locatorRoot.waitFor();
|
|
24
|
+
await ratingPO.locatorStar(4).click();
|
|
25
|
+
});
|
|
26
|
+
```
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { BasePO } from '@agnos-ui/base-po';
|
|
2
|
+
import type { Locator } from '@playwright/test';
|
|
3
|
+
import { Locator as Locator_2 } from 'playwright-core';
|
|
4
|
+
|
|
5
|
+
export declare class AccordionPO extends BasePO {
|
|
6
|
+
private readonly selectors;
|
|
7
|
+
getComponentSelector(): string;
|
|
8
|
+
/**
|
|
9
|
+
* Gets the locators of the items containing the header and the collapse inside
|
|
10
|
+
* the accordion
|
|
11
|
+
*/
|
|
12
|
+
get locatorAccordionItems(): Locator;
|
|
13
|
+
/**
|
|
14
|
+
* Gets the locators of the item specified by the itemIndex containing the header and the collapse inside
|
|
15
|
+
* the accordion
|
|
16
|
+
*/
|
|
17
|
+
locatorAccordionItem(itemIndex: number): Locator;
|
|
18
|
+
get locatorAccordionCollapses(): Locator;
|
|
19
|
+
locatorAccordionCollapse(collapseIndex: number): Locator;
|
|
20
|
+
/**
|
|
21
|
+
* Gets the locator of the bodies of the accordion.
|
|
22
|
+
*/
|
|
23
|
+
get locatorAccordionBodies(): Locator;
|
|
24
|
+
locatorAccordionBody(bodyIndex: number): Locator;
|
|
25
|
+
get locatorAccordionHeaders(): Locator;
|
|
26
|
+
locatorAccordionHeader(headerIndex: number): Locator;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the locators of the buttons that handle the accordion, present in the accordion header.
|
|
29
|
+
* It does not get the locators of the buttons present in the body, added by the developer.
|
|
30
|
+
*/
|
|
31
|
+
get locatorAccordionButtons(): Locator;
|
|
32
|
+
locatorAccordionButton(buttonIndex: number): Locator;
|
|
33
|
+
state(): Promise<{
|
|
34
|
+
rootClasses: string[];
|
|
35
|
+
items: {
|
|
36
|
+
classes: string[];
|
|
37
|
+
id: string;
|
|
38
|
+
isInDOM: boolean;
|
|
39
|
+
collapseId: string | undefined;
|
|
40
|
+
buttonId: string | undefined;
|
|
41
|
+
expanded: string | null | undefined;
|
|
42
|
+
disabled: string | null | undefined;
|
|
43
|
+
labeledBy: string | null | undefined;
|
|
44
|
+
buttonControls: string | null | undefined;
|
|
45
|
+
}[];
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export declare class AlertPO extends BasePO {
|
|
50
|
+
selectors: {
|
|
51
|
+
rootComponent: string;
|
|
52
|
+
closeButton: string;
|
|
53
|
+
};
|
|
54
|
+
getComponentSelector(): string;
|
|
55
|
+
locatorCloseButton(): Locator;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export declare const alertSelectors: {
|
|
59
|
+
rootComponent: string;
|
|
60
|
+
closeButton: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export declare class ModalPO extends BasePO {
|
|
64
|
+
selectors: {
|
|
65
|
+
rootComponent: string;
|
|
66
|
+
closeButton: string;
|
|
67
|
+
backdrop: string;
|
|
68
|
+
header: string;
|
|
69
|
+
title: string;
|
|
70
|
+
body: string;
|
|
71
|
+
footer: string;
|
|
72
|
+
};
|
|
73
|
+
getComponentSelector(): string;
|
|
74
|
+
locatorHeader(): Locator;
|
|
75
|
+
locatorTitle(): Locator;
|
|
76
|
+
locatorBody(): Locator;
|
|
77
|
+
locatorFooter(): Locator;
|
|
78
|
+
locatorCloseButton(): Locator;
|
|
79
|
+
locatorBackdrop(): Locator;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export declare const modalSelectors: {
|
|
83
|
+
rootComponent: string;
|
|
84
|
+
closeButton: string;
|
|
85
|
+
backdrop: string;
|
|
86
|
+
header: string;
|
|
87
|
+
title: string;
|
|
88
|
+
body: string;
|
|
89
|
+
footer: string;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export declare class PaginationPO extends BasePO {
|
|
93
|
+
selectors: {
|
|
94
|
+
rootComponent: string;
|
|
95
|
+
activePage: string;
|
|
96
|
+
previousPage: string;
|
|
97
|
+
nextPage: string;
|
|
98
|
+
firstPage: string;
|
|
99
|
+
lastPage: string;
|
|
100
|
+
pages: string;
|
|
101
|
+
ellipses: string;
|
|
102
|
+
};
|
|
103
|
+
getComponentSelector(): string;
|
|
104
|
+
/**
|
|
105
|
+
* Gets the locator of the button is the current page in the pagination component.
|
|
106
|
+
*/
|
|
107
|
+
get locatorActivePage(): Locator;
|
|
108
|
+
/**
|
|
109
|
+
* Gets the locator of the button that once clicked moves to the previous page in the pagination component.
|
|
110
|
+
*/
|
|
111
|
+
get locatorPreviousButton(): Locator;
|
|
112
|
+
/**
|
|
113
|
+
* Gets the locator of the button that once clicked moves to the next page in the pagination component.
|
|
114
|
+
*/
|
|
115
|
+
get locatorNextButton(): Locator;
|
|
116
|
+
/**
|
|
117
|
+
* Gets the locator of the button that once clicked moves to the first page in the pagination component.
|
|
118
|
+
*/
|
|
119
|
+
get locatorFirstButton(): Locator;
|
|
120
|
+
/**
|
|
121
|
+
* Gets the locator of the button that once clicked moves to the last page in the pagination component.
|
|
122
|
+
*/
|
|
123
|
+
get locatorLastButton(): Locator;
|
|
124
|
+
/**
|
|
125
|
+
* Gets the locators of the pages
|
|
126
|
+
*/
|
|
127
|
+
get locatorPages(): Locator;
|
|
128
|
+
/**
|
|
129
|
+
* Gets the locator of a page button in the pagination component given his position.
|
|
130
|
+
* @param pageNumber - The number of the page in the pagination object.
|
|
131
|
+
*/
|
|
132
|
+
locatorNthPage(pageNumber: number): Locator;
|
|
133
|
+
/**
|
|
134
|
+
* Gets the locator of a page button in the pagination component given a string.
|
|
135
|
+
* @param pageString - The string of the page in the pagination object.
|
|
136
|
+
*/
|
|
137
|
+
locatorPage(pageString: string): Locator;
|
|
138
|
+
get locatorEllipses(): Locator;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export declare const paginationSelectors: {
|
|
142
|
+
rootComponent: string;
|
|
143
|
+
activePage: string;
|
|
144
|
+
previousPage: string;
|
|
145
|
+
nextPage: string;
|
|
146
|
+
firstPage: string;
|
|
147
|
+
lastPage: string;
|
|
148
|
+
pages: string;
|
|
149
|
+
ellipses: string;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export declare class RatingPO extends BasePO {
|
|
153
|
+
selectors: {
|
|
154
|
+
rootComponent: string;
|
|
155
|
+
star: string;
|
|
156
|
+
};
|
|
157
|
+
getComponentSelector(): string;
|
|
158
|
+
/**
|
|
159
|
+
* Get the main title locator of the feature page
|
|
160
|
+
*/
|
|
161
|
+
locatorStar(index: number): Locator_2;
|
|
162
|
+
state(): Promise<{
|
|
163
|
+
rootClasses: string[];
|
|
164
|
+
value: string | null;
|
|
165
|
+
min: string | null;
|
|
166
|
+
max: string | null;
|
|
167
|
+
text: string | null;
|
|
168
|
+
disabled: string | null;
|
|
169
|
+
readonly: string | null;
|
|
170
|
+
stars: string[];
|
|
171
|
+
classes: string[][];
|
|
172
|
+
}>;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export declare const ratingSelectors: {
|
|
176
|
+
rootComponent: string;
|
|
177
|
+
star: string;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export declare class SelectPO extends BasePO {
|
|
181
|
+
selectors: {
|
|
182
|
+
rootComponent: string;
|
|
183
|
+
};
|
|
184
|
+
getComponentSelector(): string;
|
|
185
|
+
/**
|
|
186
|
+
* Get the main title locator of the feature page
|
|
187
|
+
*/
|
|
188
|
+
get locatorInput(): Locator_2;
|
|
189
|
+
/**
|
|
190
|
+
* Menu container
|
|
191
|
+
*/
|
|
192
|
+
get locatorMenu(): Locator_2;
|
|
193
|
+
/**
|
|
194
|
+
* Return the first menu item locator including the text
|
|
195
|
+
*/
|
|
196
|
+
locatorMenuItem(text: string): Locator_2;
|
|
197
|
+
/**
|
|
198
|
+
* Bages container
|
|
199
|
+
*/
|
|
200
|
+
get locatorBadges(): Locator_2;
|
|
201
|
+
/**
|
|
202
|
+
* Return the first badge locator including the text
|
|
203
|
+
*/
|
|
204
|
+
locatorBadgeItem(text: string): Locator_2;
|
|
205
|
+
/**
|
|
206
|
+
* Return the cross locator for the first badge including the text
|
|
207
|
+
*/
|
|
208
|
+
locatorBadgeItemCross(text: string): Locator_2;
|
|
209
|
+
state(): Promise<{
|
|
210
|
+
text: string;
|
|
211
|
+
badges: string[][];
|
|
212
|
+
isOpen: boolean;
|
|
213
|
+
list: {
|
|
214
|
+
text: string | undefined;
|
|
215
|
+
hasCheckBox: boolean;
|
|
216
|
+
isChecked: boolean;
|
|
217
|
+
}[];
|
|
218
|
+
}>;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export declare const selectSelectors: {
|
|
222
|
+
rootComponent: string;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export { }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var x=Object.defineProperty;var R=(s,e,t)=>e in s?x(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var l=(s,e,t)=>(R(s,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@agnos-ui/base-po"),A={rootComponent:".modal",closeButton:".btn-close",backdrop:"xpath=./preceding-sibling::div[contains(@class,'modal-backdrop')]",header:".modal-header",title:".modal-title",body:".modal-body",footer:".modal-footer"};class v extends n.BasePO{constructor(){super(...arguments);l(this,"selectors",structuredClone(A))}getComponentSelector(){return this.selectors.rootComponent}locatorHeader(){return this.locatorRoot.locator(this.selectors.header)}locatorTitle(){return this.locatorHeader().locator(this.selectors.title)}locatorBody(){return this.locatorRoot.locator(this.selectors.body)}locatorFooter(){return this.locatorRoot.locator(this.selectors.footer)}locatorCloseButton(){return this.locatorRoot.locator(this.selectors.closeButton)}locatorBackdrop(){return this.locatorRoot.locator(this.selectors.backdrop)}}const C={rootComponent:".au-pagination",activePage:".active",previousPage:".au-previous",nextPage:".au-next",firstPage:".au-first",lastPage:".au-last",pages:".au-page",ellipses:".au-ellipsis"};class f extends n.BasePO{constructor(){super(...arguments);l(this,"selectors",structuredClone(C))}getComponentSelector(){return this.selectors.rootComponent}get locatorActivePage(){return this.locatorRoot.locator(this.selectors.activePage)}get locatorPreviousButton(){return this.locatorRoot.locator(this.selectors.previousPage)}get locatorNextButton(){return this.locatorRoot.locator(this.selectors.nextPage)}get locatorFirstButton(){return this.locatorRoot.locator(this.selectors.firstPage)}get locatorLastButton(){return this.locatorRoot.locator(this.selectors.lastPage)}get locatorPages(){return this.locatorRoot.locator(this.selectors.pages)}locatorNthPage(t){return this.locatorRoot.locator(this.selectors.pages).nth(t-1)}locatorPage(t){return this.locatorRoot.locator(this.selectors.pages,{hasText:t})}get locatorEllipses(){return this.locatorRoot.locator(this.selectors.ellipses)}}const P={rootComponent:".au-rating",star:".au-rating-star"};class O extends n.BasePO{constructor(){super(...arguments);l(this,"selectors",structuredClone(P))}getComponentSelector(){return this.selectors.rootComponent}locatorStar(t){return this.locatorRoot.locator(this.selectors.star).nth(t)}async state(){return await this.locatorRoot.evaluate((t,i)=>{const c=[...t.querySelectorAll(i.star)],a=[],r=[];for(const o of c)a.push((o.textContent||"").trim()),r.push(o.className.split(" "));return{rootClasses:t.className.trim().split(" "),value:t.getAttribute("aria-valuenow"),min:t.getAttribute("aria-valuemin"),max:t.getAttribute("aria-valuemax"),text:t.getAttribute("aria-valuetext"),disabled:t.getAttribute("aria-disabled"),readonly:t.getAttribute("aria-readonly"),stars:a,classes:r}},this.selectors)}}const S={rootComponent:".au-select"};class I extends n.BasePO{constructor(){super(...arguments);l(this,"selectors",structuredClone(S))}getComponentSelector(){return this.selectors.rootComponent}get locatorInput(){return this.locatorRoot.locator("div.input-group").locator("input")}get locatorMenu(){return this.locatorRoot.locator(".dropdown-menu")}locatorMenuItem(t){return this.locatorMenu.getByText(t).nth(0)}get locatorBadges(){return this.locatorRoot.locator("div.input-group").locator(".input-group-text")}locatorBadgeItem(t){return this.locatorBadges.locator("div.badge").filter({hasText:t}).nth(0)}locatorBadgeItemCross(t){return this.locatorBadgeItem(t).getByRole("button")}async state(){return await this.locatorRoot.evaluate(t=>{var m;const i=t.querySelector(".input-group"),c=t.querySelector("div.input-group-text"),a=i.querySelector("input"),r=[];if(c){const g=c.querySelectorAll("div.badge");for(const u of g){const d=[...u.children];r.push([...d.map(h=>(h.textContent??"").trim())])}}const o=t.querySelector("ul.dropdown-menu"),B=o!=null,p=[];if(o!=null){const g=o.querySelectorAll("li.dropdown-item");for(const u of g){let d=!1,h=!1;const b=u.querySelector("input.form-check-input");b&&(d=!0,h=b.checked),p.push({text:(m=u.textContent)==null?void 0:m.trim(),hasCheckBox:d,isChecked:h})}}return{text:a.value,badges:r,isOpen:B,list:p}})}}const y={rootComponent:".alert",closeButton:".btn-close"};class q extends n.BasePO{constructor(){super(...arguments);l(this,"selectors",structuredClone(y))}getComponentSelector(){return this.selectors.rootComponent}locatorCloseButton(){return this.locatorRoot.locator(this.selectors.closeButton)}}class k extends n.BasePO{constructor(){super(...arguments);l(this,"selectors",{item:".accordion-item",collapse:".accordion-collapse",body:".accordion-body",header:".accordion-header",buttons:".accordion-button"})}getComponentSelector(){return".accordion"}get locatorAccordionItems(){return this.locatorRoot.locator(this.selectors.item)}locatorAccordionItem(t){return this.locatorRoot.locator(this.selectors.item).nth(t)}get locatorAccordionCollapses(){return this.locatorAccordionItems.locator(this.selectors.collapse)}locatorAccordionCollapse(t){return this.locatorAccordionItem(t).locator(this.selectors.collapse)}get locatorAccordionBodies(){return this.locatorAccordionCollapses.locator(this.selectors.body)}locatorAccordionBody(t){return this.locatorAccordionCollapse(t).locator(this.selectors.body)}get locatorAccordionHeaders(){return this.locatorAccordionItems.locator(this.selectors.header)}locatorAccordionHeader(t){return this.locatorAccordionItem(t).locator(this.selectors.header)}get locatorAccordionButtons(){return this.locatorAccordionHeaders.locator(this.selectors.buttons)}locatorAccordionButton(t){return this.locatorAccordionHeader(t).locator(this.selectors.buttons)}async state(){return await this.locatorRoot.evaluate(t=>{const i=[...t.querySelectorAll(".accordion-item")],c=[];for(const a of i){const r=a.querySelector(".accordion-collapse"),o=a.querySelector(".accordion-button");c.push({classes:a.className.trim().split(" "),id:a.id,isInDOM:r!==null,collapseId:r==null?void 0:r.id,buttonId:o==null?void 0:o.id,expanded:o==null?void 0:o.getAttribute("aria-expanded"),disabled:o==null?void 0:o.getAttribute("aria-disabled"),labeledBy:r==null?void 0:r.getAttribute("aria-labelledby"),buttonControls:o==null?void 0:o.getAttribute("aria-controls")})}return{rootClasses:t.className.trim().split(" "),items:c}})}}exports.AccordionPO=k;exports.AlertPO=q;exports.ModalPO=v;exports.PaginationPO=f;exports.RatingPO=O;exports.SelectPO=I;exports.alertSelectors=y;exports.modalSelectors=A;exports.paginationSelectors=C;exports.ratingSelectors=P;exports.selectSelectors=S;
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
var A = Object.defineProperty;
|
|
2
|
+
var x = (s, e, t) => e in s ? A(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var l = (s, e, t) => (x(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import { BasePO as n } from "@agnos-ui/base-po";
|
|
5
|
+
const y = {
|
|
6
|
+
// TODO: should we use bootstrap-independent classes starting with au- ?
|
|
7
|
+
rootComponent: ".modal",
|
|
8
|
+
closeButton: ".btn-close",
|
|
9
|
+
backdrop: "xpath=./preceding-sibling::div[contains(@class,'modal-backdrop')]",
|
|
10
|
+
header: ".modal-header",
|
|
11
|
+
title: ".modal-title",
|
|
12
|
+
body: ".modal-body",
|
|
13
|
+
footer: ".modal-footer"
|
|
14
|
+
};
|
|
15
|
+
class I extends n {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
l(this, "selectors", structuredClone(y));
|
|
19
|
+
}
|
|
20
|
+
getComponentSelector() {
|
|
21
|
+
return this.selectors.rootComponent;
|
|
22
|
+
}
|
|
23
|
+
// TODO: should we expose getters instead?
|
|
24
|
+
locatorHeader() {
|
|
25
|
+
return this.locatorRoot.locator(this.selectors.header);
|
|
26
|
+
}
|
|
27
|
+
locatorTitle() {
|
|
28
|
+
return this.locatorHeader().locator(this.selectors.title);
|
|
29
|
+
}
|
|
30
|
+
locatorBody() {
|
|
31
|
+
return this.locatorRoot.locator(this.selectors.body);
|
|
32
|
+
}
|
|
33
|
+
locatorFooter() {
|
|
34
|
+
return this.locatorRoot.locator(this.selectors.footer);
|
|
35
|
+
}
|
|
36
|
+
locatorCloseButton() {
|
|
37
|
+
return this.locatorRoot.locator(this.selectors.closeButton);
|
|
38
|
+
}
|
|
39
|
+
locatorBackdrop() {
|
|
40
|
+
return this.locatorRoot.locator(this.selectors.backdrop);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const B = {
|
|
44
|
+
rootComponent: ".au-pagination",
|
|
45
|
+
activePage: ".active",
|
|
46
|
+
previousPage: ".au-previous",
|
|
47
|
+
nextPage: ".au-next",
|
|
48
|
+
firstPage: ".au-first",
|
|
49
|
+
lastPage: ".au-last",
|
|
50
|
+
pages: ".au-page",
|
|
51
|
+
ellipses: ".au-ellipsis"
|
|
52
|
+
};
|
|
53
|
+
class q extends n {
|
|
54
|
+
constructor() {
|
|
55
|
+
super(...arguments);
|
|
56
|
+
l(this, "selectors", structuredClone(B));
|
|
57
|
+
}
|
|
58
|
+
// TODO should we add this in the list of selector ?
|
|
59
|
+
// Depend on the setSelectors usage...
|
|
60
|
+
getComponentSelector() {
|
|
61
|
+
return this.selectors.rootComponent;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Gets the locator of the button is the current page in the pagination component.
|
|
65
|
+
*/
|
|
66
|
+
get locatorActivePage() {
|
|
67
|
+
return this.locatorRoot.locator(this.selectors.activePage);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Gets the locator of the button that once clicked moves to the previous page in the pagination component.
|
|
71
|
+
*/
|
|
72
|
+
get locatorPreviousButton() {
|
|
73
|
+
return this.locatorRoot.locator(this.selectors.previousPage);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Gets the locator of the button that once clicked moves to the next page in the pagination component.
|
|
77
|
+
*/
|
|
78
|
+
get locatorNextButton() {
|
|
79
|
+
return this.locatorRoot.locator(this.selectors.nextPage);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Gets the locator of the button that once clicked moves to the first page in the pagination component.
|
|
83
|
+
*/
|
|
84
|
+
get locatorFirstButton() {
|
|
85
|
+
return this.locatorRoot.locator(this.selectors.firstPage);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Gets the locator of the button that once clicked moves to the last page in the pagination component.
|
|
89
|
+
*/
|
|
90
|
+
get locatorLastButton() {
|
|
91
|
+
return this.locatorRoot.locator(this.selectors.lastPage);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Gets the locators of the pages
|
|
95
|
+
*/
|
|
96
|
+
get locatorPages() {
|
|
97
|
+
return this.locatorRoot.locator(this.selectors.pages);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Gets the locator of a page button in the pagination component given his position.
|
|
101
|
+
* @param pageNumber - The number of the page in the pagination object.
|
|
102
|
+
*/
|
|
103
|
+
locatorNthPage(t) {
|
|
104
|
+
return this.locatorRoot.locator(this.selectors.pages).nth(t - 1);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Gets the locator of a page button in the pagination component given a string.
|
|
108
|
+
* @param pageString - The string of the page in the pagination object.
|
|
109
|
+
*/
|
|
110
|
+
locatorPage(t) {
|
|
111
|
+
return this.locatorRoot.locator(this.selectors.pages, { hasText: t });
|
|
112
|
+
}
|
|
113
|
+
get locatorEllipses() {
|
|
114
|
+
return this.locatorRoot.locator(this.selectors.ellipses);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const R = {
|
|
118
|
+
rootComponent: ".au-rating",
|
|
119
|
+
star: ".au-rating-star"
|
|
120
|
+
};
|
|
121
|
+
class k extends n {
|
|
122
|
+
constructor() {
|
|
123
|
+
super(...arguments);
|
|
124
|
+
l(this, "selectors", structuredClone(R));
|
|
125
|
+
}
|
|
126
|
+
getComponentSelector() {
|
|
127
|
+
return this.selectors.rootComponent;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Get the main title locator of the feature page
|
|
131
|
+
*/
|
|
132
|
+
locatorStar(t) {
|
|
133
|
+
return this.locatorRoot.locator(this.selectors.star).nth(t);
|
|
134
|
+
}
|
|
135
|
+
// TODO to be pushed to the test itself
|
|
136
|
+
// We already discuss with Guillaume Saas not to put this in the basic PO which should only return locator basically
|
|
137
|
+
async state() {
|
|
138
|
+
return await this.locatorRoot.evaluate((t, i) => {
|
|
139
|
+
const a = [...t.querySelectorAll(i.star)], c = [], r = [];
|
|
140
|
+
for (const o of a)
|
|
141
|
+
c.push((o.textContent || "").trim()), r.push(o.className.split(" "));
|
|
142
|
+
return {
|
|
143
|
+
rootClasses: t.className.trim().split(" "),
|
|
144
|
+
value: t.getAttribute("aria-valuenow"),
|
|
145
|
+
min: t.getAttribute("aria-valuemin"),
|
|
146
|
+
max: t.getAttribute("aria-valuemax"),
|
|
147
|
+
text: t.getAttribute("aria-valuetext"),
|
|
148
|
+
disabled: t.getAttribute("aria-disabled"),
|
|
149
|
+
readonly: t.getAttribute("aria-readonly"),
|
|
150
|
+
stars: c,
|
|
151
|
+
classes: r
|
|
152
|
+
};
|
|
153
|
+
}, this.selectors);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const S = {
|
|
157
|
+
rootComponent: ".au-select"
|
|
158
|
+
// TODO add selector list
|
|
159
|
+
};
|
|
160
|
+
class O extends n {
|
|
161
|
+
constructor() {
|
|
162
|
+
super(...arguments);
|
|
163
|
+
l(this, "selectors", structuredClone(S));
|
|
164
|
+
}
|
|
165
|
+
getComponentSelector() {
|
|
166
|
+
return this.selectors.rootComponent;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Get the main title locator of the feature page
|
|
170
|
+
*/
|
|
171
|
+
get locatorInput() {
|
|
172
|
+
return this.locatorRoot.locator("div.input-group").locator("input");
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Menu container
|
|
176
|
+
*/
|
|
177
|
+
get locatorMenu() {
|
|
178
|
+
return this.locatorRoot.locator(".dropdown-menu");
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Return the first menu item locator including the text
|
|
182
|
+
*/
|
|
183
|
+
locatorMenuItem(t) {
|
|
184
|
+
return this.locatorMenu.getByText(t).nth(0);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Bages container
|
|
188
|
+
*/
|
|
189
|
+
get locatorBadges() {
|
|
190
|
+
return this.locatorRoot.locator("div.input-group").locator(".input-group-text");
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Return the first badge locator including the text
|
|
194
|
+
*/
|
|
195
|
+
locatorBadgeItem(t) {
|
|
196
|
+
return this.locatorBadges.locator("div.badge").filter({ hasText: t }).nth(0);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Return the cross locator for the first badge including the text
|
|
200
|
+
*/
|
|
201
|
+
locatorBadgeItemCross(t) {
|
|
202
|
+
return this.locatorBadgeItem(t).getByRole("button");
|
|
203
|
+
}
|
|
204
|
+
// TODO to be pushed to the test itself
|
|
205
|
+
// We already discuss with Guillaume Saas not to put this in the basic PO which should only return locator basically
|
|
206
|
+
async state() {
|
|
207
|
+
return await this.locatorRoot.evaluate((t) => {
|
|
208
|
+
var m;
|
|
209
|
+
const i = t.querySelector(".input-group"), a = t.querySelector("div.input-group-text"), c = i.querySelector("input"), r = [];
|
|
210
|
+
if (a) {
|
|
211
|
+
const p = a.querySelectorAll("div.badge");
|
|
212
|
+
for (const u of p) {
|
|
213
|
+
const d = [...u.children];
|
|
214
|
+
r.push([...d.map((h) => (h.textContent ?? "").trim())]);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const o = t.querySelector("ul.dropdown-menu"), C = o != null, g = [];
|
|
218
|
+
if (o != null) {
|
|
219
|
+
const p = o.querySelectorAll("li.dropdown-item");
|
|
220
|
+
for (const u of p) {
|
|
221
|
+
let d = !1, h = !1;
|
|
222
|
+
const b = u.querySelector("input.form-check-input");
|
|
223
|
+
b && (d = !0, h = b.checked), g.push({
|
|
224
|
+
text: (m = u.textContent) == null ? void 0 : m.trim(),
|
|
225
|
+
hasCheckBox: d,
|
|
226
|
+
isChecked: h
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
text: c.value,
|
|
232
|
+
badges: r,
|
|
233
|
+
isOpen: C,
|
|
234
|
+
list: g
|
|
235
|
+
};
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
const f = {
|
|
240
|
+
rootComponent: ".alert",
|
|
241
|
+
closeButton: ".btn-close"
|
|
242
|
+
};
|
|
243
|
+
class w extends n {
|
|
244
|
+
constructor() {
|
|
245
|
+
super(...arguments);
|
|
246
|
+
l(this, "selectors", structuredClone(f));
|
|
247
|
+
}
|
|
248
|
+
getComponentSelector() {
|
|
249
|
+
return this.selectors.rootComponent;
|
|
250
|
+
}
|
|
251
|
+
locatorCloseButton() {
|
|
252
|
+
return this.locatorRoot.locator(this.selectors.closeButton);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
class E extends n {
|
|
256
|
+
constructor() {
|
|
257
|
+
super(...arguments);
|
|
258
|
+
l(this, "selectors", {
|
|
259
|
+
item: ".accordion-item",
|
|
260
|
+
collapse: ".accordion-collapse",
|
|
261
|
+
body: ".accordion-body",
|
|
262
|
+
header: ".accordion-header",
|
|
263
|
+
buttons: ".accordion-button"
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
getComponentSelector() {
|
|
267
|
+
return ".accordion";
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Gets the locators of the items containing the header and the collapse inside
|
|
271
|
+
* the accordion
|
|
272
|
+
*/
|
|
273
|
+
get locatorAccordionItems() {
|
|
274
|
+
return this.locatorRoot.locator(this.selectors.item);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Gets the locators of the item specified by the itemIndex containing the header and the collapse inside
|
|
278
|
+
* the accordion
|
|
279
|
+
*/
|
|
280
|
+
locatorAccordionItem(t) {
|
|
281
|
+
return this.locatorRoot.locator(this.selectors.item).nth(t);
|
|
282
|
+
}
|
|
283
|
+
get locatorAccordionCollapses() {
|
|
284
|
+
return this.locatorAccordionItems.locator(this.selectors.collapse);
|
|
285
|
+
}
|
|
286
|
+
locatorAccordionCollapse(t) {
|
|
287
|
+
return this.locatorAccordionItem(t).locator(this.selectors.collapse);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Gets the locator of the bodies of the accordion.
|
|
291
|
+
*/
|
|
292
|
+
get locatorAccordionBodies() {
|
|
293
|
+
return this.locatorAccordionCollapses.locator(this.selectors.body);
|
|
294
|
+
}
|
|
295
|
+
locatorAccordionBody(t) {
|
|
296
|
+
return this.locatorAccordionCollapse(t).locator(this.selectors.body);
|
|
297
|
+
}
|
|
298
|
+
get locatorAccordionHeaders() {
|
|
299
|
+
return this.locatorAccordionItems.locator(this.selectors.header);
|
|
300
|
+
}
|
|
301
|
+
locatorAccordionHeader(t) {
|
|
302
|
+
return this.locatorAccordionItem(t).locator(this.selectors.header);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Gets the locators of the buttons that handle the accordion, present in the accordion header.
|
|
306
|
+
* It does not get the locators of the buttons present in the body, added by the developer.
|
|
307
|
+
*/
|
|
308
|
+
get locatorAccordionButtons() {
|
|
309
|
+
return this.locatorAccordionHeaders.locator(this.selectors.buttons);
|
|
310
|
+
}
|
|
311
|
+
locatorAccordionButton(t) {
|
|
312
|
+
return this.locatorAccordionHeader(t).locator(this.selectors.buttons);
|
|
313
|
+
}
|
|
314
|
+
async state() {
|
|
315
|
+
return await this.locatorRoot.evaluate((t) => {
|
|
316
|
+
const i = [...t.querySelectorAll(".accordion-item")], a = [];
|
|
317
|
+
for (const c of i) {
|
|
318
|
+
const r = c.querySelector(".accordion-collapse"), o = c.querySelector(".accordion-button");
|
|
319
|
+
a.push({
|
|
320
|
+
classes: c.className.trim().split(" "),
|
|
321
|
+
id: c.id,
|
|
322
|
+
isInDOM: r !== null,
|
|
323
|
+
collapseId: r == null ? void 0 : r.id,
|
|
324
|
+
buttonId: o == null ? void 0 : o.id,
|
|
325
|
+
expanded: o == null ? void 0 : o.getAttribute("aria-expanded"),
|
|
326
|
+
disabled: o == null ? void 0 : o.getAttribute("aria-disabled"),
|
|
327
|
+
labeledBy: r == null ? void 0 : r.getAttribute("aria-labelledby"),
|
|
328
|
+
buttonControls: o == null ? void 0 : o.getAttribute("aria-controls")
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
return { rootClasses: t.className.trim().split(" "), items: a };
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
export {
|
|
336
|
+
E as AccordionPO,
|
|
337
|
+
w as AlertPO,
|
|
338
|
+
I as ModalPO,
|
|
339
|
+
q as PaginationPO,
|
|
340
|
+
k as RatingPO,
|
|
341
|
+
O as SelectPO,
|
|
342
|
+
f as alertSelectors,
|
|
343
|
+
y as modalSelectors,
|
|
344
|
+
B as paginationSelectors,
|
|
345
|
+
R as ratingSelectors,
|
|
346
|
+
S as selectSelectors
|
|
347
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.36.4"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agnos-ui/page-objects",
|
|
3
|
+
"description": "Page objects to be used when testing AgnosUI-based applications with Playwright.",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"playwright",
|
|
6
|
+
"page-object",
|
|
7
|
+
"e2e",
|
|
8
|
+
"testing",
|
|
9
|
+
"AgnosUI",
|
|
10
|
+
"widgets",
|
|
11
|
+
"components"
|
|
12
|
+
],
|
|
13
|
+
"main": "dist/lib/index.js",
|
|
14
|
+
"module": "dist/lib/index.mjs",
|
|
15
|
+
"types": "dist/lib/index.d.ts",
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "npm run build:rollup && npm run build:dts && npm run build:api-extractor",
|
|
18
|
+
"build:rollup": "tsc && vite build -c vite.config.ts",
|
|
19
|
+
"build:dts": "tsc -p tsconfig.d.json",
|
|
20
|
+
"build:api-extractor": "api-extractor run"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@agnos-ui/base-po": "0.0.1-alpha.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@playwright/test": "*"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist/lib"
|
|
30
|
+
],
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"bugs": "https://github.com/AmadeusITGroup/AgnosUI/issues",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/AmadeusITGroup/AgnosUI.git",
|
|
36
|
+
"directory": "page-objects"
|
|
37
|
+
},
|
|
38
|
+
"version": "0.0.1-alpha.0"
|
|
39
|
+
}
|