2021-05-31 04:27:23 -04:00
|
|
|
import { expect } from 'chai'
|
2022-08-18 04:14:44 -04:00
|
|
|
import { screen } from '@testing-library/react'
|
2021-05-31 04:27:23 -04:00
|
|
|
|
|
|
|
import ToolbarHeader from '../../../../../frontend/js/features/editor-navigation-toolbar/components/toolbar-header'
|
2022-08-18 04:14:44 -04:00
|
|
|
import { renderWithEditorContext } from '../../../helpers/render-with-context'
|
2021-05-31 04:27:23 -04:00
|
|
|
|
|
|
|
describe('<ToolbarHeader />', function () {
|
|
|
|
const defaultProps = {
|
|
|
|
onShowLeftMenuClick: () => {},
|
|
|
|
toggleChatOpen: () => {},
|
|
|
|
toggleReviewPanelOpen: () => {},
|
|
|
|
toggleHistoryOpen: () => {},
|
|
|
|
unreadMessageCount: 0,
|
|
|
|
onlineUsers: [],
|
|
|
|
goToUser: () => {},
|
|
|
|
projectName: 'test project',
|
|
|
|
renameProject: () => {},
|
|
|
|
openShareModal: () => {},
|
2021-06-30 07:03:29 -04:00
|
|
|
hasPublishPermissions: true,
|
2021-08-11 04:50:07 -04:00
|
|
|
trackChangesVisible: true,
|
2021-11-15 10:44:06 -05:00
|
|
|
handleChangeLayout: () => {},
|
2022-07-18 06:24:14 -04:00
|
|
|
pdfLayout: 'sideBySide',
|
|
|
|
view: 'editor',
|
2021-11-15 11:33:57 -05:00
|
|
|
reattach: () => {},
|
|
|
|
detach: () => {},
|
2021-05-31 04:27:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
describe('cobranding logo', function () {
|
|
|
|
it('is not displayed by default', function () {
|
2022-08-18 04:14:44 -04:00
|
|
|
renderWithEditorContext(<ToolbarHeader {...defaultProps} />)
|
2021-05-31 04:27:23 -04:00
|
|
|
expect(screen.queryByRole('link', { name: 'variation' })).to.not.exist
|
|
|
|
})
|
|
|
|
|
|
|
|
it('is displayed when cobranding data is available', function () {
|
|
|
|
const props = {
|
|
|
|
...defaultProps,
|
|
|
|
cobranding: {
|
|
|
|
brandVariationHomeUrl: 'http://cobranding',
|
|
|
|
brandVariationName: 'variation',
|
|
|
|
logoImgUrl: 'http://cobranding/logo',
|
|
|
|
},
|
|
|
|
}
|
2022-08-18 04:14:44 -04:00
|
|
|
renderWithEditorContext(<ToolbarHeader {...props} />)
|
2021-05-31 04:27:23 -04:00
|
|
|
screen.getByRole('link', { name: 'variation' })
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('track changes toggle button', function () {
|
|
|
|
it('is displayed by default', function () {
|
2022-08-18 04:14:44 -04:00
|
|
|
renderWithEditorContext(<ToolbarHeader {...defaultProps} />)
|
2021-05-31 04:27:23 -04:00
|
|
|
screen.getByText('Review')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('is not displayed when "isRestrictedTokenMember" prop is set to true', function () {
|
|
|
|
const props = {
|
|
|
|
...defaultProps,
|
|
|
|
isRestrictedTokenMember: true,
|
|
|
|
}
|
2022-08-18 04:14:44 -04:00
|
|
|
renderWithEditorContext(<ToolbarHeader {...props} />)
|
2021-05-31 04:27:23 -04:00
|
|
|
expect(screen.queryByText('Review')).to.not.exist
|
|
|
|
})
|
2021-08-11 04:50:07 -04:00
|
|
|
|
|
|
|
it('is not displayed when "trackChangesVisible" prop is set to false', function () {
|
|
|
|
const props = {
|
|
|
|
...defaultProps,
|
|
|
|
trackChangesVisible: false,
|
|
|
|
}
|
2022-08-18 04:14:44 -04:00
|
|
|
renderWithEditorContext(<ToolbarHeader {...props} />)
|
2021-08-11 04:50:07 -04:00
|
|
|
expect(screen.queryByText('Review')).to.not.exist
|
|
|
|
})
|
2021-05-31 04:27:23 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
describe('History toggle button', function () {
|
|
|
|
it('is displayed by default', function () {
|
2022-08-18 04:14:44 -04:00
|
|
|
renderWithEditorContext(<ToolbarHeader {...defaultProps} />)
|
2021-05-31 04:27:23 -04:00
|
|
|
screen.getByText('History')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('is not displayed when "isRestrictedTokenMember" prop is set to true', function () {
|
|
|
|
const props = {
|
|
|
|
...defaultProps,
|
|
|
|
isRestrictedTokenMember: true,
|
|
|
|
}
|
2022-08-18 04:14:44 -04:00
|
|
|
renderWithEditorContext(<ToolbarHeader {...props} />)
|
2021-05-31 04:27:23 -04:00
|
|
|
expect(screen.queryByText('History')).to.not.exist
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('Chat toggle button', function () {
|
|
|
|
it('is displayed by default', function () {
|
2022-08-18 04:14:44 -04:00
|
|
|
renderWithEditorContext(<ToolbarHeader {...defaultProps} />)
|
2021-05-31 04:27:23 -04:00
|
|
|
screen.getByText('Chat')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('is not displayed when "isRestrictedTokenMember" prop is set to true', function () {
|
|
|
|
const props = {
|
|
|
|
...defaultProps,
|
|
|
|
isRestrictedTokenMember: true,
|
|
|
|
}
|
2022-08-18 04:14:44 -04:00
|
|
|
renderWithEditorContext(<ToolbarHeader {...props} />)
|
2021-05-31 04:27:23 -04:00
|
|
|
expect(screen.queryByText('Chat')).to.not.exist
|
|
|
|
})
|
|
|
|
})
|
2021-06-17 07:50:29 -04:00
|
|
|
|
|
|
|
describe('Publish button', function () {
|
|
|
|
it('is displayed by default', function () {
|
2022-08-18 04:14:44 -04:00
|
|
|
renderWithEditorContext(<ToolbarHeader {...defaultProps} />)
|
2021-06-17 07:50:29 -04:00
|
|
|
screen.getByText('Submit')
|
|
|
|
})
|
|
|
|
|
2021-06-30 07:03:29 -04:00
|
|
|
it('is not displayed for users with no publish permissions', function () {
|
2021-06-17 07:50:29 -04:00
|
|
|
const props = {
|
|
|
|
...defaultProps,
|
2021-06-30 07:03:29 -04:00
|
|
|
hasPublishPermissions: false,
|
2021-06-17 07:50:29 -04:00
|
|
|
}
|
2022-08-18 04:14:44 -04:00
|
|
|
renderWithEditorContext(<ToolbarHeader {...props} />)
|
2021-06-17 07:50:29 -04:00
|
|
|
expect(screen.queryByText('Submit')).to.not.exist
|
|
|
|
})
|
|
|
|
})
|
2021-05-31 04:27:23 -04:00
|
|
|
})
|