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', () => {
...
@@ -22,11 +22,11 @@ describe('IDE pipelines list', () => {
const
defaultState
=
{
const
defaultState
=
{
links
:
{
ciHelpPagePath
:
TEST_HOST
},
links
:
{
ciHelpPagePath
:
TEST_HOST
},
pipelinesEmptyStateSvgPath
:
TEST_HOST
,
pipelinesEmptyStateSvgPath
:
TEST_HOST
,
pipelines
:
{
};
stages
:
[],
const
defaultPipelinesState
=
{
failedS
tages
:
[],
s
tages
:
[],
isLoadingJobs
:
false
,
failedStages
:
[]
,
}
,
isLoadingJobs
:
false
,
};
};
const
fetchLatestPipelineMock
=
jest
.
fn
();
const
fetchLatestPipelineMock
=
jest
.
fn
();
...
@@ -34,23 +34,20 @@ describe('IDE pipelines list', () => {
...
@@ -34,23 +34,20 @@ describe('IDE pipelines list', () => {
const
failedStagesGetterMock
=
jest
.
fn
().
mockReturnValue
([]);
const
failedStagesGetterMock
=
jest
.
fn
().
mockReturnValue
([]);
const
fakeProjectPath
=
'
alpha/beta
'
;
const
fakeProjectPath
=
'
alpha/beta
'
;
const
createComponent
=
(
state
=
{})
=>
{
const
createStore
=
(
rootState
,
pipelinesState
)
=>
{
const
{
pipelines
:
pipelinesState
,
...
restOfState
}
=
state
;
return
new
Vuex
.
Store
({
const
{
defaultPipelines
,
...
defaultRestOfState
}
=
defaultState
;
const
fakeStore
=
new
Vuex
.
Store
({
getters
:
{
getters
:
{
currentProject
:
()
=>
({
web_url
:
'
some/url
'
,
path_with_namespace
:
fakeProjectPath
}),
currentProject
:
()
=>
({
web_url
:
'
some/url
'
,
path_with_namespace
:
fakeProjectPath
}),
},
},
state
:
{
state
:
{
...
default
RestOf
State
,
...
defaultState
,
...
r
estOf
State
,
...
r
oot
State
,
},
},
modules
:
{
modules
:
{
pipelines
:
{
pipelines
:
{
namespaced
:
true
,
namespaced
:
true
,
state
:
{
state
:
{
...
defaultPipelines
,
...
defaultPipelines
State
,
...
pipelinesState
,
...
pipelinesState
,
},
},
actions
:
{
actions
:
{
...
@@ -69,10 +66,12 @@ describe('IDE pipelines list', () => {
...
@@ -69,10 +66,12 @@ describe('IDE pipelines list', () => {
},
},
},
},
});
});
};
const
createComponent
=
(
state
=
{},
pipelinesState
=
{})
=>
{
wrapper
=
shallowMount
(
List
,
{
wrapper
=
shallowMount
(
List
,
{
localVue
,
localVue
,
store
:
fakeStore
,
store
:
createStore
(
state
,
pipelinesState
)
,
});
});
};
};
...
@@ -94,31 +93,33 @@ describe('IDE pipelines list', () => {
...
@@ -94,31 +93,33 @@ describe('IDE pipelines list', () => {
describe
(
'
when loading
'
,
()
=>
{
describe
(
'
when loading
'
,
()
=>
{
let
defaultPipelinesLoadingState
;
let
defaultPipelinesLoadingState
;
beforeAll
(()
=>
{
beforeAll
(()
=>
{
defaultPipelinesLoadingState
=
{
defaultPipelinesLoadingState
=
{
...
defaultState
.
pipelines
,
isLoadingPipeline
:
true
,
isLoadingPipeline
:
true
,
};
};
});
});
it
(
'
does not render when pipeline has loaded before
'
,
()
=>
{
it
(
'
does not render when pipeline has loaded before
'
,
()
=>
{
createComponent
({
createComponent
(
pipelines
:
{
{},
{
...
defaultPipelinesLoadingState
,
...
defaultPipelinesLoadingState
,
hasLoadedPipeline
:
true
,
hasLoadedPipeline
:
true
,
},
},
}
);
);
expect
(
wrapper
.
find
(
GlLoadingIcon
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
GlLoadingIcon
).
exists
()).
toBe
(
false
);
});
});
it
(
'
renders loading state
'
,
()
=>
{
it
(
'
renders loading state
'
,
()
=>
{
createComponent
({
createComponent
(
pipelines
:
{
{},
{
...
defaultPipelinesLoadingState
,
...
defaultPipelinesLoadingState
,
hasLoadedPipeline
:
false
,
hasLoadedPipeline
:
false
,
},
},
}
);
);
expect
(
wrapper
.
find
(
GlLoadingIcon
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
GlLoadingIcon
).
exists
()).
toBe
(
true
);
});
});
...
@@ -126,21 +127,22 @@ describe('IDE pipelines list', () => {
...
@@ -126,21 +127,22 @@ describe('IDE pipelines list', () => {
describe
(
'
when loaded
'
,
()
=>
{
describe
(
'
when loaded
'
,
()
=>
{
let
defaultPipelinesLoadedState
;
let
defaultPipelinesLoadedState
;
beforeAll
(()
=>
{
beforeAll
(()
=>
{
defaultPipelinesLoadedState
=
{
defaultPipelinesLoadedState
=
{
...
defaultState
.
pipelines
,
isLoadingPipeline
:
false
,
isLoadingPipeline
:
false
,
hasLoadedPipeline
:
true
,
hasLoadedPipeline
:
true
,
};
};
});
});
it
(
'
renders empty state when no latestPipeline
'
,
()
=>
{
it
(
'
renders empty state when no latestPipeline
'
,
()
=>
{
createComponent
({
pipelines
:
{
...
defaultPipelinesLoadedState
,
latestPipeline
:
null
}
});
createComponent
({
},
{
...
defaultPipelinesLoadedState
,
latestPipeline
:
null
});
expect
(
wrapper
.
element
).
toMatchSnapshot
();
expect
(
wrapper
.
element
).
toMatchSnapshot
();
});
});
describe
(
'
with latest pipeline loaded
'
,
()
=>
{
describe
(
'
with latest pipeline loaded
'
,
()
=>
{
let
withLatestPipelineState
;
let
withLatestPipelineState
;
beforeAll
(()
=>
{
beforeAll
(()
=>
{
withLatestPipelineState
=
{
withLatestPipelineState
=
{
...
defaultPipelinesLoadedState
,
...
defaultPipelinesLoadedState
,
...
@@ -149,12 +151,12 @@ describe('IDE pipelines list', () => {
...
@@ -149,12 +151,12 @@ describe('IDE pipelines list', () => {
});
});
it
(
'
renders ci icon
'
,
()
=>
{
it
(
'
renders ci icon
'
,
()
=>
{
createComponent
({
pipelines
:
withLatestPipelineState
}
);
createComponent
({
},
withLatestPipelineState
);
expect
(
wrapper
.
find
(
CiIcon
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
CiIcon
).
exists
()).
toBe
(
true
);
});
});
it
(
'
renders pipeline data
'
,
()
=>
{
it
(
'
renders pipeline data
'
,
()
=>
{
createComponent
({
pipelines
:
withLatestPipelineState
}
);
createComponent
({
},
withLatestPipelineState
);
expect
(
wrapper
.
text
()).
toContain
(
'
#1
'
);
expect
(
wrapper
.
text
()).
toContain
(
'
#1
'
);
});
});
...
@@ -162,7 +164,7 @@ describe('IDE pipelines list', () => {
...
@@ -162,7 +164,7 @@ describe('IDE pipelines list', () => {
it
(
'
renders list of jobs
'
,
()
=>
{
it
(
'
renders list of jobs
'
,
()
=>
{
const
stages
=
[];
const
stages
=
[];
const
isLoadingJobs
=
true
;
const
isLoadingJobs
=
true
;
createComponent
({
pipelines
:
{
...
withLatestPipelineState
,
stages
,
isLoadingJobs
}
});
createComponent
({
},
{
...
withLatestPipelineState
,
stages
,
isLoadingJobs
});
const
jobProps
=
wrapper
const
jobProps
=
wrapper
.
findAll
(
Tab
)
.
findAll
(
Tab
)
...
@@ -177,7 +179,7 @@ describe('IDE pipelines list', () => {
...
@@ -177,7 +179,7 @@ describe('IDE pipelines list', () => {
const
failedStages
=
[];
const
failedStages
=
[];
failedStagesGetterMock
.
mockReset
().
mockReturnValue
(
failedStages
);
failedStagesGetterMock
.
mockReset
().
mockReturnValue
(
failedStages
);
const
isLoadingJobs
=
true
;
const
isLoadingJobs
=
true
;
createComponent
({
pipelines
:
{
...
withLatestPipelineState
,
isLoadingJobs
}
});
createComponent
({
},
{
...
withLatestPipelineState
,
isLoadingJobs
});
const
jobProps
=
wrapper
const
jobProps
=
wrapper
.
findAll
(
Tab
)
.
findAll
(
Tab
)
...
@@ -191,12 +193,13 @@ describe('IDE pipelines list', () => {
...
@@ -191,12 +193,13 @@ describe('IDE pipelines list', () => {
describe
(
'
with YAML error
'
,
()
=>
{
describe
(
'
with YAML error
'
,
()
=>
{
it
(
'
renders YAML error
'
,
()
=>
{
it
(
'
renders YAML error
'
,
()
=>
{
const
yamlError
=
'
test yaml error
'
;
const
yamlError
=
'
test yaml error
'
;
createComponent
({
createComponent
(
pipelines
:
{
{},
{
...
defaultPipelinesLoadedState
,
...
defaultPipelinesLoadedState
,
latestPipeline
:
{
...
pipelines
[
0
],
yamlError
},
latestPipeline
:
{
...
pipelines
[
0
],
yamlError
},
},
},
}
);
);
expect
(
wrapper
.
text
()).
toContain
(
'
Found errors in your .gitlab-ci.yml:
'
);
expect
(
wrapper
.
text
()).
toContain
(
'
Found errors in your .gitlab-ci.yml:
'
);
expect
(
wrapper
.
text
()).
toContain
(
yamlError
);
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