docbrown/cypress/util/networkUtils.js
Michael Kohl 09828853f6
✂✂✂ Remove Connect (#14734)
* Remove Connect

* Remove more Connect specs

* Remove a lot more Connect code

* 🚮

* It all has to go

* Explicitly add httpclient

* Update application layout

* Remove messages association from User

* Start fixing specs

* reintroduce util function and refactor references

* Remove Connect Cypress test

* Fix more specs

* Remove Connect from listings

* Ignore contact_via_connect column on listings

* Remove contact_via_connect usages

* Ignore mod_chat_channel_id on tags

* Drop Connect tables

* Remove email_connect_messages from user notification settings

* Re-add httpclient 2.8.3

This was mistakenly removed as a merge conflict

* Don't need to exclude removed chat channel file

* Remove unneeded style for chat channels

* Remove unneeded channel list prop type

* Remove chat channels index/connect-link from getPageEntries

* Re-add comment from httpclient in Gemfile

* Remove connect references from mailers

Tag Moderators no longer have a chat channel

No longer will users be notified about new messages (there won't be
any)

No longer will users be notified about channel invites (you can't
invite anyone anymore)

* Don't configure Pusher and remove PUSHER_* from .env_sample

since it's removed from gemfile, the Pusher constant will not resolve, if this is
configured in the environment variables we'll fail to boot.

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Dan Uber <dan@forem.com>
2021-11-18 08:21:00 -06:00

34 lines
1.2 KiB
JavaScript

/**
* Helper function to intercept any network requests which may interfere with user state between user log in/out.
* Any intercepts which should be awaited are aliased and returned in an array.
*
* @param {Boolean} userLoggedIn Whether or not the user state is transitioning to logged in - defaults to false
* @returns {Array} Array of aliased Cypress intercepts which may be awaited to ensure they run to completion
*/
export const getInterceptsForLingeringUserRequests = (
url,
userLoggedIn = false,
) => {
// Stub these as response not needed to test app functionality
cy.intercept('/api/analytics/historical**', {});
cy.intercept('/api/analytics/referrers**', {});
// Await these requests as response may affect app behavior
cy.intercept('/async_info/base_data').as('baseDataRequest');
if (!userLoggedIn) {
return ['@baseDataRequest'];
}
const intercepts = ['@baseDataRequest'];
if (!url.includes('/notifications')) {
cy.intercept('/notifications?i=i').as('notificationsRequest');
cy.intercept('/notifications/counts').as('countsRequest');
intercepts.push('@notificationsRequest');
intercepts.push('@countsRequest');
}
return intercepts;
};