diff --git a/web/README.md b/web/README.md deleted file mode 100644 index f7b1ad0..0000000 --- a/web/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# sv - -Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli). - -## Creating a project - -If you're seeing this, you've probably already done this step. Congrats! - -```sh -# create a new project -npx sv create my-app -``` - -To recreate this project with the same configuration: - -```sh -# recreate this project -pnpm dlx sv@1.1.1 create --template minimal --types ts --add prettier eslint vitest="usages:unit,component" playwright="demo:no" tailwindcss="plugins:typography,forms" --install pnpm web -``` - -## Adding features - -Add features to your project with `sv add`: - -```sh -npx sv add -``` - -For example, to add Tailwind CSS: - -```sh -npx sv add tailwindcss -``` - -## Developing - -Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: - -```sh -npm run dev - -# or start the server and open the app in a new browser tab -npm run dev -- --open -``` - -## Building - -To create a production version of your app: - -```sh -npm run build -``` - -You can preview the production build with `npm run preview`. - -> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment. diff --git a/web/src/app.html b/web/src/app.html index 6a2bb58..820dbe2 100644 --- a/web/src/app.html +++ b/web/src/app.html @@ -1,5 +1,5 @@ - + diff --git a/web/src/routes/+layout.svelte b/web/src/routes/+layout.svelte index 439be08..f6e59bf 100644 --- a/web/src/routes/+layout.svelte +++ b/web/src/routes/+layout.svelte @@ -1,13 +1,45 @@ -{@render children()} +
+ + +
+ {@render children()} +
+
diff --git a/web/src/routes/+page.svelte b/web/src/routes/+page.svelte index cc88df0..e18e546 100644 --- a/web/src/routes/+page.svelte +++ b/web/src/routes/+page.svelte @@ -1,2 +1,3 @@ -

Welcome to SvelteKit

-

Visit svelte.dev/docs/kit to read the documentation

+ + Dashboard | Expenses + diff --git a/web/src/routes/accounts/+page.svelte b/web/src/routes/accounts/+page.svelte new file mode 100644 index 0000000..adf200d --- /dev/null +++ b/web/src/routes/accounts/+page.svelte @@ -0,0 +1,3 @@ + + Accounts | Expenses + diff --git a/web/src/routes/navigation.e2e.ts b/web/src/routes/navigation.e2e.ts new file mode 100644 index 0000000..fd9036d --- /dev/null +++ b/web/src/routes/navigation.e2e.ts @@ -0,0 +1,59 @@ +import { expect, test } from '@playwright/test'; + +const routes = [ + { label: 'Dashboard', path: '/' }, + { label: 'Accounts', path: '/accounts' }, + { label: 'Scheduled transactions', path: '/scheduled-transactions' }, + { label: 'Transaction history', path: '/transaction-history' } +]; + +for (const viewport of [ + { width: 1280, height: 800 }, + { width: 375, height: 812 } +]) { + test.describe(`${viewport.width}px navigation`, () => { + test.use({ viewport }); + + for (const route of routes) { + test(`${route.label} loads directly with an empty main view`, async ({ page }) => { + await page.goto(`http://localhost:4173${route.path}`); + + await expect(page).toHaveTitle(`${route.label} | Expenses`); + await expect(page.getByRole('main')).toBeEmpty(); + + const navigation = page.getByRole('navigation', { name: 'Main navigation' }); + await expect(navigation.getByRole('link')).toHaveCount(4); + await expect(navigation.locator('[aria-current="page"]')).toHaveText(route.label); + + const sidebar = await page.getByRole('complementary').boundingBox(); + expect(sidebar?.x).toBe(0); + expect(sidebar?.y).toBe(0); + expect(sidebar?.height).toBe(viewport.height); + expect( + await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth) + ).toBe(true); + }); + } + + test('menu links navigate between pages', async ({ page }) => { + await page.goto('http://localhost:4173/'); + + for (const route of [...routes.slice(1), routes[0]]) { + await page.getByRole('link', { name: route.label, exact: true }).click(); + await expect(page).toHaveURL(`http://localhost:4173${route.path}`); + await expect(page).toHaveTitle(`${route.label} | Expenses`); + await expect(page.getByRole('navigation').locator('[aria-current="page"]')).toHaveText( + route.label + ); + } + }); + + test('keyboard users can skip navigation', async ({ page }) => { + await page.goto('http://localhost:4173/'); + await page.keyboard.press('Tab'); + await expect(page.getByRole('link', { name: 'Skip to main content' })).toBeFocused(); + await page.keyboard.press('Enter'); + await expect(page.getByRole('main')).toBeFocused(); + }); + }); +} diff --git a/web/src/routes/scheduled-transactions/+page.svelte b/web/src/routes/scheduled-transactions/+page.svelte new file mode 100644 index 0000000..5030ff3 --- /dev/null +++ b/web/src/routes/scheduled-transactions/+page.svelte @@ -0,0 +1,3 @@ + + Scheduled transactions | Expenses + diff --git a/web/src/routes/transaction-history/+page.svelte b/web/src/routes/transaction-history/+page.svelte new file mode 100644 index 0000000..5d08175 --- /dev/null +++ b/web/src/routes/transaction-history/+page.svelte @@ -0,0 +1,3 @@ + + Transaction history | Expenses +