Skip to content

Commit

Permalink
Add functional tests for SVG anchor elements
Browse files Browse the repository at this point in the history
  • Loading branch information
daun committed Jan 26, 2024
1 parent b187a37 commit d913300
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/fixtures/link-types.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Link types</title>
<link rel="stylesheet" href="/assets/style.css" />
</head>
<body>
<main id="swup" class="transition-main">
<h1>Link types</h1>

<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p>
<ul>
<li><a href="/page-1.html">Page 1</a></li>
</ul>

<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<a xlink:href="/page-2.html">
<text x="10" y="10" font-size="2">SVG link to page</text>
</a>
</svg>

<img src="data:image/gif;base64,R0lGODlhAQABAAAAACw=" usemap="#imagemap" width="100" height="100" />
<map name="imagemap">
<area shape="rect" coords="0,0,100,100" href="/page-3.html" alt="Map link to page" />
</map>
</main>
<script src="/dist/swup.umd.js"></script>
<script src="/dist/index.umd.js"></script>
<script>
window._swup = new Swup({
linkSelector: 'a[href], a[*|href]',
plugins: [new SwupPreloadPlugin()]
});
</script>
</body>
</html>
8 changes: 8 additions & 0 deletions tests/functional/preload-plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ test.describe('active links', () => {
await expectSwupToHaveCacheEntry(page, '/page-2.html');
await expectSwupToHaveCacheEntry(page, '/page-3.html');
});

test('preloads svg links', async ({ page }) => {
await page.goto('/link-types.html');
await waitForSwup(page);
await expectSwupNotToHaveCacheEntry(page, '/page-2.html');
await page.focus('svg a', { strict: true });
await expectSwupToHaveCacheEntry(page, '/page-2.html');
});
});

test.describe('visible links', () => {
Expand Down

0 comments on commit d913300

Please sign in to comment.