diff --git a/tests/pages/HomePage.test.ts b/tests/pages/HomePage.test.ts
index 182eb807..6308a1f5 100644
--- a/tests/pages/HomePage.test.ts
+++ b/tests/pages/HomePage.test.ts
@@ -71,4 +71,27 @@ describe('HomePage', () => {
const { debugError } = await import('@api/http-error.ts');
expect(debugError).toHaveBeenCalledWith(error);
});
+
+ it('renders a back to top link targeting the home container', async () => {
+ const wrapper = mount(HomePage, {
+ global: {
+ stubs: {
+ SideNavPartial: true,
+ HeaderPartial: true,
+ HeroPartial: true,
+ FooterPartial: true,
+ ArticlesListPartial: true,
+ FeaturedProjectsPartial: true,
+ TalksPartial: true,
+ WidgetSponsorPartial: true,
+ WidgetSkillsPartial: true,
+ },
+ },
+ });
+
+ await flushPromises();
+
+ const backToTopLink = wrapper.find('a[href="#home-top"]');
+ expect(backToTopLink.exists()).toBe(true);
+ });
});
diff --git a/tests/pages/PostPage.test.ts b/tests/pages/PostPage.test.ts
index 98de0b3f..9438f0c9 100644
--- a/tests/pages/PostPage.test.ts
+++ b/tests/pages/PostPage.test.ts
@@ -52,24 +52,28 @@ vi.mock('@/public.ts', () => ({
getReadingTime: () => '',
}));
+const mountComponent = () =>
+ mount(PostPage, {
+ global: {
+ stubs: {
+ SideNavPartial: true,
+ HeaderPartial: true,
+ FooterPartial: true,
+ WidgetSponsorPartial: true,
+ WidgetSocialPartial: true,
+ WidgetSkillsPartial: true,
+ RouterLink: { template: '
' },
+ },
+ },
+ });
+
describe('PostPage', () => {
beforeEach(() => {
vi.clearAllMocks();
});
it('fetches post on mount', async () => {
- const wrapper = mount(PostPage, {
- global: {
- stubs: {
- SideNavPartial: true,
- HeaderPartial: true,
- FooterPartial: true,
- WidgetSponsorPartial: true,
- WidgetSkillsPartial: true,
- RouterLink: { template: '
' },
- },
- },
- });
+ const wrapper = mountComponent();
const skeleton = wrapper.find('[data-testid="post-page-skeleton"]');
expect(skeleton.exists()).toBe(true);
expect(skeleton.classes()).toContain('min-h-[25rem]');
@@ -80,18 +84,7 @@ describe('PostPage', () => {
});
it('initializes highlight.js on mount', async () => {
- const wrapper = mount(PostPage, {
- global: {
- stubs: {
- SideNavPartial: true,
- HeaderPartial: true,
- FooterPartial: true,
- WidgetSponsorPartial: true,
- WidgetSkillsPartial: true,
- RouterLink: { template: '
' },
- },
- },
- });
+ const wrapper = mountComponent();
await flushPromises();
const highlightCore = await import('highlight.js/lib/core');
expect(initializeHighlighter).toHaveBeenCalledWith(highlightCore.default);
@@ -101,18 +94,7 @@ describe('PostPage', () => {
it('processes markdown content', async () => {
const DOMPurify = await import('dompurify');
- const wrapper = mount(PostPage, {
- global: {
- stubs: {
- SideNavPartial: true,
- HeaderPartial: true,
- FooterPartial: true,
- WidgetSponsorPartial: true,
- WidgetSkillsPartial: true,
- RouterLink: { template: '
' },
- },
- },
- });
+ const wrapper = mountComponent();
await flushPromises();
expect(renderMarkdown).toHaveBeenCalledWith(post.content);
expect(DOMPurify.default.sanitize).toHaveBeenCalled();
@@ -122,22 +104,37 @@ describe('PostPage', () => {
it('handles post errors gracefully', async () => {
const error = new Error('fail');
getPost.mockRejectedValueOnce(error);
- const wrapper = mount(PostPage, {
- global: {
- stubs: {
- SideNavPartial: true,
- HeaderPartial: true,
- FooterPartial: true,
- WidgetSponsorPartial: true,
- WidgetSkillsPartial: true,
- RouterLink: { template: '
' },
- },
- },
- });
+ const wrapper = mountComponent();
await flushPromises();
const { debugError } = await import('@api/http-error.ts');
expect(debugError).toHaveBeenCalledWith(error);
expect(wrapper.find('[data-testid="post-page-skeleton"]').exists()).toBe(false);
expect(wrapper.text()).toContain("We couldn't load this post.");
});
+
+ it('renders the follow widget above the sponsor widget', async () => {
+ const wrapper = mountComponent();
+
+ await flushPromises();
+
+ const aside = wrapper.find('aside');
+ expect(aside.exists()).toBe(true);
+
+ const container = aside.find('div');
+ expect(container.exists()).toBe(true);
+
+ const children = container.element.children;
+ expect(children.length).toBeGreaterThanOrEqual(2);
+ expect(children[0].tagName).toBe('WIDGET-SOCIAL-PARTIAL-STUB');
+ expect(children[1].tagName).toBe('WIDGET-SPONSOR-PARTIAL-STUB');
+ });
+
+ it('renders a back to top link targeting the post header', async () => {
+ const wrapper = mountComponent();
+
+ await flushPromises();
+
+ const backToTopLink = wrapper.find('a[href="#post-top"]');
+ expect(backToTopLink.exists()).toBe(true);
+ });
});