feat: social links with inline SVG icons from CMS
SocialRecord gains icon field (SVG markup string). InlineSvg component parses SVG string via html-react-parser. Footer renders icon on mobile (sm:hidden label), label on sm+ (hidden icon). Email field refactored from string to SocialRecord relation.
This commit is contained in:
@@ -21,9 +21,19 @@ const mockSettings = {
|
||||
collectionName: 'contacts',
|
||||
created: '',
|
||||
updated: '',
|
||||
email: 'hello@allmy.work',
|
||||
email: 'e1',
|
||||
socials: ['s1'],
|
||||
expand: {
|
||||
email: {
|
||||
id: 'e1',
|
||||
collectionId: 'contact',
|
||||
collectionName: 'contact',
|
||||
created: '',
|
||||
updated: '',
|
||||
label: 'hello@allmy.work',
|
||||
url: 'mailto:hello@allmy.work',
|
||||
icon: '',
|
||||
},
|
||||
socials: [
|
||||
{
|
||||
id: 's1',
|
||||
@@ -33,6 +43,7 @@ const mockSettings = {
|
||||
updated: '',
|
||||
label: 'GitHub',
|
||||
url: 'https://github.com',
|
||||
icon: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -58,19 +69,28 @@ describe('Footer', () => {
|
||||
});
|
||||
|
||||
describe('email link', () => {
|
||||
it('renders the contact email as a mailto link', async () => {
|
||||
it('renders the contact email link', async () => {
|
||||
render(await Footer());
|
||||
const link = screen.getByRole('link', { name: /hello@allmy\.work/i });
|
||||
expect(link).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('email link points to the mailto url', async () => {
|
||||
render(await Footer());
|
||||
const link = screen.getByRole('link', { name: /hello@allmy\.work/i });
|
||||
expect(link).toHaveAttribute('href', 'mailto:hello@allmy.work');
|
||||
});
|
||||
|
||||
it('does not render email link when contacts.email is missing', async () => {
|
||||
it('does not render email link when expand.email is missing', async () => {
|
||||
vi.mocked(getFirstRecord).mockResolvedValue({
|
||||
...mockSettings,
|
||||
expand: {
|
||||
contacts: {
|
||||
...mockSettings.expand.contacts,
|
||||
email: '',
|
||||
expand: {
|
||||
...mockSettings.expand.contacts.expand,
|
||||
email: undefined,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -98,7 +118,10 @@ describe('Footer', () => {
|
||||
expand: {
|
||||
contacts: {
|
||||
...mockSettings.expand.contacts,
|
||||
expand: { socials: [] },
|
||||
expand: {
|
||||
...mockSettings.expand.contacts.expand,
|
||||
socials: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user