* create new pack, handle user follow buttons, use pack on article page, remove initializeUserFollowButts * init all follow button types, add pack to tag index and podcast episode pages * add pack to all relevant pages, listen for newly inserted follow buttons * change to searchParams to remove follow button initializer calls * fix bug with tag page, add pack to notifications page * fix issue with follow back inner text * update cypress specs * run the followbuttons code on sponsors page * remove extra foreach * add test for follow from article sidebar * add test for follow and unfollow tag * add test for the tag index page * add spec for organisation profile follow * add tests for follow buttons in search results * add tests for notification follows * commit missed file - woops * show login modal if user is logged out when they click * add cypress tests for logged out state * change tag button initialization * remove data-button-initialized * init follow buttons from base pack * handle the case where multiple follow buttons exist on a page for the same user * account for instantclick and userdata not being defined, lower coverage for jest * use getInstantClick * fix issue with set initialisation * only listen for mutations in areas we know follow buttons may be added dynamically * small refactors
89 lines
3 KiB
JavaScript
89 lines
3 KiB
JavaScript
describe('Show log in modal', () => {
|
|
const verifyLoginModalBehavior = (getTriggerElement) => {
|
|
getTriggerElement().click();
|
|
cy.findByTestId('modal-container').as('modal');
|
|
cy.get('@modal').findByText('Log in to continue').should('exist');
|
|
cy.get('@modal').findByLabelText('Log in').should('exist');
|
|
cy.get('@modal').findByLabelText('Create new account').should('exist');
|
|
cy.get('@modal').findByRole('button').first().should('have.focus');
|
|
|
|
cy.get('@modal').findByRole('button', { name: /Close/ }).click();
|
|
getTriggerElement().should('have.focus');
|
|
cy.findByTestId('modal-container').should('not.exist');
|
|
};
|
|
|
|
beforeEach(() => {
|
|
cy.testSetup();
|
|
cy.visit('/');
|
|
});
|
|
|
|
it('should show a log in modal on Feed bookmark click', () => {
|
|
cy.findAllByRole('button', { name: /Save/ }).first().as('bookmarkButton');
|
|
// Wait for the click handler to be attached to the button
|
|
cy.get('@bookmarkButton').should('have.attr', 'data-save-initialized');
|
|
|
|
verifyLoginModalBehavior(() => cy.get('@bookmarkButton'));
|
|
});
|
|
|
|
it('should show login modal for article reaction clicks', () => {
|
|
cy.findAllByText('Test article').last().click();
|
|
|
|
cy.findByRole('button', { name: 'Like' }).as('heartReaction');
|
|
cy.findByRole('button', { name: 'React with unicorn' }).as(
|
|
'unicornReaction',
|
|
);
|
|
cy.findByRole('button', { name: 'Add to reading list' }).as(
|
|
'bookmarkReaction',
|
|
);
|
|
|
|
['@heartReaction', '@unicornReaction', '@bookmarkReaction'].forEach(
|
|
(reaction) => {
|
|
verifyLoginModalBehavior(() => cy.get(reaction));
|
|
},
|
|
);
|
|
});
|
|
|
|
it('should show login modal for comment subscription', () => {
|
|
cy.findAllByText('Test article').last().click();
|
|
|
|
verifyLoginModalBehavior(() =>
|
|
cy.findByRole('button', { name: /Subscribe/ }),
|
|
);
|
|
});
|
|
|
|
it('should show login modal for article follow button click', () => {
|
|
cy.viewport('macbook-16');
|
|
cy.findAllByRole('link', { name: 'Test article' })
|
|
.first()
|
|
.click({ force: true });
|
|
|
|
cy.get('[data-follow-clicks-initialized]');
|
|
|
|
verifyLoginModalBehavior(() =>
|
|
cy
|
|
.findByRole('complementary', { name: 'Author details' })
|
|
.findByRole('button', { name: 'Follow' }),
|
|
);
|
|
});
|
|
|
|
it('should show login modal for tag follow button click', () => {
|
|
cy.visit('/tags');
|
|
cy.findByRole('heading', { name: 'Top tags' });
|
|
cy.get('[data-follow-clicks-initialized]');
|
|
|
|
verifyLoginModalBehavior(() => cy.findByRole('button', { name: 'Follow' }));
|
|
|
|
cy.visit('/t/tag1');
|
|
cy.findByRole('heading', { name: '# tag1' });
|
|
|
|
verifyLoginModalBehavior(() => cy.findByRole('button', { name: 'Follow' }));
|
|
});
|
|
|
|
it('should show login modal for user profile follow button click', () => {
|
|
cy.visit('/admin_mcadmin');
|
|
cy.get('[data-follow-clicks-initialized]');
|
|
|
|
cy.findByRole('heading', { name: 'Admin McAdmin' });
|
|
verifyLoginModalBehavior(() => cy.findByRole('button', { name: 'Follow' }));
|
|
});
|
|
});
|