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
5b8e339e
Commit
5b8e339e
authored
Aug 28, 2020
by
Vitaly Slobodin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor pipelines list spec for Vuex upgrade
parent
a2662bf5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
30 deletions
+33
-30
spec/frontend/ide/components/pipelines/list_spec.js
spec/frontend/ide/components/pipelines/list_spec.js
+33
-30
No files found.
spec/frontend/ide/components/pipelines/list_spec.js
View file @
5b8e339e
...
...
@@ -22,11 +22,11 @@ describe('IDE pipelines list', () => {
const
defaultState
=
{
links
:
{
ciHelpPagePath
:
TEST_HOST
},
pipelinesEmptyStateSvgPath
:
TEST_HOST
,
pipelines
:
{
stages
:
[],
failedS
tages
:
[],
isLoadingJobs
:
false
,
}
,
};
const
defaultPipelinesState
=
{
s
tages
:
[],
failedStages
:
[]
,
isLoadingJobs
:
false
,
};
const
fetchLatestPipelineMock
=
jest
.
fn
();
...
...
@@ -34,23 +34,20 @@ describe('IDE pipelines list', () => {
const
failedStagesGetterMock
=
jest
.
fn
().
mockReturnValue
([]);
const
fakeProjectPath
=
'
alpha/beta
'
;
const
createComponent
=
(
state
=
{})
=>
{
const
{
pipelines
:
pipelinesState
,
...
restOfState
}
=
state
;
const
{
defaultPipelines
,
...
defaultRestOfState
}
=
defaultState
;
const
fakeStore
=
new
Vuex
.
Store
({
const
createStore
=
(
rootState
,
pipelinesState
)
=>
{
return
new
Vuex
.
Store
({
getters
:
{
currentProject
:
()
=>
({
web_url
:
'
some/url
'
,
path_with_namespace
:
fakeProjectPath
}),
},
state
:
{
...
default
RestOf
State
,
...
r
estOf
State
,
...
defaultState
,
...
r
oot
State
,
},
modules
:
{
pipelines
:
{
namespaced
:
true
,
state
:
{
...
defaultPipelines
,
...
defaultPipelines
State
,
...
pipelinesState
,
},
actions
:
{
...
...
@@ -69,10 +66,12 @@ describe('IDE pipelines list', () => {
},
},
});
};
const
createComponent
=
(
state
=
{},
pipelinesState
=
{})
=>
{
wrapper
=
shallowMount
(
List
,
{
localVue
,
store
:
fakeStore
,
store
:
createStore
(
state
,
pipelinesState
)
,
});
};
...
...
@@ -94,31 +93,33 @@ describe('IDE pipelines list', () => {
describe
(
'
when loading
'
,
()
=>
{
let
defaultPipelinesLoadingState
;
beforeAll
(()
=>
{
defaultPipelinesLoadingState
=
{
...
defaultState
.
pipelines
,
isLoadingPipeline
:
true
,
};
});
it
(
'
does not render when pipeline has loaded before
'
,
()
=>
{
createComponent
({
pipelines
:
{
createComponent
(
{},
{
...
defaultPipelinesLoadingState
,
hasLoadedPipeline
:
true
,
},
}
);
);
expect
(
wrapper
.
find
(
GlLoadingIcon
).
exists
()).
toBe
(
false
);
});
it
(
'
renders loading state
'
,
()
=>
{
createComponent
({
pipelines
:
{
createComponent
(
{},
{
...
defaultPipelinesLoadingState
,
hasLoadedPipeline
:
false
,
},
}
);
);
expect
(
wrapper
.
find
(
GlLoadingIcon
).
exists
()).
toBe
(
true
);
});
...
...
@@ -126,21 +127,22 @@ describe('IDE pipelines list', () => {
describe
(
'
when loaded
'
,
()
=>
{
let
defaultPipelinesLoadedState
;
beforeAll
(()
=>
{
defaultPipelinesLoadedState
=
{
...
defaultState
.
pipelines
,
isLoadingPipeline
:
false
,
hasLoadedPipeline
:
true
,
};
});
it
(
'
renders empty state when no latestPipeline
'
,
()
=>
{
createComponent
({
pipelines
:
{
...
defaultPipelinesLoadedState
,
latestPipeline
:
null
}
});
createComponent
({
},
{
...
defaultPipelinesLoadedState
,
latestPipeline
:
null
});
expect
(
wrapper
.
element
).
toMatchSnapshot
();
});
describe
(
'
with latest pipeline loaded
'
,
()
=>
{
let
withLatestPipelineState
;
beforeAll
(()
=>
{
withLatestPipelineState
=
{
...
defaultPipelinesLoadedState
,
...
...
@@ -149,12 +151,12 @@ describe('IDE pipelines list', () => {
});
it
(
'
renders ci icon
'
,
()
=>
{
createComponent
({
pipelines
:
withLatestPipelineState
}
);
createComponent
({
},
withLatestPipelineState
);
expect
(
wrapper
.
find
(
CiIcon
).
exists
()).
toBe
(
true
);
});
it
(
'
renders pipeline data
'
,
()
=>
{
createComponent
({
pipelines
:
withLatestPipelineState
}
);
createComponent
({
},
withLatestPipelineState
);
expect
(
wrapper
.
text
()).
toContain
(
'
#1
'
);
});
...
...
@@ -162,7 +164,7 @@ describe('IDE pipelines list', () => {
it
(
'
renders list of jobs
'
,
()
=>
{
const
stages
=
[];
const
isLoadingJobs
=
true
;
createComponent
({
pipelines
:
{
...
withLatestPipelineState
,
stages
,
isLoadingJobs
}
});
createComponent
({
},
{
...
withLatestPipelineState
,
stages
,
isLoadingJobs
});
const
jobProps
=
wrapper
.
findAll
(
Tab
)
...
...
@@ -177,7 +179,7 @@ describe('IDE pipelines list', () => {
const
failedStages
=
[];
failedStagesGetterMock
.
mockReset
().
mockReturnValue
(
failedStages
);
const
isLoadingJobs
=
true
;
createComponent
({
pipelines
:
{
...
withLatestPipelineState
,
isLoadingJobs
}
});
createComponent
({
},
{
...
withLatestPipelineState
,
isLoadingJobs
});
const
jobProps
=
wrapper
.
findAll
(
Tab
)
...
...
@@ -191,12 +193,13 @@ describe('IDE pipelines list', () => {
describe
(
'
with YAML error
'
,
()
=>
{
it
(
'
renders YAML error
'
,
()
=>
{
const
yamlError
=
'
test yaml error
'
;
createComponent
({
pipelines
:
{
createComponent
(
{},
{
...
defaultPipelinesLoadedState
,
latestPipeline
:
{
...
pipelines
[
0
],
yamlError
},
},
}
);
);
expect
(
wrapper
.
text
()).
toContain
(
'
Found errors in your .gitlab-ci.yml:
'
);
expect
(
wrapper
.
text
()).
toContain
(
yamlError
);
...
...
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