fix(web): build test users with an email address, so the type check passes
The tests of Discover, the Lidarr button and the admin libraries built a signed-in user with a username, which no longer exists since accounts are identified by email. They passed, but the type check failed on 18 fixtures and so did npm run build. Closes #71.
This commit is contained in:
parent
0b9d158f2b
commit
04526f8576
13 changed files with 18 additions and 18 deletions
|
|
@ -36,11 +36,11 @@ function admin(routes: MockRoutes) {
|
|||
beforeEach(async () => {
|
||||
vi.spyOn(navigator, 'language', 'get').mockReturnValue('en-US')
|
||||
await initI18n()
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, username: 'tom', is_admin: true } })
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, email: 'tom@example.org', is_admin: true } })
|
||||
})
|
||||
|
||||
test('a user who is not an admin sees nothing and nothing is asked', async () => {
|
||||
sessionStore.setState({ user: { id: 2, username: 'ann', is_admin: false } })
|
||||
sessionStore.setState({ user: { id: 2, email: 'ann@example.org', is_admin: false } })
|
||||
const { calls } = admin({})
|
||||
const view = renderButton()
|
||||
await new Promise((r) => setTimeout(r, 50))
|
||||
|
|
|
|||
|
|
@ -40,13 +40,13 @@ const adminRoutes = {
|
|||
}
|
||||
|
||||
test('an admin has an Admin link, and a user who is not one has none', () => {
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, username: 'tom', is_admin: false } })
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, email: 'tom@example.org', is_admin: false } })
|
||||
renderAt('/artists')
|
||||
expect(within(mainNav()).queryByRole('link', { name: 'Admin' })).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
test('the Admin link opens the libraries and stays current inside the admin area', async () => {
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, username: 'tom', is_admin: true } })
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, email: 'tom@example.org', is_admin: true } })
|
||||
mockFetch(adminRoutes)
|
||||
renderAt('/admin')
|
||||
expect(await screen.findByRole('region', { name: 'Libraries' })).toBeInTheDocument()
|
||||
|
|
@ -54,7 +54,7 @@ test('the Admin link opens the libraries and stays current inside the admin area
|
|||
})
|
||||
|
||||
test('someone who is not an admin who opens the admin address gets a notice and no request', async () => {
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 2, username: 'ann', is_admin: false } })
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 2, email: 'ann@example.org', is_admin: false } })
|
||||
const { calls } = mockFetch(adminRoutes)
|
||||
renderAt('/admin/libraries')
|
||||
expect(screen.getByText('Only admins can see this page.')).toBeInTheDocument()
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ const tab = (name: string) => screen.getByRole('tab', { name })
|
|||
beforeEach(async () => {
|
||||
vi.spyOn(navigator, 'language', 'get').mockReturnValue('en-US')
|
||||
await initI18n()
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, username: 'tom', is_admin: false } })
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, email: 'tom@example.org', is_admin: false } })
|
||||
})
|
||||
|
||||
test('it opens on the suggestions', async () => {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ const add = () => screen.getByRole('button', { name: 'Add library' })
|
|||
beforeEach(async () => {
|
||||
vi.spyOn(navigator, 'language', 'get').mockReturnValue('en-US')
|
||||
await initI18n()
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, username: 'tom', is_admin: true } })
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, email: 'tom@example.org', is_admin: true } })
|
||||
})
|
||||
|
||||
test('it says the folder is on the machine that runs Sonda, not on this computer', () => {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ beforeEach(async () => {
|
|||
})
|
||||
|
||||
test('an admin gets the admin page with its sections and the page of the section', () => {
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, username: 'tom', is_admin: true } })
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, email: 'tom@example.org', is_admin: true } })
|
||||
renderAdmin()
|
||||
expect(screen.getByRole('heading', { level: 1, name: 'Admin' })).toBeInTheDocument()
|
||||
expect(screen.getByRole('navigation', { name: 'Admin sections' })).toBeInTheDocument()
|
||||
|
|
@ -33,7 +33,7 @@ test('an admin gets the admin page with its sections and the page of the section
|
|||
})
|
||||
|
||||
test('anyone else sees a notice, not the section, and nothing is asked of the server', async () => {
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 2, username: 'ann', is_admin: false } })
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 2, email: 'ann@example.org', is_admin: false } })
|
||||
const { calls } = mockFetch({})
|
||||
renderAdmin()
|
||||
expect(screen.getByText('Only admins can see this page.')).toBeInTheDocument()
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ const bodies = (calls: RecordedCall[], key: string) => calls.filter((c) => c.key
|
|||
beforeEach(async () => {
|
||||
vi.spyOn(navigator, 'language', 'get').mockReturnValue('en-US')
|
||||
await initI18n()
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, username: 'tom', is_admin: true } })
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, email: 'tom@example.org', is_admin: true } })
|
||||
})
|
||||
|
||||
test('each library shows its name and its folder on the server', async () => {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ const posts = (calls: RecordedCall[]) => calls.filter((c) => c.key === 'POST /ap
|
|||
beforeEach(async () => {
|
||||
vi.spyOn(navigator, 'language', 'get').mockReturnValue('en-US')
|
||||
await initI18n()
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, username: 'tom', is_admin: true } })
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, email: 'tom@example.org', is_admin: true } })
|
||||
})
|
||||
|
||||
test('after a scan it shows how it went, and the files Sonda cannot read yet stand out', async () => {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ function wishlist(over: MockRoutes = {}): MockRoutes {
|
|||
beforeEach(async () => {
|
||||
vi.spyOn(navigator, 'language', 'get').mockReturnValue('en-US')
|
||||
await initI18n()
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, username: 'tom', is_admin: false } })
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, email: 'tom@example.org', is_admin: false } })
|
||||
})
|
||||
|
||||
test('an artist you have links to its page, one you only wish for is just a name', async () => {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ const box = () => screen.getByRole('searchbox', { name: 'Find an artist to start
|
|||
beforeEach(async () => {
|
||||
vi.spyOn(navigator, 'language', 'get').mockReturnValue('en-US')
|
||||
await initI18n()
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, username: 'tom', is_admin: false } })
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, email: 'tom@example.org', is_admin: false } })
|
||||
})
|
||||
|
||||
test('nothing is asked of the library until something is typed', async () => {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ function renderCard(suggestion: Suggestion) {
|
|||
beforeEach(async () => {
|
||||
vi.spyOn(navigator, 'language', 'get').mockReturnValue('en-US')
|
||||
await initI18n()
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, username: 'tom', is_admin: false } })
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, email: 'tom@example.org', is_admin: false } })
|
||||
})
|
||||
|
||||
test('it names the artist with a link, the score in percent, and what it comes from', () => {
|
||||
|
|
@ -62,7 +62,7 @@ test('an artist you have shows its photo', () => {
|
|||
})
|
||||
|
||||
test('an admin can request the artist on Lidarr from the card, and the card asks Lidarr nothing before that', async () => {
|
||||
sessionStore.setState({ user: { id: 1, username: 'tom', is_admin: true } })
|
||||
sessionStore.setState({ user: { id: 1, email: 'tom@example.org', is_admin: true } })
|
||||
const { calls } = mockFetch({})
|
||||
renderCard(make())
|
||||
expect(screen.getByRole('button', { name: 'Request on Lidarr' })).toBeInTheDocument()
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ const discoverCalls = (calls: RecordedCall[]) => calls.filter((c) => c.key === '
|
|||
beforeEach(async () => {
|
||||
vi.spyOn(navigator, 'language', 'get').mockReturnValue('en-US')
|
||||
await initI18n()
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, username: 'tom', is_admin: false } })
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, email: 'tom@example.org', is_admin: false } })
|
||||
})
|
||||
|
||||
test('with no starting artist and your listening not allowed, nothing is sent and you are invited to pick', async () => {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ function renderPanel() {
|
|||
beforeEach(async () => {
|
||||
vi.spyOn(navigator, 'language', 'get').mockReturnValue('en-US')
|
||||
await initI18n()
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, username: 'tom', is_admin: false } })
|
||||
sessionStore.setState({ status: 'authenticated', user: { id: 1, email: 'tom@example.org', is_admin: false } })
|
||||
})
|
||||
|
||||
test('it shows the kinds of music and the artists you like', async () => {
|
||||
|
|
|
|||
|
|
@ -372,7 +372,7 @@ test('an artist a provider named, with nothing to play, still has a page', async
|
|||
})
|
||||
|
||||
test('an admin gets the Lidarr button on the page of an artist they have nothing of', async () => {
|
||||
sessionStore.setState({ user: { id: 1, username: 'tom', is_admin: true } })
|
||||
sessionStore.setState({ user: { id: 1, email: 'tom@example.org', is_admin: true } })
|
||||
mockFetch(
|
||||
artistRoutes({
|
||||
'GET /api/v1/artists/5': () => ({ ...artist, album_count: 0, track_count: 0 }),
|
||||
|
|
|
|||
Loading…
Reference in a new issue