mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-09 08:47:11 -05:00
* fix: move foreman to global gems to fix startup crash (#1971) * Update exporting code to stream points data to file in batches to red… (#1980) * Update exporting code to stream points data to file in batches to reduce memory usage * Update changelog * Update changelog * Feature/maplibre frontend (#1953) * Add a plan to use MapLibre GL JS for the frontend map rendering, replacing Leaflet * Implement phase 1 * Phases 1-3 + part of 4 * Fix e2e tests * Phase 6 * Implement fog of war * Phase 7 * Next step: fix specs, phase 7 done * Use our own map tiles * Extract v2 map logic to separate manager classes * Update settings panel on v2 map * Update v2 e2e tests structure * Reimplement location search in maps v2 * Update speed routes * Implement visits and places creation in v2 * Fix last failing test * Implement visits merging * Fix a routes e2e test and simplify the routes layer styling. * Extract js to modules from maps_v2_controller.js * Implement area creation * Fix spec problem * Fix some e2e tests * Implement live mode in v2 map * Update icons and panel * Extract some styles * Remove unused file * Start adding dark theme to popups on MapLibre maps * Make popups respect dark theme * Move v2 maps to maplibre namespace * Update v2 references to maplibre * Put place, area and visit info into side panel * Update API to use safe settings config method * Fix specs * Fix method name to config in SafeSettings and update usages accordingly * Add missing public files * Add handling for real time points * Fix remembering enabled/disabled layers of the v2 map * Fix lots of e2e tests * Add settings to select map version * Use maps/v2 as main path for MapLibre maps * Update routing * Update live mode * Update maplibre controller * Update changelog * Remove some console.log statements * Pull only necessary data for map v2 points * Feature/raw data archive (#2009) * 0.36.2 (#2007) * fix: move foreman to global gems to fix startup crash (#1971) * Update exporting code to stream points data to file in batches to red… (#1980) * Update exporting code to stream points data to file in batches to reduce memory usage * Update changelog * Update changelog * Feature/maplibre frontend (#1953) * Add a plan to use MapLibre GL JS for the frontend map rendering, replacing Leaflet * Implement phase 1 * Phases 1-3 + part of 4 * Fix e2e tests * Phase 6 * Implement fog of war * Phase 7 * Next step: fix specs, phase 7 done * Use our own map tiles * Extract v2 map logic to separate manager classes * Update settings panel on v2 map * Update v2 e2e tests structure * Reimplement location search in maps v2 * Update speed routes * Implement visits and places creation in v2 * Fix last failing test * Implement visits merging * Fix a routes e2e test and simplify the routes layer styling. * Extract js to modules from maps_v2_controller.js * Implement area creation * Fix spec problem * Fix some e2e tests * Implement live mode in v2 map * Update icons and panel * Extract some styles * Remove unused file * Start adding dark theme to popups on MapLibre maps * Make popups respect dark theme * Move v2 maps to maplibre namespace * Update v2 references to maplibre * Put place, area and visit info into side panel * Update API to use safe settings config method * Fix specs * Fix method name to config in SafeSettings and update usages accordingly * Add missing public files * Add handling for real time points * Fix remembering enabled/disabled layers of the v2 map * Fix lots of e2e tests * Add settings to select map version * Use maps/v2 as main path for MapLibre maps * Update routing * Update live mode * Update maplibre controller * Update changelog * Remove some console.log statements --------- Co-authored-by: Robin Tuszik <mail@robin.gg> * Remove esbuild scripts from package.json * Remove sideEffects field from package.json * Raw data archivation * Add tests * Fix tests * Fix tests * Update ExceptionReporter * Add schedule to run raw data archival job monthly * Change file structure for raw data archival feature * Update changelog and version for raw data archival feature --------- Co-authored-by: Robin Tuszik <mail@robin.gg> * Set raw_data to an empty hash instead of nil when archiving * Fix storage configuration and file extraction * Consider MIN_MINUTES_SPENT_IN_CITY during stats calculation (#2018) * Consider MIN_MINUTES_SPENT_IN_CITY during stats calculation * Remove raw data from visited cities api endpoint * Use user timezone to show dates on maps (#2020) * Fix/pre epoch time (#2019) * Use user timezone to show dates on maps * Limit timestamps to valid range to prevent database errors when users enter pre-epoch dates. * Limit timestamps to valid range to prevent database errors when users enter pre-epoch dates. * Fix tests failing due to new index on stats table * Fix failing specs * Update redis client configuration to support unix socket connection * Update changelog * Fix kml kmz import issues (#2023) * Fix kml kmz import issues * Refactor KML importer to improve readability and maintainability * Implement moving points in map v2 and fix route rendering logic to ma… (#2027) * Implement moving points in map v2 and fix route rendering logic to match map v1. * Fix route spec * fix(maplibre): update date format to ISO 8601 (#2029) * Add verification step to raw data archival process (#2028) * Add verification step to raw data archival process * Add actual verification of raw data archives after creation, and only clear raw_data for verified archives. * Fix failing specs * Eliminate zip-bomb risk * Fix potential memory leak in js * Return .keep files * Use Toast instead of alert for notifications * Add help section to navbar dropdown * Update changelog * Remove raw_data_archival_job * Ensure file is being closed properly after reading in Archivable concern * Add composite index to stats table if not exists * Update changelog * Update entrypoint to always sync static assets (not only new ones) * Add family layer to MapLibre maps (#2055) * Add family layer to MapLibre maps * Update migration * Don't show family toggle if feature is disabled * Update changelog * Return changelog * Update changelog * Update tailwind file --------- Co-authored-by: Robin Tuszik <mail@robin.gg>
370 lines
14 KiB
JavaScript
370 lines
14 KiB
JavaScript
import { test, expect } from '@playwright/test'
|
|
import { closeOnboardingModal } from '../../../helpers/navigation.js'
|
|
import { navigateToMapsV2, waitForMapLibre, waitForLoadingComplete, getMapCenter } from '../../helpers/setup.js'
|
|
|
|
test.describe('Family Members Layer', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await navigateToMapsV2(page)
|
|
await closeOnboardingModal(page)
|
|
await waitForMapLibre(page)
|
|
await waitForLoadingComplete(page)
|
|
await page.waitForTimeout(1500)
|
|
})
|
|
|
|
test.describe('Toggle', () => {
|
|
test('family members toggle exists in Layers tab', async ({ page }) => {
|
|
// Open settings panel
|
|
await page.click('button[title="Open map settings"]')
|
|
await page.waitForTimeout(400)
|
|
|
|
// Click Layers tab
|
|
await page.click('button[data-tab="layers"]')
|
|
await page.waitForTimeout(300)
|
|
|
|
// Check if Family Members toggle exists
|
|
const familyToggle = page.locator('label:has-text("Family Members")').first().locator('input.toggle')
|
|
await expect(familyToggle).toBeVisible()
|
|
})
|
|
|
|
test('family members toggle is unchecked by default', async ({ page }) => {
|
|
await page.click('button[title="Open map settings"]')
|
|
await page.waitForTimeout(400)
|
|
await page.click('button[data-tab="layers"]')
|
|
await page.waitForTimeout(300)
|
|
|
|
const familyToggle = page.locator('label:has-text("Family Members")').first().locator('input.toggle')
|
|
const isChecked = await familyToggle.isChecked()
|
|
expect(isChecked).toBe(false)
|
|
})
|
|
|
|
test('can toggle family members layer on', async ({ page }) => {
|
|
await page.click('button[title="Open map settings"]')
|
|
await page.waitForTimeout(400)
|
|
await page.click('button[data-tab="layers"]')
|
|
await page.waitForTimeout(300)
|
|
|
|
const familyToggle = page.locator('label:has-text("Family Members")').first().locator('input.toggle')
|
|
|
|
// Toggle on
|
|
await familyToggle.check()
|
|
await page.waitForTimeout(1000) // Wait for API call and layer update
|
|
|
|
const isChecked = await familyToggle.isChecked()
|
|
expect(isChecked).toBe(true)
|
|
})
|
|
|
|
test('can toggle family members layer off', async ({ page }) => {
|
|
await page.click('button[title="Open map settings"]')
|
|
await page.waitForTimeout(400)
|
|
await page.click('button[data-tab="layers"]')
|
|
await page.waitForTimeout(300)
|
|
|
|
const familyToggle = page.locator('label:has-text("Family Members")').first().locator('input.toggle')
|
|
|
|
// Toggle on first
|
|
await familyToggle.check()
|
|
await page.waitForTimeout(1000)
|
|
|
|
// Then toggle off
|
|
await familyToggle.uncheck()
|
|
await page.waitForTimeout(500)
|
|
|
|
const isChecked = await familyToggle.isChecked()
|
|
expect(isChecked).toBe(false)
|
|
})
|
|
})
|
|
|
|
test.describe('Family Members List', () => {
|
|
test('family members list is hidden by default', async ({ page }) => {
|
|
await page.click('button[title="Open map settings"]')
|
|
await page.waitForTimeout(400)
|
|
await page.click('button[data-tab="layers"]')
|
|
await page.waitForTimeout(300)
|
|
|
|
const familyMembersList = page.locator('[data-maps--maplibre-target="familyMembersList"]')
|
|
|
|
// Should be hidden initially
|
|
const isHidden = await familyMembersList.evaluate(el => el.style.display === 'none')
|
|
expect(isHidden).toBe(true)
|
|
})
|
|
|
|
test('family members list appears when toggle is enabled', async ({ page }) => {
|
|
await page.click('button[title="Open map settings"]')
|
|
await page.waitForTimeout(400)
|
|
await page.click('button[data-tab="layers"]')
|
|
await page.waitForTimeout(300)
|
|
|
|
const familyToggle = page.locator('label:has-text("Family Members")').first().locator('input.toggle')
|
|
const familyMembersList = page.locator('[data-maps--maplibre-target="familyMembersList"]')
|
|
|
|
// Toggle on
|
|
await familyToggle.check()
|
|
await page.waitForTimeout(1000)
|
|
|
|
// List should now be visible
|
|
const isVisible = await familyMembersList.evaluate(el => el.style.display === 'block')
|
|
expect(isVisible).toBe(true)
|
|
})
|
|
|
|
test('family members list shows members when data exists', async ({ page }) => {
|
|
// Skip if no family members exist
|
|
const hasFamilyMembers = await page.evaluate(async () => {
|
|
const apiKey = document.querySelector('[data-maps--maplibre-api-key-value]')?.dataset.mapsMaplibreApiKeyValue
|
|
if (!apiKey) return false
|
|
|
|
try {
|
|
const response = await fetch(`/api/v1/families/locations?api_key=${apiKey}`)
|
|
if (!response.ok) return false
|
|
const data = await response.json()
|
|
return data.locations && data.locations.length > 0
|
|
} catch (error) {
|
|
return false
|
|
}
|
|
})
|
|
|
|
if (!hasFamilyMembers) {
|
|
test.skip()
|
|
return
|
|
}
|
|
|
|
await page.click('button[title="Open map settings"]')
|
|
await page.waitForTimeout(400)
|
|
await page.click('button[data-tab="layers"]')
|
|
await page.waitForTimeout(300)
|
|
|
|
const familyToggle = page.locator('label:has-text("Family Members")').first().locator('input.toggle')
|
|
|
|
// Toggle on
|
|
await familyToggle.check()
|
|
await page.waitForTimeout(1500) // Wait for API call
|
|
|
|
const familyMembersContainer = page.locator('[data-maps--maplibre-target="familyMembersContainer"]')
|
|
|
|
// Should have at least one member
|
|
const memberItems = familyMembersContainer.locator('div[data-action*="centerOnFamilyMember"]')
|
|
const count = await memberItems.count()
|
|
expect(count).toBeGreaterThan(0)
|
|
})
|
|
|
|
test('family member item displays email and timestamp', async ({ page }) => {
|
|
// Skip if no family members exist
|
|
const hasFamilyMembers = await page.evaluate(async () => {
|
|
const apiKey = document.querySelector('[data-maps--maplibre-api-key-value]')?.dataset.mapsMaplibreApiKeyValue
|
|
if (!apiKey) return false
|
|
|
|
try {
|
|
const response = await fetch(`/api/v1/families/locations?api_key=${apiKey}`)
|
|
if (!response.ok) return false
|
|
const data = await response.json()
|
|
return data.locations && data.locations.length > 0
|
|
} catch (error) {
|
|
return false
|
|
}
|
|
})
|
|
|
|
if (!hasFamilyMembers) {
|
|
test.skip()
|
|
return
|
|
}
|
|
|
|
await page.click('button[title="Open map settings"]')
|
|
await page.waitForTimeout(400)
|
|
await page.click('button[data-tab="layers"]')
|
|
await page.waitForTimeout(300)
|
|
|
|
const familyToggle = page.locator('label:has-text("Family Members")').first().locator('input.toggle')
|
|
await familyToggle.check()
|
|
await page.waitForTimeout(1500)
|
|
|
|
const familyMembersContainer = page.locator('[data-maps--maplibre-target="familyMembersContainer"]')
|
|
const firstMember = familyMembersContainer.locator('div[data-action*="centerOnFamilyMember"]').first()
|
|
|
|
// Should have email
|
|
const emailElement = firstMember.locator('.text-sm.font-medium')
|
|
await expect(emailElement).toBeVisible()
|
|
|
|
// Should have timestamp
|
|
const timestampElement = firstMember.locator('.text-xs.text-base-content\\/60')
|
|
await expect(timestampElement).toBeVisible()
|
|
})
|
|
})
|
|
|
|
test.describe('Center on Member', () => {
|
|
test('clicking family member centers map on their location', async ({ page }) => {
|
|
// Skip if no family members exist
|
|
const hasFamilyMembers = await page.evaluate(async () => {
|
|
const apiKey = document.querySelector('[data-maps--maplibre-api-key-value]')?.dataset.mapsMaplibreApiKeyValue
|
|
if (!apiKey) return false
|
|
|
|
try {
|
|
const response = await fetch(`/api/v1/families/locations?api_key=${apiKey}`)
|
|
if (!response.ok) return false
|
|
const data = await response.json()
|
|
return data.locations && data.locations.length > 0
|
|
} catch (error) {
|
|
return false
|
|
}
|
|
})
|
|
|
|
if (!hasFamilyMembers) {
|
|
test.skip()
|
|
return
|
|
}
|
|
|
|
await page.click('button[title="Open map settings"]')
|
|
await page.waitForTimeout(400)
|
|
await page.click('button[data-tab="layers"]')
|
|
await page.waitForTimeout(300)
|
|
|
|
const familyToggle = page.locator('label:has-text("Family Members")').first().locator('input.toggle')
|
|
await familyToggle.check()
|
|
await page.waitForTimeout(1500)
|
|
|
|
// Get initial map center
|
|
const initialCenter = await getMapCenter(page)
|
|
|
|
// Click on first family member
|
|
const familyMembersContainer = page.locator('[data-maps--maplibre-target="familyMembersContainer"]')
|
|
const firstMember = familyMembersContainer.locator('div[data-action*="centerOnFamilyMember"]').first()
|
|
await firstMember.click()
|
|
|
|
// Wait for map animation
|
|
await page.waitForTimeout(2000)
|
|
|
|
// Get new map center
|
|
const newCenter = await getMapCenter(page)
|
|
|
|
// Map should have moved (centers should be different)
|
|
const hasMoved = initialCenter.lat !== newCenter.lat || initialCenter.lng !== newCenter.lng
|
|
expect(hasMoved).toBe(true)
|
|
})
|
|
|
|
test('shows success toast when centering on member', async ({ page }) => {
|
|
// Skip if no family members exist
|
|
const hasFamilyMembers = await page.evaluate(async () => {
|
|
const apiKey = document.querySelector('[data-maps--maplibre-api-key-value]')?.dataset.mapsMaplibreApiKeyValue
|
|
if (!apiKey) return false
|
|
|
|
try {
|
|
const response = await fetch(`/api/v1/families/locations?api_key=${apiKey}`)
|
|
if (!response.ok) return false
|
|
const data = await response.json()
|
|
return data.locations && data.locations.length > 0
|
|
} catch (error) {
|
|
return false
|
|
}
|
|
})
|
|
|
|
if (!hasFamilyMembers) {
|
|
test.skip()
|
|
return
|
|
}
|
|
|
|
await page.click('button[title="Open map settings"]')
|
|
await page.waitForTimeout(400)
|
|
await page.click('button[data-tab="layers"]')
|
|
await page.waitForTimeout(300)
|
|
|
|
const familyToggle = page.locator('label:has-text("Family Members")').first().locator('input.toggle')
|
|
await familyToggle.check()
|
|
await page.waitForTimeout(1500)
|
|
|
|
// Click on first family member
|
|
const familyMembersContainer = page.locator('[data-maps--maplibre-target="familyMembersContainer"]')
|
|
const firstMember = familyMembersContainer.locator('div[data-action*="centerOnFamilyMember"]').first()
|
|
await firstMember.click()
|
|
|
|
// Wait for toast to appear
|
|
await page.waitForTimeout(500)
|
|
|
|
// Check for success toast
|
|
const toast = page.locator('.alert-success, .toast, [role="alert"]').filter({ hasText: 'Centered on family member' })
|
|
await expect(toast).toBeVisible({ timeout: 3000 })
|
|
})
|
|
})
|
|
|
|
test.describe('Family Layer on Map', () => {
|
|
test('family layer exists on map', async ({ page }) => {
|
|
const hasLayer = await page.evaluate(() => {
|
|
const element = document.querySelector('[data-controller*="maps--maplibre"]')
|
|
const app = window.Stimulus || window.Application
|
|
const controller = app?.getControllerForElementAndIdentifier(element, 'maps--maplibre')
|
|
return controller?.map?.getLayer('family') !== undefined
|
|
})
|
|
|
|
expect(hasLayer).toBe(true)
|
|
})
|
|
|
|
test('family layer is hidden by default', async ({ page }) => {
|
|
const isVisible = await page.evaluate(() => {
|
|
const element = document.querySelector('[data-controller*="maps--maplibre"]')
|
|
const app = window.Stimulus || window.Application
|
|
const controller = app?.getControllerForElementAndIdentifier(element, 'maps--maplibre')
|
|
const visibility = controller?.map?.getLayoutProperty('family', 'visibility')
|
|
return visibility === 'visible'
|
|
})
|
|
|
|
expect(isVisible).toBe(false)
|
|
})
|
|
|
|
test('family layer becomes visible when toggle is enabled', async ({ page }) => {
|
|
await page.click('button[title="Open map settings"]')
|
|
await page.waitForTimeout(400)
|
|
await page.click('button[data-tab="layers"]')
|
|
await page.waitForTimeout(300)
|
|
|
|
const familyToggle = page.locator('label:has-text("Family Members")').first().locator('input.toggle')
|
|
await familyToggle.check()
|
|
await page.waitForTimeout(1500)
|
|
|
|
const isVisible = await page.evaluate(() => {
|
|
const element = document.querySelector('[data-controller*="maps--maplibre"]')
|
|
const app = window.Stimulus || window.Application
|
|
const controller = app?.getControllerForElementAndIdentifier(element, 'maps--maplibre')
|
|
const visibility = controller?.map?.getLayoutProperty('family', 'visibility')
|
|
return visibility === 'visible' || visibility === undefined
|
|
})
|
|
|
|
expect(isVisible).toBe(true)
|
|
})
|
|
})
|
|
|
|
test.describe('No Family Members', () => {
|
|
test('shows appropriate message when no family members are sharing', async ({ page }) => {
|
|
// This test checks the message when API returns empty array
|
|
const hasFamilyMembers = await page.evaluate(async () => {
|
|
const apiKey = document.querySelector('[data-maps--maplibre-api-key-value]')?.dataset.mapsMaplibreApiKeyValue
|
|
if (!apiKey) return false
|
|
|
|
try {
|
|
const response = await fetch(`/api/v1/families/locations?api_key=${apiKey}`)
|
|
if (!response.ok) return false
|
|
const data = await response.json()
|
|
return data.locations && data.locations.length > 0
|
|
} catch (error) {
|
|
return false
|
|
}
|
|
})
|
|
|
|
// Only run this test if there are NO family members
|
|
if (hasFamilyMembers) {
|
|
test.skip()
|
|
return
|
|
}
|
|
|
|
await page.click('button[title="Open map settings"]')
|
|
await page.waitForTimeout(400)
|
|
await page.click('button[data-tab="layers"]')
|
|
await page.waitForTimeout(300)
|
|
|
|
const familyToggle = page.locator('label:has-text("Family Members")').first().locator('input.toggle')
|
|
await familyToggle.check()
|
|
await page.waitForTimeout(1500)
|
|
|
|
const familyMembersContainer = page.locator('[data-maps--maplibre-target="familyMembersContainer"]')
|
|
const noMembersMessage = familyMembersContainer.getByText('No family members sharing location')
|
|
|
|
await expect(noMembersMessage).toBeVisible()
|
|
})
|
|
})
|
|
})
|