Skip to content
代码片段 群组 项目
提交 5e8440d6 编辑于 作者: Paul Gascou-Vaillancourt's avatar Paul Gascou-Vaillancourt
浏览文件

Ensure todo counts are re-fetched upon mark all as done

Fixes the todo counts query name in the `updateCounts` to ensure counts
are properly re-fetched when marking all todos as done.
上级 412fbaa1
No related branches found
No related tags found
无相关合并请求
...@@ -145,7 +145,7 @@ export default { ...@@ -145,7 +145,7 @@ export default {
this.queryFilterValues = { ...data }; this.queryFilterValues = { ...data };
}, },
updateCounts() { updateCounts() {
this.$apollo.queries.todosCount.refetch(); this.$apollo.queries.pendingTodosCount.refetch();
}, },
}, },
}; };
......
...@@ -7,6 +7,7 @@ import waitForPromises from 'helpers/wait_for_promises'; ...@@ -7,6 +7,7 @@ import waitForPromises from 'helpers/wait_for_promises';
import TodosApp from '~/todos/components/todos_app.vue'; import TodosApp from '~/todos/components/todos_app.vue';
import TodoItem from '~/todos/components/todo_item.vue'; import TodoItem from '~/todos/components/todo_item.vue';
import TodosFilterBar from '~/todos/components/todos_filter_bar.vue'; import TodosFilterBar from '~/todos/components/todos_filter_bar.vue';
import TodosMarkAllDoneButton from '~/todos/components/todos_mark_all_done_button.vue';
import getTodosQuery from '~/todos/components/queries/get_todos.query.graphql'; import getTodosQuery from '~/todos/components/queries/get_todos.query.graphql';
import { INSTRUMENT_TAB_LABELS, STATUS_BY_TAB } from '~/todos/constants'; import { INSTRUMENT_TAB_LABELS, STATUS_BY_TAB } from '~/todos/constants';
import { mockTracking, unmockTracking } from 'jest/__helpers__/tracking_helper'; import { mockTracking, unmockTracking } from 'jest/__helpers__/tracking_helper';
...@@ -37,6 +38,7 @@ describe('TodosApp', () => { ...@@ -37,6 +38,7 @@ describe('TodosApp', () => {
const findTodoItems = () => wrapper.findAllComponents(TodoItem); const findTodoItems = () => wrapper.findAllComponents(TodoItem);
const findGlTabs = () => wrapper.findComponent(GlTabs); const findGlTabs = () => wrapper.findComponent(GlTabs);
const findFilterBar = () => wrapper.findComponent(TodosFilterBar); const findFilterBar = () => wrapper.findComponent(TodosFilterBar);
const findMarkAllDoneButton = () => wrapper.findComponent(TodosMarkAllDoneButton);
const findPendingTodosCount = () => wrapper.findByTestId('pending-todos-count'); const findPendingTodosCount = () => wrapper.findByTestId('pending-todos-count');
it('should have a tracking event for each tab', () => { it('should have a tracking event for each tab', () => {
...@@ -83,6 +85,17 @@ describe('TodosApp', () => { ...@@ -83,6 +85,17 @@ describe('TodosApp', () => {
expect(todosCountsQuerySuccessHandler).toHaveBeenLastCalledWith(filters); expect(todosCountsQuerySuccessHandler).toHaveBeenLastCalledWith(filters);
}); });
it('re-fetches the pending todos count when mark all done button is clicked', async () => {
createComponent();
await waitForPromises();
expect(todosCountsQuerySuccessHandler).toHaveBeenCalledTimes(1);
findMarkAllDoneButton().vm.$emit('change');
expect(todosCountsQuerySuccessHandler).toHaveBeenCalledTimes(2);
});
it('shows the pending todos count once it has been fetched', async () => { it('shows the pending todos count once it has been fetched', async () => {
createComponent(); createComponent();
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册