Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 0 deletions e2e/e2e-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export { derivePort } from './derivePort'
export { localDummyServer } from './localDummyServer'
export { toRuntimePath } from './to-runtime-path'
export { resolveRuntimeSuffix } from './resolve-runtime-suffix'
13 changes: 13 additions & 0 deletions e2e/e2e-utils/src/resolve-runtime-suffix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Resolves the runtime suffix based on the provided input or the environment variable `VITE_APP_HISTORY`.
*
* @param {string} [input] - Optional input to override the environment variable.
* @returns {string} Returns 'hash' if the input or `VITE_APP_HISTORY` is set to 'hash', otherwise returns 'browser'.
*/
export function resolveRuntimeSuffix(input?: string): string {
const value =
input === 'hash' || process.env.VITE_APP_HISTORY === 'hash'
? 'hash'
: 'browser'
return value
}
17 changes: 17 additions & 0 deletions e2e/e2e-utils/src/to-runtime-path.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Converts the given input string to a valid runtime path based on the environment configuration.
* If the environment variable `VITE_APP_HISTORY` is set to 'hash', the input will be prefixed with `/#`.
* Otherwise, the input will be returned as is.
*
* @param {string} input - The input string to be converted.
* @returns {string} - The converted test URL value.
* @example
* toRuntimePath('/normal-page') // '/normal-page'
* // or
* process.env.VITE_APP_HISTORY = 'hash'
* toRuntimePath('/normal-page') // '/#/normal-page'
*/
export function toRuntimePath(input: string) {
const value = process.env.VITE_APP_HISTORY === 'hash' ? `/#${input}` : input
return value
}
1 change: 1 addition & 0 deletions e2e/react-router/basic-esbuild-file-based/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

Expand Down
1 change: 1 addition & 0 deletions e2e/react-router/basic-file-based/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

Expand Down
1 change: 1 addition & 0 deletions e2e/react-router/basic-react-query-file-based/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

Expand Down
1 change: 1 addition & 0 deletions e2e/react-router/basic-react-query/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

Expand Down
1 change: 1 addition & 0 deletions e2e/react-router/basic-scroll-restoration/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

Expand Down
1 change: 1 addition & 0 deletions e2e/react-router/basic-virtual-file-based/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

Expand Down
1 change: 1 addition & 0 deletions e2e/react-router/basic/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

Expand Down
1 change: 1 addition & 0 deletions e2e/react-router/rspack-basic-file-based/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Dist
node_modules
dist/
dist-hash/

# IDE
.vscode/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Dist
node_modules
dist/
dist-hash/

# IDE
.vscode/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { defineConfig, devices } from '@playwright/test'
import { derivePort } from '@tanstack/router-e2e-utils'
import { derivePort, resolveRuntimeSuffix } from '@tanstack/router-e2e-utils'
import packageJson from './package.json' with { type: 'json' }

