Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
f9b292e
fix: set base URL to '/' and add comprehensive tests
github-actions[bot] Jan 5, 2026
757f958
fix :Errors
AvivAbachi Jan 5, 2026
ad3d436
fix: update ASSET_URL in build workflow for consistency
AvivAbachi Jan 5, 2026
7f3448e
fix: remove vite.config.test.ts to fix Jest/Vitest conflict
github-actions[bot] Jan 5, 2026
d03ff57
Merge branch 'claude/issue-329-20260105-1935' of https://github.com/h…
AvivAbachi Jan 5, 2026
43493f8
test: add assertions to verify asset arrays aren't empty
github-actions[bot] Jan 7, 2026
3aed960
fix: update environment variable from ASSET_URL to PREVIEW_URL for co…
AvivAbachi Jan 7, 2026
ed10d79
fix: reorder imports in vite.config.ts for clarity
AvivAbachi Jan 7, 2026
657364b
fix: rename environment variable from PREVIEW_URL to VITE_PREVIEW_URL…
AvivAbachi Jan 7, 2026
7537a0d
fix: configure Storybook base URL for preview deployments
github-actions[bot] Jan 7, 2026
997fd33
fix: add basename to router for VITE_PREVIEW_URL support
AvivAbachi Jan 7, 2026
98f1514
fix: rename VITE_PREVIEW_URL to VITE_BASE_PATH for consistency across…
AvivAbachi Jan 7, 2026
57d4f5e
fix: update VITE_BASE_PATH to include domain for consistency in build…
AvivAbachi Jan 7, 2026
0119317
fix: update VITE_BASE_PATH to remove hardcoded domain for flexibility
AvivAbachi Jan 7, 2026
a9420ef
fix: update VITE_BASE_PATH to include hardcoded domain for consistency
AvivAbachi Jan 7, 2026
e263ff4
fix: update base path configuration to use process.env for consistency
AvivAbachi Jan 7, 2026
8d4b6a7
fix: tests
AvivAbachi Jan 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ permissions:
issues: write

env:
VITE_MSW_S3_URL: https://s3.amazonaws.com/noam-gaash.co.il/${{ github.run_id }}/open-bus/${{ github.run_number }}/storybook/mockServiceWorker.js
ASSET_URL: https://s3.amazonaws.com/noam-gaash.co.il/${{ github.run_id }}/open-bus/${{ github.run_number }}/

jobs:
build:
Expand Down
89 changes: 89 additions & 0 deletions tests/baseUrl.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { expect, setupTest, test } from './utils'

test.describe('Base URL configuration tests', () => {
test('assets should load from root path on nested routes', async ({ page }) => {
await setupTest(page)

// Navigate to a nested route (e.g., /profile/:id)
// We'll use a direct navigation to simulate the issue scenario
await page.goto('/profile/8235701')

// Wait for the page to load
await page.waitForLoadState('networkidle')

// Check that JavaScript assets are loaded from the correct path
const scriptTags = await page.locator('script[src]').all()
const scriptSources = await Promise.all(scriptTags.map((tag) => tag.getAttribute('src')))

// Filter for asset files (typically in /assets/ directory)
const assetScripts = scriptSources.filter((src) => src && src.includes('/assets/'))
Comment thread
AvivAbachi marked this conversation as resolved.
Outdated

// Verify that asset paths start with /assets/ (from root) and not /profile/assets/
for (const src of assetScripts) {
if (src) {
expect(src.startsWith('/assets/')).toBeTruthy()
expect(src.startsWith('/profile/assets/')).toBeFalsy()
}
}

// Also verify that all script resources loaded successfully (no 404s)
const failedRequests: string[] = []
page.on('requestfailed', (request) => {
if (request.resourceType() === 'script') {
failedRequests.push(request.url())
}
})

// Reload the page to trigger all resource loads again
await page.reload()
await page.waitForLoadState('networkidle')

// Check that no script requests failed
expect(failedRequests.length).toBe(0)
})

test('assets should load correctly on dashboard page', async ({ page }) => {
await setupTest(page)

// Navigate to dashboard (a top-level route)
await page.goto('/dashboard')
await page.waitForLoadState('networkidle')

// Check that JavaScript assets are loaded from the correct path
const scriptTags = await page.locator('script[src]').all()
const scriptSources = await Promise.all(scriptTags.map((tag) => tag.getAttribute('src')))

// Filter for asset files
const assetScripts = scriptSources.filter((src) => src && src.includes('/assets/'))
Comment thread
AvivAbachi marked this conversation as resolved.
Outdated

// Verify that asset paths start with /assets/ (from root)
for (const src of assetScripts) {
if (src) {
expect(src.startsWith('/assets/')).toBeTruthy()
}
}
})

test('CSS assets should load from root path on nested routes', async ({ page }) => {
await setupTest(page)

// Navigate to a nested route
await page.goto('/profile/8235701')
await page.waitForLoadState('networkidle')

// Check that CSS assets are loaded from the correct path
const linkTags = await page.locator('link[rel="stylesheet"]').all()
const linkHrefs = await Promise.all(linkTags.map((tag) => tag.getAttribute('href')))

// Filter for asset files
const assetLinks = linkHrefs.filter((href) => href && href.includes('/assets/'))
Comment thread
AvivAbachi marked this conversation as resolved.
Outdated

// Verify that asset paths start with /assets/ (from root) and not /profile/assets/
for (const href of assetLinks) {
if (href) {
expect(href.startsWith('/assets/')).toBeTruthy()
expect(href.startsWith('/profile/assets/')).toBeFalsy()
}
}
})
})
4 changes: 2 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import react from '@vitejs/plugin-react-oxc'
import { loadEnv } from 'vite'
import { defineConfig } from 'vite'
import IstanbulPlugin from 'vite-plugin-istanbul'
import { defineConfig } from 'vitest/config'

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd())

return {
base: env?.ASSET_URL || '',
base: env?.ASSET_URL || '/',
plugins: [
react(),
...(env?.VITE_COVERAGE
Expand Down
Loading