Skip to content

Commit 42071aa

Browse files
zoldarapata
andauthored
Extend E2E dashboard tests (#6077)
* Add helper for adding custom goal and use it in a new test * Extend and add goal helpers to support all goal types * Add intro tests * Add js-joda for time manipulation in tests * Properly test for different time ranges * Test graph intervals * Test comparing stats over time * Split filter tests into a separate context and cover page related ones * Add hostname filter test * Add goal filter tests * Add property filtering tests * Remove unnecessary assertions for goal setup fixtures * Add tests for all acquisition related filters * Add tests for filtering by location * Shorten test timeout for local dev env from 30s to 10s * Add (broken) test for screen size filtering * Add missing type definitions in frontend event fixture * Test filtering by browser * Test operating system filters (broken the same way as screen size) * WIP * Add remaining time related tests * Add tests for site switcher * Add breakdown tests * Add more breakdown tests * Move some of the helpers to `test-utils` * Add behaviour tests along with fixtures for custom props and funnels * Extend behaviour tests * Test breakdown layout change (report and modal) for goals in filters * Add more detailed modal tests * Add modal tests to breakdowns * Add modal tests to behaviours * Test funnels tab dropdown * Test props dropdown search * Test current realtime visitors counter in top stats * Move filter helpers to test-utils for reuse in segments tests * Add one more filter helper * Test creating personal segment * Fix existing tests * Test adding site segments * Test combining filters and segments * Remove commented out, brittle version of `addFunnel` fixture * Test editing existing segment * Test saving segment as new * Test deleting segment * Test closing edited segment without saving * Fix type signature ofr MovePeriodArrows * Fix formatting * Don't include backend E2E logic in CE * Increase the number of E2E CI shards from 2 to 4 * Fix problematic test cases * Move general tests under `dashboard/` and remove redundant cases * Add test for accessing dashboard via shared link * Add basic e2e test for imported data with all the necessary tooling * Make site switcher test less brittle * Make E2E tests run server using distinct HTTP port * Add alias for conveniently setting up E2E * Bump log level to error for `MIX_ENV=e2e_test` * Update typespec in fixtures * Extract `currentTime` in top-stats * Add typechecking * Fix imports * Fix TS issues, enforce code format on CI and enforce type-correctness * Comment out slowMo and headless commands * Finetune mix * Revert timeout * Revert unnecessary config changes * Fix github actions commands * Add missing awaits * Increase timeouts for local dev env to account for patahto hardware * Rename testid data attribute for better consistency * Fix formatting --------- Co-authored-by: Artur Pata <artur.pata@gmail.com>
1 parent 710381e commit 42071aa

42 files changed

Lines changed: 5168 additions & 190 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/elixir.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ jobs:
119119
timeout-minutes: 15
120120
env:
121121
MIX_ENV: e2e_test
122-
BASE_URL: "http://localhost:8000"
122+
BASE_URL: "http://localhost:8111"
123123
services:
124124
postgres:
125125
image: "postgres:18"
@@ -146,8 +146,8 @@ jobs:
146146
strategy:
147147
fail-fast: false
148148
matrix:
149-
shardIndex: [1, 2]
150-
shardTotal: [2]
149+
shardIndex: [1, 2, 3, 4]
150+
shardTotal: [4]
151151
steps:
152152
- uses: actions/checkout@v6
153153
with:
@@ -209,6 +209,12 @@ jobs:
209209
- name: Install E2E dependencies
210210
run: npm --prefix ./e2e ci
211211

212+
- name: Check format
213+
run: npm --prefix ./e2e run check-format
214+
215+
- name: Check types
216+
run: npm --prefix ./e2e run typecheck
217+
212218
- name: Install E2E Playwright Browsers
213219
if: steps.playwright-cache.outputs.cache-hit != 'true'
214220
working-directory: ./e2e

assets/js/dashboard/components/filter-operator-selector.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ export default function FilterOperatorSelector(props) {
3030
ref={buttonRef}
3131
className="relative flex justify-between items-center w-full rounded-md border border-gray-300 dark:border-gray-750 px-4 py-2 bg-white dark:bg-gray-750 text-sm text-gray-700 dark:text-gray-200 dark:hover:bg-gray-700 focus:outline-hidden focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 dark:focus:ring-offset-gray-900 focus:ring-indigo-500 text-left"
3232
>
33-
{FILTER_OPERATIONS_DISPLAY_NAMES[props.selectedType]}
33+
<span data-testid="filter-operator">
34+
{FILTER_OPERATIONS_DISPLAY_NAMES[props.selectedType]}
35+
</span>
3436
<ChevronDownIcon
3537
className="-mr-2 ml-2 h-4 w-4 text-gray-500 dark:text-gray-400"
3638
aria-hidden="true"
@@ -63,6 +65,7 @@ export default function FilterOperatorSelector(props) {
6365
.filter(([_operation, supported]) => supported)
6466
.map(([operation]) => (
6567
<button
68+
data-testid="filter-operator-option"
6669
key={operation}
6770
data-selected={operation === props.selectedType}
6871
onClick={(e) => {

assets/js/dashboard/components/search-input.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export const SearchInput = ({
7171
/>
7272
<div className={classNames('relative max-w-64 w-full', className)}>
7373
<input
74+
data-testid="search-input"
7475
onBlur={() => setIsFocused(false)}
7576
onFocus={() => setIsFocused(true)}
7677
ref={searchRef}

assets/js/dashboard/components/table.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const TableHeaderCell = ({
3737
}) => {
3838
return (
3939
<th
40+
data-testid="report-header"
4041
className={classNames(
4142
'p-2 text-xs font-semibold text-gray-500 dark:text-gray-400',
4243
className
@@ -105,6 +106,7 @@ export const ItemRow = <T extends Record<string, string | number | ReactNode>>({
105106

106107
return (
107108
<tr
109+
data-testid="report-row"
108110
className="group text-sm dark:text-gray-200 md:cursor-default cursor-pointer"
109111
onMouseEnter={() => setIsHovered(true)}
110112
onMouseLeave={() => setIsHovered(false)}

assets/js/dashboard/components/tabs.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ const TabButtonText = ({
3838
'text-gray-900 dark:text-gray-100 font-bold tracking-[-.01em]': active
3939
})}
4040
>
41-
{children}
41+
<span data-active={active ? 'true' : 'false'} data-testid="tab-button">
42+
{children}
43+
</span>
4244
</span>
4345
)
4446

@@ -183,6 +185,7 @@ const Items = ({ options, searchable, closeDropdown }: ItemsProps) => {
183185
</div>
184186
)}
185187
<div
188+
data-testid="dropdown-items"
186189
className={'max-h-[224px] overflow-y-auto flex flex-col gap-y-0.5 p-1'}
187190
>
188191
{showableData.map(({ selected, label, onClick }, index) => {

assets/js/dashboard/nav-menu/query-periods/dashboard-period-menu.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ export const DashboardPeriodMenu = ({
9696
<>
9797
<BlurMenuButtonOnEscape targetRef={buttonRef} />
9898
<Popover.Button ref={buttonRef} className={datemenuButtonClassName}>
99-
<span className={popover.toggleButton.classNames.truncatedText}>
99+
<span
100+
data-testid="current-query-period"
101+
className={popover.toggleButton.classNames.truncatedText}
102+
>
100103
{getCurrentPeriodDisplayName({ dashboardState, site })}
101104
</span>
102105
<DateMenuChevron />

assets/js/dashboard/nav-menu/query-periods/dashboard-period-picker.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ export function DashboardPeriodPicker({ className }: { className?: string }) {
1717
const compareCalendarButtonRef = useRef<HTMLButtonElement>(null)
1818

1919
return (
20-
<div className={classNames('flex shrink-0', className)}>
20+
<div
21+
data-testid="query-period-picker"
22+
className={classNames('flex shrink-0', className)}
23+
>
2124
<MovePeriodArrows className={isComparing ? 'hidden md:flex' : ''} />
2225
<Popover className="min-w-36 md:relative lg:w-48">
2326
{({ close }) => (

assets/js/dashboard/nav-menu/query-periods/move-period-arrows.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,17 @@ const ArrowKeybind = ({
4141
}
4242

4343
function ArrowIcon({
44+
testId,
4445
direction,
4546
disabled = false
4647
}: {
48+
testId?: string
4749
direction: 'left' | 'right'
4850
disabled?: boolean
4951
}) {
5052
return (
5153
<svg
54+
data-testid={testId}
5255
className={classNames(
5356
'feather size-4',
5457
disabled
@@ -117,7 +120,11 @@ export function MovePeriodArrows({ className }: { className?: string }) {
117120
: (search) => search
118121
}
119122
>
120-
<ArrowIcon direction="left" disabled={!canGoBack} />
123+
<ArrowIcon
124+
testId="period-move-back"
125+
direction="left"
126+
disabled={!canGoBack}
127+
/>
121128
</AppNavigationLink>
122129
<AppNavigationLink
123130
className={classNames(sharedClass, 'rounded-r', {
@@ -135,7 +142,11 @@ export function MovePeriodArrows({ className }: { className?: string }) {
135142
: (search) => search
136143
}
137144
>
138-
<ArrowIcon direction="right" disabled={!canGoForward} />
145+
<ArrowIcon
146+
testId="period-move-forward"
147+
direction="right"
148+
disabled={!canGoForward}
149+
/>
139150
</AppNavigationLink>
140151
{!!dashboardRouteMatch && <ArrowKeybind keyboardKey="ArrowLeft" />}
141152
{!!dashboardRouteMatch && <ArrowKeybind keyboardKey="ArrowRight" />}

assets/js/dashboard/nav-menu/segments/segment-menu.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export const SegmentMenu = () => {
8686
)}
8787
>
8888
<ChevronDownIcon
89+
data-testid="segment-menu"
8990
className="w-4 h-4 md:h-5 md:w-5 block"
9091
aria-hidden="true"
9192
/>

assets/js/dashboard/site-switcher.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,10 @@ export const SiteSwitcher = () => {
183183
className="block h-4 w-4 mx-1"
184184
/>
185185
)}
186-
<span className={'truncate hidden sm:block sm:mr-1 lg:mr-0'}>
186+
<span
187+
data-testid="site-switcher-current-site"
188+
className={'truncate hidden sm:block sm:mr-1 lg:mr-0'}
189+
>
187190
{currentSite.isConsolidatedView
188191
? 'All sites'
189192
: currentSite.domain}

0 commit comments

Comments
 (0)