-
Notifications
You must be signed in to change notification settings - Fork 923
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
802 additions
and
166 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# AutoLink | ||
|
||
<div id="route-link"> | ||
<AutoLink v-for="item in routeLinksConfig" v-bind="item" /> | ||
</div> | ||
|
||
<div id="external-link"> | ||
<AutoLink v-for="item in externalLinksConfig" v-bind="item" /> | ||
</div> | ||
|
||
<div id="config"> | ||
<AutoLink v-bind="{ text: 'text1', link: '/', ariaLabel: 'label' }" /> | ||
<AutoLink v-bind="{ text: 'text2', link: 'https://example.com/test/' }" /> | ||
</div> | ||
|
||
<script setup lang="ts"> | ||
import { AutoLink } from 'vuepress/client' | ||
|
||
const routeLinks = [ | ||
'/', | ||
'/README.md', | ||
'/index.html', | ||
'/non-existent', | ||
'/non-existent.md', | ||
'/non-existent.html', | ||
'/routes/non-ascii-paths/中文目录名/中文文件名', | ||
'/routes/non-ascii-paths/中文目录名/中文文件名.md', | ||
'/routes/non-ascii-paths/中文目录名/中文文件名.html', | ||
'/README.md#hash', | ||
'/README.md?query', | ||
'/README.md?query#hash', | ||
'/#hash', | ||
'/?query', | ||
'/?query#hash', | ||
'#hash', | ||
'?query', | ||
'?query#hash', | ||
'route-link', | ||
'route-link.md', | ||
'route-link.html', | ||
'not-existent', | ||
'not-existent.md', | ||
'not-existent.html', | ||
'../', | ||
'../README.md', | ||
'../404.md', | ||
'../404.html', | ||
] | ||
|
||
const routeLinksConfig = routeLinks.map((link) => ({ link, text: 'text' })) | ||
|
||
const externalLinks = [ | ||
'//example.com', | ||
'http://example.com', | ||
'https://example.com', | ||
'mailto:example@example.com', | ||
'tel:+1234567890', | ||
] | ||
|
||
const externalLinksConfig = externalLinks.map((link) => ({ link, text: 'text' })) | ||
</script> |
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,41 @@ | ||
import { expect, test } from '@playwright/test' | ||
import { BASE } from '../../utils/env' | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto('components/auto-link.html') | ||
}) | ||
|
||
test('should render route-link correctly', async ({ page }) => { | ||
for (const el of await page | ||
.locator('.e2e-theme-content #route-link a') | ||
.all()) { | ||
await expect(el).toHaveAttribute('class', /route-link/) | ||
} | ||
}) | ||
|
||
test('should render external-link correctly', async ({ page }) => { | ||
for (const el of await page | ||
.locator('.e2e-theme-content #external-link a') | ||
.all()) { | ||
await expect(el).toHaveAttribute('class', /external-link/) | ||
} | ||
}) | ||
|
||
test('should render config correctly', async ({ page }) => { | ||
const locator = page.locator('.e2e-theme-content #config a') | ||
|
||
await expect(await locator.nth(0)).toHaveText('text1') | ||
await expect(await locator.nth(0)).toHaveAttribute('href', BASE) | ||
await expect(await locator.nth(0)).toHaveAttribute('aria-label', 'label') | ||
|
||
await expect(await locator.nth(1)).toHaveText('text2') | ||
await expect(await locator.nth(1)).toHaveAttribute( | ||
'href', | ||
'https://example.com/test/', | ||
) | ||
await expect(await locator.nth(1)).toHaveAttribute('target', '_blank') | ||
await expect(await locator.nth(1)).toHaveAttribute( | ||
'rel', | ||
'noopener noreferrer', | ||
) | ||
}) |
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.