diff options
Diffstat (limited to 'spec/frontend/releases')
21 files changed, 72 insertions, 86 deletions
diff --git a/spec/frontend/releases/components/app_edit_new_spec.js b/spec/frontend/releases/components/app_edit_new_spec.js index 828d1b46a80..1e55ab8f9e4 100644 --- a/spec/frontend/releases/components/app_edit_new_spec.js +++ b/spec/frontend/releases/components/app_edit_new_spec.js @@ -1,13 +1,13 @@ -import Vuex from 'vuex'; import { mount } from '@vue/test-utils'; -import { merge } from 'lodash'; import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; +import { merge } from 'lodash'; +import Vuex from 'vuex'; import { getJSONFixture } from 'helpers/fixtures'; -import ReleaseEditNewApp from '~/releases/components/app_edit_new.vue'; import * as commonUtils from '~/lib/utils/common_utils'; -import { BACK_URL_PARAM } from '~/releases/constants'; +import ReleaseEditNewApp from '~/releases/components/app_edit_new.vue'; import AssetLinksForm from '~/releases/components/asset_links_form.vue'; +import { BACK_URL_PARAM } from '~/releases/constants'; const originalRelease = getJSONFixture('api/releases/release.json'); const originalMilestones = originalRelease.milestones; diff --git a/spec/frontend/releases/components/app_index_spec.js b/spec/frontend/releases/components/app_index_spec.js index 1481dd30fd4..2b5270e29d6 100644 --- a/spec/frontend/releases/components/app_index_spec.js +++ b/spec/frontend/releases/components/app_index_spec.js @@ -1,15 +1,15 @@ +import { shallowMount, createLocalVue } from '@vue/test-utils'; import { range as rge } from 'lodash'; import Vuex from 'vuex'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; -import waitForPromises from 'helpers/wait_for_promises'; import { getJSONFixture } from 'helpers/fixtures'; +import waitForPromises from 'helpers/wait_for_promises'; +import api from '~/api'; +import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import ReleasesApp from '~/releases/components/app_index.vue'; +import ReleasesPagination from '~/releases/components/releases_pagination.vue'; import createStore from '~/releases/stores'; import createListModule from '~/releases/stores/modules/list'; -import api from '~/api'; import { pageInfoHeadersWithoutPagination, pageInfoHeadersWithPagination } from '../mock_data'; -import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; -import ReleasesPagination from '~/releases/components/releases_pagination.vue'; jest.mock('~/lib/utils/common_utils', () => ({ ...jest.requireActual('~/lib/utils/common_utils'), diff --git a/spec/frontend/releases/components/app_show_spec.js b/spec/frontend/releases/components/app_show_spec.js index b1f94ca9859..5caea395f0a 100644 --- a/spec/frontend/releases/components/app_show_spec.js +++ b/spec/frontend/releases/components/app_show_spec.js @@ -1,10 +1,10 @@ -import Vuex from 'vuex'; import { shallowMount } from '@vue/test-utils'; +import Vuex from 'vuex'; import { getJSONFixture } from 'helpers/fixtures'; +import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import ReleaseShowApp from '~/releases/components/app_show.vue'; -import ReleaseSkeletonLoader from '~/releases/components/release_skeleton_loader.vue'; import ReleaseBlock from '~/releases/components/release_block.vue'; -import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; +import ReleaseSkeletonLoader from '~/releases/components/release_skeleton_loader.vue'; const originalRelease = getJSONFixture('api/releases/release.json'); diff --git a/spec/frontend/releases/components/asset_links_form_spec.js b/spec/frontend/releases/components/asset_links_form_spec.js index 2b2ad0150ab..bbaa4e9dc94 100644 --- a/spec/frontend/releases/components/asset_links_form_spec.js +++ b/spec/frontend/releases/components/asset_links_form_spec.js @@ -1,9 +1,9 @@ -import Vuex from 'vuex'; import { mount, createLocalVue } from '@vue/test-utils'; +import Vuex from 'vuex'; import { getJSONFixture } from 'helpers/fixtures'; -import AssetLinksForm from '~/releases/components/asset_links_form.vue'; import * as commonUtils from '~/lib/utils/common_utils'; import { ENTER_KEY } from '~/lib/utils/keys'; +import AssetLinksForm from '~/releases/components/asset_links_form.vue'; import { ASSET_LINK_TYPE, DEFAULT_ASSET_LINK_TYPE } from '~/releases/constants'; const localVue = createLocalVue(); diff --git a/spec/frontend/releases/components/evidence_block_spec.js b/spec/frontend/releases/components/evidence_block_spec.js index b8c78f90fc2..50b6d1c4707 100644 --- a/spec/frontend/releases/components/evidence_block_spec.js +++ b/spec/frontend/releases/components/evidence_block_spec.js @@ -1,10 +1,10 @@ -import { mount } from '@vue/test-utils'; import { GlLink, GlIcon } from '@gitlab/ui'; +import { mount } from '@vue/test-utils'; import { getJSONFixture } from 'helpers/fixtures'; +import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import { truncateSha } from '~/lib/utils/text_utility'; import EvidenceBlock from '~/releases/components/evidence_block.vue'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; -import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; const originalRelease = getJSONFixture('api/releases/release.json'); diff --git a/spec/frontend/releases/components/release_block_assets_spec.js b/spec/frontend/releases/components/release_block_assets_spec.js index 77bd35f94aa..3b9b16fa890 100644 --- a/spec/frontend/releases/components/release_block_assets_spec.js +++ b/spec/frontend/releases/components/release_block_assets_spec.js @@ -1,7 +1,7 @@ -import { mount } from '@vue/test-utils'; import { GlCollapse } from '@gitlab/ui'; -import { trimText } from 'helpers/text_helper'; +import { mount } from '@vue/test-utils'; import { getJSONFixture } from 'helpers/fixtures'; +import { trimText } from 'helpers/text_helper'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import ReleaseBlockAssets from '~/releases/components/release_block_assets.vue'; import { ASSET_LINK_TYPE } from '~/releases/constants'; diff --git a/spec/frontend/releases/components/release_block_footer_spec.js b/spec/frontend/releases/components/release_block_footer_spec.js index f1c0c24f8ca..e9fa22b4ec7 100644 --- a/spec/frontend/releases/components/release_block_footer_spec.js +++ b/spec/frontend/releases/components/release_block_footer_spec.js @@ -1,26 +1,16 @@ -import { mount } from '@vue/test-utils'; import { GlLink, GlIcon } from '@gitlab/ui'; -import { trimText } from 'helpers/text_helper'; -import { getJSONFixture } from 'helpers/fixtures'; +import { mount } from '@vue/test-utils'; import { cloneDeep } from 'lodash'; -import ReleaseBlockFooter from '~/releases/components/release_block_footer.vue'; +import { getJSONFixture } from 'helpers/fixtures'; +import { trimText } from 'helpers/text_helper'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; +import ReleaseBlockFooter from '~/releases/components/release_block_footer.vue'; const originalRelease = getJSONFixture('api/releases/release.json'); -const mockFutureDate = new Date(9999, 0, 0).toISOString(); -let mockIsFutureRelease = false; - -jest.mock('~/vue_shared/mixins/timeago', () => ({ - methods: { - timeFormatted() { - return mockIsFutureRelease ? 'in 1 month' : '7 fortnights ago'; - }, - tooltipTitle() { - return 'February 30, 2401'; - }, - }, -})); +// TODO: Encapsulate date helpers https://gitlab.com/gitlab-org/gitlab/-/issues/320883 +const MONTHS_IN_MS = 1000 * 60 * 60 * 24 * 31; +const mockFutureDate = new Date(new Date().getTime() + MONTHS_IN_MS).toISOString(); describe('Release block footer', () => { let wrapper; @@ -44,7 +34,6 @@ describe('Release block footer', () => { afterEach(() => { wrapper.destroy(); wrapper = null; - mockIsFutureRelease = false; }); const commitInfoSection = () => wrapper.find('.js-commit-info'); @@ -88,7 +77,7 @@ describe('Release block footer', () => { it('renders the author and creation time info', () => { expect(trimText(authorDateInfoSection().text())).toBe( - `Created 7 fortnights ago by ${release.author.username}`, + `Created 1 year ago by ${release.author.username}`, ); }); @@ -100,7 +89,6 @@ describe('Release block footer', () => { describe('renders the author and creation time info with future release date', () => { beforeEach(() => { - mockIsFutureRelease = true; factory({ releasedAt: mockFutureDate }); }); @@ -113,7 +101,6 @@ describe('Release block footer', () => { describe('when the release date is in the future', () => { beforeEach(() => { - mockIsFutureRelease = true; factory({ releasedAt: mockFutureDate }); }); @@ -177,13 +164,12 @@ describe('Release block footer', () => { beforeEach(() => factory({ author: undefined })); it('renders the release date without the author name', () => { - expect(trimText(authorDateInfoSection().text())).toBe(`Created 7 fortnights ago`); + expect(trimText(authorDateInfoSection().text())).toBe(`Created 1 year ago`); }); }); describe('future release without any author info', () => { beforeEach(() => { - mockIsFutureRelease = true; factory({ author: undefined, releasedAt: mockFutureDate }); }); diff --git a/spec/frontend/releases/components/release_block_header_spec.js b/spec/frontend/releases/components/release_block_header_spec.js index f2159871395..0f6657090e6 100644 --- a/spec/frontend/releases/components/release_block_header_spec.js +++ b/spec/frontend/releases/components/release_block_header_spec.js @@ -1,9 +1,9 @@ +import { GlLink } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import { merge } from 'lodash'; -import { GlLink } from '@gitlab/ui'; import { getJSONFixture } from 'helpers/fixtures'; -import ReleaseBlockHeader from '~/releases/components/release_block_header.vue'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; +import ReleaseBlockHeader from '~/releases/components/release_block_header.vue'; import { BACK_URL_PARAM } from '~/releases/constants'; const originalRelease = getJSONFixture('api/releases/release.json'); diff --git a/spec/frontend/releases/components/release_block_milestone_info_spec.js b/spec/frontend/releases/components/release_block_milestone_info_spec.js index 4eb15e9da12..47fe10af946 100644 --- a/spec/frontend/releases/components/release_block_milestone_info_spec.js +++ b/spec/frontend/releases/components/release_block_milestone_info_spec.js @@ -1,10 +1,10 @@ -import { mount } from '@vue/test-utils'; import { GlProgressBar, GlLink, GlBadge, GlButton } from '@gitlab/ui'; -import { trimText } from 'helpers/text_helper'; +import { mount } from '@vue/test-utils'; import { getJSONFixture } from 'helpers/fixtures'; +import { trimText } from 'helpers/text_helper'; +import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import ReleaseBlockMilestoneInfo from '~/releases/components/release_block_milestone_info.vue'; import { MAX_MILESTONES_TO_DISPLAY } from '~/releases/constants'; -import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; const { milestones: originalMilestones } = getJSONFixture('api/releases/release.json'); diff --git a/spec/frontend/releases/components/release_block_spec.js b/spec/frontend/releases/components/release_block_spec.js index 633c6690529..1ca441f7a5a 100644 --- a/spec/frontend/releases/components/release_block_spec.js +++ b/spec/frontend/releases/components/release_block_spec.js @@ -1,13 +1,13 @@ -import $ from 'jquery'; import { mount } from '@vue/test-utils'; +import $ from 'jquery'; import { getJSONFixture } from 'helpers/fixtures'; +import * as commonUtils from '~/lib/utils/common_utils'; +import * as urlUtility from '~/lib/utils/url_utility'; import EvidenceBlock from '~/releases/components/evidence_block.vue'; import ReleaseBlock from '~/releases/components/release_block.vue'; import ReleaseBlockFooter from '~/releases/components/release_block_footer.vue'; -import timeagoMixin from '~/vue_shared/mixins/timeago'; -import * as commonUtils from '~/lib/utils/common_utils'; import { BACK_URL_PARAM } from '~/releases/constants'; -import * as urlUtility from '~/lib/utils/url_utility'; +import timeagoMixin from '~/vue_shared/mixins/timeago'; const originalRelease = getJSONFixture('api/releases/release.json'); diff --git a/spec/frontend/releases/components/release_skeleton_loader_spec.js b/spec/frontend/releases/components/release_skeleton_loader_spec.js index 7fbf864568a..7f81081ff6c 100644 --- a/spec/frontend/releases/components/release_skeleton_loader_spec.js +++ b/spec/frontend/releases/components/release_skeleton_loader_spec.js @@ -1,5 +1,5 @@ -import { mount } from '@vue/test-utils'; import { GlSkeletonLoader } from '@gitlab/ui'; +import { mount } from '@vue/test-utils'; import ReleaseSkeletonLoader from '~/releases/components/release_skeleton_loader.vue'; describe('release_skeleton_loader.vue', () => { diff --git a/spec/frontend/releases/components/releases_pagination_graphql_spec.js b/spec/frontend/releases/components/releases_pagination_graphql_spec.js index cee5e72e1c0..de80d82e93c 100644 --- a/spec/frontend/releases/components/releases_pagination_graphql_spec.js +++ b/spec/frontend/releases/components/releases_pagination_graphql_spec.js @@ -1,9 +1,9 @@ -import Vuex from 'vuex'; import { mount, createLocalVue } from '@vue/test-utils'; +import Vuex from 'vuex'; +import { historyPushState } from '~/lib/utils/common_utils'; +import ReleasesPaginationGraphql from '~/releases/components/releases_pagination_graphql.vue'; import createStore from '~/releases/stores'; import createListModule from '~/releases/stores/modules/list'; -import ReleasesPaginationGraphql from '~/releases/components/releases_pagination_graphql.vue'; -import { historyPushState } from '~/lib/utils/common_utils'; jest.mock('~/lib/utils/common_utils', () => ({ ...jest.requireActual('~/lib/utils/common_utils'), diff --git a/spec/frontend/releases/components/releases_pagination_rest_spec.js b/spec/frontend/releases/components/releases_pagination_rest_spec.js index b015792c96b..6f2690f5322 100644 --- a/spec/frontend/releases/components/releases_pagination_rest_spec.js +++ b/spec/frontend/releases/components/releases_pagination_rest_spec.js @@ -1,10 +1,10 @@ -import Vuex from 'vuex'; -import { mount, createLocalVue } from '@vue/test-utils'; import { GlPagination } from '@gitlab/ui'; +import { mount, createLocalVue } from '@vue/test-utils'; +import Vuex from 'vuex'; +import * as commonUtils from '~/lib/utils/common_utils'; import ReleasesPaginationRest from '~/releases/components/releases_pagination_rest.vue'; import createStore from '~/releases/stores'; import createListModule from '~/releases/stores/modules/list'; -import * as commonUtils from '~/lib/utils/common_utils'; commonUtils.historyPushState = jest.fn(); diff --git a/spec/frontend/releases/components/releases_sort_spec.js b/spec/frontend/releases/components/releases_sort_spec.js index c089ee3cc38..f17c6678592 100644 --- a/spec/frontend/releases/components/releases_sort_spec.js +++ b/spec/frontend/releases/components/releases_sort_spec.js @@ -1,6 +1,6 @@ -import Vuex from 'vuex'; import { GlSorting, GlSortingItem } from '@gitlab/ui'; import { shallowMount, createLocalVue } from '@vue/test-utils'; +import Vuex from 'vuex'; import ReleasesSort from '~/releases/components/releases_sort.vue'; import createStore from '~/releases/stores'; import createListModule from '~/releases/stores/modules/list'; diff --git a/spec/frontend/releases/components/tag_field_exsting_spec.js b/spec/frontend/releases/components/tag_field_exsting_spec.js index d4110b57776..cef7a0272a6 100644 --- a/spec/frontend/releases/components/tag_field_exsting_spec.js +++ b/spec/frontend/releases/components/tag_field_exsting_spec.js @@ -1,6 +1,6 @@ -import Vuex from 'vuex'; import { GlFormInput } from '@gitlab/ui'; import { shallowMount, mount, createLocalVue } from '@vue/test-utils'; +import Vuex from 'vuex'; import TagFieldExisting from '~/releases/components/tag_field_existing.vue'; import createStore from '~/releases/stores'; import createDetailModule from '~/releases/stores/modules/detail'; diff --git a/spec/frontend/releases/components/tag_field_new_spec.js b/spec/frontend/releases/components/tag_field_new_spec.js index eba0e286b27..d87718138b8 100644 --- a/spec/frontend/releases/components/tag_field_new_spec.js +++ b/spec/frontend/releases/components/tag_field_new_spec.js @@ -1,9 +1,9 @@ -import { mount, shallowMount } from '@vue/test-utils'; import { GlFormInput } from '@gitlab/ui'; +import { mount, shallowMount } from '@vue/test-utils'; +import RefSelector from '~/ref/components/ref_selector.vue'; import TagFieldNew from '~/releases/components/tag_field_new.vue'; import createStore from '~/releases/stores'; import createDetailModule from '~/releases/stores/modules/detail'; -import RefSelector from '~/ref/components/ref_selector.vue'; const TEST_TAG_NAME = 'test-tag-name'; const TEST_PROJECT_ID = '1234'; diff --git a/spec/frontend/releases/components/tag_field_spec.js b/spec/frontend/releases/components/tag_field_spec.js index c7909a2369b..2cf5944f9e6 100644 --- a/spec/frontend/releases/components/tag_field_spec.js +++ b/spec/frontend/releases/components/tag_field_spec.js @@ -1,7 +1,7 @@ import { shallowMount } from '@vue/test-utils'; import TagField from '~/releases/components/tag_field.vue'; -import TagFieldNew from '~/releases/components/tag_field_new.vue'; import TagFieldExisting from '~/releases/components/tag_field_existing.vue'; +import TagFieldNew from '~/releases/components/tag_field_new.vue'; import createStore from '~/releases/stores'; import createDetailModule from '~/releases/stores/modules/detail'; diff --git a/spec/frontend/releases/stores/modules/detail/actions_spec.js b/spec/frontend/releases/stores/modules/detail/actions_spec.js index 396e7bd8745..9c125fbb87b 100644 --- a/spec/frontend/releases/stores/modules/detail/actions_spec.js +++ b/spec/frontend/releases/stores/modules/detail/actions_spec.js @@ -1,17 +1,17 @@ import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; -import testAction from 'helpers/vuex_action_helper'; -import { getJSONFixture } from 'helpers/fixtures'; import { cloneDeep } from 'lodash'; -import * as actions from '~/releases/stores/modules/detail/actions'; -import * as types from '~/releases/stores/modules/detail/mutation_types'; -import createState from '~/releases/stores/modules/detail/state'; +import { getJSONFixture } from 'helpers/fixtures'; +import testAction from 'helpers/vuex_action_helper'; +import api from '~/api'; import { deprecatedCreateFlash as createFlash } from '~/flash'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; -import { redirectTo } from '~/lib/utils/url_utility'; -import api from '~/api'; import httpStatus from '~/lib/utils/http_status'; +import { redirectTo } from '~/lib/utils/url_utility'; import { ASSET_LINK_TYPE } from '~/releases/constants'; +import * as actions from '~/releases/stores/modules/detail/actions'; +import * as types from '~/releases/stores/modules/detail/mutation_types'; +import createState from '~/releases/stores/modules/detail/state'; import { releaseToApiJson, apiJsonToRelease } from '~/releases/util'; jest.mock('~/flash'); diff --git a/spec/frontend/releases/stores/modules/detail/mutations_spec.js b/spec/frontend/releases/stores/modules/detail/mutations_spec.js index 88eddc4019c..cdf26bfa834 100644 --- a/spec/frontend/releases/stores/modules/detail/mutations_spec.js +++ b/spec/frontend/releases/stores/modules/detail/mutations_spec.js @@ -1,9 +1,9 @@ import { getJSONFixture } from 'helpers/fixtures'; -import createState from '~/releases/stores/modules/detail/state'; -import mutations from '~/releases/stores/modules/detail/mutations'; -import * as types from '~/releases/stores/modules/detail/mutation_types'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import { ASSET_LINK_TYPE, DEFAULT_ASSET_LINK_TYPE } from '~/releases/constants'; +import * as types from '~/releases/stores/modules/detail/mutation_types'; +import mutations from '~/releases/stores/modules/detail/mutations'; +import createState from '~/releases/stores/modules/detail/state'; const originalRelease = getJSONFixture('api/releases/release.json'); diff --git a/spec/frontend/releases/stores/modules/list/actions_spec.js b/spec/frontend/releases/stores/modules/list/actions_spec.js index 35551b77dc4..309f7387929 100644 --- a/spec/frontend/releases/stores/modules/list/actions_spec.js +++ b/spec/frontend/releases/stores/modules/list/actions_spec.js @@ -1,6 +1,14 @@ import { cloneDeep } from 'lodash'; -import testAction from 'helpers/vuex_action_helper'; import { getJSONFixture } from 'helpers/fixtures'; +import testAction from 'helpers/vuex_action_helper'; +import api from '~/api'; +import { + normalizeHeaders, + parseIntPagination, + convertObjectPropsToCamelCase, +} from '~/lib/utils/common_utils'; +import { PAGE_SIZE } from '~/releases/constants'; +import allReleasesQuery from '~/releases/queries/all_releases.query.graphql'; import { fetchReleases, fetchReleasesGraphQl, @@ -8,18 +16,10 @@ import { receiveReleasesError, setSorting, } from '~/releases/stores/modules/list/actions'; -import createState from '~/releases/stores/modules/list/state'; import * as types from '~/releases/stores/modules/list/mutation_types'; -import api from '~/api'; +import createState from '~/releases/stores/modules/list/state'; import { gqClient, convertAllReleasesGraphQLResponse } from '~/releases/util'; -import { - normalizeHeaders, - parseIntPagination, - convertObjectPropsToCamelCase, -} from '~/lib/utils/common_utils'; import { pageInfoHeadersWithoutPagination } from '../../../mock_data'; -import allReleasesQuery from '~/releases/queries/all_releases.query.graphql'; -import { PAGE_SIZE } from '~/releases/constants'; const originalRelease = getJSONFixture('api/releases/release.json'); const originalReleases = [originalRelease]; diff --git a/spec/frontend/releases/stores/modules/list/mutations_spec.js b/spec/frontend/releases/stores/modules/list/mutations_spec.js index 78071573072..ea6a4ada16a 100644 --- a/spec/frontend/releases/stores/modules/list/mutations_spec.js +++ b/spec/frontend/releases/stores/modules/list/mutations_spec.js @@ -1,10 +1,10 @@ import { getJSONFixture } from 'helpers/fixtures'; -import createState from '~/releases/stores/modules/list/state'; -import mutations from '~/releases/stores/modules/list/mutations'; -import * as types from '~/releases/stores/modules/list/mutation_types'; import { parseIntPagination, convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; -import { pageInfoHeadersWithoutPagination } from '../../../mock_data'; +import * as types from '~/releases/stores/modules/list/mutation_types'; +import mutations from '~/releases/stores/modules/list/mutations'; +import createState from '~/releases/stores/modules/list/state'; import { convertAllReleasesGraphQLResponse } from '~/releases/util'; +import { pageInfoHeadersWithoutPagination } from '../../../mock_data'; const originalRelease = getJSONFixture('api/releases/release.json'); const originalReleases = [originalRelease]; |