diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-22 12:07:34 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-22 12:07:34 +0300 |
commit | 672f729cf283c4495ccf5071007e25b33c30daff (patch) | |
tree | 587af1b51e3f94762d59038b65377fa8c9955bcd /spec/frontend/repository | |
parent | f9a4c3a3b853533336efabf7631c7981c8ac7673 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/repository')
-rw-r--r-- | spec/frontend/repository/components/blob_content_viewer_spec.js | 21 | ||||
-rw-r--r-- | spec/frontend/repository/mock_data.js | 2 |
2 files changed, 14 insertions, 9 deletions
diff --git a/spec/frontend/repository/components/blob_content_viewer_spec.js b/spec/frontend/repository/components/blob_content_viewer_spec.js index 7e14d292946..21b37f5cfbc 100644 --- a/spec/frontend/repository/components/blob_content_viewer_spec.js +++ b/spec/frontend/repository/components/blob_content_viewer_spec.js @@ -38,6 +38,7 @@ import { userPermissionsMock, propsMock, refMock, + axiosMockResponse, } from '../mock_data'; jest.mock('~/repository/components/blob_viewers'); @@ -61,6 +62,8 @@ const mockRouter = { push: mockRouterPush, }; +const legacyViewerUrl = 'some_file.js?format=json&viewer=simple'; + const createComponent = async (mockData = {}, mountFn = shallowMount, mockRoute = {}) => { Vue.use(VueApollo); @@ -79,8 +82,12 @@ const createComponent = async (mockData = {}, mountFn = shallowMount, mockRoute const blobInfo = { ...projectMock, repository: { + __typename: 'Repository', empty, - blobs: { nodes: [blob] }, + blobs: { + __typename: 'RepositoryBlobConnection', + nodes: [blob], + }, }, }; @@ -148,10 +155,6 @@ const createComponent = async (mockData = {}, mountFn = shallowMount, mockRoute }), ); - // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details - // eslint-disable-next-line no-restricted-syntax - wrapper.setData({ project: blobInfo, isBinary }); - await waitForPromises(); }; @@ -216,7 +219,6 @@ describe('Blob content viewer component', () => { }); describe('legacy viewers', () => { - const legacyViewerUrl = 'some_file.js?format=json&viewer=simple'; const fileType = 'text'; const highlightJs = false; @@ -437,8 +439,8 @@ describe('Blob content viewer component', () => { }); it('renders WebIdeLink button for binary files', async () => { - await createComponent({ blob: richViewerMock, isBinary: true }, mount); - + mockAxios.onGet(legacyViewerUrl).replyOnce(HTTP_STATUS_OK, axiosMockResponse); + await createComponent({}, mount); expect(findWebIdeLink().props()).toMatchObject({ editUrl: editBlobPath, webIdeUrl: ideEditPath, @@ -448,7 +450,8 @@ describe('Blob content viewer component', () => { describe('blob header binary file', () => { it('passes the correct isBinary value when viewing a binary file', async () => { - await createComponent({ blob: richViewerMock, isBinary: true }); + mockAxios.onGet(legacyViewerUrl).replyOnce(HTTP_STATUS_OK, axiosMockResponse); + await createComponent(); expect(findBlobHeader().props('isBinary')).toBe(true); }); diff --git a/spec/frontend/repository/mock_data.js b/spec/frontend/repository/mock_data.js index 399341d23a0..e20849d1085 100644 --- a/spec/frontend/repository/mock_data.js +++ b/spec/frontend/repository/mock_data.js @@ -198,3 +198,5 @@ export const paginatedTreeResponseFactory = ({ }, }, }); + +export const axiosMockResponse = { html: 'text', binary: true }; |