Skip to content

Commit 75c2dcf

Browse files
Refactor everything (#268)
1 parent bad10cc commit 75c2dcf

File tree

138 files changed

+13250
-9731
lines changed

Some content is hidden

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

138 files changed

+13250
-9731
lines changed

.env

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
SKIP_PREFLIGHT_CHECK=true
2-
REACT_APP_VALHALLA_URL=https://valhalla1.openstreetmap.de
3-
REACT_APP_NOMINATIM_URL=https://nominatim.openstreetmap.org
4-
REACT_APP_TILE_SERVER_URL="https://tile.openstreetmap.org/{z}/{x}/{y}.png"
5-
REACT_APP_CENTER_COORDS="52.51831,13.393707"
6-
7-
# uncomment this variable to set boundaries on the leaflet map
8-
# southwest corner, northeast corner
9-
REACT_APP_MAX_BOUNDS="-180,-90,180,90"
2+
VITE_VALHALLA_URL=https://valhalla1.openstreetmap.de
3+
VITE_NOMINATIM_URL=https://nominatim.openstreetmap.org
4+
VITE_TILE_SERVER_URL="https://tile.openstreetmap.org/{z}/{x}/{y}.png"
5+
VITE_CENTER_COORDS="52.51831,13.393707"

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,12 @@ node_modules/
3535
/blob-report/
3636
/playwright/.cache/
3737
tsconfig.tsbuildinfo
38+
39+
# tanstack router
40+
dist
41+
dist-ssr
42+
*.local
43+
count.txt
44+
.nitro
45+
.tanstack
46+
.wrangler

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm run typecheck && npx lint-staged

.vscode/settings.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"files.watcherExclude": {
3+
"**/routeTree.gen.ts": true
4+
},
5+
"search.exclude": {
6+
"**/routeTree.gen.ts": true
7+
},
8+
"files.readonlyInclude": {
9+
"**/routeTree.gen.ts": true
10+
}
11+
}

components.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "new-york",
4+
"rsc": false,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "",
8+
"css": "src/index.css",
9+
"baseColor": "slate",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"iconLibrary": "lucide",
14+
"aliases": {
15+
"components": "@/components",
16+
"utils": "@/lib/utils",
17+
"ui": "@/components/ui",
18+
"lib": "@/lib",
19+
"hooks": "@/hooks"
20+
},
21+
"registries": {}
22+
}

