Add "New" badge to library nav link and a feedback link on the library page

GitOrigin-RevId: 6c936ca8168dd718c4eaf806f426d5c00078add8
This commit is contained in:
Domagoj Kriskovic
2026-09-17 11:58:32 +00:00
committed by Copybot
parent a4b9b18109
commit d7b4ef33ed
5 changed files with 52 additions and 3 deletions
@@ -1,4 +1,4 @@
import { screen, waitFor } from '@testing-library/react'
import { screen, waitFor, within } from '@testing-library/react'
import { expect } from 'chai'
import SidebarDsNav from '../../../../../../frontend/js/features/project-list/components/sidebar/sidebar-ds-nav'
import {
@@ -44,6 +44,9 @@ describe('<SidebarDsNav />', function () {
window.metaAttributesCache.set('ol-splitTestVariants', {
'overleaf-library': 'enabled',
})
window.metaAttributesCache.set('ol-inactiveTutorials', [
'library-new-badge',
])
window.metaAttributesCache.set('ol-userSettings', {})
window.metaAttributesCache.set('ol-navbar', {
sessionUser: { email: 'fake@example.com' },
@@ -92,6 +95,46 @@ describe('<SidebarDsNav />', function () {
).to.be.null
})
describe('library "New" badge', function () {
it('shows the badge on the projects page when the tutorial is active', async function () {
window.metaAttributesCache.set('ol-inactiveTutorials', [])
await renderSidebar({ activePage: 'projects' })
const link = screen.getByRole('link', { name: /library/i })
expect(within(link).getByText('New')).to.exist
})
it('hides the badge once the tutorial has been dismissed', async function () {
window.metaAttributesCache.set('ol-inactiveTutorials', [
'library-new-badge',
])
await renderSidebar({ activePage: 'projects' })
const link = screen.getByRole('link', { name: /library/i })
expect(within(link).queryByText('New')).to.be.null
})
it('hides the badge on the library page itself', async function () {
window.metaAttributesCache.set('ol-inactiveTutorials', [])
await renderSidebar({ activePage: 'library' })
const link = screen.getByRole('link', { name: /library/i })
expect(within(link).queryByText('New')).to.be.null
})
it('hides the badge in the library trash', async function () {
window.metaAttributesCache.set('ol-inactiveTutorials', [])
await renderSidebar({ activePage: 'library', trashActive: true })
const link = screen.getByRole('link', { name: /library/i })
expect(within(link).queryByText('New')).to.be.null
})
})
describe('add affiliation widget', function () {
it('shows the widget on the library page when the user has no affiliations', async function () {
window.metaAttributesCache.set('ol-userAffiliations', [])