Repository navigation
feat(v2): the invite link page uses the sign-in card #3309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a25300d
feat(v2): the invite link page is the sign-in card holding the pod
lilyshen0722 56a93d5
fix(v2): invite title margin wins on specificity; tests for the signe…
lilyshen0722 99c7a31
fix(v2): a long unbroken pod description wraps inside the invite card
lilyshen0722 89ee894
test(v2): the community invite preview asserts the pod as the page he…
lilyshen0722 533b844
docs(design): d215 s-invite names which unavailable state is drawn (s…
lilyshen0722 1a63ca7
fix(invite): a long pod name wraps inside the join key; a refetch cle…
lilyshen0722 0ed5467
fix(auth): keep the phone sign-in key at 44px; the stacked card's key…
lilyshen0722 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| // @ts-nocheck | ||
| // The d215 invite frames: the auth card holding a pod, one key per state. | ||
| import React from 'react'; | ||
| import { fireEvent, render, screen, within } from '@testing-library/react'; | ||
| import { MemoryRouter, Route, Routes } from 'react-router-dom'; | ||
| import axios from 'axios'; | ||
| import V2InviteRedeem from '../components/V2InviteRedeem'; | ||
|
|
||
| const mockApi = { get: jest.fn(), post: jest.fn(), patch: jest.fn(), del: jest.fn() }; | ||
| let mockAuthenticated = false; | ||
|
|
||
| jest.mock('axios', () => ({ get: jest.fn() })); | ||
| jest.mock('../../context/AuthContext', () => ({ | ||
| useAuth: () => ({ isAuthenticated: mockAuthenticated, loading: false }), | ||
| })); | ||
| jest.mock('../hooks/useV2Api', () => ({ useV2Api: () => mockApi })); | ||
|
|
||
| const TOKEN = 'b'.repeat(32); | ||
| const renderPage = () => render( | ||
| <MemoryRouter initialEntries={[`/v2/invite/${TOKEN}`]}> | ||
| <Routes><Route path="/v2/invite/:token" element={<V2InviteRedeem />} /></Routes> | ||
| </MemoryRouter>, | ||
| ); | ||
|
|
||
| describe('V2InviteRedeem layout', () => { | ||
| beforeEach(() => { jest.clearAllMocks(); mockAuthenticated = false; }); | ||
|
|
||
| test('signed out: the pod is the title inside the auth card, with sign up and log in', async () => { | ||
| axios.get.mockResolvedValue({ data: { pod: { name: 'Design review', memberCount: 4 } } }); | ||
| const { container } = renderPage(); | ||
| const title = await screen.findByRole('heading', { level: 1, name: 'Design review' }); | ||
| const card = container.querySelector('.v2-login__card.v2-login__card--stack'); | ||
| expect(card).toContainElement(title); | ||
| expect(card.querySelector('.v2-login__brand')).not.toBeNull(); | ||
| expect(within(card).getByText('You’re invited to')).toHaveClass('v2-invite__eyebrow'); | ||
| expect(within(card).getByText(/4 members/)).toHaveClass('v2-invite__meta'); | ||
| expect(within(card).getByRole('button', { name: 'Sign up to join' })).toHaveClass('v2-login__submit'); | ||
| expect(within(card).getByRole('link', { name: 'Log in' })).toHaveAttribute('href', `/v2/login?next=${encodeURIComponent(`/v2/invite/${TOKEN}`)}`); | ||
| expect(container.querySelector('.v2-invite-card, .v2-invite-page')).toBeNull(); | ||
| }); | ||
|
|
||
| test('a dead link: the alert row and one plain key', async () => { | ||
| axios.get.mockRejectedValue(new Error('gone')); | ||
| renderPage(); | ||
| expect(await screen.findByRole('heading', { level: 1, name: 'Invite unavailable' })).toBeInTheDocument(); | ||
| expect(screen.getByRole('alert')).toHaveTextContent('This invite is no longer valid.'); | ||
| const key = screen.getByRole('button', { name: 'What is Commonly?' }); | ||
| expect(key).toHaveClass('v2-login__submit', 'v2-login__submit--ghost'); | ||
| }); | ||
|
|
||
| test('signed in: description, member count and Join; a member gets Go to pod', async () => { | ||
| mockAuthenticated = true; | ||
| mockApi.get.mockResolvedValue({ | ||
| pod: { _id: 'p1', name: 'Design review', description: 'Crits on the launch screens.', memberCount: 4 }, | ||
| alreadyMember: false, | ||
| }); | ||
| const { unmount } = renderPage(); | ||
| expect(await screen.findByRole('heading', { level: 1, name: 'Design review' })).toBeInTheDocument(); | ||
| expect(screen.getByText('Crits on the launch screens.')).toHaveClass('v2-invite__description'); | ||
| expect(screen.getByRole('button', { name: 'Join Design review' })).toHaveClass('v2-login__submit'); | ||
| unmount(); | ||
|
|
||
| mockApi.get.mockResolvedValue({ pod: { _id: 'p1', name: 'Design review', memberCount: 4 }, alreadyMember: true }); | ||
| renderPage(); | ||
| expect(await screen.findByRole('button', { name: 'Go to pod' })).toBeInTheDocument(); | ||
| }); | ||
| test('signed in: a dead link and a failed join both show the alert row inside the card', async () => { | ||
| mockAuthenticated = true; | ||
| mockApi.get.mockRejectedValue({ response: { data: { msg: 'Invite expired' } } }); | ||
| const { container, unmount } = renderPage(); | ||
| expect(await screen.findByRole('heading', { level: 1, name: 'Invite unavailable' })).toBeInTheDocument(); | ||
| const card = container.querySelector('.v2-login__card'); | ||
| expect(within(card).getByRole('alert')).toHaveTextContent('Invite expired'); | ||
| expect(within(card).getByRole('button', { name: 'Go to your pods' })).toHaveClass('v2-login__submit--ghost'); | ||
| unmount(); | ||
|
|
||
| mockApi.get.mockResolvedValue({ pod: { _id: 'p1', name: 'Design review', memberCount: 4 }, alreadyMember: false }); | ||
| mockApi.post.mockRejectedValue({ response: { data: { msg: 'Pod is full' } } }); | ||
| const second = renderPage(); | ||
| fireEvent.click(await screen.findByRole('button', { name: 'Join Design review' })); | ||
| const alert = await screen.findByRole('alert'); | ||
| expect(second.container.querySelector('.v2-login__card')).toContainElement(alert); | ||
| expect(alert).toHaveTextContent('Pod is full'); | ||
| expect(screen.getByRole('button', { name: 'Join Design review' })).toBeInTheDocument(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /* Invite link, the d215 invite frames: the auth card holding a pod. The pod's | ||
| seeded mark sits beside a mono eyebrow and the pod name as the 28px title. */ | ||
| .v2-invite__pod { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 12px; | ||
| min-width: 0; | ||
| } | ||
| .v2-root .v2-avatar.v2-invite__mark { | ||
| flex: none; | ||
| width: 44px; | ||
| height: 44px; | ||
| border-radius: 11px; | ||
| font-size: 15px; | ||
| } | ||
| .v2-invite__heading { | ||
| min-width: 0; | ||
| } | ||
| .v2-invite__eyebrow { | ||
| display: block; | ||
| font: 500 11.5px/1 var(--v2-font-mono); | ||
| color: var(--v2-text-muted); | ||
| } | ||
| /* Outranks .v2-login__card--stack .v2-login__title (4px) on specificity, not | ||
| on the order the lazy chunk's stylesheet lands. */ | ||
| .v2-login__card--stack .v2-invite__heading .v2-login__title { | ||
| margin: 6px 0 0; | ||
| overflow-wrap: anywhere; | ||
| } | ||
| .v2-invite__description { | ||
| margin: 0; | ||
| overflow-wrap: anywhere; | ||
| font-size: 14px; | ||
| line-height: 21px; | ||
| color: var(--v2-text-secondary); | ||
| } | ||
| .v2-invite__meta { | ||
| margin: 0; | ||
| font-size: 13px; | ||
| line-height: 19px; | ||
| color: var(--v2-text-secondary); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.