-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restricting fetchModuleList calls to Atomic sites only #91170
Changes from 1 commit
10eefe7
57a7ce9
69c9c80
2e34bb3
ef93cca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ jest.mock( 'calypso/state/jetpack/modules/actions', () => ( { | |
} ) ); | ||
|
||
let isWpcomAtomic = false; | ||
let isJetpack = false; | ||
const siteId = 1; | ||
const mockStore = configureStore( middlewares ); | ||
|
||
|
@@ -36,6 +37,7 @@ function getStore() { | |
options: { | ||
is_wpcom_atomic: isWpcomAtomic, | ||
}, | ||
jetpack: isJetpack, | ||
}, | ||
}, | ||
}, | ||
|
@@ -49,6 +51,9 @@ function getStore() { | |
|
||
describe( 'fetchModuleList', () => { | ||
test( "Ensure we're NOT calling fetchModuleList for simple sites", async () => { | ||
isWpcomAtomic = false; | ||
isJetpack = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we always declare these in the beginning of the test, we might as well remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if I understood your suggestion since we're using these variables inside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, that makes sense. Let's leave them as they are then 👍 |
||
|
||
render( | ||
<Provider store={ getStore() }> | ||
<QueryJetpackModules siteId={ siteId } /> | ||
|
@@ -58,8 +63,9 @@ describe( 'fetchModuleList', () => { | |
expect( mockFetchModuleList ).not.toHaveBeenCalled(); | ||
} ); | ||
|
||
test( "Ensure we're calling fetchModuleList only for atomic sites", async () => { | ||
test( "Ensure we're calling fetchModuleList for Atomic sites", async () => { | ||
isWpcomAtomic = true; | ||
isJetpack = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't seem like a valid scenario. AFAIK there can't be a working Atomic site that isn't a Jetpack site under the hood. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense, updated it here @tyxla. |
||
|
||
render( | ||
<Provider store={ getStore() }> | ||
|
@@ -69,4 +75,17 @@ describe( 'fetchModuleList', () => { | |
|
||
expect( mockFetchModuleList ).toHaveBeenCalled(); | ||
} ); | ||
|
||
test( "Ensure we're calling fetchModuleList for Jetpack Non Atomic sites", async () => { | ||
isWpcomAtomic = false; | ||
isJetpack = true; | ||
|
||
render( | ||
<Provider store={ getStore() }> | ||
<QueryJetpackModules siteId={ siteId } /> | ||
</Provider> | ||
); | ||
|
||
expect( mockFetchModuleList ).toHaveBeenCalledTimes( 2 ); | ||
} ); | ||
} ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about non-atomic Jetpack sites? From what I recall, Jetpack sites (which aren't necessarily Atomic sites) also used the module data - extensively in site settings (but not only there).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch @tyxla! Adding support to Jetpack non-Atomic sites here: 2e34bb3