Files
baserow/web-frontend/test/unit/builder/components/BuilderToasts.spec.js
Tsering Paljor 674e4b12a8 feat: Add markdown support to more Builder elements (#6124)
* WIP

* Remove formula conversion related changes

* Move the file input click guard to formatted text component

* Move format types into their own components

* Use a shared markdown-it instance

* Move the formatter into data explorer

* Move minification logic into BaserowFormulaMinified

* Renderer should own the root element

* Ensure long choice names are truncated

* Ensure line height doesn't grow for paragraphs

* Add tests

* Add changelog

* Add specific tests for choice element
2026-10-09 09:36:32 +04:00

54 lines
1.6 KiB
JavaScript

import { TestApp } from '@baserow/test/helpers/testApp'
import BuilderToasts from '@baserow/modules/builder/components/BuilderToasts.vue'
describe('BuilderToasts', () => {
let testApp = null
beforeEach(() => {
testApp = new TestApp()
})
afterEach(async () => {
await testApp.afterEach()
})
const mountWithToast = async (toast) => {
await testApp.store.dispatch('builderToast/info', toast)
return testApp.mount(BuilderToasts)
}
test('renders a plain title and message without interpreting markdown', async () => {
const wrapper = await mountWithToast({
title: '**Saved**',
message: 'Line 1\nLine 2',
})
const title = wrapper.find('.ab-toast__title')
expect(title.text()).toBe('**Saved**')
expect(title.find('strong').exists()).toBe(false)
expect(
wrapper.findAll('.ab-toast__message p.ab-text').map((p) => p.text())
).toEqual(['Line 1', 'Line 2'])
})
test('renders a markdown title inline and a markdown message as a block', async () => {
const wrapper = await mountWithToast({
title: '**Saved**',
titleFormat: 'markdown',
message: 'Row _created_\n\n[Open it](https://baserow.io)',
messageFormat: 'markdown',
})
const title = wrapper.find('.ab-toast__title')
expect(title.find('strong').text()).toBe('Saved')
expect(title.find('p').exists()).toBe(false)
const message = wrapper.find('.ab-toast__message')
expect(message.findAll('p.ab-text')).toHaveLength(2)
expect(message.find('em').text()).toBe('created')
expect(message.find('a.ab-link').attributes('href')).toBe(
'https://baserow.io'
)
})
})