@vonage/vivid-test-utils 5.2.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 +102 -0
- package/dist/actions.d.ts +31 -0
- package/dist/base.d.ts +38 -0
- package/dist/components.generated-DY7hz_DE.js +3311 -0
- package/dist/components.generated-DiskE4p5.cjs +1 -0
- package/dist/components.generated.d.ts +2581 -0
- package/dist/cypress.cjs +3 -0
- package/dist/cypress.d.ts +7 -0
- package/dist/cypress.js +133 -0
- package/dist/dom.cjs +3 -0
- package/dist/dom.d.ts +4 -0
- package/dist/dom.js +120 -0
- package/dist/drivers/cypress.d.ts +7 -0
- package/dist/drivers/dom.d.ts +5 -0
- package/dist/drivers/driver.d.ts +54 -0
- package/dist/drivers/playwright.d.ts +3 -0
- package/dist/jsdom-polyfill.cjs +1 -0
- package/dist/jsdom-polyfill.d.ts +1 -0
- package/dist/jsdom-polyfill.js +37 -0
- package/dist/playwright.cjs +3 -0
- package/dist/playwright.d.ts +4 -0
- package/dist/playwright.js +87 -0
- package/dist/queries.d.ts +20 -0
- package/dist/refs.d.ts +8 -0
- package/dist/selectors.d.ts +7 -0
- package/dist/utils/cssSelectors.d.ts +2 -0
- package/dist/utils/runSequence.d.ts +1 -0
- package/package.json +56 -0
package/dist/cypress.cjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./components.generated-DiskE4p5.cjs"),w=async()=>new Promise(i=>requestAnimationFrame(()=>i())),k=i=>{const u=r=>r===i;let n;const l=r=>{const e=n;return(...a)=>{const t=window.Error;window.Error=class extends Error{constructor(o){super(o),o==="userInvocationStack"&&(this.stack=e)}static captureStackTrace(o,c){o.message!=="userInvocationStack"&&super.captureStackTrace(o,c)}};try{return r(...a)}finally{window.Error=t}}};return{querySelector:(r,e)=>l(()=>u(r)?r.get(e):r().find(e)),enterShadow:r=>l(()=>r().shadow()),querySelectorAll:(r,e)=>l(()=>u(r)?r.get(e):r().find(e)),nth:(r,e)=>l(()=>r().eq(e)),userClick:r=>r().click(),userClear:r=>r().clear(),userFocus:r=>r().focus(),userBlur:r=>r().blur(),userHover:r=>r().then(e=>e.get(0).dispatchEvent(new MouseEvent("mouseover"))),userFill:(r,e)=>e===""?r().clear():r().clear().type(e),userDragSlider:(r,e,a,t)=>{r().then(s=>{a().then(async o=>{const c=s.get(0),p=o.get(0);p.id==="start-thumb"?(c.startAsNumber=t,c.$emit("input:start"),c.$emit("input")):p.id==="end-thumb"?(c.endAsNumber=t,c.$emit("input:end"),c.$emit("input")):c.valueAsNumber=t,await w()})})},eval:(r,e,a,t)=>{const s=n;r().then(async o=>{n=s;try{const c=await e(o.get(0),a);await(t==null?void 0:t(c))}finally{n=void 0}})},waitForUpdate(r){r().then(()=>new Promise(e=>{requestAnimationFrame(()=>{e()})}))},expectEq:(r,e,a)=>{const t=n;switch(r.type){case"eval":r.el().should(s=>{try{expect(r.fn(s.get(0),r.arg)).to.deep.equal(e)}catch(o){const c=new Error(`${a}
|
|
2
|
+
|
|
3
|
+
Original error: ${o.message}`);throw t&&(c.stack=t),c}});break;case"count":r.el().should("have.length",e);break}},wrapAction:r=>function e(...a){if(!n){const t=new Error;Error.captureStackTrace(t,e),n=t.stack}try{return r(...a)}finally{n=void 0}},wrapExpect:r=>function e(...a){if(!n){const t=new Error;Error.captureStackTrace(t,e),n=t.stack}try{return r(...a)}finally{n=void 0}},wrapSelector:r=>function e(...a){if(!n){const t=new Error;Error.captureStackTrace(t,e),n=t.stack}try{return r(...a)}finally{n=void 0}}}},v=i=>{const u={rootLocator:i,driver:k(i)};return new d.VividWrapper(u)};exports.vividCypress=v;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
/// <reference types="cypress" />
|
|
3
|
+
/// <reference types="cypress" />
|
|
4
|
+
/// <reference types="cypress" />
|
|
5
|
+
import type { CypressDriverT } from './drivers/driver';
|
|
6
|
+
import { VividWrapper } from './components.generated';
|
|
7
|
+
export declare const vividCypress: (cy: Cypress.cy) => VividWrapper<CypressDriverT>;
|
package/dist/cypress.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { V as w } from "./components.generated-DY7hz_DE.js";
|
|
2
|
+
const d = async () => new Promise((i) => requestAnimationFrame(() => i())), k = (i) => {
|
|
3
|
+
const u = (r) => r === i;
|
|
4
|
+
let a;
|
|
5
|
+
const l = (r) => {
|
|
6
|
+
const t = a;
|
|
7
|
+
return (...n) => {
|
|
8
|
+
const e = window.Error;
|
|
9
|
+
window.Error = class extends Error {
|
|
10
|
+
constructor(o) {
|
|
11
|
+
super(o), o === "userInvocationStack" && (this.stack = t);
|
|
12
|
+
}
|
|
13
|
+
static captureStackTrace(o, c) {
|
|
14
|
+
o.message !== "userInvocationStack" && super.captureStackTrace(o, c);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
try {
|
|
18
|
+
return r(...n);
|
|
19
|
+
} finally {
|
|
20
|
+
window.Error = e;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
querySelector: (r, t) => l(
|
|
26
|
+
() => u(r) ? r.get(t) : r().find(t)
|
|
27
|
+
),
|
|
28
|
+
enterShadow: (r) => l(() => r().shadow()),
|
|
29
|
+
querySelectorAll: (r, t) => l(
|
|
30
|
+
() => u(r) ? r.get(t) : r().find(t)
|
|
31
|
+
),
|
|
32
|
+
nth: (r, t) => l(() => r().eq(t)),
|
|
33
|
+
userClick: (r) => r().click(),
|
|
34
|
+
userClear: (r) => r().clear(),
|
|
35
|
+
userFocus: (r) => r().focus(),
|
|
36
|
+
userBlur: (r) => r().blur(),
|
|
37
|
+
userHover: (r) => r().then((t) => t.get(0).dispatchEvent(new MouseEvent("mouseover"))),
|
|
38
|
+
userFill: (r, t) => t === "" ? r().clear() : r().clear().type(t),
|
|
39
|
+
userDragSlider: (r, t, n, e) => {
|
|
40
|
+
r().then((s) => {
|
|
41
|
+
n().then(async (o) => {
|
|
42
|
+
const c = s.get(0), p = o.get(0);
|
|
43
|
+
p.id === "start-thumb" ? (c.startAsNumber = e, c.$emit("input:start"), c.$emit("input")) : p.id === "end-thumb" ? (c.endAsNumber = e, c.$emit("input:end"), c.$emit("input")) : c.valueAsNumber = e, await d();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
eval: (r, t, n, e) => {
|
|
48
|
+
const s = a;
|
|
49
|
+
r().then(async (o) => {
|
|
50
|
+
a = s;
|
|
51
|
+
try {
|
|
52
|
+
const c = await t(o.get(0), n);
|
|
53
|
+
await (e == null ? void 0 : e(c));
|
|
54
|
+
} finally {
|
|
55
|
+
a = void 0;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
waitForUpdate(r) {
|
|
60
|
+
r().then(() => new Promise((t) => {
|
|
61
|
+
requestAnimationFrame(() => {
|
|
62
|
+
t();
|
|
63
|
+
});
|
|
64
|
+
}));
|
|
65
|
+
},
|
|
66
|
+
expectEq: (r, t, n) => {
|
|
67
|
+
const e = a;
|
|
68
|
+
switch (r.type) {
|
|
69
|
+
case "eval":
|
|
70
|
+
r.el().should((s) => {
|
|
71
|
+
try {
|
|
72
|
+
expect(
|
|
73
|
+
r.fn(s.get(0), r.arg)
|
|
74
|
+
).to.deep.equal(t);
|
|
75
|
+
} catch (o) {
|
|
76
|
+
const c = new Error(
|
|
77
|
+
`${n}
|
|
78
|
+
|
|
79
|
+
Original error: ${o.message}`
|
|
80
|
+
);
|
|
81
|
+
throw e && (c.stack = e), c;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
break;
|
|
85
|
+
case "count":
|
|
86
|
+
r.el().should("have.length", t);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
wrapAction: (r) => function t(...n) {
|
|
91
|
+
if (!a) {
|
|
92
|
+
const e = new Error();
|
|
93
|
+
Error.captureStackTrace(e, t), a = e.stack;
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
return r(...n);
|
|
97
|
+
} finally {
|
|
98
|
+
a = void 0;
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
wrapExpect: (r) => function t(...n) {
|
|
102
|
+
if (!a) {
|
|
103
|
+
const e = new Error();
|
|
104
|
+
Error.captureStackTrace(e, t), a = e.stack;
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
return r(...n);
|
|
108
|
+
} finally {
|
|
109
|
+
a = void 0;
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
wrapSelector: (r) => function t(...n) {
|
|
113
|
+
if (!a) {
|
|
114
|
+
const e = new Error();
|
|
115
|
+
Error.captureStackTrace(e, t), a = e.stack;
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
return r(...n);
|
|
119
|
+
} finally {
|
|
120
|
+
a = void 0;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}, v = (i) => {
|
|
125
|
+
const u = {
|
|
126
|
+
rootLocator: i,
|
|
127
|
+
driver: k(i)
|
|
128
|
+
};
|
|
129
|
+
return new w(u);
|
|
130
|
+
};
|
|
131
|
+
export {
|
|
132
|
+
v as vividCypress
|
|
133
|
+
};
|
package/dist/dom.cjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./components.generated-DiskE4p5.cjs"),w=require("@testing-library/user-event"),n=()=>new Promise(c=>{requestAnimationFrame(()=>c())}),l=c=>{const s=w.setup(),i=async r=>{r.focus(),r.value="",r.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0}))};return{querySelector:(r,t)=>{const a=r.querySelector(t);if(!a)throw new Error(`Could not find element: ${t}`);return a},enterShadow(r){if(!r.shadowRoot)throw new Error(`Element ${r.outerHTML} does not have a shadow root`);return r.shadowRoot},querySelectorAll:(r,t)=>r?Array.from(r.querySelectorAll(t)):[],nth:(r,t)=>{if(t<0||t>r.length-1)throw new Error(`Could not find element with index "${t}". Collection only has "${r.length}" elements.`);return r[t]},userClick:async r=>{await s.click(r),await n()},userFill:async(r,t)=>{await i(r),t&&await s.type(r,t),await n()},userClear:async r=>{await i(r),await n()},userFocus:async r=>{r.focus(),await n()},userBlur:async r=>{r.blur(),(r.tagName==="INPUT"||r.tagName==="TEXTAREA")&&r.dispatchEvent(new InputEvent("change",{bubbles:!0,composed:!0})),await n()},userHover:async r=>{await s.hover(r),await n()},userDragSlider:async(r,t,a,e)=>{if(a.id==="start-thumb"){const o=r;o.startAsNumber=e,o.$emit("input:start"),o.$emit("input")}else if(a.id==="end-thumb"){const o=r;o.endAsNumber=e,o.$emit("input:end"),o.$emit("input")}else{const o=r;o.valueAsNumber=e}await n()},eval:async(r,t,a,e)=>{const o=await t(r,a);await(e==null?void 0:e(o))},waitForUpdate:async()=>{await n()},expectEq:(r,t,a)=>{switch(r.type){case"eval":try{c(r.fn(r.el,r.arg)).toEqual(t)}catch(e){throw e instanceof Error&&(e.message=`${a}
|
|
2
|
+
|
|
3
|
+
Original error: ${e.message}`),e}break;case"count":c(r.el.length).toEqual(t);break}},wrapAction:r=>async function t(...a){try{return await r(...a)}catch(e){throw e instanceof Error&&Error.captureStackTrace(e,t),e}},wrapExpect:r=>function t(...a){try{return r(...a)}catch(e){throw e instanceof Error&&Error.captureStackTrace(e,t),e}},wrapSelector:r=>function t(...a){try{return r(...a)}catch(e){throw e instanceof Error&&Error.captureStackTrace(e,t),e}}}},p=(c,s)=>{const i={rootLocator:s,driver:l(c)};return new u.VividWrapper(i)};exports.vividDOM=p;
|
package/dist/dom.d.ts
ADDED
package/dist/dom.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { V as u } from "./components.generated-DY7hz_DE.js";
|
|
2
|
+
import w from "@testing-library/user-event";
|
|
3
|
+
const n = () => new Promise((c) => {
|
|
4
|
+
requestAnimationFrame(() => c());
|
|
5
|
+
}), p = (c) => {
|
|
6
|
+
const s = w.setup(), i = async (r) => {
|
|
7
|
+
r.focus(), r.value = "", r.dispatchEvent(
|
|
8
|
+
new InputEvent("input", { bubbles: !0, composed: !0 })
|
|
9
|
+
);
|
|
10
|
+
};
|
|
11
|
+
return {
|
|
12
|
+
querySelector: (r, t) => {
|
|
13
|
+
const a = r.querySelector(t);
|
|
14
|
+
if (!a)
|
|
15
|
+
throw new Error(`Could not find element: ${t}`);
|
|
16
|
+
return a;
|
|
17
|
+
},
|
|
18
|
+
enterShadow(r) {
|
|
19
|
+
if (!r.shadowRoot)
|
|
20
|
+
throw new Error(`Element ${r.outerHTML} does not have a shadow root`);
|
|
21
|
+
return r.shadowRoot;
|
|
22
|
+
},
|
|
23
|
+
querySelectorAll: (r, t) => r ? Array.from(r.querySelectorAll(t)) : [],
|
|
24
|
+
nth: (r, t) => {
|
|
25
|
+
if (t < 0 || t > r.length - 1)
|
|
26
|
+
throw new Error(
|
|
27
|
+
`Could not find element with index "${t}". Collection only has "${r.length}" elements.`
|
|
28
|
+
);
|
|
29
|
+
return r[t];
|
|
30
|
+
},
|
|
31
|
+
userClick: async (r) => {
|
|
32
|
+
await s.click(r), await n();
|
|
33
|
+
},
|
|
34
|
+
userFill: async (r, t) => {
|
|
35
|
+
await i(r), t && await s.type(r, t), await n();
|
|
36
|
+
},
|
|
37
|
+
userClear: async (r) => {
|
|
38
|
+
await i(r), await n();
|
|
39
|
+
},
|
|
40
|
+
userFocus: async (r) => {
|
|
41
|
+
r.focus(), await n();
|
|
42
|
+
},
|
|
43
|
+
userBlur: async (r) => {
|
|
44
|
+
r.blur(), (r.tagName === "INPUT" || r.tagName === "TEXTAREA") && r.dispatchEvent(
|
|
45
|
+
new InputEvent("change", { bubbles: !0, composed: !0 })
|
|
46
|
+
), await n();
|
|
47
|
+
},
|
|
48
|
+
userHover: async (r) => {
|
|
49
|
+
await s.hover(r), await n();
|
|
50
|
+
},
|
|
51
|
+
userDragSlider: async (r, t, a, e) => {
|
|
52
|
+
if (a.id === "start-thumb") {
|
|
53
|
+
const o = r;
|
|
54
|
+
o.startAsNumber = e, o.$emit("input:start"), o.$emit("input");
|
|
55
|
+
} else if (a.id === "end-thumb") {
|
|
56
|
+
const o = r;
|
|
57
|
+
o.endAsNumber = e, o.$emit("input:end"), o.$emit("input");
|
|
58
|
+
} else {
|
|
59
|
+
const o = r;
|
|
60
|
+
o.valueAsNumber = e;
|
|
61
|
+
}
|
|
62
|
+
await n();
|
|
63
|
+
},
|
|
64
|
+
eval: async (r, t, a, e) => {
|
|
65
|
+
const o = await t(r, a);
|
|
66
|
+
await (e == null ? void 0 : e(o));
|
|
67
|
+
},
|
|
68
|
+
waitForUpdate: async () => {
|
|
69
|
+
await n();
|
|
70
|
+
},
|
|
71
|
+
expectEq: (r, t, a) => {
|
|
72
|
+
switch (r.type) {
|
|
73
|
+
case "eval":
|
|
74
|
+
try {
|
|
75
|
+
c(r.fn(r.el, r.arg)).toEqual(
|
|
76
|
+
t
|
|
77
|
+
);
|
|
78
|
+
} catch (e) {
|
|
79
|
+
throw e instanceof Error && (e.message = `${a}
|
|
80
|
+
|
|
81
|
+
Original error: ${e.message}`), e;
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
case "count":
|
|
85
|
+
c(r.el.length).toEqual(t);
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
wrapAction: (r) => async function t(...a) {
|
|
90
|
+
try {
|
|
91
|
+
return await r(...a);
|
|
92
|
+
} catch (e) {
|
|
93
|
+
throw e instanceof Error && Error.captureStackTrace(e, t), e;
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
wrapExpect: (r) => function t(...a) {
|
|
97
|
+
try {
|
|
98
|
+
return r(...a);
|
|
99
|
+
} catch (e) {
|
|
100
|
+
throw e instanceof Error && Error.captureStackTrace(e, t), e;
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
wrapSelector: (r) => function t(...a) {
|
|
104
|
+
try {
|
|
105
|
+
return r(...a);
|
|
106
|
+
} catch (e) {
|
|
107
|
+
throw e instanceof Error && Error.captureStackTrace(e, t), e;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}, f = (c, s) => {
|
|
112
|
+
const i = {
|
|
113
|
+
rootLocator: s,
|
|
114
|
+
driver: p(c)
|
|
115
|
+
};
|
|
116
|
+
return new u(i);
|
|
117
|
+
};
|
|
118
|
+
export {
|
|
119
|
+
f as vividDOM
|
|
120
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
/// <reference types="cypress" />
|
|
3
|
+
/// <reference types="cypress" />
|
|
4
|
+
/// <reference types="cypress" />
|
|
5
|
+
import type { CypressDriverT, Driver } from './driver';
|
|
6
|
+
export declare const nextDOMUpdate: () => Promise<void>;
|
|
7
|
+
export declare const createCypressDriver: (cy: Cypress.cy) => Driver<CypressDriverT>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
/// <reference types="cypress" />
|
|
3
|
+
import type { Locator, Page } from '@playwright/test';
|
|
4
|
+
export type DOMDriverT = {
|
|
5
|
+
rootLocator: HTMLElement;
|
|
6
|
+
locator: HTMLElement;
|
|
7
|
+
locatorMultiple: HTMLElement[];
|
|
8
|
+
actionReturn: Promise<void>;
|
|
9
|
+
expectReturn: void;
|
|
10
|
+
};
|
|
11
|
+
export type PlaywrightDriverT = {
|
|
12
|
+
rootLocator: Page;
|
|
13
|
+
locator: Locator;
|
|
14
|
+
locatorMultiple: Locator;
|
|
15
|
+
actionReturn: Promise<void>;
|
|
16
|
+
expectReturn: Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
export type CypressDriverT = {
|
|
19
|
+
rootLocator: Cypress.cy;
|
|
20
|
+
locator: () => Cypress.Chainable;
|
|
21
|
+
locatorMultiple: () => Cypress.Chainable;
|
|
22
|
+
actionReturn: void;
|
|
23
|
+
expectReturn: void;
|
|
24
|
+
};
|
|
25
|
+
export type DriverT = DOMDriverT | PlaywrightDriverT | CypressDriverT;
|
|
26
|
+
type QueryCommand<D extends DriverT> = {
|
|
27
|
+
type: 'eval';
|
|
28
|
+
el: D['locator'];
|
|
29
|
+
fn: (el: any, arg?: any) => any;
|
|
30
|
+
arg?: any;
|
|
31
|
+
} | {
|
|
32
|
+
type: 'count';
|
|
33
|
+
el: D['locator'];
|
|
34
|
+
};
|
|
35
|
+
export type Driver<D extends DriverT> = {
|
|
36
|
+
querySelector: (loc: D['locator'] | D['rootLocator'], selector: string) => D['locator'];
|
|
37
|
+
enterShadow: (loc: D['locator']) => D['locator'];
|
|
38
|
+
querySelectorAll: (loc: D['locator'] | D['rootLocator'], selector: string) => D['locatorMultiple'];
|
|
39
|
+
nth: (loc: D['locatorMultiple'], n: number) => D['locator'];
|
|
40
|
+
userClick: (loc: D['locator']) => D['actionReturn'];
|
|
41
|
+
userFill: (loc: D['locator'], text: string) => D['actionReturn'];
|
|
42
|
+
userClear: (loc: D['locator']) => D['actionReturn'];
|
|
43
|
+
userFocus: (loc: D['locator']) => D['actionReturn'];
|
|
44
|
+
userBlur: (loc: D['locator']) => D['actionReturn'];
|
|
45
|
+
userHover: (loc: D['locator']) => D['actionReturn'];
|
|
46
|
+
userDragSlider: (loc: D['locator'], track: D['locator'], thumb: D['locator'], value: number) => D['actionReturn'];
|
|
47
|
+
eval: (loc: D['locator'], fn: (el: any, arg?: any) => any, arg?: any, continuation?: (result: any) => void | Promise<void>) => D['actionReturn'];
|
|
48
|
+
waitForUpdate: (loc: D['locator']) => D['actionReturn'];
|
|
49
|
+
expectEq: (query: QueryCommand<D>, value: any, message: string) => D['expectReturn'];
|
|
50
|
+
wrapAction: <A extends (...args: any[]) => D['actionReturn']>(action: A) => A;
|
|
51
|
+
wrapExpect: <E extends (...args: any[]) => D['expectReturn']>(expectation: E) => E;
|
|
52
|
+
wrapSelector: <S extends (...args: any[]) => unknown>(selector: S) => S;
|
|
53
|
+
};
|
|
54
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@vonage/vivid");function e(){HTMLDialogElement.prototype.showModal=function(){this.open=!0,this.setAttribute("open","")},HTMLDialogElement.prototype.close=function(){this.open=!1,this.removeAttribute("open")},HTMLElement.prototype.hidePopover=function(){},HTMLElement.prototype.showPopover=function(){},HTMLElement.prototype.scrollIntoView=function(){},Object.defineProperty(Object.getPrototypeOf(t.VwcButtonElement).prototype,"handleUnsupportedDelegatesFocus",{set(){},get(){return()=>{}}}),window.ResizeObserver=class{constructor(){}observe(){}disconnect(){}}}e();window.HTMLElement.prototype.scrollIntoView=function(){};window.HTMLElement.prototype.scrollTo=function(){};exports.setDialogPolyfill=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setDialogPolyfill(): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { VwcButtonElement as e } from "@vonage/vivid";
|
|
2
|
+
function t() {
|
|
3
|
+
HTMLDialogElement.prototype.showModal = function() {
|
|
4
|
+
this.open = !0, this.setAttribute("open", "");
|
|
5
|
+
}, HTMLDialogElement.prototype.close = function() {
|
|
6
|
+
this.open = !1, this.removeAttribute("open");
|
|
7
|
+
}, HTMLElement.prototype.hidePopover = function() {
|
|
8
|
+
}, HTMLElement.prototype.showPopover = function() {
|
|
9
|
+
}, HTMLElement.prototype.scrollIntoView = function() {
|
|
10
|
+
}, Object.defineProperty(
|
|
11
|
+
Object.getPrototypeOf(e).prototype,
|
|
12
|
+
"handleUnsupportedDelegatesFocus",
|
|
13
|
+
{
|
|
14
|
+
set() {
|
|
15
|
+
},
|
|
16
|
+
get() {
|
|
17
|
+
return () => {
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
), window.ResizeObserver = class {
|
|
22
|
+
constructor() {
|
|
23
|
+
}
|
|
24
|
+
observe() {
|
|
25
|
+
}
|
|
26
|
+
disconnect() {
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
t();
|
|
31
|
+
window.HTMLElement.prototype.scrollIntoView = function() {
|
|
32
|
+
};
|
|
33
|
+
window.HTMLElement.prototype.scrollTo = function() {
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
t as setDialogPolyfill
|
|
37
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./components.generated-DiskE4p5.cjs"),w=c=>({querySelector:(r,e)=>r.locator(e),enterShadow:r=>r,querySelectorAll:(r,e)=>r.locator(e),nth:(r,e)=>r.nth(e),userClick:r=>r.click(),userFill:(r,e)=>r.fill(e),userClear:r=>r.clear(),userFocus:r=>r.focus(),userBlur:r=>r.blur(),userHover:r=>r.hover(),userDragSlider:async(r,e,a,t)=>{const s=await a.getAttribute("id");await r.evaluate((o,[l,n])=>{if(l==="start-thumb"){const i=o;i.startAsNumber=n,i.$emit("input:start"),i.$emit("input")}else if(l==="end-thumb"){const i=o;i.endAsNumber=n,i.$emit("input:end"),i.$emit("input")}else{const i=o;i.valueAsNumber=n}},[s,t])},eval:async(r,e,a,t)=>{const s=await r.evaluate(e,a);await(t==null?void 0:t(s))},waitForUpdate:async r=>{await r.evaluate(()=>new Promise(e=>{requestAnimationFrame(()=>e())}))},expectEq:async(r,e,a)=>{switch(r.type){case"eval":try{await c(async()=>c(await r.el.evaluate(r.fn,r.arg)).toEqual(e)).toPass()}catch(t){throw t instanceof Error&&(t.message=`${a}
|
|
2
|
+
|
|
3
|
+
Original error: ${t.message}`),t}break;case"count":await c(r.el).toHaveCount(e);break}},wrapAction:r=>async function e(...a){try{return await r(...a)}catch(t){throw t instanceof Error&&Error.captureStackTrace(t,e),t}},wrapExpect:r=>async function e(...a){try{return await r(...a)}catch(t){throw t instanceof Error&&Error.captureStackTrace(t,e),t}},wrapSelector:r=>r}),p=(c,r)=>{const e={rootLocator:c,driver:w(r)};return new u.VividWrapper(e)};exports.vividPlaywright=p;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PlaywrightDriverT } from './drivers/driver';
|
|
2
|
+
import type { expect as pwExpect, Page } from '@playwright/test';
|
|
3
|
+
import { VividWrapper } from './components.generated';
|
|
4
|
+
export declare const vividPlaywright: (page: Page, expect: typeof pwExpect) => VividWrapper<PlaywrightDriverT>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { V as u } from "./components.generated-DY7hz_DE.js";
|
|
2
|
+
const w = (i) => ({
|
|
3
|
+
querySelector: (r, t) => r.locator(t),
|
|
4
|
+
enterShadow: (r) => r,
|
|
5
|
+
querySelectorAll: (r, t) => r.locator(t),
|
|
6
|
+
nth: (r, t) => r.nth(t),
|
|
7
|
+
userClick: (r) => r.click(),
|
|
8
|
+
userFill: (r, t) => r.fill(t),
|
|
9
|
+
userClear: (r) => r.clear(),
|
|
10
|
+
userFocus: (r) => r.focus(),
|
|
11
|
+
userBlur: (r) => r.blur(),
|
|
12
|
+
userHover: (r) => r.hover(),
|
|
13
|
+
userDragSlider: async (r, t, a, e) => {
|
|
14
|
+
const s = await a.getAttribute("id");
|
|
15
|
+
await r.evaluate(
|
|
16
|
+
(o, [l, n]) => {
|
|
17
|
+
if (l === "start-thumb") {
|
|
18
|
+
const c = o;
|
|
19
|
+
c.startAsNumber = n, c.$emit("input:start"), c.$emit("input");
|
|
20
|
+
} else if (l === "end-thumb") {
|
|
21
|
+
const c = o;
|
|
22
|
+
c.endAsNumber = n, c.$emit("input:end"), c.$emit("input");
|
|
23
|
+
} else {
|
|
24
|
+
const c = o;
|
|
25
|
+
c.valueAsNumber = n;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
[s, e]
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
eval: async (r, t, a, e) => {
|
|
32
|
+
const s = await r.evaluate(t, a);
|
|
33
|
+
await (e == null ? void 0 : e(s));
|
|
34
|
+
},
|
|
35
|
+
waitForUpdate: async (r) => {
|
|
36
|
+
await r.evaluate(() => new Promise((t) => {
|
|
37
|
+
requestAnimationFrame(() => t());
|
|
38
|
+
}));
|
|
39
|
+
},
|
|
40
|
+
expectEq: async (r, t, a) => {
|
|
41
|
+
switch (r.type) {
|
|
42
|
+
case "eval":
|
|
43
|
+
try {
|
|
44
|
+
await i(
|
|
45
|
+
async () => i(
|
|
46
|
+
await r.el.evaluate(
|
|
47
|
+
r.fn,
|
|
48
|
+
r.arg
|
|
49
|
+
)
|
|
50
|
+
).toEqual(t)
|
|
51
|
+
).toPass();
|
|
52
|
+
} catch (e) {
|
|
53
|
+
throw e instanceof Error && (e.message = `${a}
|
|
54
|
+
|
|
55
|
+
Original error: ${e.message}`), e;
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
case "count":
|
|
59
|
+
await i(r.el).toHaveCount(t);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
wrapAction: (r) => async function t(...a) {
|
|
64
|
+
try {
|
|
65
|
+
return await r(...a);
|
|
66
|
+
} catch (e) {
|
|
67
|
+
throw e instanceof Error && Error.captureStackTrace(e, t), e;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
wrapExpect: (r) => async function t(...a) {
|
|
71
|
+
try {
|
|
72
|
+
return await r(...a);
|
|
73
|
+
} catch (e) {
|
|
74
|
+
throw e instanceof Error && Error.captureStackTrace(e, t), e;
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
wrapSelector: (r) => r
|
|
78
|
+
}), h = (i, r) => {
|
|
79
|
+
const t = {
|
|
80
|
+
rootLocator: i,
|
|
81
|
+
driver: w(r)
|
|
82
|
+
};
|
|
83
|
+
return new u(t);
|
|
84
|
+
};
|
|
85
|
+
export {
|
|
86
|
+
h as vividPlaywright
|
|
87
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare function checked(el: any): boolean;
|
|
2
|
+
export declare function checkedState(el: any): 'checked' | 'unchecked' | 'indeterminate';
|
|
3
|
+
export declare function visibleError(el: any): any;
|
|
4
|
+
export declare function headline(el: any): any;
|
|
5
|
+
export declare function open(el: any): any;
|
|
6
|
+
export declare function value(el: any): any;
|
|
7
|
+
export declare function valueAsNumber(el: any): number;
|
|
8
|
+
export declare function values(el: any): any;
|
|
9
|
+
export declare function selectedOptionsText(el: any): any;
|
|
10
|
+
export declare function expanded(el: any): any;
|
|
11
|
+
export declare function active(el: any): any;
|
|
12
|
+
export declare function navCurrent(el: any): any;
|
|
13
|
+
export declare function selected(el: any): any;
|
|
14
|
+
export declare function disabled(el: any): any;
|
|
15
|
+
export declare function range(el: any): any[];
|
|
16
|
+
export declare function rangeAsNumber(el: any): any[];
|
|
17
|
+
export declare function name(el: any): any;
|
|
18
|
+
export declare function total(el: any): any;
|
|
19
|
+
export declare function paginationSelectedPage(el: any): any;
|
|
20
|
+
export declare function affixIcon(el: any): any;
|
package/dist/refs.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DriverT } from './drivers/driver';
|
|
2
|
+
import { BaseWrapper } from './base';
|
|
3
|
+
import { ButtonWrapper, TextFieldWrapper } from './components.generated';
|
|
4
|
+
export declare function light<D extends DriverT>(this: BaseWrapper<D>, selector: string): D['locator'];
|
|
5
|
+
export declare function shadow<D extends DriverT>(this: BaseWrapper<D>, selector: string): D['locator'];
|
|
6
|
+
export declare function nestedShadow<D extends DriverT>(this: BaseWrapper<D>, selector1: string, selector2: string): D['locator'];
|
|
7
|
+
export declare function shadowButton<D extends DriverT>(this: BaseWrapper<D>, selector: string): ButtonWrapper<D>;
|
|
8
|
+
export declare function shadowTextField<D extends DriverT>(this: BaseWrapper<D>, selector: string): TextFieldWrapper<D>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DriverT } from './drivers/driver';
|
|
2
|
+
import { BaseComponent, BaseWrapper } from './base';
|
|
3
|
+
export declare function byTestId<D extends DriverT, W extends BaseWrapper<D>>(this: BaseComponent<D, W>, id: string): W;
|
|
4
|
+
export declare function byLabel<D extends DriverT, W extends BaseWrapper<D>>(this: BaseComponent<D, W>, label: string): W;
|
|
5
|
+
export declare function byHeading<D extends DriverT, W extends BaseWrapper<D>>(this: BaseComponent<D, W>, heading: string): W;
|
|
6
|
+
export declare function byHeadline<D extends DriverT, W extends BaseWrapper<D>>(this: BaseComponent<D, W>, headline: string): W;
|
|
7
|
+
export declare function byText<D extends DriverT, W extends BaseWrapper<D>>(this: BaseComponent<D, W>, text: string): W;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const runSequence: (steps: Array<() => Promise<void> | void>) => any;
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vonage/vivid-test-utils",
|
|
3
|
+
"version": "5.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
"./dom": {
|
|
7
|
+
"types": "./dist/dom.d.ts",
|
|
8
|
+
"import": "./dist/dom.js",
|
|
9
|
+
"require": "./dist/dom.cjs"
|
|
10
|
+
},
|
|
11
|
+
"./playwright": {
|
|
12
|
+
"types": "./dist/playwright.d.ts",
|
|
13
|
+
"import": "./dist/playwright.js",
|
|
14
|
+
"require": "./dist/playwright.cjs"
|
|
15
|
+
},
|
|
16
|
+
"./cypress": {
|
|
17
|
+
"types": "./dist/cypress.d.ts",
|
|
18
|
+
"import": "./dist/cypress.js",
|
|
19
|
+
"require": "./dist/cypress.cjs"
|
|
20
|
+
},
|
|
21
|
+
"./jsdom-polyfill": {
|
|
22
|
+
"types": "./dist/jsdom-polyfill.d.ts",
|
|
23
|
+
"import": "./dist/jsdom-polyfill.js",
|
|
24
|
+
"require": "./dist/jsdom-polyfill.cjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"prebuild": "tsx scripts/codegen.ts",
|
|
32
|
+
"build": "vite build",
|
|
33
|
+
"lint": "eslint . --max-warnings=0",
|
|
34
|
+
"lint:fix": "eslint . --max-warnings=0 --fix",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"e2e": "concurrently -k -s first -n VITE,TEST \"npx vite src/tests/cases -c ./vite.config.ts --host\" \"npx wait-on http://localhost:5173 && npx playwright test\"",
|
|
37
|
+
"cy": "concurrently -k -s first -n VITE,TEST \"npx vite src/tests/cases -c ./vite.config.ts --host\" \"npx wait-on http://localhost:5173 && npx cypress run\"",
|
|
38
|
+
"e2e:ui": "playwright test --ui",
|
|
39
|
+
"cy:ui": "cypress open",
|
|
40
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.tools.json",
|
|
41
|
+
"prepack": "tsx scripts/updateDependencyVersion.ts"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@testing-library/user-event": "^14.6.1",
|
|
45
|
+
"@vonage/vivid": "^5.2.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@repo/eslint-config": "*",
|
|
49
|
+
"@repo/typescript-config": "*",
|
|
50
|
+
"@repo/vitest-config": "*",
|
|
51
|
+
"@vonage/vivid-vue": "*",
|
|
52
|
+
"@vue/test-utils": "^2",
|
|
53
|
+
"cypress": "^14.5.1",
|
|
54
|
+
"vue": "^3"
|
|
55
|
+
}
|
|
56
|
+
}
|