.dependabot
.github
.storybook
cypress
fixtures
integration
common
editorial_workflow_migration_spec_github_backend_rest.js
editorial_workflow_spec_bitbucket_backend.js
editorial_workflow_spec_git-gateway_github_backend.js
editorial_workflow_spec_git-gateway_gitlab_backend.js
editorial_workflow_spec_github_backend_graphql.js
editorial_workflow_spec_github_backend_graphql_open_authoring.js
editorial_workflow_spec_github_backend_rest.js
editorial_workflow_spec_github_backend_rest_open_authoring.js
editorial_workflow_spec_gitlab_backend.js
editorial_workflow_spec_proxy_git_backend.js
editorial_workflow_spec_test_backend.js
field_validations_spec.js
i18n_editorial_workflow_spec_test_backend.js
i18n_simple_workflow_spec_proxy_fs_backend.js
markdown_widget_backspace_spec.js
markdown_widget_code_block_spec.js
markdown_widget_enter_spec.js
markdown_widget_hotkeys_spec.js
markdown_widget_link_spec.js
markdown_widget_list_spec.js
markdown_widget_marks_spec.js
markdown_widget_quote_spec.js
media_library_spec_bitbucket_backend.js
media_library_spec_bitbucket_backend_large_media.js
media_library_spec_git-gateway_github_backend_large_media.js
media_library_spec_git-gateway_gitlab_backend_large_media.js
media_library_spec_github_backend_graphql.js
media_library_spec_github_backend_rest.js
media_library_spec_gitlab_backend.js
media_library_spec_proxy_git_backend.js
media_library_spec_test_backend.js
search_suggestion_spec.js
simple_workflow_spec_bitbucket_backend.js
simple_workflow_spec_git-gateway_github_backend.js
simple_workflow_spec_git-gateway_gitlab_backend.js
simple_workflow_spec_github_backend_graphql.js
simple_workflow_spec_github_backend_rest.js
simple_workflow_spec_gitlab_backend.js
simple_workflow_spec_proxy_fs_backend.js
simple_workflow_spec_proxy_git_backend.js
simple_workflow_spec_test_backend.js
view_filters_spec.js
plugins
snapshots
support
utils
Readme.md
dev-test
functions
img
packages
scripts
website
.all-contributorsrc
.editorconfig
.eslintrc.js
.gitignore
.nvmrc
.prettierignore
.prettierrc
.stylelintrc
.vale.ini
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
README.md
babel.config.js
commitlint.config.js
cypress.json
jest.config.js
lerna.json
netlify.toml
package.json
renovate.json
setupTestFramework.js
tsconfig.json
yarn.lock
79 lines
2.1 KiB
JavaScript
79 lines
2.1 KiB
JavaScript
![]() |
import { login } from '../utils/steps';
|
||
|
|
||
|
const search = (term, collection) => {
|
||
|
cy.get('[class*=SearchInput]').clear({ force: true });
|
||
|
cy.get('[class*=SearchInput]').type(term, { force: true });
|
||
|
cy.get('[class*=SuggestionsContainer]').within(() => {
|
||
|
cy.contains(collection).click();
|
||
|
});
|
||
|
};
|
||
|
|
||
|
const assertSearchHeading = title => {
|
||
|
cy.get('[class*=SearchResultHeading]').should('have.text', title);
|
||
|
};
|
||
|
|
||
|
const assertSearchResult = (text, collection) => {
|
||
|
cy.get('[class*=ListCardLink]').within(() => {
|
||
|
if (collection) {
|
||
|
cy.contains('h2', collection);
|
||
|
}
|
||
|
cy.contains('h2', text);
|
||
|
});
|
||
|
};
|
||
|
|
||
|
const assertNotInSearch = text => {
|
||
|
cy.get('[class*=ListCardLink]').within(() => {
|
||
|
cy.contains('h2', text).should('not.exist');
|
||
|
});
|
||
|
};
|
||
|
|
||
|
describe('Search Suggestion', () => {
|
||
|
before(() => {
|
||
|
Cypress.config('defaultCommandTimeout', 4000);
|
||
|
cy.task('setupBackend', { backend: 'test' });
|
||
|
});
|
||
|
|
||
|
after(() => {
|
||
|
cy.task('teardownBackend', { backend: 'test' });
|
||
|
});
|
||
|
|
||
|
beforeEach(() => {
|
||
|
login();
|
||
|
});
|
||
|
|
||
|
it('can search in all collections', () => {
|
||
|
search('this', 'All Collections');
|
||
|
|
||
|
assertSearchHeading('Search Results for "this"');
|
||
|
|
||
|
assertSearchResult('This is post # 20', 'Posts');
|
||
|
assertSearchResult('This is a TOML front matter post', 'Posts');
|
||
|
assertSearchResult('This is a JSON front matter post', 'Posts');
|
||
|
assertSearchResult('This is a YAML front matter post', 'Posts');
|
||
|
assertSearchResult('This FAQ item # 5', 'FAQ');
|
||
|
});
|
||
|
|
||
|
it('can search in posts collection', () => {
|
||
|
search('this', 'Posts');
|
||
|
|
||
|
assertSearchHeading('Search Results for "this" in Posts');
|
||
|
|
||
|
assertSearchResult('This is post # 20');
|
||
|
assertSearchResult('This is a TOML front matter post');
|
||
|
assertSearchResult('This is a JSON front matter post');
|
||
|
assertSearchResult('This is a YAML front matter post');
|
||
|
|
||
|
assertNotInSearch('This FAQ item # 5');
|
||
|
});
|
||
|
|
||
|
it('can search in faq collection', () => {
|
||
|
search('this', 'FAQ');
|
||
|
|
||
|
assertSearchHeading('Search Results for "this" in FAQ');
|
||
|
|
||
|
assertSearchResult('This FAQ item # 5');
|
||
|
|
||
|
assertNotInSearch('This is post # 20');
|
||
|
});
|
||
|
});
|