Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
06f5f500
Commit
06f5f500
authored
Oct 08, 2021
by
Albert Salim
Committed by
Mike Greiling
Oct 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use import for json fixture - 1/7
parent
95862f8c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
26 deletions
+22
-26
spec/frontend/gfm_auto_complete_spec.js
spec/frontend/gfm_auto_complete_spec.js
+1
-3
spec/frontend/ref/components/ref_selector_spec.js
spec/frontend/ref/components/ref_selector_spec.js
+4
-7
spec/frontend/related_merge_requests/components/related_merge_requests_spec.js
..._merge_requests/components/related_merge_requests_spec.js
+1
-5
spec/frontend/runner/mock_data.js
spec/frontend/runner/mock_data.js
+13
-9
spec/frontend/users_select/test_helper.js
spec/frontend/users_select/test_helper.js
+3
-2
No files found.
spec/frontend/gfm_auto_complete_spec.js
View file @
06f5f500
/* eslint no-param-reassign: "off" */
/* eslint no-param-reassign: "off" */
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
labelsFixture
from
'
test_fixtures/autocomplete_sources/labels.json
'
;
import
GfmAutoComplete
,
{
membersBeforeSave
}
from
'
ee_else_ce/gfm_auto_complete
'
;
import
GfmAutoComplete
,
{
membersBeforeSave
}
from
'
ee_else_ce/gfm_auto_complete
'
;
import
{
initEmojiMock
}
from
'
helpers/emoji
'
;
import
{
initEmojiMock
}
from
'
helpers/emoji
'
;
import
'
~/lib/utils/jquery_at_who
'
;
import
'
~/lib/utils/jquery_at_who
'
;
import
{
getJSONFixture
}
from
'
helpers/fixtures
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
AjaxCache
from
'
~/lib/utils/ajax_cache
'
;
import
AjaxCache
from
'
~/lib/utils/ajax_cache
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
const
labelsFixture
=
getJSONFixture
(
'
autocomplete_sources/labels.json
'
);
describe
(
'
GfmAutoComplete
'
,
()
=>
{
describe
(
'
GfmAutoComplete
'
,
()
=>
{
const
fetchDataMock
=
{
fetchData
:
jest
.
fn
()
};
const
fetchDataMock
=
{
fetchData
:
jest
.
fn
()
};
let
gfmAutoCompleteCallbacks
=
GfmAutoComplete
.
prototype
.
getDefaultCallbacks
.
call
(
fetchDataMock
);
let
gfmAutoCompleteCallbacks
=
GfmAutoComplete
.
prototype
.
getDefaultCallbacks
.
call
(
fetchDataMock
);
...
...
spec/frontend/ref/components/ref_selector_spec.js
View file @
06f5f500
...
@@ -4,6 +4,9 @@ import axios from 'axios';
...
@@ -4,6 +4,9 @@ import axios from 'axios';
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
{
merge
,
last
}
from
'
lodash
'
;
import
{
merge
,
last
}
from
'
lodash
'
;
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
commit
from
'
test_fixtures/api/commits/commit.json
'
;
import
branches
from
'
test_fixtures/api/branches/branches.json
'
;
import
tags
from
'
test_fixtures/api/tags/tags.json
'
;
import
{
trimText
}
from
'
helpers/text_helper
'
;
import
{
trimText
}
from
'
helpers/text_helper
'
;
import
{
ENTER_KEY
}
from
'
~/lib/utils/keys
'
;
import
{
ENTER_KEY
}
from
'
~/lib/utils/keys
'
;
import
{
sprintf
}
from
'
~/locale
'
;
import
{
sprintf
}
from
'
~/locale
'
;
...
@@ -21,11 +24,7 @@ const localVue = createLocalVue();
...
@@ -21,11 +24,7 @@ const localVue = createLocalVue();
localVue
.
use
(
Vuex
);
localVue
.
use
(
Vuex
);
describe
(
'
Ref selector component
'
,
()
=>
{
describe
(
'
Ref selector component
'
,
()
=>
{
const
fixtures
=
{
const
fixtures
=
{
branches
,
tags
,
commit
};
branches
:
getJSONFixture
(
'
api/branches/branches.json
'
),
tags
:
getJSONFixture
(
'
api/tags/tags.json
'
),
commit
:
getJSONFixture
(
'
api/commits/commit.json
'
),
};
const
projectId
=
'
8
'
;
const
projectId
=
'
8
'
;
...
@@ -480,8 +479,6 @@ describe('Ref selector component', () => {
...
@@ -480,8 +479,6 @@ describe('Ref selector component', () => {
it
(
'
renders each commit as a selectable item with the short SHA and commit title
'
,
()
=>
{
it
(
'
renders each commit as a selectable item with the short SHA and commit title
'
,
()
=>
{
const
dropdownItems
=
findCommitDropdownItems
();
const
dropdownItems
=
findCommitDropdownItems
();
const
{
commit
}
=
fixtures
;
expect
(
dropdownItems
.
at
(
0
).
text
()).
toBe
(
`
${
commit
.
short_id
}
${
commit
.
title
}
`
);
expect
(
dropdownItems
.
at
(
0
).
text
()).
toBe
(
`
${
commit
.
short_id
}
${
commit
.
title
}
`
);
});
});
});
});
...
...
spec/frontend/related_merge_requests/components/related_merge_requests_spec.js
View file @
06f5f500
import
{
mount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
mount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
mockData
from
'
test_fixtures/issues/related_merge_requests.json
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
RelatedMergeRequests
from
'
~/related_merge_requests/components/related_merge_requests.vue
'
;
import
RelatedMergeRequests
from
'
~/related_merge_requests/components/related_merge_requests.vue
'
;
import
createStore
from
'
~/related_merge_requests/store/index
'
;
import
createStore
from
'
~/related_merge_requests/store/index
'
;
import
RelatedIssuableItem
from
'
~/vue_shared/components/issue/related_issuable_item.vue
'
;
import
RelatedIssuableItem
from
'
~/vue_shared/components/issue/related_issuable_item.vue
'
;
const
FIXTURE_PATH
=
'
issues/related_merge_requests.json
'
;
const
API_ENDPOINT
=
'
/api/v4/projects/2/issues/33/related_merge_requests
'
;
const
API_ENDPOINT
=
'
/api/v4/projects/2/issues/33/related_merge_requests
'
;
const
localVue
=
createLocalVue
();
const
localVue
=
createLocalVue
();
describe
(
'
RelatedMergeRequests
'
,
()
=>
{
describe
(
'
RelatedMergeRequests
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
let
mock
;
let
mock
;
let
mockData
;
beforeEach
((
done
)
=>
{
beforeEach
((
done
)
=>
{
loadFixtures
(
FIXTURE_PATH
);
mockData
=
getJSONFixture
(
FIXTURE_PATH
);
// put the fixture in DOM as the component expects
// put the fixture in DOM as the component expects
document
.
body
.
innerHTML
=
`<div id="js-issuable-app"></div>`
;
document
.
body
.
innerHTML
=
`<div id="js-issuable-app"></div>`
;
document
.
getElementById
(
'
js-issuable-app
'
).
dataset
.
initial
=
JSON
.
stringify
(
mockData
);
document
.
getElementById
(
'
js-issuable-app
'
).
dataset
.
initial
=
JSON
.
stringify
(
mockData
);
...
...
spec/frontend/runner/mock_data.js
View file @
06f5f500
const
runnerFixture
=
(
filename
)
=>
getJSONFixture
(
`graphql/runner/
${
filename
}
`
);
// Fixtures generated by: spec/frontend/fixtures/runner.rb
// Fixtures generated by: spec/frontend/fixtures/runner.rb
// Admin queries
// Admin queries
export
const
runnersData
=
runnerFixture
(
'
get_runners.query.graphql.json
'
)
;
import
runnersData
from
'
test_fixtures/graphql/runner/get_runners.query.graphql.json
'
;
export
const
runnersDataPaginated
=
runnerFixture
(
'
get_runners.query.graphql.paginated.json
'
)
;
import
runnersDataPaginated
from
'
test_fixtures/graphql/runner/get_runners.query.graphql.paginated.json
'
;
export
const
runnerData
=
runnerFixture
(
'
get_runner.query.graphql.json
'
)
;
import
runnerData
from
'
test_fixtures/graphql/runner/get_runner.query.graphql.json
'
;
// Group queries
// Group queries
export
const
groupRunnersData
=
runnerFixture
(
'
get_group_runners.query.graphql.json
'
);
import
groupRunnersData
from
'
test_fixtures/graphql/runner/get_group_runners.query.graphql.json
'
;
export
const
groupRunnersDataPaginated
=
runnerFixture
(
import
groupRunnersDataPaginated
from
'
test_fixtures/graphql/runner/get_group_runners.query.graphql.paginated.json
'
;
'
get_group_runners.query.graphql.paginated.json
'
,
);
export
{
runnerData
,
runnersDataPaginated
,
runnersData
,
groupRunnersData
,
groupRunnersDataPaginated
,
};
spec/frontend/users_select/test_helper.js
View file @
06f5f500
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
{
memoize
,
cloneDeep
}
from
'
lodash
'
;
import
{
memoize
,
cloneDeep
}
from
'
lodash
'
;
import
{
getFixture
,
getJSONFixture
}
from
'
helpers/fixtures
'
;
import
usersFixture
from
'
test_fixtures/autocomplete/users.json
'
;
import
{
getFixture
}
from
'
helpers/fixtures
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
UsersSelect
from
'
~/users_select
'
;
import
UsersSelect
from
'
~/users_select
'
;
...
@@ -15,7 +16,7 @@ const getUserSearchHTML = memoize((fixturePath) => {
...
@@ -15,7 +16,7 @@ const getUserSearchHTML = memoize((fixturePath) => {
return
el
.
outerHTML
;
return
el
.
outerHTML
;
});
});
const
getUsersFixture
=
memoize
(()
=>
getJSONFixture
(
'
autocomplete/users.json
'
))
;
const
getUsersFixture
=
()
=>
usersFixture
;
export
const
getUsersFixtureAt
=
(
idx
)
=>
getUsersFixture
()[
idx
];
export
const
getUsersFixtureAt
=
(
idx
)
=>
getUsersFixture
()[
idx
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment