Commit 31554cac authored by Phil Hughes's avatar Phil Hughes

Merge branch 'kp-fix-test-cases-tasklist-header-count' into 'master'

Fix task-list header counts in Test Cases

See merge request gitlab-org/gitlab!73453
parents 85044051 0303c8b1
...@@ -50,6 +50,7 @@ export default { ...@@ -50,6 +50,7 @@ export default {
data() { data() {
return { return {
testCase: {}, testCase: {},
taskCompletionStatus: {},
editTestCaseFormVisible: false, editTestCaseFormVisible: false,
testCaseSaveInProgress: false, testCaseSaveInProgress: false,
testCaseStateChangeInProgress: false, testCaseStateChangeInProgress: false,
...@@ -103,6 +104,9 @@ export default { ...@@ -103,6 +104,9 @@ export default {
this.testCaseStateChangeInProgress = false; this.testCaseStateChangeInProgress = false;
}); });
}, },
handleTaskListUpdateSuccess() {
this.$apollo.queries.taskCompletionStatus.refetch();
},
handleTaskListUpdateFailure() { handleTaskListUpdateFailure() {
this.taskListUpdateFailed = true; this.taskListUpdateFailed = true;
}, },
...@@ -159,10 +163,11 @@ export default { ...@@ -159,10 +163,11 @@ export default {
:edit-form-visible="editTestCaseFormVisible" :edit-form-visible="editTestCaseFormVisible"
:description-preview-path="descriptionPreviewPath" :description-preview-path="descriptionPreviewPath"
:description-help-path="descriptionHelpPath" :description-help-path="descriptionHelpPath"
:task-completion-status="testCase.taskCompletionStatus" :task-completion-status="taskCompletionStatus"
:task-list-update-path="updatePath" :task-list-update-path="updatePath"
:task-list-lock-version="lockVersion" :task-list-lock-version="lockVersion"
@edit-issuable="handleEditTestCase" @edit-issuable="handleEditTestCase"
@task-list-update-success="handleTaskListUpdateSuccess"
@task-list-update-failure="handleTaskListUpdateFailure" @task-list-update-failure="handleTaskListUpdateFailure"
> >
<template #status-badge> <template #status-badge>
......
...@@ -6,6 +6,7 @@ import { s__ } from '~/locale'; ...@@ -6,6 +6,7 @@ import { s__ } from '~/locale';
import markTestCaseTodoDone from '../queries/mark_test_case_todo_done.mutation.graphql'; import markTestCaseTodoDone from '../queries/mark_test_case_todo_done.mutation.graphql';
import moveTestCase from '../queries/move_test_case.mutation.graphql'; import moveTestCase from '../queries/move_test_case.mutation.graphql';
import projectTestCase from '../queries/project_test_case.query.graphql'; import projectTestCase from '../queries/project_test_case.query.graphql';
import projectTestCaseTaskList from '../queries/test_case_tasklist.query.graphql';
import updateTestCase from '../queries/update_test_case.mutation.graphql'; import updateTestCase from '../queries/update_test_case.mutation.graphql';
export default { export default {
...@@ -34,6 +35,26 @@ export default { ...@@ -34,6 +35,26 @@ export default {
throw error; throw error;
}, },
}, },
taskCompletionStatus: {
query: projectTestCaseTaskList,
variables() {
return {
projectPath: this.projectFullPath,
testCaseId: this.testCaseId,
};
},
update(data) {
return data.project?.issue?.taskCompletionStatus;
},
error(error) {
createFlash({
message: s__('TestCases|Something went wrong while updating the test case.'),
captureError: true,
error,
});
throw error;
},
},
}, },
data() { data() {
return { return {
......
...@@ -35,8 +35,4 @@ fragment TestCase on Issue { ...@@ -35,8 +35,4 @@ fragment TestCase on Issue {
state state
} }
} }
taskCompletionStatus {
count
completedCount
}
} }
query projectTestCaseTaskList($projectPath: ID!, $testCaseId: String) {
project(fullPath: $projectPath) {
__typename
issue(iid: $testCaseId) {
__typename
id
taskCompletionStatus {
__typename
count
completedCount
}
}
}
}
...@@ -28,6 +28,9 @@ const createComponent = ({ testCase, testCaseQueryLoading = false } = {}) => ...@@ -28,6 +28,9 @@ const createComponent = ({ testCase, testCaseQueryLoading = false } = {}) =>
loading: testCaseQueryLoading, loading: testCaseQueryLoading,
refetch: jest.fn(), refetch: jest.fn(),
}, },
taskCompletionStatus: {
refetch: jest.fn(),
},
}, },
}, },
}, },
...@@ -303,12 +306,18 @@ describe('TestCaseShowRoot', () => { ...@@ -303,12 +306,18 @@ describe('TestCaseShowRoot', () => {
issuable: mockTestCase, issuable: mockTestCase,
enableEdit: canEditTestCase, enableEdit: canEditTestCase,
editFormVisible: editTestCaseFormVisible, editFormVisible: editTestCaseFormVisible,
taskCompletionStatus: mockTestCase.taskCompletionStatus, taskCompletionStatus: {},
taskListUpdatePath: updatePath, taskListUpdatePath: updatePath,
taskListLockVersion: lockVersion, taskListLockVersion: lockVersion,
}); });
}); });
it('refetches taskCompletionStatus when issuable-show emits `task-list-update-success` event', async () => {
await wrapper.find(IssuableShow).vm.$emit('task-list-update-success');
expect(wrapper.vm.$apollo.queries.taskCompletionStatus.refetch).toHaveBeenCalled();
});
it('does not render issuable-show when `testCaseLoading` prop is false and `testCaseLoadFailed` prop is true', async () => { it('does not render issuable-show when `testCaseLoading` prop is false and `testCaseLoadFailed` prop is true', async () => {
wrapper.setData({ wrapper.setData({
testCaseLoading: false, testCaseLoading: false,
......
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