mirror of
https://github.com/hanzoai/insights-js.git
synced 2026-11-03 00:53:53 +00:00
Bulk rename across 989 files: - Package names: posthog-js → @hanzo/insights, posthog-node → @hanzo/insights-node, etc. - Repository URLs: posthog/posthog-js → hanzoai/insights-js - Brand names: PostHog → Insights - File renames: 259 reference JSON files, source files, workflow files - Directory rename: eslint-plugin-posthog-js → eslint-plugin-insights Remaining: 8 refs to @posthog/rrweb-* (real npm deps, need fork+publish)
86 lines
3.0 KiB
TypeScript
86 lines
3.0 KiB
TypeScript
import { expect, test } from '../utils/insights-playwright-test-base'
|
|
import { start } from '../utils/setup'
|
|
|
|
const startOptions = {
|
|
options: {},
|
|
flagsResponseOverrides: {
|
|
surveys: true,
|
|
},
|
|
url: './playground/cypress/index.html',
|
|
}
|
|
|
|
const emojiRatingQuestion = {
|
|
type: 'rating',
|
|
display: 'emoji',
|
|
scale: 5,
|
|
question: 'How happy are you with your purchase?',
|
|
optional: true,
|
|
id: 'emoji_rating_1',
|
|
}
|
|
|
|
const appearanceWithThanks = {
|
|
displayThankYouMessage: true,
|
|
thankyouMessageHeader: 'Thanks!',
|
|
thankyouMessageBody: 'We appreciate your feedback.',
|
|
}
|
|
|
|
test.describe('surveys - feedback widget', () => {
|
|
test('shows confirmation message after submitting', async ({ page, context }) => {
|
|
const surveysAPICall = page.route('**/surveys/**', async (route) => {
|
|
await route.fulfill({
|
|
json: {
|
|
surveys: [
|
|
{
|
|
id: '123',
|
|
name: 'Test survey',
|
|
type: 'popover',
|
|
start_date: '2021-01-01T00:00:00Z',
|
|
questions: [emojiRatingQuestion],
|
|
appearance: { ...appearanceWithThanks, backgroundColor: 'black' },
|
|
},
|
|
],
|
|
},
|
|
})
|
|
})
|
|
|
|
await start(startOptions, page, context)
|
|
await surveysAPICall
|
|
|
|
await expect(page.locator('.InsightsSurvey-123 .ratings-emoji')).toHaveCount(5)
|
|
await page.locator('.InsightsSurvey-123 .ratings-emoji').first().click()
|
|
|
|
await page.locator('.InsightsSurvey-123 .form-submit').click()
|
|
await expect(page.locator('.InsightsSurvey-123 .thank-you-message')).toBeVisible()
|
|
})
|
|
|
|
test('counts down with auto disappear after 5 seconds', async ({ page, context }) => {
|
|
const surveysAPICall = page.route('**/surveys/**', async (route) => {
|
|
await route.fulfill({
|
|
json: {
|
|
surveys: [
|
|
{
|
|
id: '123',
|
|
name: 'Test survey',
|
|
type: 'popover',
|
|
start_date: '2021-01-01T00:00:00Z',
|
|
questions: [emojiRatingQuestion],
|
|
appearance: { ...appearanceWithThanks, autoDisappear: true },
|
|
},
|
|
],
|
|
},
|
|
})
|
|
})
|
|
|
|
await start(startOptions, page, context)
|
|
await surveysAPICall
|
|
|
|
await expect(page.locator('.InsightsSurvey-123 .ratings-emoji')).toHaveCount(5)
|
|
await page.locator('.InsightsSurvey-123 .ratings-emoji').first().click()
|
|
await page.locator('.InsightsSurvey-123 .form-submit').click()
|
|
|
|
await expect(page.locator('.InsightsSurvey-123 .thank-you-message')).toBeVisible()
|
|
await page.waitForTimeout(5000)
|
|
await expect(page.locator('.InsightsSurvey-123 .thank-you-message')).not.toBeVisible()
|
|
})
|
|
})
|