generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Improve the algorithm of link detection and html insertion to re…
…move bugs - refs 282898 * Drop dangerouslySetInnerHTML * Improve FootnotesBlockView.jsx * Update FootnotesBlockView.jsx * Update FootnotesBlockView.jsx * Create FootnotesBlockView.test.jsx * Update FootnotesBlockView.test.jsx * Update FootnotesBlockView.jsx to check if on the Client Side * Update render.jsx to improve link detection * Update render.jsx * Update utils.js * Update FootnotesBlockView.jsx * Update FootnotesBlockView.test.jsx * tests * tests * fix refresh of page when clicking on a ref * cypress test * cypress test * unit test * make links clickable * make links clickable
- Loading branch information
Showing
5 changed files
with
268 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import FootnotesBlockView from './FootnotesBlockView'; | ||
|
||
jest.mock('@plone/volto/components', () => ({ | ||
UniversalLink: ({ children, href }) => <a href={href}>{children}</a>, | ||
})); | ||
|
||
jest.mock('@eeacms/volto-slate-footnote/editor/utils', () => ({ | ||
openAccordionOrTabIfContainsFootnoteReference: jest.fn(), | ||
renderTextWithLinks: jest.fn(), | ||
getAllBlocksAndSlateFields: jest.fn(() => [ | ||
{ id: 'block1', footnote: 'Footnote with no link' }, | ||
{ id: 'block2', footnote: 'Footnote with link http://example.com' }, | ||
{ id: 'block3', footnote: 'Footnote with <b>HTML</b>' }, | ||
]), | ||
makeFootnoteListOfUniqueItems: jest.fn((blocks) => ({ | ||
note1: { | ||
uid: '1', | ||
footnote: 'First note with a reference', | ||
zoteroId: 'zotero1', | ||
refs: { ref1: 'ref1' }, | ||
}, | ||
note2: { | ||
uid: '2', | ||
footnote: 'Second note with multiple references', | ||
zoteroId: null, | ||
refs: { ref2: 'ref2', ref3: 'ref3' }, | ||
}, | ||
note3: { | ||
uid: '3', | ||
footnote: '<i>Note with HTML</i>', | ||
zoteroId: 'zotero3', | ||
refs: {}, | ||
}, | ||
})), | ||
})); | ||
|
||
describe('FootnotesBlockView', () => { | ||
const propsVariations = [ | ||
{ | ||
description: 'renders with global metadata', | ||
props: { | ||
data: { title: 'Global Metadata', global: true, placeholder: 'Global' }, | ||
properties: { test: 'metadata' }, | ||
tabData: null, | ||
content: null, | ||
metadata: { test: 'metadata' }, | ||
}, | ||
}, | ||
{ | ||
description: 'renders with tabData', | ||
props: { | ||
data: { title: 'Tab Data', global: false, placeholder: 'Tab' }, | ||
properties: { test: 'tabProperties' }, | ||
tabData: { test: 'tabData' }, | ||
content: null, | ||
}, | ||
}, | ||
{ | ||
description: 'renders with content', | ||
props: { | ||
data: { title: 'Content Data', global: false, placeholder: 'Content' }, | ||
properties: { test: 'contentProperties' }, | ||
tabData: null, | ||
content: { test: 'contentData' }, | ||
}, | ||
}, | ||
{ | ||
description: 'renders with no metadata', | ||
props: { | ||
data: { title: 'No Metadata', global: false, placeholder: 'Default' }, | ||
properties: { test: 'defaultProperties' }, | ||
tabData: null, | ||
content: null, | ||
}, | ||
}, | ||
]; | ||
|
||
test.each(propsVariations)('$description', ({ props }) => { | ||
render(<FootnotesBlockView {...props} />); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.