diff --git a/web/README.md b/web/README.md
index 9400d5e..80f1dae 100644
--- a/web/README.md
+++ b/web/README.md
@@ -124,10 +124,9 @@ keep falling back to broad permissions for a few minutes after publishing.
## Deploying (`lanyards.app`)
The app deploys from the Vercel project **`lanyards`** (team `renderghost`,
-Git repo `renderghost/lanyards`), with Root Directory `web`. Until the swap
-(#154), that project served the legacy Next.js app from the repository root,
-and the beta ran on a second project, `lanyards-next`, at
-`next.lanyards.app`.
+Git repo `renderghost/lanyards`), with Root Directory `web`. It was the
+beta's project, `lanyards-next`, renamed at the swap (#154), when the legacy
+Next.js project was deleted and `lanyards.app` moved to it.
### 1. Project settings
diff --git a/web/e2e/callback.spec.ts b/web/e2e/callback.spec.ts
index af159d8..b00a831 100644
--- a/web/e2e/callback.spec.ts
+++ b/web/e2e/callback.spec.ts
@@ -6,7 +6,7 @@ test('explains a cancelled sign-in and scrubs the URL', async ({ page }) => {
expect(page.url()).not.toContain('#');
await expect(page.getByRole('link', { name: 'Try again' })).toHaveAttribute(
'href',
- '/'
+ '/sign-in'
);
});
diff --git a/web/e2e/fixtures.ts b/web/e2e/fixtures.ts
index 11829ba..4312122 100644
--- a/web/e2e/fixtures.ts
+++ b/web/e2e/fixtures.ts
@@ -2,9 +2,6 @@ import { test as base, expect } from '@playwright/test';
export const HEADING = 'Welcome to Lanyards';
-/** The homepage's live sample lanyard (#145), framed at `md` and up. */
-export const SAMPLE_PATH = '/renderg.host';
-
const APP_ORIGIN = 'http://127.0.0.1:4173';
/**
@@ -24,16 +21,6 @@ export const test = base.extend({
await page.route('https://public.api.bsky.app/**', (route) =>
route.fulfill({ json: { actors: [] } })
);
- // The homepage frames a real person's lanyard: stand in a page, so its
- // reads of that person never leave the run.
- await page.route(
- (url) => url.origin === APP_ORIGIN && url.pathname === SAMPLE_PATH,
- (route) =>
- route.fulfill({
- contentType: 'text/html',
- body: '
Sample lanyard
Sample
',
- })
- );
await use(page);
expect(unexpected, 'unexpected third-party requests').toEqual([]);
},
diff --git a/web/e2e/landing.spec.ts b/web/e2e/landing.spec.ts
index 00b3061..191a8f0 100644
--- a/web/e2e/landing.spec.ts
+++ b/web/e2e/landing.spec.ts
@@ -1,12 +1,15 @@
import AxeBuilder from '@axe-core/playwright';
-import { expect, HEADING, SAMPLE_PATH, test } from './fixtures';
+import { expect, HEADING, test } from './fixtures';
const WCAG = ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22aa'];
+/** The sign-in page's heading (#157). */
+const SIGN_IN = { level: 1, name: 'Sign in' } as const;
+
test('asks for a handle when submitted empty', async ({ page }) => {
- await page.goto('/');
- await expect(page.getByRole('heading', { name: HEADING })).toBeVisible();
+ await page.goto('/sign-in');
+ await expect(page.getByRole('heading', SIGN_IN)).toBeVisible();
await page.getByRole('button', { name: 'Sign in' }).click();
await expect(page.getByText('Enter your handle')).toBeVisible();
});
@@ -16,6 +19,11 @@ for (const colorScheme of ['light', 'dark'] as const) {
await page.emulateMedia({ colorScheme });
await page.goto('/');
await expect(page.getByRole('heading', { name: HEADING })).toBeVisible();
+ const home = await new AxeBuilder({ page }).withTags(WCAG).analyze();
+ expect(home.violations).toEqual([]);
+
+ await page.goto('/sign-in');
+ await expect(page.getByRole('heading', SIGN_IN)).toBeVisible();
const clean = await new AxeBuilder({ page }).withTags(WCAG).analyze();
expect(clean.violations).toEqual([]);
@@ -26,70 +34,62 @@ for (const colorScheme of ['light', 'dark'] as const) {
});
}
-test('fits a 320px-wide screen without sideways scrolling', async ({
- page,
-}) => {
- await page.setViewportSize({ width: 320, height: 640 });
- await page.goto('/');
- await expect(page.getByRole('heading', { name: HEADING })).toBeVisible();
- const scrollWidth = await page.evaluate(
- () => document.documentElement.scrollWidth
- );
- expect(scrollWidth).toBeLessThanOrEqual(320);
-});
+for (const path of ['/', '/sign-in']) {
+ test(`fits a 320px-wide screen without sideways scrolling (${path})`, async ({
+ page,
+ }) => {
+ await page.setViewportSize({ width: 320, height: 640 });
+ await page.goto(path);
+ await expect(page.getByRole('heading', { level: 1 })).toBeVisible();
+ const scrollWidth = await page.evaluate(
+ () => document.documentElement.scrollWidth
+ );
+ expect(scrollWidth).toBeLessThanOrEqual(320);
+ });
+}
test.describe('the homepage (#145)', () => {
- test('frames a sample lanyard on desktop, and links to it', async ({
+ test('takes Sign in at the top to the sign-in page (#157)', async ({
page,
}) => {
- await page.setViewportSize({ width: 1280, height: 900 });
await page.goto('/');
- await expect(page.getByRole('heading', { name: HEADING })).toBeVisible();
- const frame = page.getByTitle('Sample lanyard');
- await expect(frame).toBeVisible();
- await expect(frame).toHaveAttribute('src', SAMPLE_PATH);
+ const banner = page.getByRole('banner');
await expect(
- page.frameLocator('iframe[title="Sample lanyard"]').getByRole('heading')
- ).toHaveText('Sample');
+ banner.getByRole('button', { name: 'Make your lanyard' })
+ ).toHaveCount(0);
+ await banner.getByRole('link', { name: 'Sign in' }).click();
+ await expect(page).toHaveURL('/sign-in');
+ await expect(page.getByRole('heading', SIGN_IN)).toBeVisible();
await expect(
- page.getByRole('link', { name: /View sample profile/ })
- ).toHaveAttribute('href', SAMPLE_PATH);
+ page.getByRole('combobox', { name: 'Your handle' })
+ ).toBeVisible();
});
- test('links to the sample, without the frame, on phones', async ({
+ test('leads with a call to action to the sign-in page (#157)', async ({
page,
}) => {
- await page.setViewportSize({ width: 320, height: 640 });
await page.goto('/');
- await expect(page.getByRole('heading', { name: HEADING })).toBeVisible();
- await expect(page.getByTitle('Sample lanyard')).toBeHidden();
- await expect(
- page.getByRole('link', { name: /View sample profile/ })
- ).toBeVisible();
+ await expect(page.getByRole('combobox')).toHaveCount(0);
+ await expect(page.getByTitle('Sample lanyard')).toHaveCount(0);
+ const start = page.getByRole('region', {
+ name: 'Everything you work on, in one link',
+ });
+ await start.getByRole('link', { name: 'Sign in to get started' }).click();
+ await expect(page).toHaveURL('/sign-in');
});
- test('takes “Create your lanyard” to the sign-in form', async ({ page }) => {
+ test('takes “Create your lanyard” to the sign-in page', async ({ page }) => {
await page.goto('/');
- await page.getByRole('button', { name: 'Create your lanyard' }).click();
- const handle = page.getByRole('combobox', { name: 'Your handle' });
- await expect(handle).toBeFocused();
- await expect(handle).toBeInViewport();
+ await page.getByRole('link', { name: 'Create your lanyard' }).click();
+ await expect(page).toHaveURL('/sign-in');
+ await expect(page.getByRole('heading', SIGN_IN)).toBeVisible();
});
- test('offers Sign in at the top, taking people to the form (#148)', async ({
- page,
- }) => {
- await page.setViewportSize({ width: 1920, height: 1080 });
- await page.goto('/');
- const signIn = page
- .getByRole('banner')
- .getByRole('link', { name: 'Sign in' });
- await expect(signIn).toBeInViewport();
- const handle = page.getByRole('combobox', { name: 'Your handle' });
- await expect(handle).not.toBeInViewport();
- await signIn.click();
- await expect(handle).toBeFocused();
- await expect(handle).toBeInViewport();
+ // Old links to the homepage's sign-in (#157).
+ test('sends /?returnTo= on to the sign-in page', async ({ page }) => {
+ await page.goto('/?returnTo=%2Fsettings');
+ await expect(page).toHaveURL('/sign-in?returnTo=%2Fsettings');
+ await expect(page.getByRole('heading', SIGN_IN)).toBeVisible();
});
});
diff --git a/web/e2e/settings.spec.ts b/web/e2e/settings.spec.ts
index 4079ebf..dc02a01 100644
--- a/web/e2e/settings.spec.ts
+++ b/web/e2e/settings.spec.ts
@@ -1,8 +1,10 @@
-import { expect, HEADING, test } from './fixtures';
+import { expect, test } from './fixtures';
test('sends signed-out visitors to sign in first', async ({ page }) => {
await page.goto('/settings');
- await expect(page).toHaveURL('/?returnTo=%2Fsettings');
- await expect(page.getByRole('heading', { name: HEADING })).toBeVisible();
+ await expect(page).toHaveURL('/sign-in?returnTo=%2Fsettings');
+ await expect(
+ page.getByRole('heading', { level: 1, name: 'Sign in' })
+ ).toBeVisible();
await expect(page.getByRole('button', { name: 'Sign in' })).toBeVisible();
});
diff --git a/web/src/app/callback.test.tsx b/web/src/app/callback.test.tsx
index cc155a4..27322b1 100644
--- a/web/src/app/callback.test.tsx
+++ b/web/src/app/callback.test.tsx
@@ -43,7 +43,10 @@ describe('OAuth callback, trying again', () => {
);
renderRoute('/oauth/callback#error=access_denied');
await screen.findByText('Sign-in was cancelled.');
- expect(tryAgain()).toHaveAttribute('href', '/?returnTo=%2F%40alice.test');
+ expect(tryAgain()).toHaveAttribute(
+ 'href',
+ '/sign-in?returnTo=%2F%40alice.test'
+ );
sessionStorage.clear();
});
@@ -54,7 +57,7 @@ describe('OAuth callback, trying again', () => {
);
renderRoute('/oauth/callback#error=access_denied');
await screen.findByText('Sign-in was cancelled.');
- expect(tryAgain()).toHaveAttribute('href', '/');
+ expect(tryAgain()).toHaveAttribute('href', '/sign-in');
sessionStorage.clear();
});
});
@@ -68,7 +71,7 @@ describe('OAuth callback', () => {
expect(
await screen.findByText('Sign-in was cancelled.')
).toBeInTheDocument();
- expect(tryAgain()).toHaveAttribute('href', '/');
+ expect(tryAgain()).toHaveAttribute('href', '/sign-in');
expect(completeSignIn).toHaveBeenCalledTimes(1);
expect(completeSignIn).toHaveBeenCalledWith('#error=access_denied');
expect(router.state.location.hash).toBe('');
@@ -83,13 +86,16 @@ describe('OAuth callback', () => {
vi.mocked(completeSignIn).mockRejectedValue(
new OAuthCallbackError('denied')
);
- renderRoute('/oauth/callback#error=access_denied');
+ const { router } = renderRoute('/oauth/callback#error=access_denied');
await userEvent.click(
await screen.findByRole('link', { name: 'Try again' })
);
+ // Trying again goes to the sign-in page (#157), whose heading is also
+ // "Sign in": wait for it to replace the callback page's.
+ await waitForRoute(router, '/sign-in');
const heading = await screen.findByRole('heading', {
level: 1,
- name: 'Welcome to Lanyards',
+ name: 'Sign in',
});
await waitFor(() => expect(heading).toHaveFocus());
});
@@ -104,7 +110,7 @@ describe('OAuth callback', () => {
'This sign-in link has expired or was already used.'
)
).toBeInTheDocument();
- expect(tryAgain()).toHaveAttribute('href', '/');
+ expect(tryAgain()).toHaveAttribute('href', '/sign-in');
});
it('explains a failed exchange and reports it', async () => {
diff --git a/web/src/app/customise.test.tsx b/web/src/app/customise.test.tsx
index 79bb663..ac7c84b 100644
--- a/web/src/app/customise.test.tsx
+++ b/web/src/app/customise.test.tsx
@@ -132,7 +132,7 @@ describe('//edit', { timeout: 20_000 }, () => {
it('sends signed-out visitors to sign in, then back here', async () => {
vi.mocked(useSession).mockReturnValue(signedOutSession());
const { router } = renderRoute(EDIT);
- await waitForRoute(router, `/?returnTo=${encodeURIComponent(EDIT)}`, 5000);
+ await waitForRoute(router, `/sign-in?returnTo=${encodeURIComponent(EDIT)}`, 5000);
});
it('forwards /lanyard to your own //edit (#150)', async () => {
diff --git a/web/src/app/landing.test.tsx b/web/src/app/landing.test.tsx
index fd77dba..d8b9a36 100644
--- a/web/src/app/landing.test.tsx
+++ b/web/src/app/landing.test.tsx
@@ -33,12 +33,12 @@ describe('landing page', () => {
refresh: vi.fn(),
});
renderRoute('/');
- await screen.findByRole('button', { name: 'Sign in' });
+ await screen.findByRole('heading', { name: 'Welcome to Lanyards' });
expect(screen.queryByRole('button', { name: 'Send feedback' })).toBeNull();
expect(screen.queryByRole('button', { name: 'Give feedback' })).toBeNull();
});
- it('shows the sign-in form to signed-out visitors', async () => {
+ it('shows signed-out visitors the homepage, with no form on it (#157)', async () => {
vi.mocked(useSession).mockReturnValue({
status: 'signedOut',
signOut: vi.fn(),
@@ -48,13 +48,14 @@ describe('landing page', () => {
expect(
await screen.findByRole('heading', { name: 'Welcome to Lanyards' })
).toBeInTheDocument();
- expect(screen.getByRole('button', { name: 'Sign in' })).toBeInTheDocument();
+ expect(screen.queryByRole('combobox')).toBeNull();
+ expect(screen.queryByRole('button', { name: 'Sign in' })).toBeNull();
expect(document.title).toBe(
'Researcher profiles on the AT Protocol · Lanyards'
);
});
- it('offers Sign in and Make your lanyard in the header (#148)', async () => {
+ it('offers Sign in in the header, to its own page (#157)', async () => {
vi.mocked(useSession).mockReturnValue({
status: 'signedOut',
signOut: vi.fn(),
@@ -64,21 +65,41 @@ describe('landing page', () => {
const banner = await screen.findByRole('banner');
expect(
await within(banner).findByRole('link', { name: 'Sign in' })
+ ).toHaveAttribute('href', '/sign-in');
+ expect(
+ within(banner).queryByRole('button', { name: 'Make your lanyard' })
+ ).toBeNull();
+ });
+
+ it('signs in on /sign-in, with the typeahead (#157)', async () => {
+ vi.mocked(useSession).mockReturnValue({
+ status: 'signedOut',
+ signOut: vi.fn(),
+ refresh: vi.fn(),
+ });
+ renderRoute('/sign-in?returnTo=%2Fsettings');
+ expect(
+ await screen.findByRole('heading', { level: 1, name: 'Sign in' })
).toBeInTheDocument();
expect(
- within(banner).getByRole('button', { name: 'Make your lanyard' })
+ screen.getByRole('combobox', { name: 'Your handle' })
).toBeInTheDocument();
+ expect(screen.getAllByRole('banner')).toHaveLength(1);
+ expect(document.title).toBe('Sign in · Lanyards');
});
- it('is titled for signing in when sent here to sign in (#145)', async () => {
+ // Links from before the sign-in page had its own address (#157).
+ it('sends /?returnTo= on to /sign-in, keeping where to return', async () => {
vi.mocked(useSession).mockReturnValue({
status: 'signedOut',
signOut: vi.fn(),
refresh: vi.fn(),
});
- renderRoute('/?returnTo=%2Fsettings');
- await screen.findByRole('heading', { name: 'Welcome to Lanyards' });
- expect(document.title).toBe('Sign in · Lanyards');
+ const { router } = renderRoute('/?returnTo=%2Fsettings');
+ await waitForRoute(router, '/sign-in?returnTo=%2Fsettings');
+ expect(
+ await screen.findByRole('heading', { level: 1, name: 'Sign in' })
+ ).toBeInTheDocument();
});
it('sends a signed-in visitor to their own customiser (#150)', async () => {
diff --git a/web/src/app/lanyard.test.tsx b/web/src/app/lanyard.test.tsx
index f003768..65bab4b 100644
--- a/web/src/app/lanyard.test.tsx
+++ b/web/src/app/lanyard.test.tsx
@@ -201,7 +201,7 @@ describe('lanyard page states', () => {
).toBeInTheDocument();
expect(
within(screen.getByRole('main')).getByRole('link', { name: 'Sign in' })
- ).toHaveAttribute('href', '/?returnTo=%2Falice.test');
+ ).toHaveAttribute('href', '/sign-in?returnTo=%2Falice.test');
expect(screen.queryByText('Dr Ada Example')).not.toBeInTheDocument();
// The name must not leak through the tab title either.
await waitFor(() =>
@@ -366,7 +366,7 @@ describe('visitor actions on the page', () => {
within(header).getByRole('link', { name: 'Sign in' })
).toHaveAttribute(
'href',
- `/?returnTo=${encodeURIComponent('/alice.test')}`
+ `/sign-in?returnTo=${encodeURIComponent('/alice.test')}`
);
expect(
within(header).getByRole('button', { name: 'Make your lanyard' })
diff --git a/web/src/app/settings.test.tsx b/web/src/app/settings.test.tsx
index 31c673b..a86e7ff 100644
--- a/web/src/app/settings.test.tsx
+++ b/web/src/app/settings.test.tsx
@@ -27,7 +27,7 @@ describe('/settings', () => {
refresh: vi.fn(),
});
const { router } = renderRoute('/settings');
- await waitForRoute(router, '/?returnTo=%2Fsettings');
+ await waitForRoute(router, '/sign-in?returnTo=%2Fsettings');
});
it('shows the account to signed-in visitors', async () => {
diff --git a/web/src/components/AppHeader/AppHeader.test.tsx b/web/src/components/AppHeader/AppHeader.test.tsx
index 26f9b3e..b95a221 100644
--- a/web/src/components/AppHeader/AppHeader.test.tsx
+++ b/web/src/components/AppHeader/AppHeader.test.tsx
@@ -158,7 +158,7 @@ describe('AppHeader', () => {
await screen.findByRole('link', { name: 'Sign in' })
).toHaveAttribute(
'href',
- `/?returnTo=${encodeURIComponent('/@alice.test')}`
+ `/sign-in?returnTo=${encodeURIComponent('/@alice.test')}`
);
await userEvent.click(
screen.getByRole('button', { name: 'Make your lanyard' })
diff --git a/web/src/components/AppHeader/AppHeader.tsx b/web/src/components/AppHeader/AppHeader.tsx
index b0ed5a2..6755741 100644
--- a/web/src/components/AppHeader/AppHeader.tsx
+++ b/web/src/components/AppHeader/AppHeader.tsx
@@ -43,7 +43,11 @@ export function AppHeader({
} else if (signedOutActions && session.status === 'signedOut') {
end = (