Files
.github
.storybook
__mocks__
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
view_groups_spec.js
plugins
snapshots
support
utils
Readme.md
run.mjs
dev-test
functions
img
packages
scripts
website
.all-contributorsrc
.editorconfig
.eslintrc.js
.gitattributes
.gitignore
.nvmrc
.prettierignore
.prettierrc
.stylelintrc
.vale.ini
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
README.md
babel.config.js
cms.png
commitlint.config.js
cypress.json
jest.config.js
lerna.json
netlify.toml
package.json
renovate.json
setupTestFramework.js
tsconfig.json
yarn.lock
static-cms/cypress/integration/view_groups_spec.js
2021-01-04 13:30:18 +02:00

73 lines
1.7 KiB
JavaScript

import { login } from '../utils/steps';
const group = term => {
cy.contains('span', 'Group by').click();
cy.contains(term).click();
cy.contains('Contents').click();
};
const assertGroupsCount = count => {
cy.get('[class*=GroupContainer]').should('have.length', count);
};
const assertEachGroupCount = (id, count) => {
cy.get(`[id='${id}']`).within(() => {
assertEntriesCount(count);
});
};
const assertEntriesCount = count => {
cy.get('[class*=ListCardLink]').should('have.length', count);
};
const assertInEntries = text => {
cy.get('[class*=ListCardLink]').within(() => {
cy.contains('h2', text);
});
};
describe('View Group', () => {
before(() => {
Cypress.config('defaultCommandTimeout', 4000);
cy.task('setupBackend', { backend: 'test' });
});
after(() => {
cy.task('teardownBackend', { backend: 'test' });
});
beforeEach(() => {
login();
});
it('can apply string group', () => {
// enable group
group('Year');
assertGroupsCount(2);
const year = new Date().getFullYear();
assertEachGroupCount(`Year${year}`, 20);
assertEachGroupCount('Year2015', 3);
//disable group
group('Year');
assertEntriesCount(23);
for (let i = 1; i <= 20; i++) {
assertInEntries(`This is post # ${i} --`);
}
assertInEntries('This is a YAML front matter post');
assertInEntries('This is a JSON front matter post');
assertInEntries('This is a TOML front matter post');
//enable group
group('Drafts');
assertEntriesCount(23);
assertGroupsCount(3);
assertEachGroupCount('Draftstrue', 10);
assertEachGroupCount('Draftsfalse', 10);
assertEachGroupCount('missing_value', 3);
});
});