Commit ec7b1214 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'jswain_whats_new_stale_content' into 'master'

Bust the cache for /whats-new

See merge request gitlab-org/gitlab!61081
parents f3761e02 db1766f5
......@@ -30,7 +30,7 @@ export default {
},
mounted() {
this.openDrawer(this.versionDigest);
this.fetchItems();
this.fetchFreshItems();
const body = document.querySelector('body');
const namespaceId = body.getAttribute('data-namespace-id');
......@@ -42,13 +42,18 @@ export default {
bottomReached() {
const page = this.pageInfo.nextPage;
if (page) {
this.fetchItems({ page });
this.fetchFreshItems(page);
}
},
handleResize() {
const height = getDrawerBodyHeight(this.$refs.drawer.$el);
this.setDrawerBodyHeight(height);
},
fetchFreshItems(page) {
const { versionDigest } = this;
this.fetchItems({ page, versionDigest });
},
},
};
</script>
......
......@@ -14,17 +14,19 @@ export default {
localStorage.setItem(STORAGE_KEY, versionDigest);
}
},
fetchItems({ commit, state }, { page } = { page: null }) {
fetchItems({ commit, state }, { page, versionDigest } = { page: null, versionDigest: null }) {
if (state.fetching) {
return false;
}
commit(types.SET_FETCHING, true);
const v = versionDigest;
return axios
.get('/-/whats_new', {
params: {
page,
v,
},
})
.then(({ data, headers }) => {
......
---
title: Bust the cache for /whats-new
merge_request: 61081
author:
type: fixed
......@@ -149,7 +149,10 @@ describe('App', () => {
wrapper.vm.$store.state.pageInfo = { nextPage: 840 };
emitBottomReached();
expect(actions.fetchItems).toHaveBeenCalledWith(expect.anything(), { page: 840 });
expect(actions.fetchItems).toHaveBeenCalledWith(expect.anything(), {
page: 840,
versionDigest: 'version-digest',
});
});
it('when nextPage does not exist it does not call fetchItems', () => {
......
......@@ -44,16 +44,33 @@ describe('whats new actions', () => {
axiosMock.restore();
});
it("doesn't require arguments", () => {
axiosMock.reset();
axiosMock
.onGet('/-/whats_new', { params: { page: undefined, v: undefined } })
.replyOnce(200, [{ title: 'GitLab Stories' }]);
testAction(
actions.fetchItems,
{},
{},
expect.arrayContaining([
{ type: types.ADD_FEATURES, payload: [{ title: 'GitLab Stories' }] },
]),
);
});
it('passes arguments', () => {
axiosMock.reset();
axiosMock
.onGet('/-/whats_new', { params: { page: 8 } })
.onGet('/-/whats_new', { params: { page: 8, v: 42 } })
.replyOnce(200, [{ title: 'GitLab Stories' }]);
testAction(
actions.fetchItems,
{ page: 8 },
{ page: 8, versionDigest: 42 },
{},
expect.arrayContaining([
{ type: types.ADD_FEATURES, payload: [{ title: 'GitLab Stories' }] },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment