Commit a5dc3452 authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch 'sh-fix-missing-commit-graphql-filepath' into 'master'

Fix filePath not being stored in GraphQL log tree cache

See merge request gitlab-org/gitlab!66029
parents 81620f09 f8d175ef
...@@ -5,5 +5,6 @@ fragment TreeEntryCommit on LogTreeCommit { ...@@ -5,5 +5,6 @@ fragment TreeEntryCommit on LogTreeCommit {
committedDate committedDate
commitPath commitPath
fileName fileName
filePath
type type
} }
...@@ -5,6 +5,7 @@ fragment TreeEntryCommit on LogTreeCommit { ...@@ -5,6 +5,7 @@ fragment TreeEntryCommit on LogTreeCommit {
committedDate committedDate
commitPath commitPath
fileName fileName
filePath
type type
lockLabel lockLabel
} }
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { createMockClient } from 'helpers/mock_apollo_helper';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { resolveCommit, fetchLogsTree } from '~/repository/log_tree'; import { resolveCommit, fetchLogsTree } from '~/repository/log_tree';
import commitsQuery from '~/repository/queries/commits.query.graphql';
import projectPathQuery from '~/repository/queries/project_path.query.graphql';
import refQuery from '~/repository/queries/ref.query.graphql';
const mockData = [ const mockData = [
{ {
...@@ -10,6 +14,7 @@ const mockData = [ ...@@ -10,6 +14,7 @@ const mockData = [
committed_date: '2019-01-01', committed_date: '2019-01-01',
}, },
commit_path: `https://test.com`, commit_path: `https://test.com`,
commit_title_html: 'commit title',
file_name: 'index.js', file_name: 'index.js',
type: 'blob', type: 'blob',
}, },
...@@ -50,19 +55,15 @@ describe('fetchLogsTree', () => { ...@@ -50,19 +55,15 @@ describe('fetchLogsTree', () => {
global.gon = { relative_url_root: '' }; global.gon = { relative_url_root: '' };
client = {
readQuery: () => ({
projectPath: 'gitlab-org/gitlab-foss',
escapedRef: 'main',
commits: [],
}),
writeQuery: jest.fn(),
};
resolver = { resolver = {
entry: { name: 'index.js', type: 'blob' }, entry: { name: 'index.js', type: 'blob' },
resolve: jest.fn(), resolve: jest.fn(),
}; };
client = createMockClient();
client.writeQuery({ query: projectPathQuery, data: { projectPath: 'gitlab-org/gitlab-foss' } });
client.writeQuery({ query: refQuery, data: { ref: 'main', escapedRef: 'main' } });
client.writeQuery({ query: commitsQuery, data: { commits: [] } });
}); });
afterEach(() => { afterEach(() => {
...@@ -125,25 +126,19 @@ describe('fetchLogsTree', () => { ...@@ -125,25 +126,19 @@ describe('fetchLogsTree', () => {
it('writes query to client', async () => { it('writes query to client', async () => {
await fetchLogsTree(client, '', '0', resolver); await fetchLogsTree(client, '', '0', resolver);
expect(client.writeQuery).toHaveBeenCalledWith({ expect(client.readQuery({ query: commitsQuery })).toEqual({
query: expect.anything(),
data: {
projectPath: 'gitlab-org/gitlab-foss',
escapedRef: 'main',
commits: [ commits: [
expect.objectContaining({ expect.objectContaining({
__typename: 'LogTreeCommit',
commitPath: 'https://test.com', commitPath: 'https://test.com',
committedDate: '2019-01-01', committedDate: '2019-01-01',
fileName: 'index.js', fileName: 'index.js',
filePath: '/index.js', filePath: '/index.js',
message: 'testing message', message: 'testing message',
sha: '123', sha: '123',
titleHtml: undefined, titleHtml: 'commit title',
type: 'blob', type: 'blob',
}), }),
], ],
},
}); });
}); });
}); });
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