diff --git a/tests/components/ct-react-vite/package.json b/tests/components/ct-react-vite/package.json
index eca3c9b3a6..6ecf422656 100644
--- a/tests/components/ct-react-vite/package.json
+++ b/tests/components/ct-react-vite/package.json
@@ -10,7 +10,8 @@
},
"dependencies": {
"react": "^17.0.2",
- "react-dom": "^17.0.2"
+ "react-dom": "^17.0.2",
+ "react-router-dom": "^6.4.2"
},
"devDependencies": {
"@types/react": "^17.0.33",
diff --git a/tests/components/ct-react-vite/src/App.css b/tests/components/ct-react-vite/src/App.css
deleted file mode 100644
index 8da3fde63d..0000000000
--- a/tests/components/ct-react-vite/src/App.css
+++ /dev/null
@@ -1,42 +0,0 @@
-.App {
- text-align: center;
-}
-
-.App-logo {
- height: 40vmin;
- pointer-events: none;
-}
-
-@media (prefers-reduced-motion: no-preference) {
- .App-logo {
- animation: App-logo-spin infinite 20s linear;
- }
-}
-
-.App-header {
- background-color: #282c34;
- min-height: 100vh;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- font-size: calc(10px + 2vmin);
- color: white;
-}
-
-.App-link {
- color: #61dafb;
-}
-
-@keyframes App-logo-spin {
- from {
- transform: rotate(0deg);
- }
- to {
- transform: rotate(360deg);
- }
-}
-
-button {
- font-size: calc(10px + 2vmin);
-}
diff --git a/tests/components/ct-react-vite/src/App.tsx b/tests/components/ct-react-vite/src/App.tsx
index 8a1bf0f964..5f4afe2236 100644
--- a/tests/components/ct-react-vite/src/App.tsx
+++ b/tests/components/ct-react-vite/src/App.tsx
@@ -1,45 +1,20 @@
-import { useState } from 'react'
-import logo from './assets/logo.svg'
-import './App.css'
+import { Routes, Route, Link } from 'react-router-dom';
+import logo from './assets/logo.svg';
+import LoginPage from './pages/LoginPage';
+import DashboardPage from './pages/DashboardPage';
-function App() {
- const [count, setCount] = useState(0)
-
- return (
-
-
-
- Hello Vite + React!
-
-
-
-
- Edit App.tsx
and save to test HMR updates.
-
-
-
- Learn React
-
- {' | '}
-
- Vite Docs
-
-
-
-
- )
+export default function App() {
+ return <>
+
+
+ Login
+ Dashboard
+
+
+
+ } />
+ } />
+
+
+ >
}
-
-export default App
diff --git a/tests/components/ct-react-vite/src/main.tsx b/tests/components/ct-react-vite/src/main.tsx
index 919f50052b..e02d5e7d44 100644
--- a/tests/components/ct-react-vite/src/main.tsx
+++ b/tests/components/ct-react-vite/src/main.tsx
@@ -1,11 +1,12 @@
-import React from 'react'
-import ReactDOM from 'react-dom'
-import './assets/index.css'
-import App from './App'
+import React from 'react';
+import ReactDOM from 'react-dom';
+import { BrowserRouter } from 'react-router-dom';
+import App from './App';
+import './assets/index.css';
ReactDOM.render(
-
+
,
document.getElementById('root')
)
diff --git a/tests/components/ct-react-vite/src/pages/DashboardPage.tsx b/tests/components/ct-react-vite/src/pages/DashboardPage.tsx
new file mode 100644
index 0000000000..64307e87f3
--- /dev/null
+++ b/tests/components/ct-react-vite/src/pages/DashboardPage.tsx
@@ -0,0 +1,3 @@
+export default function DashboardPage() {
+ return Dashboard
+}
diff --git a/tests/components/ct-react-vite/src/pages/LoginPage.tsx b/tests/components/ct-react-vite/src/pages/LoginPage.tsx
new file mode 100644
index 0000000000..96adc431ed
--- /dev/null
+++ b/tests/components/ct-react-vite/src/pages/LoginPage.tsx
@@ -0,0 +1,3 @@
+export default function LoginPage() {
+ return Login
+}
diff --git a/tests/components/ct-react-vite/src/tests.spec.tsx b/tests/components/ct-react-vite/src/tests.spec.tsx
index 9542bec7a8..d8c18554a8 100644
--- a/tests/components/ct-react-vite/src/tests.spec.tsx
+++ b/tests/components/ct-react-vite/src/tests.spec.tsx
@@ -1,4 +1,6 @@
import { test, expect } from '@playwright/experimental-ct-react';
+import { BrowserRouter } from 'react-router-dom';
+import App from './App';
import Button from './components/Button';
import DefaultChildren from './components/DefaultChildren';
import MultipleChildren from './components/MultipleChildren';
@@ -139,3 +141,12 @@ test('get textContent of the empty fragment', async ({ mount }) => {
expect(await component.textContent()).toBe('');
await expect(component).toHaveText('');
});
+
+test('navigate to a page by clicking a link', async ({ page, mount }) => {
+ const component = await mount();
+ await expect(component.getByRole('main')).toHaveText('Login');
+ await expect(page).toHaveURL('/');
+ await component.getByRole('link', { name: 'Dashboard' }).click();
+ await expect(component.getByRole('main')).toHaveText('Dashboard');
+ await expect(page).toHaveURL('/dashboard');
+});