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) => {
);
};
export function suggestionCommitMessage(state) {
export function suggestionCommitMessage(state, _, rootState) {
return (values = {}) =>
computeSuggestionCommitMessage({
message: state.defaultSuggestionCommitMessage,
values: {
branch_name: state.branchName,
project_path: state.projectPath,
project_name: state.projectName,
username: state.username,
user_full_name: state.userFullName,
branch_name: rootState.page.mrMetadata.branch_name,
project_path: rootState.page.mrMetadata.project_path,
project_name: rootState.page.mrMetadata.project_name,
username: rootState.page.mrMetadata.username,
user_full_name: rootState.page.mrMetadata.user_full_name,
...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', () => {
});
describe('suggestionCommitMessage', () => {
let rootState;
beforeEach(() => {
Object.assign(localState, {
defaultSuggestionCommitMessage:
'%{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`
specialState | output
${{}} | ${'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}'}
${{ projectName: 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}'}
${{ branchName: null }} | ${'%{branch_name}/pathnameuseruser userton%{file_paths}%{suggestions_count}%{files_count}'}
${{ project_name: null }} | ${'branch/path%{project_name}useruser userton%{file_paths}%{suggestions_count}%{files_count}'}
${{ project_path: null }} | ${'branch%{project_path}nameuseruser 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)',
({ 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', () => {
`(
"properly overrides state values ($stateOverrides) if they're provided",
({ 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', () => {
`(
"fills in any missing interpolations ($providedValues) when they're provided at the getter callsite",
({ 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', () => {
state: {
defaultSuggestionCommitMessage:
'%{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 },
},
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