1
0
Fork 0
docsearch/cypress/support/commands.ts
Pierre Millot 93578a4de0
fix: upgrade algoliasearch to v5 (#2326)
We can use the new generated client to stay up to date and upgrade packages that depends on docsearch.

---------

Co-authored-by: shortcuts <vannicattec@gmail.com>
2024-10-30 15:46:38 +01:00

41 lines
1.1 KiB
TypeScript

Cypress.Commands.add('modalIsVisibleAndFocused', () => {
cy.get('.DocSearch-Modal', { timeout: 10000 }).should('be.visible');
cy.get('.DocSearch-Input').should('be.focus');
});
Cypress.Commands.add('modalIsNotVisible', () => {
cy.get('body').should('not.have.class', 'DocSearch--active');
cy.get('.DocSearch-Modal').should('not.exist');
});
Cypress.Commands.add('darkmode', () => {
cy.get('.react-toggle').click({ force: true });
cy.get('.react-toggle-screenreader-only').blur();
cy.get('html.dark').should('be.visible');
});
Cypress.Commands.add('waitLoad', () => {
cy.get('.DocSearch-Button', { timeout: 10000 }).should('be.visible');
});
Cypress.Commands.add('openModal', () => {
cy.get('.DocSearch-Button').should('be.visible').click();
cy.modalIsVisibleAndFocused();
});
Cypress.Commands.add('closeModal', () => {
cy.get('body').type('{esc}');
cy.modalIsNotVisible();
});
Cypress.Commands.add('search', (query: string) => {
cy.get('.DocSearch-Input').should('be.visible').type(query);
});
Cypress.Commands.add('typeQueryMatching', () => {
cy.search('g');
});
Cypress.Commands.add('typeQueryNotMatching', () => {
cy.search('zzz');
});