diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-17 09:10:09 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-17 09:10:09 +0000 |
commit | eeb25534bae1021f5b7940138ee56dea8fc79949 (patch) | |
tree | 26cf3d6a4ac582ed3d0d3a20b82a200da580f1e3 /spec | |
parent | 75621c94b5dbe233edd72c3d8cc602fed25e84d2 (diff) | |
download | gitlab-ce-eeb25534bae1021f5b7940138ee56dea8fc79949.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
7 files changed, 439 insertions, 87 deletions
diff --git a/spec/features/snippets/explore_spec.rb b/spec/features/snippets/explore_spec.rb index ef4b75ac3b4..2e06125963e 100644 --- a/spec/features/snippets/explore_spec.rb +++ b/spec/features/snippets/explore_spec.rb @@ -6,16 +6,15 @@ RSpec.describe 'Explore Snippets', feature_category: :source_code_management do let!(:public_snippet) { create(:personal_snippet, :public) } let!(:internal_snippet) { create(:personal_snippet, :internal) } let!(:private_snippet) { create(:personal_snippet, :private) } - let(:user) { nil } - - before do - sign_in(user) if user - visit explore_snippets_path - end context 'User' do let(:user) { create(:user) } + before do + sign_in(user) + visit explore_snippets_path + end + it 'see snippets that are not private' do expect(page).to have_content(public_snippet.title) expect(page).to have_content(internal_snippet.title) @@ -31,6 +30,11 @@ RSpec.describe 'Explore Snippets', feature_category: :source_code_management do context 'External user' do let(:user) { create(:user, :external) } + before do + sign_in(user) + visit explore_snippets_path + end + it 'see only public snippets' do expect(page).to have_content(public_snippet.title) expect(page).not_to have_content(internal_snippet.title) @@ -55,6 +59,10 @@ RSpec.describe 'Explore Snippets', feature_category: :source_code_management do end context 'Not authenticated user' do + before do + visit explore_snippets_path + end + it 'see only public snippets' do expect(page).to have_content(public_snippet.title) expect(page).not_to have_content(internal_snippet.title) diff --git a/spec/frontend/boards/components/board_content_spec.js b/spec/frontend/boards/components/board_content_spec.js index e14f661a8bd..c8b1811cdeb 100644 --- a/spec/frontend/boards/components/board_content_spec.js +++ b/spec/frontend/boards/components/board_content_spec.js @@ -11,6 +11,7 @@ import getters from 'ee_else_ce/boards/stores/getters'; import BoardColumn from '~/boards/components/board_column.vue'; import BoardContent from '~/boards/components/board_content.vue'; import BoardContentSidebar from '~/boards/components/board_content_sidebar.vue'; +import BoardAddNewColumn from 'ee_else_ce/boards/components/board_add_new_column.vue'; import { mockLists, mockListsById } from '../mock_data'; Vue.use(Vuex); @@ -76,6 +77,9 @@ describe('BoardContent', () => { }); }; + const findBoardColumns = () => wrapper.findAllComponents(BoardColumn); + const findBoardAddNewColumn = () => wrapper.findComponent(BoardAddNewColumn); + describe('default', () => { beforeEach(() => { createComponent(); @@ -100,6 +104,10 @@ describe('BoardContent', () => { expect(listEl.attributes('delay')).toBe('100'); expect(listEl.attributes('delayontouchonly')).toBe('true'); }); + + it('does not show the "add column" form', () => { + expect(findBoardAddNewColumn().exists()).toBe(false); + }); }); describe('when issuableType is not issue', () => { @@ -155,4 +163,20 @@ describe('BoardContent', () => { expect(eventHub.$on).toHaveBeenCalledWith('updateBoard', wrapper.vm.refetchLists); }); }); + + describe('when "add column" form is visible', () => { + beforeEach(() => { + createComponent({ state: { addColumnForm: { visible: true } } }); + }); + + it('shows the "add column" form', () => { + expect(findBoardAddNewColumn().exists()).toBe(true); + }); + + it('hides other columns on mobile viewports', () => { + findBoardColumns().wrappers.forEach((column) => { + expect(column.classes()).toEqual(['gl-display-none!', 'gl-sm-display-inline-block!']); + }); + }); + }); }); diff --git a/spec/frontend/work_items/components/notes/system_note_spec.js b/spec/frontend/work_items/components/notes/system_note_spec.js index fd5f373d076..03f1aa356ad 100644 --- a/spec/frontend/work_items/components/notes/system_note_spec.js +++ b/spec/frontend/work_items/components/notes/system_note_spec.js @@ -1,54 +1,32 @@ import { GlIcon } from '@gitlab/ui'; -import MockAdapter from 'axios-mock-adapter'; import { shallowMount } from '@vue/test-utils'; -import waitForPromises from 'helpers/wait_for_promises'; -import { renderGFM } from '~/behaviors/markdown/render_gfm'; +import MockAdapter from 'axios-mock-adapter'; +import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import WorkItemSystemNote from '~/work_items/components/notes/system_note.vue'; -import NoteHeader from '~/notes/components/note_header.vue'; +import { workItemSystemNoteWithMetadata } from 'jest/work_items/mock_data'; import axios from '~/lib/utils/axios_utils'; -import { HTTP_STATUS_OK } from '~/lib/utils/http_status'; jest.mock('~/behaviors/markdown/render_gfm'); -describe('system note component', () => { +describe('Work Items system note component', () => { let wrapper; - let props; let mock; - const findTimelineIcon = () => wrapper.findComponent(GlIcon); - const findSystemNoteMessage = () => wrapper.findComponent(NoteHeader); - const findOutdatedLineButton = () => - wrapper.findComponent('[data-testid="outdated-lines-change-btn"]'); - const findOutdatedLines = () => wrapper.findComponent('[data-testid="outdated-lines"]'); + const createComponent = ({ note = workItemSystemNoteWithMetadata } = {}) => { + mock = new MockAdapter(axios); - const createComponent = (propsData = {}) => { wrapper = shallowMount(WorkItemSystemNote, { - propsData, - slots: { - 'extra-controls': - '<gl-button data-testid="outdated-lines-change-btn">Compare with last version</gl-button>', + propsData: { + note, }, }); }; - beforeEach(() => { - props = { - note: { - id: '1424', - author: { - id: 1, - name: 'Root', - username: 'root', - state: 'active', - avatarUrl: 'path', - path: '/root', - }, - bodyHtml: '<p dir="auto">closed</p>', - systemNoteIconName: 'status_closed', - createdAt: '2017-08-02T10:51:58.559Z', - }, - }; + const findTimelineIcon = () => wrapper.findComponent(GlIcon); + const findComparePreviousVersionButton = () => wrapper.find('[data-testid="compare-btn"]'); + beforeEach(() => { + createComponent(); mock = new MockAdapter(axios); }); @@ -57,56 +35,16 @@ describe('system note component', () => { }); it('should render a list item with correct id', () => { - createComponent(props); - - expect(wrapper.attributes('id')).toBe(`note_${props.note.id}`); - }); - - // Note: The test case below is to handle a use case related to vuex store but since this does not - // have a vuex store , disabling it now will be fixing it in the next iteration - // eslint-disable-next-line jest/no-disabled-tests - it.skip('should render target class is note is target note', () => { - createComponent(props); - - expect(wrapper.classes()).toContain('target'); + expect(wrapper.attributes('id')).toBe( + `note_${getIdFromGraphQLId(workItemSystemNoteWithMetadata.id)}`, + ); }); it('should render svg icon', () => { - createComponent(props); - expect(findTimelineIcon().exists()).toBe(true); }); - // Redcarpet Markdown renderer wraps text in `<p>` tags - // we need to strip them because they break layout of commit lists in system notes: - // https://gitlab.com/gitlab-org/gitlab-foss/uploads/b07a10670919254f0220d3ff5c1aa110/jqzI.png - it('removes wrapping paragraph from note HTML', () => { - createComponent(props); - - expect(findSystemNoteMessage().html()).toContain('<span>closed</span>'); - }); - - it('should renderGFM onMount', () => { - createComponent(props); - - expect(renderGFM).toHaveBeenCalled(); - }); - - // eslint-disable-next-line jest/no-disabled-tests - it.skip('renders outdated code lines', async () => { - mock - .onGet('/outdated_line_change_path') - .reply(HTTP_STATUS_OK, [ - { rich_text: 'console.log', type: 'new', line_code: '123', old_line: null, new_line: 1 }, - ]); - - createComponent({ - note: { ...props.note, outdated_line_change_path: '/outdated_line_change_path' }, - }); - - await findOutdatedLineButton().vm.$emit('click'); - await waitForPromises(); - - expect(findOutdatedLines().exists()).toBe(true); + it('should not show compare previous version for FOSS', () => { + expect(findComparePreviousVersionButton().exists()).toBe(false); }); }); diff --git a/spec/frontend/work_items/components/notes/work_item_add_note_spec.js b/spec/frontend/work_items/components/notes/work_item_add_note_spec.js index 739340f4936..e575b6bc097 100644 --- a/spec/frontend/work_items/components/notes/work_item_add_note_spec.js +++ b/spec/frontend/work_items/components/notes/work_item_add_note_spec.js @@ -225,7 +225,7 @@ describe('Work item add note', () => { }); it('skips calling the work item query when missing workItemIid', async () => { - await createComponent({ workItemIid: null, isEditing: false }); + await createComponent({ workItemIid: '', isEditing: false }); expect(workItemResponseHandler).not.toHaveBeenCalled(); }); diff --git a/spec/frontend/work_items/components/work_item_labels_spec.js b/spec/frontend/work_items/components/work_item_labels_spec.js index 554c9a4f7b8..6894aa236e3 100644 --- a/spec/frontend/work_items/components/work_item_labels_spec.js +++ b/spec/frontend/work_items/components/work_item_labels_spec.js @@ -266,7 +266,7 @@ describe('WorkItemLabels component', () => { }); it('skips calling the work item query when missing workItemIid', async () => { - createComponent({ workItemIid: null }); + createComponent({ workItemIid: '' }); await waitForPromises(); expect(workItemQuerySuccess).not.toHaveBeenCalled(); diff --git a/spec/frontend/work_items/mock_data.js b/spec/frontend/work_items/mock_data.js index 05c6a21bb38..93f24cf2337 100644 --- a/spec/frontend/work_items/mock_data.js +++ b/spec/frontend/work_items/mock_data.js @@ -1879,6 +1879,10 @@ export const mockWorkItemNotesResponse = { repositionNote: true, __typename: 'NotePermissions', }, + systemNoteMetadata: { + id: 'gid://gitlab/SystemNoteMetadata/36', + descriptionVersion: null, + }, author: { avatarUrl: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', @@ -1924,6 +1928,10 @@ export const mockWorkItemNotesResponse = { repositionNote: true, __typename: 'NotePermissions', }, + systemNoteMetadata: { + id: 'gid://gitlab/SystemNoteMetadata/76', + descriptionVersion: null, + }, author: { avatarUrl: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', @@ -1968,6 +1976,10 @@ export const mockWorkItemNotesResponse = { repositionNote: true, __typename: 'NotePermissions', }, + systemNoteMetadata: { + id: 'gid://gitlab/SystemNoteMetadata/71', + descriptionVersion: null, + }, author: { avatarUrl: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', @@ -2073,6 +2085,10 @@ export const mockWorkItemNotesByIidResponse = { repositionNote: true, __typename: 'NotePermissions', }, + systemNoteMetadata: { + id: 'gid://gitlab/SystemNoteMetadata/72', + descriptionVersion: null, + }, author: { id: 'gid://gitlab/User/1', avatarUrl: @@ -2120,6 +2136,10 @@ export const mockWorkItemNotesByIidResponse = { repositionNote: true, __typename: 'NotePermissions', }, + systemNoteMetadata: { + id: 'gid://gitlab/SystemNoteMetadata/76', + descriptionVersion: null, + }, author: { id: 'gid://gitlab/User/1', avatarUrl: @@ -2168,6 +2188,10 @@ export const mockWorkItemNotesByIidResponse = { repositionNote: true, __typename: 'NotePermissions', }, + systemNoteMetadata: { + id: 'gid://gitlab/SystemNoteMetadata/22', + descriptionVersion: null, + }, author: { id: 'gid://gitlab/User/1', avatarUrl: @@ -2274,6 +2298,10 @@ export const mockMoreWorkItemNotesResponse = { repositionNote: true, __typename: 'NotePermissions', }, + systemNoteMetadata: { + id: 'gid://gitlab/SystemNoteMetadata/16', + descriptionVersion: null, + }, author: { avatarUrl: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', @@ -2321,6 +2349,10 @@ export const mockMoreWorkItemNotesResponse = { repositionNote: true, __typename: 'NotePermissions', }, + systemNoteMetadata: { + id: 'gid://gitlab/SystemNoteMetadata/96', + descriptionVersion: null, + }, author: { avatarUrl: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', @@ -2366,6 +2398,10 @@ export const mockMoreWorkItemNotesResponse = { repositionNote: true, __typename: 'NotePermissions', }, + systemNoteMetadata: { + id: 'gid://gitlab/SystemNoteMetadata/56', + descriptionVersion: null, + }, author: { avatarUrl: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', @@ -2430,6 +2466,7 @@ export const createWorkItemNoteResponse = { webUrl: 'http://127.0.0.1:3000/root', __typename: 'UserCore', }, + systemNoteMetadata: null, userPermissions: { adminNote: true, awardEmoji: true, @@ -2479,6 +2516,7 @@ export const mockWorkItemCommentNote = { repositionNote: true, __typename: 'NotePermissions', }, + systemNoteMetadata: null, author: { avatarUrl: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', id: 'gid://gitlab/User/1', @@ -2564,6 +2602,7 @@ export const mockWorkItemNotesResponseWithComments = { webUrl: 'http://127.0.0.1:3000/root', __typename: 'UserCore', }, + systemNoteMetadata: null, userPermissions: { adminNote: true, awardEmoji: true, @@ -2601,6 +2640,7 @@ export const mockWorkItemNotesResponseWithComments = { webUrl: 'http://127.0.0.1:3000/root', __typename: 'UserCore', }, + systemNoteMetadata: null, userPermissions: { adminNote: true, awardEmoji: true, @@ -2646,6 +2686,7 @@ export const mockWorkItemNotesResponseWithComments = { repositionNote: true, __typename: 'NotePermissions', }, + systemNoteMetadata: null, author: { avatarUrl: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', @@ -2716,6 +2757,10 @@ export const workItemNotesCreateSubscriptionResponse = { repositionNote: true, __typename: 'NotePermissions', }, + systemNoteMetadata: { + id: 'gid://gitlab/SystemNoteMetadata/65', + descriptionVersion: null, + }, author: { avatarUrl: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', @@ -2739,6 +2784,10 @@ export const workItemNotesCreateSubscriptionResponse = { repositionNote: true, __typename: 'NotePermissions', }, + systemNoteMetadata: { + id: 'gid://gitlab/SystemNoteMetadata/26', + descriptionVersion: null, + }, author: { avatarUrl: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', @@ -2778,6 +2827,10 @@ export const workItemNotesUpdateSubscriptionResponse = { repositionNote: true, __typename: 'NotePermissions', }, + systemNoteMetadata: { + id: 'gid://gitlab/SystemNoteMetadata/46', + descriptionVersion: null, + }, author: { avatarUrl: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', @@ -2801,3 +2854,303 @@ export const workItemNotesDeleteSubscriptionResponse = { }, }, }; + +export const workItemSystemNoteWithMetadata = { + id: 'gid://gitlab/Note/1651', + body: 'changed the description', + bodyHtml: '<p data-sourcepos="1:1-1:23" dir="auto">changed the description</p>', + system: true, + internal: false, + systemNoteIconName: 'pencil', + createdAt: '2023-05-05T07:19:37Z', + lastEditedAt: '2023-05-05T07:19:37Z', + url: 'https://gdk.test:3443/flightjs/Flight/-/work_items/46#note_1651', + lastEditedBy: null, + discussion: { + id: 'gid://gitlab/Discussion/7d4a46ea0525e2eeed451f7b718b0ebe73205374', + __typename: 'Discussion', + }, + author: { + id: 'gid://gitlab/User/1', + avatarUrl: + 'https://secure.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', + name: 'Administrator', + username: 'root', + webUrl: 'https://gdk.test:3443/root', + __typename: 'UserCore', + }, + userPermissions: { + adminNote: false, + awardEmoji: true, + readNote: true, + createNote: true, + resolveNote: true, + repositionNote: false, + __typename: 'NotePermissions', + }, + systemNoteMetadata: { + id: 'gid://gitlab/SystemNoteMetadata/670', + descriptionVersion: { + id: 'gid://gitlab/DescriptionVersion/167', + description: '5th May 90 987', + diff: '<span class="idiff">5th May 90</span><span class="idiff addition"> 987</span>', + diffPath: '/flightjs/Flight/-/issues/46/descriptions/167/diff', + deletePath: '/flightjs/Flight/-/issues/46/descriptions/167', + canDelete: true, + deleted: false, + startVersionId: '', + __typename: 'DescriptionVersion', + }, + __typename: 'SystemNoteMetadata', + }, + __typename: 'Note', +}; + +export const workItemNotesWithSystemNotesWithChangedDescription = { + data: { + workspace: { + id: 'gid://gitlab/Project/4', + workItems: { + nodes: [ + { + id: 'gid://gitlab/WorkItem/733', + iid: '79', + widgets: [ + { + __typename: 'WorkItemWidgetAssignees', + }, + { + __typename: 'WorkItemWidgetLabels', + }, + { + __typename: 'WorkItemWidgetDescription', + }, + { + __typename: 'WorkItemWidgetHierarchy', + }, + { + __typename: 'WorkItemWidgetMilestone', + }, + { + type: 'NOTES', + discussions: { + pageInfo: { + hasNextPage: false, + hasPreviousPage: false, + startCursor: null, + endCursor: null, + __typename: 'PageInfo', + }, + nodes: [ + { + id: 'gid://gitlab/Discussion/aa72f4c2f3eef66afa6d79a805178801ce4bd89f', + notes: { + nodes: [ + { + id: 'gid://gitlab/Note/1687', + body: 'changed the description', + bodyHtml: + '<p data-sourcepos="1:1-1:23" dir="auto">changed the description</p>', + system: true, + internal: false, + systemNoteIconName: 'pencil', + createdAt: '2023-05-10T05:21:01Z', + lastEditedAt: '2023-05-10T05:21:01Z', + url: 'https://gdk.test:3443/gnuwget/Wget2/-/work_items/79#note_1687', + lastEditedBy: null, + discussion: { + id: + 'gid://gitlab/Discussion/aa72f4c2f3eef66afa6d79a805178801ce4bd89f', + __typename: 'Discussion', + }, + author: { + id: 'gid://gitlab/User/1', + avatarUrl: + 'https://secure.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', + name: 'Administrator', + username: 'root', + webUrl: 'https://gdk.test:3443/root', + __typename: 'UserCore', + }, + userPermissions: { + adminNote: false, + awardEmoji: true, + readNote: true, + createNote: true, + resolveNote: true, + repositionNote: false, + __typename: 'NotePermissions', + }, + systemNoteMetadata: { + id: 'gid://gitlab/SystemNoteMetadata/703', + descriptionVersion: { + id: 'gid://gitlab/DescriptionVersion/198', + description: 'Desc1', + diff: '<span class="idiff addition">Desc1</span>', + diffPath: '/gnuwget/Wget2/-/issues/79/descriptions/198/diff', + deletePath: '/gnuwget/Wget2/-/issues/79/descriptions/198', + canDelete: true, + deleted: false, + __typename: 'DescriptionVersion', + }, + __typename: 'SystemNoteMetadata', + }, + __typename: 'Note', + }, + ], + __typename: 'NoteConnection', + }, + __typename: 'Discussion', + }, + { + id: 'gid://gitlab/Discussion/a7d3cf7bd72f7a98f802845f538af65cb11a02cc', + notes: { + nodes: [ + { + id: 'gid://gitlab/Note/1688', + body: 'changed the description', + bodyHtml: + '<p data-sourcepos="1:1-1:23" dir="auto">changed the description</p>', + system: true, + internal: false, + systemNoteIconName: 'pencil', + createdAt: '2023-05-10T05:21:05Z', + lastEditedAt: '2023-05-10T05:21:05Z', + url: 'https://gdk.test:3443/gnuwget/Wget2/-/work_items/79#note_1688', + lastEditedBy: null, + discussion: { + id: + 'gid://gitlab/Discussion/a7d3cf7bd72f7a98f802845f538af65cb11a02cc', + __typename: 'Discussion', + }, + author: { + id: 'gid://gitlab/User/1', + avatarUrl: + 'https://secure.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', + name: 'Administrator', + username: 'root', + webUrl: 'https://gdk.test:3443/root', + __typename: 'UserCore', + }, + userPermissions: { + adminNote: false, + awardEmoji: true, + readNote: true, + createNote: true, + resolveNote: true, + repositionNote: false, + __typename: 'NotePermissions', + }, + systemNoteMetadata: { + id: 'gid://gitlab/SystemNoteMetadata/704', + descriptionVersion: { + id: 'gid://gitlab/DescriptionVersion/199', + description: 'Desc2', + diff: + '<span class="idiff">Desc</span><span class="idiff deletion">1</span><span class="idiff addition">2</span>', + diffPath: '/gnuwget/Wget2/-/issues/79/descriptions/199/diff', + deletePath: '/gnuwget/Wget2/-/issues/79/descriptions/199', + canDelete: true, + deleted: false, + __typename: 'DescriptionVersion', + }, + __typename: 'SystemNoteMetadata', + }, + __typename: 'Note', + }, + ], + __typename: 'NoteConnection', + }, + __typename: 'Discussion', + }, + { + id: 'gid://gitlab/Discussion/391eed1ee0a258cc966a51dde900424f3b51b95d', + notes: { + nodes: [ + { + id: 'gid://gitlab/Note/1689', + body: 'changed the description', + bodyHtml: + '<p data-sourcepos="1:1-1:23" dir="auto">changed the description</p>', + system: true, + internal: false, + systemNoteIconName: 'pencil', + createdAt: '2023-05-10T05:21:08Z', + lastEditedAt: '2023-05-10T05:21:08Z', + url: 'https://gdk.test:3443/gnuwget/Wget2/-/work_items/79#note_1689', + lastEditedBy: null, + discussion: { + id: + 'gid://gitlab/Discussion/391eed1ee0a258cc966a51dde900424f3b51b95d', + __typename: 'Discussion', + }, + author: { + id: 'gid://gitlab/User/1', + avatarUrl: + 'https://secure.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', + name: 'Administrator', + username: 'root', + webUrl: 'https://gdk.test:3443/root', + __typename: 'UserCore', + }, + userPermissions: { + adminNote: false, + awardEmoji: true, + readNote: true, + createNote: true, + resolveNote: true, + repositionNote: false, + __typename: 'NotePermissions', + }, + systemNoteMetadata: { + id: 'gid://gitlab/SystemNoteMetadata/705', + descriptionVersion: { + id: 'gid://gitlab/DescriptionVersion/200', + description: 'Desc3', + diff: + '<span class="idiff">Desc</span><span class="idiff deletion">2</span><span class="idiff addition">3</span>', + diffPath: '/gnuwget/Wget2/-/issues/79/descriptions/200/diff', + deletePath: '/gnuwget/Wget2/-/issues/79/descriptions/200', + canDelete: true, + deleted: false, + __typename: 'DescriptionVersion', + }, + __typename: 'SystemNoteMetadata', + }, + __typename: 'Note', + }, + ], + __typename: 'NoteConnection', + }, + __typename: 'Discussion', + }, + ], + __typename: 'DiscussionConnection', + }, + __typename: 'WorkItemWidgetNotes', + }, + { + __typename: 'WorkItemWidgetHealthStatus', + }, + { + __typename: 'WorkItemWidgetProgress', + }, + { + __typename: 'WorkItemWidgetNotifications', + }, + { + __typename: 'WorkItemWidgetCurrentUserTodos', + }, + { + __typename: 'WorkItemWidgetAwardEmoji', + }, + ], + __typename: 'WorkItem', + }, + ], + __typename: 'WorkItemConnection', + }, + __typename: 'Project', + }, + }, +}; diff --git a/spec/frontend/work_items/notes/collapse_utils_spec.js b/spec/frontend/work_items/notes/collapse_utils_spec.js new file mode 100644 index 00000000000..c26ef891e9f --- /dev/null +++ b/spec/frontend/work_items/notes/collapse_utils_spec.js @@ -0,0 +1,29 @@ +import { + isDescriptionSystemNote, + getTimeDifferenceInMinutes, +} from '~/work_items/notes/collapse_utils'; +import { workItemSystemNoteWithMetadata } from '../mock_data'; + +describe('Work items collapse utils', () => { + it('checks if a system note is of a description type', () => { + expect(isDescriptionSystemNote(workItemSystemNoteWithMetadata)).toEqual(true); + }); + + it('returns false when a system note is not a description type', () => { + expect(isDescriptionSystemNote({ ...workItemSystemNoteWithMetadata, system: false })).toEqual( + false, + ); + }); + + it('gets the time difference between two notes', () => { + const anotherSystemNote = { + ...workItemSystemNoteWithMetadata, + createdAt: '2023-05-06T07:19:37Z', + }; + + // kept the dates 24 hours apart so 24 * 60 mins = 1440 + expect(getTimeDifferenceInMinutes(workItemSystemNoteWithMetadata, anotherSystemNote)).toEqual( + 1440, + ); + }); +}); |