-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: embedded chat mode - lazy style attachment (DX-996) (#110)
- Loading branch information
1 parent
9a250ba
commit 623a014
Showing
59 changed files
with
1,339 additions
and
419 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title>Embedded Mode</title> | ||
<style> | ||
body { | ||
background-color: #f9f9f9; | ||
} | ||
|
||
#flat-chat { | ||
width: 100vw; | ||
height: 100vh; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id="flat-chat"></div> | ||
|
||
<script type="text/javascript"> | ||
(function (d, t) { | ||
var v = d.createElement(t), s = d.getElementsByTagName(t)[0]; | ||
v.onload = function () { | ||
window.voiceflow.chat.load({ | ||
verify: { projectID: 'projectID' }, | ||
render: { | ||
mode: 'embedded', | ||
target: document.getElementById('flat-chat'), | ||
}, | ||
}); | ||
} | ||
v.src = "../dist/bundle.mjs"; v.type = "text/javascript"; s.parentNode.insertBefore(v, s); | ||
})(document, 'script'); | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { expect, test } from '@playwright/test'; | ||
|
||
test('renders embedded webchat and starts automatically', async ({ page }) => { | ||
await page.goto('embedded'); | ||
|
||
const chat = page.locator('.vfrc-chat'); | ||
await chat.waitFor({ state: 'visible' }); | ||
expect(chat).toBeInViewport(); | ||
|
||
await page.locator('.vfrc-chat-input').waitFor({ state: 'visible' }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title>Overlay mode</title> | ||
<style> | ||
body { | ||
background-color: #f9f9f9; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<script type="text/javascript"> | ||
(function (d, t) { | ||
var v = d.createElement(t), s = d.getElementsByTagName(t)[0]; | ||
v.onload = function () { | ||
window.voiceflow.chat.load({ | ||
verify: { projectID: 'projectID' }, | ||
render: { mode: 'overlay' } | ||
}); | ||
} | ||
v.src = "../dist/bundle.mjs"; v.type = "text/javascript"; s.parentNode.insertBefore(v, s); | ||
})(document, 'script'); | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { expect, test } from '@playwright/test'; | ||
|
||
test('renders launcher and widget appears on click', async ({ page }) => { | ||
await page.goto('overlay'); | ||
|
||
const launcher = page.locator('.vfrc-launcher'); | ||
await launcher.waitFor({ state: 'visible' }); | ||
await launcher.click(); | ||
|
||
await page.locator('.vfrc-chat').waitFor({ state: 'visible' }); | ||
|
||
page.locator('.vfrc-footer .vfrc-button').click(); | ||
|
||
await page.locator('.vfrc-chat-input').waitFor({ state: 'visible' }); | ||
}); | ||
|
||
test('control widget visibility and open state', async ({ page }) => { | ||
await page.goto('overlay'); | ||
|
||
const launcher = page.locator('.vfrc-launcher'); | ||
const chat = page.locator('.vfrc-chat'); | ||
|
||
await launcher.waitFor({ state: 'visible' }); | ||
|
||
await page.evaluate(() => window.voiceflow?.chat?.open()); | ||
|
||
await chat.waitFor({ state: 'visible' }); | ||
|
||
await page.evaluate(() => window.voiceflow?.chat?.close()); | ||
|
||
expect(chat).not.toBeInViewport(); | ||
|
||
await page.evaluate(() => window.voiceflow?.chat?.hide()); | ||
|
||
await launcher.waitFor({ state: 'hidden' }); | ||
|
||
await page.evaluate(() => window.voiceflow?.chat?.show()); | ||
|
||
await launcher.waitFor({ state: 'visible' }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title>Overlay mode - proactive messages</title> | ||
<style> | ||
body { | ||
background-color: #f9f9f9; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<script type="text/javascript"> | ||
(function (d, t) { | ||
var v = d.createElement(t), s = d.getElementsByTagName(t)[0]; | ||
v.onload = function () { | ||
window.voiceflow.chat.load({ | ||
verify: { projectID: 'projectID' }, | ||
render: { mode: 'overlay' }, | ||
autostart: true | ||
}); | ||
} | ||
v.src = "../dist/bundle.mjs"; v.type = "text/javascript"; s.parentNode.insertBefore(v, s); | ||
})(document, 'script'); | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { test } from '@playwright/test'; | ||
import { Trace } from '@voiceflow/base-types'; | ||
|
||
test('renders launcher and widget appears on click', async ({ page }) => { | ||
const message = 'Welcome to our chat'; | ||
|
||
await page.goto('proactive'); | ||
|
||
await page.locator('.vfrc-launcher').waitFor({ state: 'visible' }); | ||
|
||
await page.evaluate( | ||
([message]) => | ||
window.voiceflow?.chat?.proactive.push({ | ||
type: 'text' as Trace.TraceType.TEXT, | ||
payload: { slate: { id: '', content: [] }, message }, | ||
}), | ||
[message] | ||
); | ||
|
||
await page.waitForSelector(`text=${message}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.