Skip to content

Commit

Permalink
fix: autostart default value (DX-1087) (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
ninabondar committed Feb 22, 2024
1 parent 397dbcb commit d2e6978
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/react-chat/e2e/embedded.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ test('renders embedded webchat and starts automatically', async ({ page }) => {
const chat = page.locator('.vfrc-chat');
await chat.waitFor({ state: 'visible' });
expect(chat).toBeInViewport();
page.locator('.vfrc-footer .vfrc-button').click();

await page.locator('.vfrc-chat-input').waitFor({ state: 'visible' });
});
6 changes: 2 additions & 4 deletions packages/react-chat/e2e/overlay.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ test('renders launcher and widget appears on click', async ({ page }) => {
const launcher = page.locator('.vfrc-launcher');
await launcher.waitFor({ state: 'visible' });
await launcher.click();
const chat = page.locator('.vfrc-chat');

await page.locator('.vfrc-chat').waitFor({ state: 'visible' });

page.locator('.vfrc-footer .vfrc-button').click();

await chat.waitFor({ state: 'visible' });
await page.locator('.vfrc-chat-input').waitFor({ state: 'visible' });
});

Expand Down
3 changes: 1 addition & 2 deletions packages/react-chat/examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
name: 'Development User',
},
render: {
mode: 'embedded',
target: document.getElementById('flat-chat'),
mode: 'overlay',
},
autostart: true,
allowDangerousHTML: false,
Expand Down
6 changes: 3 additions & 3 deletions packages/react-chat/src/dtos/ChatConfig.dto.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('ChatConfig', () => {
});

expect(result).toEqual({
autostart: false,
autostart: true,
allowDangerousHTML: true,
url: RUNTIME_URL,
verify: { projectID },
Expand Down Expand Up @@ -48,7 +48,7 @@ describe('ChatConfig', () => {
});

expect(result).toEqual({
autostart: false,
autostart: true,
allowDangerousHTML: true,
url: RUNTIME_URL,
verify: { projectID },
Expand All @@ -66,7 +66,7 @@ describe('ChatConfig', () => {
});

expect(result).toEqual({
autostart: false,
autostart: true,
allowDangerousHTML: true,
url: RUNTIME_URL,
verify: { projectID },
Expand Down
4 changes: 2 additions & 2 deletions packages/react-chat/src/dtos/ChatConfig.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ export const ChatConfig = z
.transform((config) => ({
...config,

// if not configured default to enabling autostart during embedded mode and disabling it otherwise
autostart: config.autostart ?? config.render.mode === RenderMode.EMBEDDED,
// if not configured default to enabling autostart during overlay mode and disabling it otherwise
autostart: config.autostart ?? config.render.mode === RenderMode.OVERLAY,
}));

0 comments on commit d2e6978

Please sign in to comment.