diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8bb0b5348..8019d5ce4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -96,7 +96,7 @@ jobs: uses: actions/upload-artifact@v7 if: failure() with: - name: ${{ matrix.os }}-${{ matrix.node-version }}-artifacts + name: test-artifacts-${{ github.run_id }}-${{ github.run_attempt }} path: | _playwright-results/ _playwright-report/ diff --git a/src/themes/shared/_markdown.css b/src/themes/shared/_markdown.css index b0ba76044..61a58897e 100644 --- a/src/themes/shared/_markdown.css +++ b/src/themes/shared/_markdown.css @@ -30,6 +30,8 @@ } a { + overflow-wrap: anywhere; + &.anchor { color: inherit; diff --git a/test/e2e/sidebar.test.js b/test/e2e/sidebar.test.js index ff4526601..88b444d9a 100644 --- a/test/e2e/sidebar.test.js +++ b/test/e2e/sidebar.test.js @@ -70,6 +70,43 @@ test.describe('Sidebar Tests', () => { }); }); +test.describe('Mobile sidebar toggle', () => { + test('wraps long links without causing horizontal overflow', async ({ + page, + }) => { + await page.setViewportSize({ width: 390, height: 844 }); + + const longUrl = `https://example.com/${'a'.repeat(240)}`; + const content = Array.from( + { length: 80 }, + (_, index) => `## Section ${index + 1}\n\nLong content for scrolling.`, + ).join('\n\n'); + + await docsifyInit({ + config: { + loadSidebar: '_sidebar.md', + }, + markdown: { + homepage: `# Mobile scrolling\n\n${content}\n\n[${longUrl}](${longUrl})`, + sidebar: '- [Mobile scrolling](README.md)', + }, + styleURLs: ['/dist/themes/core.css'], + }); + + await expect + .poll(() => page.evaluate(() => document.documentElement.scrollWidth)) + .toBe(page.viewportSize().width); + + await page.mouse.wheel(0, 1200); + await expect + .poll(() => page.evaluate(() => window.scrollY)) + .toBeGreaterThan(0); + + await page.mouse.wheel(0, -1200); + await expect.poll(() => page.evaluate(() => window.scrollY)).toBe(0); + }); +}); + test.describe('Configuration: autoHeader', () => { test('autoHeader=false', async ({ page }) => { const docsifyInitConfig = {