-
Notifications
You must be signed in to change notification settings - Fork 37
/
sample.cy.ts
47 lines (46 loc) · 1.46 KB
/
sample.cy.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
describe('Basic Tests', () => {
beforeEach(() => {
cy.visit('http://127.0.0.1:8000/'); //change link when testing locally
});
it('search field working', () => {
cy.get('.md-search__input').type('config').should('have.value', 'config');
});
it('toggle light/dark mode', () => {
cy.get('[data-md-color-scheme="default"]');
cy.get('.md-header__option').click();
cy.get('[data-md-color-scheme="slate"]');
});
it('previous and next button works', () => {
let nextUrl: any, prevUrl: any;
cy.get('.md-footer__link--next')
.should('have.attr', 'href')
.then((href) => {
nextUrl = href;
});
cy.get('.md-footer__link--next').click();
cy.location().should((loc) => {
expect(loc.href.includes(nextUrl)).to.eq(true);
});
cy.get('.md-footer__link--prev')
.should('have.attr', 'href')
.then((href) => {
prevUrl = href;
console.log(prevUrl);
});
cy.get('.md-footer__link--prev').click();
cy.location().should((loc) => {
if (prevUrl === '..') prevUrl = '/';
expect(loc.href.includes(prevUrl)).to.eq(true);
});
});
it('sidebar button works', () => {
cy.get('[class="md-header__button md-icon"]').each((headerItem, index) => {
if (index === 0) {
cy.wrap(headerItem).click();
cy.get('.md-nav__list').should('be.visible');
cy.get('.md-overlay').click();
cy.get('.md-nav__list').should('be.hidden');
}
});
});
});