* Some div soup to semantic markup. * Small refactor to inline mapping of available tags. * Renamed <ItemListTags /> component to <TagList />. * Now a select is used for picking a tag to filter on. * Added custom Cypress command to create an article. * Added documentation for the create article custom command. * Removed unnecesary properties from payload to create an article. * reading list mobile view wip. * Reworked styles in <TagList />. * Reworked reading list to use <MediaQuery /> component. * Removed bottom padding from reading list header. * styling tweaks if there are no available tags. * Added some E2E tests. * Removed reading list component test in favour of e2e test. * Made breakpoint values numbers. * Added some padding and more grid gap to filter on small screens. * Adjusted jest coverage thresholds as we're moving some tests to e2e tests. * Reverting a VS Code setting change caused by one of my extensions. * First pass for E2E tests for the reading list. * Added some more grid gap. * Fixed load next page to send tags properly. * Added some more tests. * Improved label and placeholder for text filter in reading list. * Added more tests * Fixed media queries so it works in Chrome as well. * Removed aside as tag filters are not complimentary information. * Update app/javascript/readingList/components/TagList.jsx Co-authored-by: Suzanne Aitchison <suzanne@forem.com> * Update docs/tests/e2e-tests.md Co-authored-by: Suzanne Aitchison <suzanne@forem.com> * Turned off deprecated rule in jsx-a11y eslint plugin. * Reverted to links instead of radio buttons. * Added an all tags link and select option. * Fixed relayout issue. * Fixed View Archive button size. * Fixed styling of the load more button. * Fixed empty list issue toggling between archive and reading list. * Fixed request changes from PR review. * Removed CSS change that is no longer required. * Trigger Build * Fixed centering of items in top fieldset. * Fixed issue with search text field resetting reading list. * Fixed component tests for the reading list. * Fixed empty state popping up between search queries. * Fixed casing of fixture filenames. * Update app/javascript/readingList/readingList.jsx Co-authored-by: Suzanne Aitchison <suzanne@forem.com> * Reverted change in reading list component test. * Added missing JSDoc comment. * Now links are in an unordered list. * Promoted some CSS classes from the <nav /> to the <ul /> for spacing. Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
166 lines
5.6 KiB
JavaScript
166 lines
5.6 KiB
JavaScript
import { BREAKPOINTS } from '../../../app/javascript/shared/components/useMediaQuery';
|
|
|
|
describe('Reading List Archive', () => {
|
|
beforeEach(() => {
|
|
cy.testSetup();
|
|
cy.fixture('users/articleEditorV1User.json').as('user');
|
|
cy.get('@user').then((user) => {
|
|
cy.loginUser(user);
|
|
});
|
|
});
|
|
|
|
it('should load an empty reading list', () => {
|
|
cy.intercept(
|
|
Cypress.config().baseUrl +
|
|
'search/reactions?page=0&per_page=80&status%5B%5D=valid&status%5B%5D=confirmed',
|
|
{ fixture: 'search/emptyReadingList.json' },
|
|
).as('emptyReadingList');
|
|
|
|
cy.visit('/readinglist');
|
|
cy.wait('@emptyReadingList');
|
|
|
|
cy.findByRole('main')
|
|
.as('main')
|
|
.findByText(/^Your reading list is empty$/i);
|
|
cy.get('@main').findByText(/^View archive$/i);
|
|
cy.get('@main').findByLabelText(/^Filter reading list by text$/i);
|
|
cy.get('@main').findByText(/^Reading list \(0\)$/i);
|
|
cy.get('@main')
|
|
.findByRole('navigation', { name: /^Filter by tag$/i })
|
|
.findByText(/all tags/i);
|
|
});
|
|
|
|
it('should filter by text', () => {
|
|
cy.intercept(
|
|
Cypress.config().baseUrl +
|
|
'search/reactions?page=0&per_page=80&status%5B%5D=valid&status%5B%5D=confirmed',
|
|
{ fixture: 'search/readingList.json' },
|
|
).as('readingList');
|
|
|
|
cy.intercept(
|
|
Cypress.config().baseUrl +
|
|
'search/reactions?search_fields=article+3&page=0&per_page=80&status%5B%5D=valid&status%5B%5D=confirmed',
|
|
{ fixture: 'search/readingListFilterByText.json' },
|
|
).as('readingListFilteredByText');
|
|
|
|
cy.visit('/readinglist');
|
|
cy.wait('@readingList');
|
|
|
|
cy.findByRole('main').as('main');
|
|
cy.get('@main')
|
|
.findByLabelText(/^Filter reading list by text$/i)
|
|
.type('article 3');
|
|
|
|
cy.wait('@readingListFilteredByText');
|
|
|
|
cy.get('@main').findByText('Test Article 1').should('not.exist');
|
|
cy.get('@main').findByText('Test Article 2').should('not.exist');
|
|
cy.get('@main').findByText('Test Article 3');
|
|
});
|
|
|
|
describe('small screens', () => {
|
|
beforeEach(() => {
|
|
cy.intercept(
|
|
Cypress.config().baseUrl +
|
|
'search/reactions?page=0&per_page=80&status%5B%5D=valid&status%5B%5D=confirmed',
|
|
{ fixture: 'search/readingList.json' },
|
|
).as('readingList');
|
|
|
|
cy.viewport(BREAKPOINTS.Medium - 1, BREAKPOINTS.Medium);
|
|
cy.visit('/readinglist');
|
|
cy.wait('@readingList');
|
|
});
|
|
|
|
it('should load the reading list with items', () => {
|
|
cy.findByRole('main')
|
|
.as('main')
|
|
.findByText(/^Your reading list is empty$/i)
|
|
.should('not.exist');
|
|
cy.get('@main').findByText(/^View archive$/i);
|
|
cy.get('@main').findByLabelText(/Filter reading list by text$/i);
|
|
cy.get('@main').findByText(/^Reading list \(3\)$/);
|
|
cy.get('@main').findByLabelText(/^Filter by tag$/i, {
|
|
selector: 'select',
|
|
});
|
|
cy.get('@main')
|
|
.findByText(/^Filter by tag$/i, { selector: 'legend' })
|
|
.should('not.exist');
|
|
|
|
cy.get('@main').findByText('Test Article 1');
|
|
cy.get('@main').findByText('Test Article 2');
|
|
cy.get('@main').findByText('Test Article 3');
|
|
});
|
|
|
|
it('should filter by tag', () => {
|
|
cy.intercept(
|
|
Cypress.config().baseUrl +
|
|
'search/reactions?search_fields=&page=0&per_page=80&tag_names%5B%5D=productivity&tag_boolean_mode=all&status%5B%5D=valid&status%5B%5D=confirmed',
|
|
{ fixture: 'search/readingListFilterByTagProductivity.json' },
|
|
).as('filteredReadingList');
|
|
|
|
cy.findByRole('main')
|
|
.as('main')
|
|
.findByLabelText('Filter by tag')
|
|
.as('tagFilter')
|
|
.select('productivity');
|
|
|
|
cy.wait('@filteredReadingList');
|
|
|
|
cy.get('@main').findByText('Test Article 1');
|
|
cy.get('@main').findByText('Test Article 2').should('not.exist');
|
|
cy.get('@main').findByText('Test Article 3');
|
|
});
|
|
});
|
|
|
|
describe('large screens', () => {
|
|
beforeEach(() => {
|
|
cy.intercept(
|
|
Cypress.config().baseUrl +
|
|
'search/reactions?page=0&per_page=80&status%5B%5D=valid&status%5B%5D=confirmed',
|
|
{ fixture: 'search/readingList.json' },
|
|
).as('readingList');
|
|
|
|
cy.viewport(BREAKPOINTS.Large, 600);
|
|
cy.visit('/readinglist');
|
|
cy.wait('@readingList');
|
|
});
|
|
|
|
it('should load the reading list with items', () => {
|
|
cy.findByRole('main')
|
|
.as('main')
|
|
.findByText(/^Your reading list is empty$/i)
|
|
.should('not.exist');
|
|
cy.get('@main').findByText(/^View archive$/i);
|
|
cy.get('@main').findByLabelText(/Filter reading list by text$/i);
|
|
cy.get('@main').findByText(/^Reading list \(3\)$/);
|
|
cy.get('@main').findByRole('navigation', { name: /^Filter by tag$/i });
|
|
cy.get('@main')
|
|
.findByRole('select', { name: /^Filter by tag$/i })
|
|
.should('not.exist');
|
|
|
|
cy.get('@main').findByText('Test Article 1');
|
|
cy.get('@main').findByText('Test Article 2');
|
|
cy.get('@main').findByText('Test Article 3');
|
|
});
|
|
|
|
it('should filter by tag', () => {
|
|
cy.intercept(
|
|
Cypress.config().baseUrl +
|
|
'search/reactions?search_fields=&page=0&per_page=80&tag_names%5B%5D=productivity&tag_boolean_mode=all&status%5B%5D=valid&status%5B%5D=confirmed',
|
|
{ fixture: 'search/readingListFilterByTagProductivity.json' },
|
|
).as('filteredReadingList');
|
|
|
|
cy.findByRole('main')
|
|
.as('main')
|
|
.findByRole('navigation', { name: /^Filter by tag$/i })
|
|
.findByText('#productivity')
|
|
.click();
|
|
|
|
cy.wait('@filteredReadingList');
|
|
|
|
cy.get('@main').findByText('Test Article 1');
|
|
cy.get('@main').findByText('Test Article 2').should('not.exist');
|
|
cy.get('@main').findByText('Test Article 3');
|
|
});
|
|
});
|
|
});
|