* feat(v4): add new UI (#2555) * feat: add new footer ui * feat: add new search box ui * feat: add searchbox actions * feat: add start screen * feat: add no results screen * feat: add new card ui * feat: add new icons * feat: add new key press class * fix: cypress tests * fix: circleci * fix: circleci * fix: close aria label * fix: circleci * fix: remove unused classes * fix: circleci * feat: update version * feat: add new dark mode ui * fix: colors * fix: design review * fix: hit title length * fix: improve accessibility * fix: ci * chore: increase bundle size threshold * fix: css * feat(v4): ask-ai foundations ✨ (#2574) * feat(v4): docsearch askAI context (#2587) * fix(v4): ask ai updates (#2654) * feat(v4): update beta documentation (#2659) * chore: release v4.0.0-beta.0 (#2660) * fix: make release run on branches like v4 * chore: release v4.0.0-beta.0 * hotfix: closing on askai error * chore: release v4.0.0-beta.1 (#2661) * fix: add a section on models * fix: update to `<package>@beta` * feat(docsearch-website): Updated docs (#2662) * feat(v4): update the landing page (#2665) * fix: beta in readme * feat: added glow around the search bar and a little copy above the keyboard * feat: add glow around the search bar and copy above the keyboard * fix: Add more styling * fix: polishing v4 (#2667) * chore: release v4.0.0-beta.2 (#2668) * fix: update docusaurus tarballs * fix(website): update docusaurus tarballs * fix: mobile search bar --------- Co-authored-by: Vasco Bettencourt <32492444+vascobettencourt@users.noreply.github.com> Co-authored-by: Natan Yagudayev <natanyagudayev@gmail.com>
153 lines
4.4 KiB
TypeScript
153 lines
4.4 KiB
TypeScript
/// <reference path="../support/commands.d.ts" />
|
|
|
|
describe('Start', () => {
|
|
beforeEach(() => {
|
|
cy.visit(Cypress.config().baseUrl!);
|
|
cy.waitLoad();
|
|
});
|
|
|
|
it('Open modal on search button click', () => {
|
|
cy.openModal();
|
|
cy.modalIsVisibleAndFocused();
|
|
|
|
// check that the scrollbar offset is compensated
|
|
cy.get('body').should('have.css', 'overflow', 'hidden');
|
|
cy.get('.DocSearch-Modal').should('be.visible');
|
|
});
|
|
|
|
it('Open modal with key shortcut on Windows/Linux', () => {
|
|
cy.get('body').type('{ctrl}k');
|
|
cy.modalIsVisibleAndFocused();
|
|
});
|
|
|
|
it('Open modal with key shortcut on Windows/Linux when caps lock is on', () => {
|
|
cy.get('body').type('{ctrl}K');
|
|
cy.modalIsVisibleAndFocused();
|
|
});
|
|
|
|
it('Open modal with key shortcut on macOS', () => {
|
|
cy.get('body').type('{meta}k');
|
|
cy.modalIsVisibleAndFocused();
|
|
});
|
|
|
|
it('Open modal with key shortcut on macOS when caps lock is on', () => {
|
|
cy.get('body').type('{meta}K');
|
|
cy.modalIsVisibleAndFocused();
|
|
});
|
|
|
|
it('Open modal with forward slash key shortcut', () => {
|
|
cy.get('body').wait(1000).type('/');
|
|
cy.modalIsVisibleAndFocused();
|
|
});
|
|
});
|
|
|
|
describe('End', () => {
|
|
beforeEach(() => {
|
|
cy.visit(Cypress.config().baseUrl!);
|
|
cy.openModal();
|
|
});
|
|
|
|
it('Close modal with Esc key', () => {
|
|
cy.closeModal();
|
|
cy.modalIsNotVisible();
|
|
});
|
|
|
|
it('Close modal by clicking outside its container', () => {
|
|
cy.get('body').click(0, 0);
|
|
cy.modalIsNotVisible();
|
|
});
|
|
|
|
it('Close modal with key shortcut on Windows/Linux', () => {
|
|
cy.get('body').type('{ctrl}k');
|
|
cy.modalIsNotVisible();
|
|
});
|
|
|
|
it('Close modal with key shortcut on macOS', () => {
|
|
cy.get('body').type('{meta}k');
|
|
cy.modalIsNotVisible();
|
|
});
|
|
});
|
|
|
|
describe('Search', () => {
|
|
beforeEach(() => {
|
|
cy.visit(Cypress.config().baseUrl!);
|
|
cy.openModal();
|
|
});
|
|
|
|
it('Results are displayed after a query', () => {
|
|
cy.typeQueryMatching();
|
|
cy.get('.DocSearch-Hits').should('be.visible');
|
|
});
|
|
|
|
it('Query can be cleared', () => {
|
|
cy.typeQueryMatching();
|
|
cy.get('.DocSearch-Clear').click();
|
|
cy.get('.DocSearch-Hits').should('not.exist');
|
|
});
|
|
|
|
it('Keyboard navigation leads to result', () => {
|
|
const currentURL = cy.url();
|
|
|
|
cy.typeQueryMatching();
|
|
cy.get('.DocSearch-Input').type('{downArrow}{downArrow}{upArrow}');
|
|
cy.get('.DocSearch-Input').type('{enter}');
|
|
cy.on('url:changed', (newUrl) => {
|
|
expect(newUrl).not.equal(currentURL);
|
|
});
|
|
});
|
|
|
|
it('Pointer navigation leads to result', () => {
|
|
const currentURL = cy.url();
|
|
|
|
cy.typeQueryMatching();
|
|
cy.get('.DocSearch-Hits #docsearch-hits0-item-1 > a').click({
|
|
force: true,
|
|
});
|
|
cy.on('url:changed', (newUrl) => {
|
|
expect(newUrl).not.equal(currentURL);
|
|
});
|
|
});
|
|
|
|
it("No results are displayed if query doesn't match", () => {
|
|
cy.typeQueryNotMatching();
|
|
cy.contains('No results found for').should('be.visible');
|
|
});
|
|
|
|
it('Should not refer to Recent/Favorite in aria-controls', () => {
|
|
cy.get('.DocSearch-Input').should('not.have.attr', 'aria-controls');
|
|
});
|
|
});
|
|
|
|
describe('Recent and Favorites', () => {
|
|
beforeEach(() => {
|
|
cy.visit(Cypress.config().baseUrl!);
|
|
cy.openModal();
|
|
cy.typeQueryMatching();
|
|
cy.get('#docsearch-hits0-item-1 > a').click({ force: true }).wait(1000);
|
|
cy.openModal();
|
|
cy.contains('Recent').should('be.visible');
|
|
});
|
|
|
|
it('Recent search is displayed after visiting a result', () => {
|
|
cy.clearSearch();
|
|
cy.get('#docsearch-recentSearches-item-0').should('be.visible');
|
|
});
|
|
|
|
it('Recent search can be deleted', () => {
|
|
cy.get('#docsearch-recentSearches-item-0').find('[title="Remove this search from history"]').trigger('click');
|
|
cy.get('.DocSearch-Hits').should('not.exist');
|
|
});
|
|
|
|
it('Recent search can be favorited', () => {
|
|
cy.get('#docsearch-recentSearches-item-0').find('[title="Save this search"]').trigger('click');
|
|
cy.contains('Favorite').should('be.visible');
|
|
cy.get('#docsearch-favoriteSearches-item-0').should('be.visible');
|
|
});
|
|
|
|
it('Favorite can be deleted', () => {
|
|
cy.get('#docsearch-recentSearches-item-0').find('[title="Save this search"]').trigger('click');
|
|
cy.contains('Favorite').should('be.visible');
|
|
cy.get('#docsearch-favoriteSearches-item-0').find('[title="Remove this search from favorites"]').trigger('click');
|
|
cy.get('.DocSearch-Hits').should('not.exist');
|
|
});
|
|
});
|