-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Vinicius Reis <vinicius.reis@nextcloud.com>
- Loading branch information
Vinicius Reis
committed
Jul 8, 2022
1 parent
eb4b7d6
commit fbb3dc6
Showing
3 changed files
with
57 additions
and
0 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,48 @@ | ||
import { randHash } from '../utils/index.js' | ||
|
||
const currentUser = randHash() | ||
|
||
const refresh = () => cy.get('#controls .crumb:not(.hidden) a') | ||
.last() | ||
.click({ force: true }) | ||
|
||
const createMarkdown = (fileName, content) => { | ||
return cy.createFile(fileName, content, 'text/markdown') | ||
.then(refresh) | ||
} | ||
|
||
describe('Table of Contents', () => { | ||
before(() => { | ||
// Init user | ||
cy.nextcloudCreateUser(currentUser, 'password') | ||
cy.login(currentUser, 'password') | ||
}) | ||
|
||
beforeEach(() => { | ||
cy.login(currentUser, 'password') | ||
}) | ||
|
||
it('sidebar toc', () => { | ||
const fileName = 'toc.md' | ||
|
||
createMarkdown(fileName, '# T1 \n ## T2 \n ### T3 \n #### T4 \n ##### T5 \n ###### T6') | ||
.then(refresh) | ||
.then(() => cy.openFile(fileName)) | ||
|
||
cy.getTOC() | ||
.find('ul li') | ||
.should('have.length', 6) | ||
cy.getTOC() | ||
.find('ul li') | ||
.each((el, index) => { | ||
cy.wrap(el) | ||
.should('have.attr', 'data-toc-level') | ||
.and('equal', String(index + 1)) | ||
|
||
cy.wrap(el) | ||
.find('a') | ||
.should('have.attr', 'href') | ||
.and('equal', `#t${index + 1}`) | ||
}) | ||
}) | ||
}) |
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