From 6fd08cd2d79daa496213d49eb459a27ed5069719 Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Fri, 09 Sep 2022 00:39:43 +0100 Subject: [PATCH] Set page titles on frontend --- chartered-frontend/src/app.d.ts | 4 +++- chartered-frontend/tests/test.ts | 14 ++++++++------ chartered-frontend/src/routes/+layout.svelte | 14 ++++++++++++++ chartered-frontend/src/routes/(authed)/search/+page.ts | 5 +++++ chartered-frontend/src/routes/(authed)/ssh-keys/+page.ts | 5 +++++ chartered-frontend/src/routes/(authed)/crates/[organisation]/+page.ts | 9 +++++++++ chartered-frontend/src/routes/(authed)/organisations/create/+page.ts | 5 +++++ chartered-frontend/src/routes/(authed)/organisations/list/+page.ts | 5 +++++ chartered-frontend/src/routes/(authed)/sessions/list/+page.ts | 5 +++++ chartered-frontend/src/routes/(authed)/users/[uuid]/+page.ts | 5 +++++ chartered-frontend/src/routes/(unauthed)/auth/login/+page.ts | 5 +++++ chartered-frontend/src/routes/(unauthed)/auth/register/+page.ts | 5 +++++ chartered-frontend/src/routes/(authed)/crates/[organisation]/[crate]/+page.ts | 10 ++++++++++ 13 files changed, 83 insertions(+), 8 deletions(-) diff --git a/chartered-frontend/src/app.d.ts b/chartered-frontend/src/app.d.ts index 4ce2990..55be883 100644 --- a/chartered-frontend/src/app.d.ts +++ a/chartered-frontend/src/app.d.ts @@ -1,8 +1,10 @@ // See https://kit.svelte.dev/docs/types#app // for information about these interfaces // and what to do when importing types declare namespace App { // interface Locals {} - // interface PageData {} + interface PageData { + title?: string; + } // interface Platform {} } diff --git a/chartered-frontend/tests/test.ts b/chartered-frontend/tests/test.ts index 8878cfb..60ac5d3 100644 --- a/chartered-frontend/tests/test.ts +++ a/chartered-frontend/tests/test.ts @@ -8,7 +8,7 @@ test('register button takes user to register page', async ({ page }) => { await page.goto('/'); - await page.locator('text=Register').click(); + await page.locator('button:has-text("Register")').click(); await expect(page).toHaveURL(/.*register/); expect(await page.textContent('h1')).toBe('chartered ✈️'); expect(await page.textContent('button')).toBe('Register'); @@ -20,12 +20,12 @@ // navigate to register page await page.goto('/'); - await page.locator('text=Register').click(); + await page.locator('button:has-text("Register")').click(); // register user await page.locator('input[id="username"]').fill(username); await page.locator('input[id="password"]').fill(password); - await page.locator('text=Register').click(); + await page.locator('button:has-text("Register")').click(); // ensure there were no errors await expect(page.locator('[role="alert"]')).toHaveCount(0); @@ -49,17 +49,17 @@ await page.goto('/'); // create first user account - await page.locator('text=Register').click(); + await page.locator('button:has-text("Register")').click(); await page.locator('input[id="username"]').fill(username1); await page.locator('input[id="password"]').fill(password); - await page.locator('text=Register').click(); + await page.locator('button:has-text("Register")').click(); await expect(page).toHaveURL(/.*login/); // create second user account that we'll add to the organisation - await page.locator('text=Register').click(); + await page.locator('button:has-text("Register")').click(); await page.locator('input[id="username"]').fill(username2); await page.locator('input[id="password"]').fill(password); - await page.locator('text=Register').click(); + await page.locator('button:has-text("Register")').click(); await expect(page).toHaveURL(/.*login/); // login to first account diff --git a/chartered-frontend/src/routes/+layout.svelte b/chartered-frontend/src/routes/+layout.svelte index 1ad119e..b027795 100644 --- a/chartered-frontend/src/routes/+layout.svelte +++ a/chartered-frontend/src/routes/+layout.svelte @@ -1,5 +1,19 @@ + + + {pageTitle || defaultPageTitle} + diff --git a/chartered-frontend/src/routes/(authed)/search/+page.ts b/chartered-frontend/src/routes/(authed)/search/+page.ts new file mode 100644 index 0000000..ef72585 100644 --- /dev/null +++ a/chartered-frontend/src/routes/(authed)/search/+page.ts @@ -1,0 +1,5 @@ +export function load(): App.PageData { + return { + title: 'Search', + }; +} diff --git a/chartered-frontend/src/routes/(authed)/ssh-keys/+page.ts b/chartered-frontend/src/routes/(authed)/ssh-keys/+page.ts new file mode 100644 index 0000000..41f5fe5 100644 --- /dev/null +++ a/chartered-frontend/src/routes/(authed)/ssh-keys/+page.ts @@ -1,0 +1,5 @@ +export function load(): App.PageData { + return { + title: 'SSH Keys', + }; +} diff --git a/chartered-frontend/src/routes/(authed)/crates/[organisation]/+page.ts b/chartered-frontend/src/routes/(authed)/crates/[organisation]/+page.ts new file mode 100644 index 0000000..61178fc 100644 --- /dev/null +++ a/chartered-frontend/src/routes/(authed)/crates/[organisation]/+page.ts @@ -1,0 +1,9 @@ +interface Params { + organisation: string; +} + +export function load({ params }: { params: Params }): App.PageData { + return { + title: params.organisation, + }; +} diff --git a/chartered-frontend/src/routes/(authed)/organisations/create/+page.ts b/chartered-frontend/src/routes/(authed)/organisations/create/+page.ts new file mode 100644 index 0000000..cc3723b 100644 --- /dev/null +++ a/chartered-frontend/src/routes/(authed)/organisations/create/+page.ts @@ -1,0 +1,5 @@ +export function load(): App.PageData { + return { + title: 'Create Organisation', + }; +} diff --git a/chartered-frontend/src/routes/(authed)/organisations/list/+page.ts b/chartered-frontend/src/routes/(authed)/organisations/list/+page.ts new file mode 100644 index 0000000..c8dc3dd 100644 --- /dev/null +++ a/chartered-frontend/src/routes/(authed)/organisations/list/+page.ts @@ -1,0 +1,5 @@ +export function load(): App.PageData { + return { + title: 'Organisations', + }; +} diff --git a/chartered-frontend/src/routes/(authed)/sessions/list/+page.ts b/chartered-frontend/src/routes/(authed)/sessions/list/+page.ts new file mode 100644 index 0000000..80b1bec 100644 --- /dev/null +++ a/chartered-frontend/src/routes/(authed)/sessions/list/+page.ts @@ -1,0 +1,5 @@ +export function load(): App.PageData { + return { + title: 'Sessions', + }; +} diff --git a/chartered-frontend/src/routes/(authed)/users/[uuid]/+page.ts b/chartered-frontend/src/routes/(authed)/users/[uuid]/+page.ts new file mode 100644 index 0000000..ffafc64 100644 --- /dev/null +++ a/chartered-frontend/src/routes/(authed)/users/[uuid]/+page.ts @@ -1,0 +1,5 @@ +export function load(): App.PageData { + return { + title: 'User', + }; +} diff --git a/chartered-frontend/src/routes/(unauthed)/auth/login/+page.ts b/chartered-frontend/src/routes/(unauthed)/auth/login/+page.ts new file mode 100644 index 0000000..4cc3b56 100644 --- /dev/null +++ a/chartered-frontend/src/routes/(unauthed)/auth/login/+page.ts @@ -1,0 +1,5 @@ +export function load(): App.PageData { + return { + title: 'Login', + }; +} diff --git a/chartered-frontend/src/routes/(unauthed)/auth/register/+page.ts b/chartered-frontend/src/routes/(unauthed)/auth/register/+page.ts new file mode 100644 index 0000000..1b2c093 100644 --- /dev/null +++ a/chartered-frontend/src/routes/(unauthed)/auth/register/+page.ts @@ -1,0 +1,5 @@ +export function load(): App.PageData { + return { + title: 'Register', + }; +} diff --git a/chartered-frontend/src/routes/(authed)/crates/[organisation]/[crate]/+page.ts b/chartered-frontend/src/routes/(authed)/crates/[organisation]/[crate]/+page.ts new file mode 100644 index 0000000..681ff59 100644 --- /dev/null +++ a/chartered-frontend/src/routes/(authed)/crates/[organisation]/[crate]/+page.ts @@ -1,0 +1,10 @@ +interface Params { + organisation: string; + crate: string; +} + +export function load({ params }: { params: Params }): App.PageData { + return { + title: `${params.organisation}/${params.crate}`, + }; +} -- rgit 0.1.3