Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-05-08 06:10:29 +00:00
parent 3be5f2409a
commit 835d006431
5 changed files with 39 additions and 7 deletions

View file

@ -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>

View file

@ -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 }) => {

View file

@ -0,0 +1,5 @@
---
title: Bust the cache for /whats-new
merge_request: 61081
author:
type: fixed

View file

@ -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', () => {

View file

@ -44,16 +44,33 @@ describe('whats new actions', () => {
axiosMock.restore();
});
it('passes arguments', () => {
it("doesn't require arguments", () => {
axiosMock.reset();
axiosMock
.onGet('/-/whats_new', { params: { page: 8 } })
.onGet('/-/whats_new', { params: { page: undefined, v: undefined } })
.replyOnce(200, [{ title: 'GitLab Stories' }]);
testAction(
actions.fetchItems,
{ page: 8 },
{},
{},
expect.arrayContaining([
{ type: types.ADD_FEATURES, payload: [{ title: 'GitLab Stories' }] },
]),
);
});
it('passes arguments', () => {
axiosMock.reset();
axiosMock
.onGet('/-/whats_new', { params: { page: 8, v: 42 } })
.replyOnce(200, [{ title: 'GitLab Stories' }]);
testAction(
actions.fetchItems,
{ page: 8, versionDigest: 42 },
{},
expect.arrayContaining([
{ type: types.ADD_FEATURES, payload: [{ title: 'GitLab Stories' }] },