@@ -7,12 +7,17 @@ declare global {
7
7
}
8
8
9
9
test . describe ( 'VapiWidget Embed Tests' , ( ) => {
10
- test ( 'should load widget from script tag with data attributes' , async ( { page } ) => {
10
+ test ( 'should load widget from script tag with data attributes' , async ( {
11
+ page,
12
+ } ) => {
11
13
// Navigate to the test page
12
14
await page . goto ( '/test-widget-embed.html' ) ;
13
15
14
16
// Wait for the widget script to load
15
- await page . waitForFunction ( ( ) => ( window as any ) . WidgetLoader !== undefined , { timeout : 5000 } ) ;
17
+ await page . waitForFunction (
18
+ ( ) => ( window as any ) . WidgetLoader !== undefined ,
19
+ { timeout : 5000 }
20
+ ) ;
16
21
17
22
// Check if widget container exists
18
23
const widget1 = await page . locator ( '#vapi-widget-1' ) ;
@@ -33,16 +38,25 @@ test.describe('VapiWidget Embed Tests', () => {
33
38
const widget = document . querySelector ( '#vapi-widget-1' ) ;
34
39
if ( ! widget ) return false ;
35
40
// Check for React root or any child elements
36
- return widget . children . length > 0 || widget . shadowRoot !== null || widget . innerHTML !== '' ;
41
+ return (
42
+ widget . children . length > 0 ||
43
+ widget . shadowRoot !== null ||
44
+ widget . innerHTML !== ''
45
+ ) ;
37
46
} ) ;
38
47
expect ( widgetInitialized ) . toBe ( true ) ;
39
48
} ) ;
40
49
41
- test ( 'should load widget from script tag with data-props JSON' , async ( { page } ) => {
50
+ test ( 'should load widget from script tag with data-props JSON' , async ( {
51
+ page,
52
+ } ) => {
42
53
await page . goto ( '/test-widget-embed.html' ) ;
43
54
44
55
// Wait for the widget script to load
45
- await page . waitForFunction ( ( ) => ( window as any ) . WidgetLoader !== undefined , { timeout : 5000 } ) ;
56
+ await page . waitForFunction (
57
+ ( ) => ( window as any ) . WidgetLoader !== undefined ,
58
+ { timeout : 5000 }
59
+ ) ;
46
60
47
61
// Check if widget container exists
48
62
const widget2 = await page . locator ( '#vapi-widget-2' ) ;
@@ -62,7 +76,11 @@ test.describe('VapiWidget Embed Tests', () => {
62
76
const widgetInitialized = await page . evaluate ( ( ) => {
63
77
const widget = document . querySelector ( '#vapi-widget-2' ) ;
64
78
if ( ! widget ) return false ;
65
- return widget . children . length > 0 || widget . shadowRoot !== null || widget . innerHTML !== '' ;
79
+ return (
80
+ widget . children . length > 0 ||
81
+ widget . shadowRoot !== null ||
82
+ widget . innerHTML !== ''
83
+ ) ;
66
84
} ) ;
67
85
expect ( widgetInitialized ) . toBe ( true ) ;
68
86
} ) ;
@@ -77,12 +95,14 @@ test.describe('VapiWidget Embed Tests', () => {
77
95
expect ( hasWidgetLoader ) . toBe ( true ) ;
78
96
} ) ;
79
97
80
- test ( 'widget builds successfully and creates necessary files' , async ( { page } ) => {
98
+ test ( 'widget builds successfully and creates necessary files' , async ( {
99
+ page,
100
+ } ) => {
81
101
// Navigate to check if built files are accessible
82
102
const styleResponse = await page . goto ( '/dist/style.css' ) ;
83
103
expect ( styleResponse ?. status ( ) ) . toBe ( 200 ) ;
84
-
104
+
85
105
const scriptResponse = await page . goto ( '/dist/widget.umd.js' ) ;
86
106
expect ( scriptResponse ?. status ( ) ) . toBe ( 200 ) ;
87
107
} ) ;
88
- } ) ;
108
+ } ) ;
0 commit comments