e2e/homepage.spec.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ test('has default elements in the page', async ({ page }) => {
3030

3131
await expect(page.getByTestId('show-hide-settings-btn')).toBeVisible();
3232

33-
await expect(page.getByRole('button', { name: '1' })).toBeVisible();
34-
await expect(page.getByRole('button', { name: '2' })).toBeVisible();
33+
expect(await page.getByText('Select a waypoint...').count()).toBe(2);
3534

3635
await expect(page.getByTestId('add-waypoint-button')).toBeVisible();
3736
await expect(page.getByTestId('reset-waypoints-button')).toBeVisible();
3837

39-
await expect(page.getByText('Nonspecific timeNonspecific')).toBeVisible();
38+
await expect(page.getByText('Non-specific time')).toBeVisible();
4039
await expect(page.getByTestId('date-time-picker')).toBeVisible();
4140

4241
await expect(
@@ -45,19 +44,16 @@ test('has default elements in the page', async ({ page }) => {
4544

4645
await page.getByTestId('isochrones-tab-button').click();
4746

48-
await expect(
49-
page.getByRole('textbox', { name: 'Hit enter for search...' })
50-
).toBeVisible();
51-
await page.getByTestId('reset-center-button').click();
47+
await page.getByTestId('remove-waypoint-button').click();
5248

53-
await expect(page.getByText(/^Settings$/)).toBeVisible();
49+
await expect(page.getByText(/^Isochrones Settings$/)).toBeVisible();
5450

55-
await expect(page.getByText('Maximum Rangemins10')).toBeVisible();
56-
await expect(page.getByText('Interval Stepmins10')).toBeVisible();
57-
await expect(page.getByText('Denoise0.1')).toBeVisible();
58-
await expect(page.getByText('Generalizemeters0')).toBeVisible();
51+
await page.getByText(/^Isochrones Settings$/).click();
5952

60-
// await expect(page.getByRole('button', { name: 'Layers' })).toBeVisible();
53+
await expect(page.getByText('Maximum Range', { exact: true })).toBeVisible();
54+
await expect(page.getByText('Interval Step', { exact: true })).toBeVisible();
55+
await expect(page.getByText('Denoise', { exact: true })).toBeVisible();
56+
await expect(page.getByText('Generalize', { exact: true })).toBeVisible();
6157

6258
await expect(page.getByRole('button', { name: 'Zoom in' })).toBeVisible();
6359
await expect(page.getByRole('button', { name: 'Zoom out' })).toBeVisible();

e2e/map.spec.ts

Lines changed: 31 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,8 @@ test.describe('Map interactions with right context menu', () => {
137137
await expect(page.getByLabel('Map marker').getByRole('img')).toBeVisible();
138138

139139
await expect(
140-
page
141-
.getByTestId('waypoint-input-0')
142-
.getByRole('textbox', { name: 'Hit enter for search...' })
143-
).toHaveValue('Unter den Linden, Mitte, Berlin, Germany');
140+
page.getByTestId('waypoint-input-0').getByText('Unter den Linden, Mitte,')
141+
).toBeVisible();
144142
});
145143

146144
test('should make Nominatim request when clicking "Directions to here"', async ({
@@ -201,10 +199,8 @@ test.describe('Map interactions with right context menu', () => {
201199
await expect(page.getByLabel('Map marker').getByRole('img')).toBeVisible();
202200

203201
await expect(
204-
page
205-
.getByTestId('waypoint-input-1')
206-
.getByRole('textbox', { name: 'Hit enter for search...' })
207-
).toHaveValue('Unter den Linden, Mitte, Berlin, Germany');
202+
page.getByTestId('waypoint-input-1').getByText('Unter den Linden, Mitte,')
203+
).toBeVisible();
208204
});
209205

210206
test('should make Nominatim request when clicking "Add as via point"', async ({
@@ -241,10 +237,8 @@ test.describe('Map interactions with right context menu', () => {
241237
await expect(page.getByLabel('Map marker').getByRole('img')).toBeVisible();
242238

243239
await expect(
244-
page
245-
.getByTestId('waypoint-input-1')
246-
.getByRole('textbox', { name: 'Hit enter for search...' })
247-
).toHaveValue('Unter den Linden, Mitte, Berlin, Germany');
240+
page.getByTestId('waypoint-input-1').getByText('Unter den Linden, Mitte,')
241+
).toBeVisible();
248242
});
249243

250244
test('should add multiple via points', async ({ page }) => {
@@ -272,16 +266,12 @@ test.describe('Map interactions with right context menu', () => {
272266
).toBeVisible();
273267

274268
await expect(
275-
page
276-
.getByTestId('waypoint-input-1')
277-
.getByRole('textbox', { name: 'Hit enter for search...' })
278-
).toHaveValue('Unter den Linden, Mitte, Berlin, Germany');
269+
page.getByTestId('waypoint-input-1').getByText('Unter den Linden, Mitte,')
270+
).toBeVisible();
279271

280272
await expect(
281-
page
282-
.getByTestId('waypoint-input-2')
283-
.getByRole('textbox', { name: 'Hit enter for search...' })
284-
).toHaveValue('Unter den Linden, Mitte, Berlin, Germany');
273+
page.getByTestId('waypoint-input-2').getByText('Unter den Linden, Mitte,')
274+
).toBeVisible();
285275
});
286276

287277
test('should handle at least 9 waypoints', async ({ page }) => {
@@ -398,7 +388,7 @@ test.describe('Map interactions with right context menu', () => {
398388
).toBeVisible();
399389

400390
await expect(
401-
page.locator('div').filter({ hasText: /^Directions$/ })
391+
page.getByRole('heading', { level: 3, name: 'Directions' })
402392
).toBeVisible();
403393

404394
await expect(
@@ -566,8 +556,6 @@ test.describe('Map interactions with left context menu', () => {
566556

567557
await page.getByTestId('dd-copy-button').click();
568558

569-
await expect(page.getByText('copied')).toBeVisible();
570-
571559
const clipboardContent = await page.evaluate(() =>
572560
navigator.clipboard.readText()
573561
);
@@ -638,7 +626,7 @@ https: test.describe('Left drawer', () => {
638626

639627
await page.getByTestId('add-waypoint-button').click();
640628

641-
await expect(page.getByRole('button', { name: '3' })).toBeVisible();
629+
await expect(page.getByRole('button', { name: '3' }).first()).toBeVisible();
642630

643631
// Remove waypoint
644632
await page.getByTestId('reset-waypoints-button').click();
@@ -652,11 +640,8 @@ https: test.describe('Left drawer', () => {
652640
await setupNominatimMock(page);
653641
const searchRequests = await setupSearchMock(page);
654642

655-
const searchBox = page
656-
.getByTestId('waypoint-input-0')
657-
.getByRole('textbox', { name: 'Hit enter for search...' });
658-
659-
await searchBox.click();
643+
await page.getByTestId('waypoint-input-0').click();
644+
const searchBox = page.getByPlaceholder('Hit enter for search');
660645
await searchBox.fill('Unter den Linden');
661646
await searchBox.press('Enter');
662647

@@ -679,14 +664,10 @@ https: test.describe('Left drawer', () => {
679664
const searchRequests = await setupSearchMock(page);
680665
const routeRequests = await setupRouteMock(page);
681666

682-
// Add "from" waypoint
683-
const firstSearchBox = page
684-
.getByTestId('waypoint-input-0')
685-
.getByRole('textbox', { name: 'Hit enter for search...' });
686-
687-
await firstSearchBox.click();
688-
await firstSearchBox.fill('Unter den Linden');
689-
await firstSearchBox.press('Enter');
667+
await page.getByTestId('waypoint-input-0').click();
668+
const searchBox = page.getByPlaceholder('Hit enter for search');
669+
await searchBox.fill('Unter den Linden');
670+
await searchBox.press('Enter');
690671

691672
const firstSearchResult = page.getByTestId('search-result');
692673

@@ -698,15 +679,14 @@ https: test.describe('Left drawer', () => {
698679
).toBeVisible();
699680

700681
// Add "to" waypoint
701-
const secondSearchBox = page
702-
.getByTestId('waypoint-input-1')
703-
.getByRole('textbox', { name: 'Hit enter for search...' });
704-
705-
await secondSearchBox.click();
682+
await page.getByTestId('waypoint-input-1').click();
683+
const secondSearchBox = page.getByPlaceholder('Hit enter for search');
706684
await secondSearchBox.fill('Unter den Linden');
707685
await secondSearchBox.press('Enter');
708686

709-
const secondSearchResult = page.getByTestId('search-result').nth(1);
687+
const secondSearchResult = page
688+
.getByTestId('search-result')
689+
.getByText('Unter den Linden, Mitte,');
710690

711691
await expect(secondSearchResult).toBeVisible();
712692
await secondSearchResult.click();
@@ -745,49 +725,27 @@ https: test.describe('Left drawer', () => {
745725
).toBeVisible();
746726

747727
await expect(
748-
page
749-
.getByTestId('waypoint-input-1')
750-
.getByRole('textbox', { name: 'Hit enter for search...' })
728+
page.getByTestId('waypoint-input-1').getByText('Unter den Linden, Mitte,')
729+
// .getByRole('textbox', { name: 'Hit enter for search...' })
751730
).toBeVisible();
752731
await expect(
753-
page
754-
.getByTestId('waypoint-input-2')
755-
.getByRole('textbox', { name: 'Hit enter for search...' })
732+
page.getByTestId('waypoint-input-2').getByText('Unter den Linden, Mitte,')
756733
).toBeVisible();
757734

758-
await expect(
759-
page
760-
.getByTestId('waypoint-input-1')
761-
.getByRole('textbox', { name: 'Hit enter for search...' })
762-
).toHaveValue('Unter den Linden, Mitte, Berlin, Germany');
763-
764-
await expect(
765-
page
766-
.getByTestId('waypoint-input-2')
767-
.getByRole('textbox', { name: 'Hit enter for search...' })
768-
).toHaveValue('Unter den Linden, Mitte, Berlin, Germany');
769-
770-
// Remove waypoint 3
771735
await page.getByTestId('remove-waypoint-button').nth(2).click();
772736
await expect(
773-
page
774-
.getByTestId('waypoint-input-2')
775-
.getByRole('textbox', { name: 'Hit enter for search...' })
737+
page.getByTestId('waypoint-input-2').getByText('Unter den Linden, Mitte,')
776738
).not.toBeVisible();
777739

778740
// Remove waypoint (should just clear text without removing actual element)
779-
780741
await page.getByTestId('remove-waypoint-button').nth(1).click();
781742
await expect(
782-
page
783-
.getByTestId('waypoint-input-1')
784-
.getByRole('textbox', { name: 'Hit enter for search...' })
743+
page.getByTestId('waypoint-input-1').getByText('Select a waypoint...')
785744
).toBeVisible();
745+
786746
await expect(
787-
page
788-
.getByTestId('waypoint-input-1')
789-
.getByRole('textbox', { name: 'Hit enter for search...' })
790-
).toHaveValue('');
747+
page.getByTestId('waypoint-input-0').getByText('Select a waypoint...')
748+
).toBeVisible();
791749
});
792750

793751
test('should send the route request again when user changed profile', async ({

eslint.config.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import importPlugin from 'eslint-plugin-import';
66
import jsxA11y from 'eslint-plugin-jsx-a11y';
77
import tseslint from 'typescript-eslint';
88
import checkFile from 'eslint-plugin-check-file';
9+
import eslintPluginTanstackQuery from '@tanstack/eslint-plugin-query';
10+
import pluginRouter from '@tanstack/eslint-plugin-router';
911

10-
export default defineConfig(
12+
export default defineConfig([
1113
{
1214
ignores: [
1315
'node_modules',
@@ -46,7 +48,6 @@ export default defineConfig(
4648
'import/no-anonymous-default-export': 'warn',
4749
'react/no-unknown-property': 'off',
4850
'react/react-in-jsx-scope': 'off',
49-
'react/prop-types': 'off',
5051
'jsx-a11y/alt-text': [
5152
'warn',
5253
{
@@ -75,8 +76,10 @@ export default defineConfig(
7576
...react.configs.flat['jsx-runtime'],
7677
},
7778
{
78-
...reactHooks.configs['recommended-latest'],
79+
...reactHooks.configs.flat['recommended-latest'],
7980
},
81+
...eslintPluginTanstackQuery.configs['flat/recommended'],
82+
...pluginRouter.configs['flat/recommended'],
8083
{
8184
linterOptions: {
8285
reportUnusedDisableDirectives: true,
@@ -120,4 +123,4 @@ export default defineConfig(
120123
'check-file/filename-naming-convention': 'off',
121124
},
122125
}
123-
);
126+
]);

index.html

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,16 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<link rel="icon" type="image/png" href="%PUBLIC_URL%/favicon.png" />
6-
<meta
7-
name="viewport"
8-
content="width=device-width, initial-scale=1, shrink-to-fit=no"
9-
/>
5+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
106
<meta name="theme-color" content="#000000" />
11-
<!--
12-
manifest.json provides metadata used when your web app is added to the
13-
homescreen on Android. See https://developers.google.com/web/fundamentals/web-app-manifest/
14-
-->
15-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
16-
<!--
17-
Notice the use of %PUBLIC_URL% in the tags above.
18-
It will be replaced with the URL of the `public` folder during the build.
19-
Only files inside the `public` folder can be referenced from the HTML.
20-
21-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
22-
work correctly both with client-side routing and a non-root public URL.
23-
Learn how to configure a non-root public URL by running `npm run build`.
24-
-->
7+
<meta name="description" content="Valhalla FOSSGIS Server Demo App - Route planning and navigation" />
8+
<link rel="icon" type="image/png" href="/favicon.png" />
9+
<link rel="manifest" href="/manifest.json" />
2510
<title>Valhalla FOSSGIS Server Demo App</title>
26-
<script type="module" src="src/index"></script></head>
11+
</head>
2712
<body>
2813
<noscript>You need to enable JavaScript to run this app.</noscript>
2914
<div id="valhalla-app-root"></div>
30-
<!--
31-
This HTML file is a template.
32-
If you open it directly in the browser, you will see an empty page.
33-
34-
You can add webfonts, meta tags, or analytics to this file.
35-
The build step will place the bundled scripts into the <body> tag.
36-
37-
To begin the development, run `npm start` or `yarn start`.
38-
To create a production bundle, use `npm run build` or `yarn build`.
39-
-->
15+
<script type="module" src="/src/index.tsx"></script>
4016
</body>
4117
</html>

0 commit comments

Comments
 (0)