mirror of
https://github.com/plausible/analytics.git
synced 2024-12-25 02:24:55 +03:00
43bf7dd09f
* Use user-agent instead of screen_width to get device type Co-authored-by: eriknakata <erik.nakata5@gmail.com> * Fix credo * Log on unhandled UAInspector device type * Make 'browser' the default tab in devices report * Remove device tooltip * Remove screen_width from ingestion completely * Remove browserstack harness, run playwright directly * Select meta key based on OS platform * Run CI tests in parallel * Improve device match readability * Add changelog --------- Co-authored-by: eriknakata <erik.nakata5@gmail.com>
52 lines
2.2 KiB
JavaScript
52 lines
2.2 KiB
JavaScript
const { mockRequest, expectCustomEvent, mockManyRequests, metaKey } = require('./support/test-utils');
|
|
const { expect, test } = require('@playwright/test');
|
|
const { LOCAL_SERVER_ADDR } = require('./support/server');
|
|
|
|
|
|
test.describe('file-downloads extension', () => {
|
|
test('sends event and does not start download when link opens in new tab', async ({ page }) => {
|
|
await page.goto('/file-download.html')
|
|
const downloadURL = await page.locator('#link').getAttribute('href')
|
|
|
|
const plausibleRequestMock = mockRequest(page, '/api/event')
|
|
const downloadRequestMock = mockRequest(page, downloadURL)
|
|
await page.click('#link', { modifiers: [metaKey()] })
|
|
|
|
expectCustomEvent(await plausibleRequestMock, 'File Download', { url: downloadURL })
|
|
expect(await downloadRequestMock, "should not make download request").toBeNull()
|
|
});
|
|
|
|
test('sends event and starts download when link child is clicked', async ({ page }) => {
|
|
await page.goto('/file-download.html')
|
|
const downloadURL = await page.locator('#link').getAttribute('href')
|
|
|
|
const plausibleRequestMock = mockRequest(page, '/api/event')
|
|
const downloadRequestMock = mockRequest(page, downloadURL)
|
|
await page.click('#link-child')
|
|
|
|
expectCustomEvent(await plausibleRequestMock, 'File Download', { url: downloadURL })
|
|
expect((await downloadRequestMock).url()).toContain(downloadURL)
|
|
});
|
|
|
|
test('sends File Download event with query-stripped url property', async ({ page }) => {
|
|
await page.goto('/file-download.html')
|
|
const downloadURL = await page.locator('#link-query').getAttribute('href')
|
|
|
|
const plausibleRequestMock = mockRequest(page, '/api/event')
|
|
await page.click('#link-query')
|
|
|
|
const expectedURL = downloadURL.split("?")[0]
|
|
expectCustomEvent(await plausibleRequestMock, 'File Download', { url: expectedURL })
|
|
});
|
|
|
|
test('starts download only once', async ({ page }) => {
|
|
await page.goto('/file-download.html')
|
|
const downloadURL = LOCAL_SERVER_ADDR + '/' + await page.locator('#local-download').getAttribute('href')
|
|
|
|
const downloadRequestMockList = mockManyRequests(page, downloadURL, 2)
|
|
await page.click('#local-download')
|
|
|
|
expect((await downloadRequestMockList).length).toBe(1)
|
|
});
|
|
});
|