Skip to content

Commit fd571f5

Browse files
committed
another try for playwright
1 parent f6b09cb commit fd571f5

File tree

4 files changed

+48
-11
lines changed

4 files changed

+48
-11
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,32 @@ jobs:
136136
echo "Checking for required files..."
137137
test -f dist/widget.umd.js || (echo "widget.umd.js not found!" && exit 1)
138138
test -f dist/style.css || (echo "style.css not found!" && exit 1)
139+
echo "Contents of root directory:"
140+
ls -la
141+
echo "Checking test-widget-embed.html exists:"
142+
test -f test-widget-embed.html && echo "test-widget-embed.html found" || echo "test-widget-embed.html NOT found"
139143
140144
- name: Install Playwright
141145
run: npx playwright install chromium
142146

143-
- name: Build widget
144-
run: npm run build:widget
147+
- name: Test server availability
148+
run: |
149+
# Start the server in background
150+
npx serve -l 4200 . &
151+
SERVER_PID=$!
152+
echo "Server started with PID: $SERVER_PID"
153+
154+
# Wait for server to start
155+
sleep 5
156+
157+
# Test if server is running and files are accessible
158+
echo "Testing server endpoints:"
159+
curl -I http://localhost:4200/test-widget-embed || echo "Failed to access test-widget-embed"
160+
curl -I http://localhost:4200/dist/widget.umd.js || echo "Failed to access widget.umd.js"
161+
curl -I http://localhost:4200/dist/style.css || echo "Failed to access style.css"
162+
163+
# Kill the test server
164+
kill $SERVER_PID
145165
146166
- name: Run widget tests
147167
run: npm run test:ci:only

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"test": "npm run test:widget",
4141
"test:widget": "npm run build:widget && playwright test",
4242
"test:widget:ui": "npm run build:widget && playwright test --ui",
43-
"test:serve": "serve -s . -p 3000",
43+
"test:serve": "serve -l 4200 .",
4444
"test:ci": "npm run build:widget && playwright test --reporter=list",
4545
"test:ci:only": "playwright test --reporter=list"
4646
},

playwright.config.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ export default defineConfig({
1010
forbidOnly: !!process.env.CI,
1111
retries: process.env.CI ? 2 : 0,
1212
workers: process.env.CI ? 1 : undefined,
13-
reporter: 'html',
13+
reporter: process.env.CI ? 'list' : 'html',
1414
use: {
15-
baseURL: 'http://localhost:3000',
15+
baseURL: 'http://localhost:4200',
1616
trace: 'on-first-retry',
1717
},
1818
projects: [
@@ -22,9 +22,11 @@ export default defineConfig({
2222
},
2323
],
2424
webServer: {
25-
command: 'npm run test:serve',
26-
port: 3000,
25+
command: 'npx serve -l 4200 .',
26+
port: 4200,
2727
timeout: 60 * 1000, // 1 minute timeout
2828
reuseExistingServer: !process.env.CI,
29+
stdout: process.env.CI ? 'pipe' : 'ignore',
30+
stderr: 'pipe',
2931
},
3032
});

tests/widget-embed.spec.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,22 @@ test.describe('VapiWidget Embed Tests', () => {
1919
console.log('Page error:', error.message);
2020
});
2121

22-
await page.goto('/test-widget-embed.html');
22+
// Add response logging
23+
page.on('response', (response) => {
24+
console.log(`Response: ${response.status()} ${response.url()}`);
25+
});
26+
27+
const response = await page.goto('/test-widget-embed');
28+
console.log('Navigation response:', response?.status(), response?.url());
29+
30+
// Check page content
31+
const pageContent = await page.content();
32+
console.log('Page content length:', pageContent.length);
33+
console.log('Page title:', await page.title());
34+
35+
// Check if we got the right page
36+
const hasTestTitle = pageContent.includes('VapiWidget Embed Test');
37+
console.log('Has test page title:', hasTestTitle);
2338

2439
// Check if the script tag exists
2540
const scriptExists = await page.evaluate(() => {
@@ -58,7 +73,7 @@ test.describe('VapiWidget Embed Tests', () => {
5873
page,
5974
}) => {
6075
// Navigate to the test page
61-
await page.goto('/test-widget-embed.html');
76+
await page.goto('/test-widget-embed');
6277

6378
// Wait for the widget script to load
6479
await page.waitForFunction(
@@ -97,7 +112,7 @@ test.describe('VapiWidget Embed Tests', () => {
97112
test('should load widget from script tag with data-props JSON', async ({
98113
page,
99114
}) => {
100-
await page.goto('/test-widget-embed.html');
115+
await page.goto('/test-widget-embed');
101116

102117
// Wait for the widget script to load
103118
await page.waitForFunction(
@@ -133,7 +148,7 @@ test.describe('VapiWidget Embed Tests', () => {
133148
});
134149

135150
test('should expose WidgetLoader globally', async ({ page }) => {
136-
await page.goto('/test-widget-embed.html');
151+
await page.goto('/test-widget-embed');
137152

138153
// Wait a bit for script to load
139154
await page.waitForTimeout(1000);

0 commit comments

Comments
 (0)