const PORT = derivePort(packageJson.name + '-browser')
const PORT = derivePort(
packageJson.name + `-${resolveRuntimeSuffix('browser')}`,
)
const baseURL = `http://localhost:${PORT}`
/**
* See https://playwright.dev/docs/test-configuration.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { defineConfig, devices } from '@playwright/test'
import { derivePort } from '@tanstack/router-e2e-utils'
import { derivePort, resolveRuntimeSuffix } from '@tanstack/router-e2e-utils'
import packageJson from './package.json' with { type: 'json' }

const PORT = derivePort(packageJson.name + '-hash')
const PORT = derivePort(
packageJson.name + `-${resolveRuntimeSuffix('browser')}`,
)
const baseURL = `http://localhost:${PORT}`
/**
* See https://playwright.dev/docs/test-configuration.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { expect, test } from '@playwright/test'
import { linkOptions } from '@tanstack/react-router'

function toValue(input: string) {
const value = process.env.VITE_APP_HISTORY === 'hash' ? `/#${input}` : input
return value
}
import { toRuntimePath } from '@tanstack/router-e2e-utils'

test('Smoke - Renders home', async ({ page }) => {
await page.goto(toValue('/'))
await page.goto(toRuntimePath('/'))
await expect(
page.getByRole('heading', { name: 'Welcome Home!' }),
).toBeVisible()
Expand All @@ -24,7 +20,7 @@ test('Smoke - Renders home', async ({ page }) => {
test(`On navigate to ${options.to} (from the header), scroll should be at top`, async ({
page,
}) => {
await page.goto(toValue('/'))
await page.goto(toRuntimePath('/'))
await page.getByRole('link', { name: `Head-${options.to}` }).click()
await expect(page.getByTestId('at-the-top')).toBeInViewport()
})
Expand All @@ -33,7 +29,7 @@ test('Smoke - Renders home', async ({ page }) => {
test(`On navigate via index page tests to ${options.to}, scroll should resolve at the bottom`, async ({
page,
}) => {
await page.goto(toValue('/'))
await page.goto(toRuntimePath('/'))
await page
.getByRole('link', { name: `${options.to}#at-the-bottom` })
.click()
Expand All @@ -48,7 +44,7 @@ test('Smoke - Renders home', async ({ page }) => {
if ('search' in options) {
url = `${url}?where=${options.search.where}`
}
await page.goto(toValue(`${url}#at-the-bottom`))
await page.goto(toRuntimePath(`${url}#at-the-bottom`))
await expect(page.getByTestId('at-the-bottom')).toBeInViewport()
})
})
1 change: 1 addition & 0 deletions e2e/react-router/sentry-integration/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

Expand Down
1 change: 1 addition & 0 deletions e2e/solid-router/basic-esbuild-file-based/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

Expand Down
1 change: 1 addition & 0 deletions e2e/solid-router/basic-file-based/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

Expand Down
1 change: 1 addition & 0 deletions e2e/solid-router/basic-scroll-restoration/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

Expand Down
1 change: 1 addition & 0 deletions e2e/solid-router/basic-solid-query-file-based/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

Expand Down
1 change: 1 addition & 0 deletions e2e/solid-router/basic-solid-query/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

Expand Down
1 change: 1 addition & 0 deletions e2e/solid-router/basic-virtual-file-based/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

Expand Down
1 change: 1 addition & 0 deletions e2e/solid-router/basic/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

Expand Down
1 change: 1 addition & 0 deletions e2e/solid-router/rspack-basic-file-based/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Dist
node_modules
dist/
dist-hash/

# IDE
.vscode/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Dist
node_modules
dist/
dist-hash/

# IDE
.vscode/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { defineConfig, devices } from '@playwright/test'
import { derivePort } from '@tanstack/router-e2e-utils'
import { derivePort, resolveRuntimeSuffix } from '@tanstack/router-e2e-utils'
import packageJson from './package.json' with { type: 'json' }

const PORT = derivePort(packageJson.name + '-browser')
const PORT = derivePort(
packageJson.name + `-${resolveRuntimeSuffix('browser')}`,
)
const baseURL = `http://localhost:${PORT}`
/**
* See https://playwright.dev/docs/test-configuration.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { defineConfig, devices } from '@playwright/test'
import { derivePort } from '@tanstack/router-e2e-utils'
import { derivePort, resolveRuntimeSuffix } from '@tanstack/router-e2e-utils'
import packageJson from './package.json' with { type: 'json' }

const PORT = derivePort(packageJson.name + '-hash')
const PORT = derivePort(packageJson.name + `-${resolveRuntimeSuffix('hash')}`)
const baseURL = `http://localhost:${PORT}`
/**
* See https://playwright.dev/docs/test-configuration.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { expect, test } from '@playwright/test'

function toValue(input: string) {
const value = process.env.VITE_APP_HISTORY === 'hash' ? `/#${input}` : input
return value
}
import { toRuntimePath } from '@tanstack/router-e2e-utils'

test('Smoke - Renders home', async ({ page }) => {
await page.goto(toValue('/'))
await page.goto(toRuntimePath('/'))
await expect(
page.getByRole('heading', { name: 'Welcome Home!' }),
).toBeVisible()
Expand All @@ -23,7 +19,7 @@ test('Smoke - Renders home', async ({ page }) => {
test(`On navigate to ${options.to} (from the header), scroll should be at top`, async ({
page,
}) => {
await page.goto(toValue('/'))
await page.goto(toRuntimePath('/'))
await page.getByRole('link', { name: `Head-${options.to}` }).click()
await page.waitForTimeout(0)
await expect(page.getByTestId('at-the-top')).toBeInViewport()
Expand All @@ -33,7 +29,7 @@ test('Smoke - Renders home', async ({ page }) => {
test(`On navigate via index page tests to ${options.to}, scroll should resolve at the bottom`, async ({
page,
}) => {
await page.goto(toValue('/'))
await page.goto(toRuntimePath('/'))
await page
.getByRole('link', { name: `${options.to}#at-the-bottom` })
.click()
Expand All @@ -49,7 +45,7 @@ test('Smoke - Renders home', async ({ page }) => {
if ('search' in options) {
url = `${url}?where=${options.search?.where}`
}
await page.goto(toValue(`${url}#at-the-bottom`))
await page.goto(toRuntimePath(`${url}#at-the-bottom`))
await page.waitForTimeout(0)
await expect(page.getByTestId('at-the-bottom')).toBeInViewport()
})
Expand Down