mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* Add backend changes: models, handler, etc. * Add frontend share dashboard modal * Add public dashboard endpoint * Add frontend public dashboard view * Add public dashboard auth * Show the logo in the password page based on license * Add abuse reporting and fix license check * Fix tests * fix tests * Fix aggregation in public dashboard * Fix styling on sharing options * Ensure anonymous dashboard views only return the data it needs * DRY public access token logic * Add changelog * Added UpdateDashboardSharingActionType to ensure audit log accurately records changes. * Add e2e tests * Remove old todo; creation-time check is sufficient * Re-add request serializer field overrides * fix test * Ensure that the password protection modal can be persisted with an Enter keypress. --------- Co-authored-by: peter_baserow <peter@baserow.io>
57 lines
1.6 KiB
JavaScript
57 lines
1.6 KiB
JavaScript
import { mount } from '@vue/test-utils'
|
|
import { vi } from 'vitest'
|
|
|
|
import DashboardHeaderMenuItems from '@baserow/modules/dashboard/components/DashboardHeaderMenuItems'
|
|
|
|
function mountDashboardHeaderMenuItems({ canEdit }) {
|
|
const dispatch = vi.fn()
|
|
const wrapper = mount(DashboardHeaderMenuItems, {
|
|
props: {
|
|
dashboard: {
|
|
id: 1,
|
|
workspace: { id: 1 },
|
|
},
|
|
},
|
|
global: {
|
|
mocks: {
|
|
$hasPermission: () => canEdit,
|
|
$store: { dispatch },
|
|
$t: (key) => key,
|
|
},
|
|
stubs: {
|
|
ShareDashboardLink: {
|
|
template: '<div data-testid="share-dashboard-link"></div>',
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
return { wrapper, dispatch }
|
|
}
|
|
|
|
describe('DashboardHeaderMenuItems', () => {
|
|
test('shows the edit mode and share dashboard items to users who can update the dashboard', async () => {
|
|
const { wrapper, dispatch } = mountDashboardHeaderMenuItems({
|
|
canEdit: true,
|
|
})
|
|
|
|
expect(wrapper.text()).toContain('dashboardHeaderMenuItems.editMode')
|
|
expect(wrapper.find('[data-testid="share-dashboard-link"]').exists()).toBe(
|
|
true
|
|
)
|
|
|
|
await wrapper.get('.header__filter-link').trigger('click')
|
|
|
|
expect(dispatch).toHaveBeenCalledWith('dashboardApplication/toggleEditMode')
|
|
})
|
|
|
|
test('hides both items from users without the update permission', () => {
|
|
const { wrapper } = mountDashboardHeaderMenuItems({ canEdit: false })
|
|
|
|
expect(wrapper.text()).not.toContain('dashboardHeaderMenuItems.editMode')
|
|
expect(wrapper.find('[data-testid="share-dashboard-link"]').exists()).toBe(
|
|
false
|
|
)
|
|
})
|
|
})
|