-
Notifications
You must be signed in to change notification settings - Fork 920
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
8 changed files
with
128 additions
and
14 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,5 @@ | ||
--- | ||
permalink: /permalink-ascii-ascii/ | ||
--- | ||
|
||
/permalink-ascii-ascii/ |
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,5 @@ | ||
--- | ||
permalink: /永久链接-ascii-中文/ | ||
--- | ||
|
||
/永久链接-ascii-中文/ |
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,23 @@ | ||
### ascii-ascii | ||
|
||
- <a :href="$withBase('/permalink-ascii-ascii/')">permalink with base</a> | ||
- [permalink](/permalink-ascii-ascii/) | ||
- [filename](./ascii-ascii.md) | ||
|
||
### ascii-non-ascii | ||
|
||
- <a :href="$withBase('/永久链接-ascii-中文/')">permalink with base</a> | ||
- [permalink](/永久链接-ascii-中文/) | ||
- [filename](./ascii-non-ascii.md) | ||
|
||
### 中文-ascii | ||
|
||
- <a :href="$withBase('/permalink-non-ascii-ascii/')">permalink with base</a> | ||
- [permalink](/permalink-non-ascii-ascii/) | ||
- [filename](./中文-ascii.md) | ||
|
||
### 中文-中文 | ||
|
||
- <a :href="$withBase('/永久链接-中文-中文/')">permalink with base</a> | ||
- [permalink](/永久链接-中文-中文/) | ||
- [filename](./中文-中文.md) |
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,5 @@ | ||
--- | ||
permalink: /permalink-non-ascii-ascii/ | ||
--- | ||
|
||
/permalink-non-ascii-ascii/ |
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,5 @@ | ||
--- | ||
permalink: /永久链接-中文-中文/ | ||
--- | ||
|
||
/永久链接-中文-中文/ |
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,76 @@ | ||
const PERMALINK_PREFIX = Cypress.env('E2E_BASE').replace(/\/$/, '') | ||
|
||
const CONFIGS = [ | ||
{ | ||
id: 'ascii-ascii', | ||
filename: 'ascii-ascii.md', | ||
permalink: '/permalink-ascii-ascii/', | ||
}, | ||
{ | ||
id: 'ascii-non-ascii', | ||
filename: 'ascii-non-ascii.md', | ||
permalink: '/永久链接-ascii-中文/', | ||
}, | ||
{ | ||
id: '中文-ascii', | ||
filename: '中文-ascii.md', | ||
permalink: '/permalink-non-ascii-ascii/', | ||
}, | ||
{ | ||
id: '中文-中文', | ||
filename: '中文-中文.md', | ||
permalink: '/永久链接-中文-中文/', | ||
}, | ||
] | ||
|
||
it('should support visiting permalinks directly', () => { | ||
for (const { permalink } of CONFIGS) { | ||
cy.visit(encodeURI(permalink)) | ||
cy.get('.e2e-theme-content p').should('have.text', permalink) | ||
} | ||
}) | ||
|
||
it('should support rendering link by permalink and navigate to it correctly', () => { | ||
for (const { id, permalink } of CONFIGS) { | ||
cy.visit('/routes/permalinks/') | ||
|
||
// absolute link that does not end with '.md' will not be prepended with `base` | ||
cy.get(`.e2e-theme-content #${id} + ul > li a`) | ||
.should('have.length', 3) | ||
.eq(1) | ||
.should('have.attr', 'href', encodeURI(permalink)) | ||
|
||
// `withBase` won't encode the url | ||
cy.get(`.e2e-theme-content #${id} + ul > li a`) | ||
.should('have.length', 3) | ||
.eq(0) | ||
.should('have.attr', 'href', `${PERMALINK_PREFIX}${permalink}`) | ||
.click() | ||
|
||
cy.location('pathname').should( | ||
'eq', | ||
encodeURI(`${PERMALINK_PREFIX}${permalink}`), | ||
) | ||
|
||
cy.get('.e2e-theme-content p').should('have.text', permalink) | ||
} | ||
}) | ||
|
||
it('should support rendering link by filename and navigate to it correctly', () => { | ||
for (const { id, permalink } of CONFIGS) { | ||
cy.visit('/routes/permalinks/') | ||
|
||
cy.get(`.e2e-theme-content #${id} + ul > li a`) | ||
.should('have.length', 3) | ||
.eq(2) | ||
.should('have.attr', 'href', encodeURI(`${PERMALINK_PREFIX}${permalink}`)) | ||
.click() | ||
|
||
cy.location('pathname').should( | ||
'eq', | ||
encodeURI(`${PERMALINK_PREFIX}${permalink}`), | ||
) | ||
|
||
cy.get('.e2e-theme-content p').should('have.text', permalink) | ||
} | ||
}) |
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