Commit 766d28b0 authored by Illya Klymov's avatar Illya Klymov

Merge branch 'tor/defect/overview-placeholder-message/diffs-new-data-source' into 'master'

Switch the source for Diffs suggestion commit message to the MR Notes store

See merge request gitlab-org/gitlab!57419
parents 803caac3 ef517613
...@@ -156,16 +156,16 @@ export const diffLines = (state) => (file, unifiedDiffComponents) => { ...@@ -156,16 +156,16 @@ export const diffLines = (state) => (file, unifiedDiffComponents) => {
); );
}; };
export function suggestionCommitMessage(state) { export function suggestionCommitMessage(state, _, rootState) {
return (values = {}) => return (values = {}) =>
computeSuggestionCommitMessage({ computeSuggestionCommitMessage({
message: state.defaultSuggestionCommitMessage, message: state.defaultSuggestionCommitMessage,
values: { values: {
branch_name: state.branchName, branch_name: rootState.page.mrMetadata.branch_name,
project_path: state.projectPath, project_path: rootState.page.mrMetadata.project_path,
project_name: state.projectName, project_name: rootState.page.mrMetadata.project_name,
username: state.username, username: rootState.page.mrMetadata.username,
user_full_name: state.userFullName, user_full_name: rootState.page.mrMetadata.user_full_name,
...values, ...values,
}, },
}); });
......
---
title: Hydrate some of the variables in the Overview tab suggestion commit placeholder
by switching the Diffs data source for it
merge_request: 57419
author:
type: changed
...@@ -377,32 +377,40 @@ describe('Diffs Module Getters', () => { ...@@ -377,32 +377,40 @@ describe('Diffs Module Getters', () => {
}); });
describe('suggestionCommitMessage', () => { describe('suggestionCommitMessage', () => {
let rootState;
beforeEach(() => { beforeEach(() => {
Object.assign(localState, { Object.assign(localState, {
defaultSuggestionCommitMessage: defaultSuggestionCommitMessage:
'%{branch_name}%{project_path}%{project_name}%{username}%{user_full_name}%{file_paths}%{suggestions_count}%{files_count}', '%{branch_name}%{project_path}%{project_name}%{username}%{user_full_name}%{file_paths}%{suggestions_count}%{files_count}',
branchName: 'branch',
projectPath: '/path',
projectName: 'name',
username: 'user',
userFullName: 'user userton',
}); });
rootState = {
page: {
mrMetadata: {
branch_name: 'branch',
project_path: '/path',
project_name: 'name',
username: 'user',
user_full_name: 'user userton',
},
},
};
}); });
it.each` it.each`
specialState | output specialState | output
${{}} | ${'branch/pathnameuseruser userton%{file_paths}%{suggestions_count}%{files_count}'} ${{}} | ${'branch/pathnameuseruser userton%{file_paths}%{suggestions_count}%{files_count}'}
${{ userFullName: null }} | ${'branch/pathnameuser%{user_full_name}%{file_paths}%{suggestions_count}%{files_count}'} ${{ user_full_name: null }} | ${'branch/pathnameuser%{user_full_name}%{file_paths}%{suggestions_count}%{files_count}'}
${{ username: null }} | ${'branch/pathname%{username}user userton%{file_paths}%{suggestions_count}%{files_count}'} ${{ username: null }} | ${'branch/pathname%{username}user userton%{file_paths}%{suggestions_count}%{files_count}'}
${{ projectName: null }} | ${'branch/path%{project_name}useruser userton%{file_paths}%{suggestions_count}%{files_count}'} ${{ project_name: null }} | ${'branch/path%{project_name}useruser userton%{file_paths}%{suggestions_count}%{files_count}'}
${{ projectPath: null }} | ${'branch%{project_path}nameuseruser userton%{file_paths}%{suggestions_count}%{files_count}'} ${{ project_path: null }} | ${'branch%{project_path}nameuseruser userton%{file_paths}%{suggestions_count}%{files_count}'}
${{ branchName: null }} | ${'%{branch_name}/pathnameuseruser userton%{file_paths}%{suggestions_count}%{files_count}'} ${{ branch_name: null }} | ${'%{branch_name}/pathnameuseruser userton%{file_paths}%{suggestions_count}%{files_count}'}
`( `(
'provides the correct "base" default commit message based on state ($specialState)', 'provides the correct "base" default commit message based on state ($specialState)',
({ specialState, output }) => { ({ specialState, output }) => {
Object.assign(localState, specialState); Object.assign(rootState.page.mrMetadata, specialState);
expect(getters.suggestionCommitMessage(localState)()).toBe(output); expect(getters.suggestionCommitMessage(localState, null, rootState)()).toBe(output);
}, },
); );
...@@ -417,7 +425,9 @@ describe('Diffs Module Getters', () => { ...@@ -417,7 +425,9 @@ describe('Diffs Module Getters', () => {
`( `(
"properly overrides state values ($stateOverrides) if they're provided", "properly overrides state values ($stateOverrides) if they're provided",
({ stateOverrides, output }) => { ({ stateOverrides, output }) => {
expect(getters.suggestionCommitMessage(localState)(stateOverrides)).toBe(output); expect(getters.suggestionCommitMessage(localState, null, rootState)(stateOverrides)).toBe(
output,
);
}, },
); );
...@@ -431,7 +441,9 @@ describe('Diffs Module Getters', () => { ...@@ -431,7 +441,9 @@ describe('Diffs Module Getters', () => {
`( `(
"fills in any missing interpolations ($providedValues) when they're provided at the getter callsite", "fills in any missing interpolations ($providedValues) when they're provided at the getter callsite",
({ providedValues, output }) => { ({ providedValues, output }) => {
expect(getters.suggestionCommitMessage(localState)(providedValues)).toBe(output); expect(getters.suggestionCommitMessage(localState, null, rootState)(providedValues)).toBe(
output,
);
}, },
); );
}); });
......
...@@ -81,14 +81,21 @@ describe('issue_note_body component', () => { ...@@ -81,14 +81,21 @@ describe('issue_note_body component', () => {
state: { state: {
defaultSuggestionCommitMessage: defaultSuggestionCommitMessage:
'%{branch_name}%{project_path}%{project_name}%{username}%{user_full_name}%{file_paths}%{suggestions_count}%{files_count}', '%{branch_name}%{project_path}%{project_name}%{username}%{user_full_name}%{file_paths}%{suggestions_count}%{files_count}',
branchName: 'branch',
projectPath: '/path',
projectName: 'name',
username: 'user',
userFullName: 'user userton',
}, },
getters: { suggestionCommitMessage }, getters: { suggestionCommitMessage },
}, },
page: {
namespaced: true,
state: {
mrMetadata: {
branch_name: 'branch',
project_path: '/path',
project_name: 'name',
username: 'user',
user_full_name: 'user userton',
},
},
},
}, },
}); });
......
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