2
0

fix(lib): 🐛 Safari context menu trap

This commit is contained in:
Baptiste Arnaud
2022-04-08 18:38:36 -05:00
parent fb3bba897f
commit 144ffaeb03
8 changed files with 41 additions and 41 deletions

View File

@ -5,7 +5,7 @@ beforeEach(() => {
})
describe('openBubble', () => {
it('should add the opened bubble', () => {
it('should add the opened bubble', async () => {
expect.assertions(3)
const { open } = Typebot.initBubble({
url: 'https://typebot.io/typebot-id',
@ -13,6 +13,7 @@ describe('openBubble', () => {
const bubble = document.getElementById('typebot-bubble') as HTMLDivElement
expect(bubble.classList.contains('iframe-opened')).toBe(false)
open()
await new Promise((resolve) => setTimeout(resolve, 50))
expect(bubble.classList.contains('iframe-opened')).toBe(true)
expect(open).not.toThrow()
})
@ -35,13 +36,14 @@ describe('openBubble', () => {
})
describe('closeBubble', () => {
it('should remove the corresponding class', () => {
it('should remove the corresponding class', async () => {
expect.assertions(2)
const { close, open } = Typebot.initBubble({
url: 'https://typebot.io/typebot-id',
})
open()
const bubble = document.getElementById('typebot-bubble') as HTMLDivElement
await new Promise((resolve) => setTimeout(resolve, 50))
expect(bubble.classList.contains('iframe-opened')).toBe(true)
close()
expect(bubble.classList.contains('iframe-opened')).toBe(false)
@ -72,7 +74,7 @@ describe('openProactiveMessage', () => {
})
describe('Request commands afterwards', () => {
it('should return defined commands', () => {
it('should return defined commands', async () => {
Typebot.initBubble({
proactiveMessage: {
textContent: 'Hi click here!',
@ -85,6 +87,7 @@ describe('Request commands afterwards', () => {
expect(open).toBeDefined()
expect(openProactiveMessage).toBeDefined()
open()
await new Promise((resolve) => setTimeout(resolve, 50))
const bubble = document.getElementById('typebot-bubble') as HTMLDivElement
expect(bubble.classList.contains('iframe-opened')).toBe(true)
})

View File

@ -36,7 +36,7 @@ describe('initBubble', () => {
})
const bubble = document.querySelector('#typebot-bubble') as HTMLDivElement
expect(bubble.classList.contains('iframe-opened')).toBe(false)
await new Promise((r) => setTimeout(r, 1000))
await new Promise((r) => setTimeout(r, 1050))
expect(bubble.classList.contains('iframe-opened')).toBe(true)
const rememberCloseDecisionFromStorage = localStorage.getItem(
Typebot.localStorageKeys.rememberClose