|
@@ -3,70 +3,133 @@ import { expect } from 'chai'
|
|
|
import NewProjectButton from '../../../../../frontend/js/features/project-list/components/new-project-button'
|
|
import NewProjectButton from '../../../../../frontend/js/features/project-list/components/new-project-button'
|
|
|
|
|
|
|
|
describe('<NewProjectButton />', function () {
|
|
describe('<NewProjectButton />', function () {
|
|
|
- beforeEach(function () {
|
|
|
|
|
- window.metaAttributesCache.set('ol-ExposedSettings', {
|
|
|
|
|
- templateLinks: [
|
|
|
|
|
- {
|
|
|
|
|
- name: 'Academic Journal',
|
|
|
|
|
- url: '/gallery/tagged/academic-journal',
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- name: 'View All',
|
|
|
|
|
- url: '/latex/templates',
|
|
|
|
|
- },
|
|
|
|
|
- ],
|
|
|
|
|
|
|
+ describe('for every user (affiliated and non-affiliated)', function () {
|
|
|
|
|
+ beforeEach(function () {
|
|
|
|
|
+ window.metaAttributesCache.set('ol-ExposedSettings', {
|
|
|
|
|
+ templateLinks: [
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'Academic Journal',
|
|
|
|
|
+ url: '/gallery/tagged/academic-journal',
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'View All',
|
|
|
|
|
+ url: '/latex/templates',
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ render(<NewProjectButton id="test" />)
|
|
|
|
|
+
|
|
|
|
|
+ const newProjectButton = screen.getByRole('button', {
|
|
|
|
|
+ name: 'New Project',
|
|
|
|
|
+ })
|
|
|
|
|
+ fireEvent.click(newProjectButton)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ afterEach(function () {
|
|
|
|
|
+ window.metaAttributesCache = new Map()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- render(<NewProjectButton id="test" />)
|
|
|
|
|
|
|
+ it('shows the correct dropdown menu', function () {
|
|
|
|
|
+ // static menu
|
|
|
|
|
+ screen.getByText('Blank Project')
|
|
|
|
|
+ screen.getByText('Example Project')
|
|
|
|
|
+ screen.getByText('Upload Project')
|
|
|
|
|
+ screen.getByText('Import from GitHub')
|
|
|
|
|
|
|
|
- const newProjectButton = screen.getByRole('button', {
|
|
|
|
|
- name: 'New Project',
|
|
|
|
|
|
|
+ // static text
|
|
|
|
|
+ screen.getByText('Templates')
|
|
|
|
|
+
|
|
|
|
|
+ // dynamic menu based on templateLinks
|
|
|
|
|
+ screen.getByText('Academic Journal')
|
|
|
|
|
+ screen.getByText('View All')
|
|
|
})
|
|
})
|
|
|
- fireEvent.click(newProjectButton)
|
|
|
|
|
- })
|
|
|
|
|
|
|
|
|
|
- afterEach(function () {
|
|
|
|
|
- window.metaAttributesCache = new Map()
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ it('open new project modal when clicking at Blank Project', function () {
|
|
|
|
|
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Blank Project' }))
|
|
|
|
|
|
|
|
- it('opens a dropdown', function () {
|
|
|
|
|
- // static menu
|
|
|
|
|
- screen.getByText('Blank Project')
|
|
|
|
|
- screen.getByText('Example Project')
|
|
|
|
|
- screen.getByText('Upload Project')
|
|
|
|
|
- screen.getByText('Import from GitHub')
|
|
|
|
|
|
|
+ screen.getByPlaceholderText('Project Name')
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
- // static text
|
|
|
|
|
- screen.getByText('Templates')
|
|
|
|
|
|
|
+ it('open new project modal when clicking at Example Project', function () {
|
|
|
|
|
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Example Project' }))
|
|
|
|
|
|
|
|
- // dynamic menu based on templateLinks
|
|
|
|
|
- screen.getByText('Academic Journal')
|
|
|
|
|
- screen.getByText('View All')
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ screen.getByPlaceholderText('Project Name')
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
- it('open new project modal when clicking at Blank Project', function () {
|
|
|
|
|
- fireEvent.click(screen.getByRole('menuitem', { name: 'Blank Project' }))
|
|
|
|
|
|
|
+ it('close the new project modal when clicking at the top right "x" button', function () {
|
|
|
|
|
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Blank Project' }))
|
|
|
|
|
+ fireEvent.click(screen.getByRole('button', { name: 'Close' }))
|
|
|
|
|
|
|
|
- screen.getByPlaceholderText('Project Name')
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ expect(screen.queryByRole('dialog')).to.be.null
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
- it('open new project modal when clicking at Example Project', function () {
|
|
|
|
|
- fireEvent.click(screen.getByRole('menuitem', { name: 'Example Project' }))
|
|
|
|
|
|
|
+ it('close the new project modal when clicking at the Cancel button', function () {
|
|
|
|
|
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Blank Project' }))
|
|
|
|
|
+ fireEvent.click(screen.getByRole('button', { name: 'Cancel' }))
|
|
|
|
|
|
|
|
- screen.getByPlaceholderText('Project Name')
|
|
|
|
|
|
|
+ expect(screen.queryByRole('dialog')).to.be.null
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- it('close the new project modal when clicking at the top right "x" button', function () {
|
|
|
|
|
- fireEvent.click(screen.getByRole('menuitem', { name: 'Blank Project' }))
|
|
|
|
|
- fireEvent.click(screen.getByRole('button', { name: 'Close' }))
|
|
|
|
|
|
|
+ describe('for affiliated user with custom templates', function () {
|
|
|
|
|
+ beforeEach(function () {
|
|
|
|
|
+ window.metaAttributesCache.set('ol-ExposedSettings', {
|
|
|
|
|
+ templateLinks: [
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'Academic Journal',
|
|
|
|
|
+ url: '/gallery/tagged/academic-journal',
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'View All',
|
|
|
|
|
+ url: '/latex/templates',
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
- expect(screen.queryByRole('dialog')).to.be.null
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ window.metaAttributesCache.set('ol-portalTemplates', [
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'Affiliation 1',
|
|
|
|
|
+ url: '/edu/test-new-template',
|
|
|
|
|
+ },
|
|
|
|
|
+ ])
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ afterEach(function () {
|
|
|
|
|
+ window.metaAttributesCache = new Map()
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ it('shows the correct dropdown menu', function () {
|
|
|
|
|
+ render(<NewProjectButton id="test" />)
|
|
|
|
|
+
|
|
|
|
|
+ const newProjectButton = screen.getByRole('button', {
|
|
|
|
|
+ name: 'New Project',
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ fireEvent.click(newProjectButton)
|
|
|
|
|
+ // static menu
|
|
|
|
|
+ screen.getByText('Blank Project')
|
|
|
|
|
+ screen.getByText('Example Project')
|
|
|
|
|
+ screen.getByText('Upload Project')
|
|
|
|
|
+ screen.getByText('Import from GitHub')
|
|
|
|
|
|
|
|
- it('close the new project modal when clicking at the Cancel button', function () {
|
|
|
|
|
- fireEvent.click(screen.getByRole('menuitem', { name: 'Blank Project' }))
|
|
|
|
|
- fireEvent.click(screen.getByRole('button', { name: 'Cancel' }))
|
|
|
|
|
|
|
+ // static text for institution templates
|
|
|
|
|
+ screen.getByText('Institution Templates')
|
|
|
|
|
|
|
|
- expect(screen.queryByRole('dialog')).to.be.null
|
|
|
|
|
|
|
+ // dynamic menu based on portalTemplates
|
|
|
|
|
+ const affiliationTemplate = screen.getByRole('menuitem', {
|
|
|
|
|
+ name: 'Affiliation 1',
|
|
|
|
|
+ })
|
|
|
|
|
+ expect(affiliationTemplate.getAttribute('href')).to.equal(
|
|
|
|
|
+ '/edu/test-new-template#templates'
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ // static text
|
|
|
|
|
+ screen.getByText('Templates')
|
|
|
|
|
+
|
|
|
|
|
+ // dynamic menu based on templateLinks
|
|
|
|
|
+ screen.getByText('Academic Journal')
|
|
|
|
|
+ screen.getByText('View All')
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|