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
79416de2
Commit
79416de2
authored
Feb 10, 2022
by
Janis Altherr
Committed by
David O'Regan
Feb 10, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the step_nav component to be used by the Pipeline Wizard
Signed-off-by:
Janis Altherr
<
jaltherr@gitlab.com
>
parent
33c3e20e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
133 additions
and
0 deletions
+133
-0
app/assets/javascripts/pipeline_wizard/components/step_nav.vue
...ssets/javascripts/pipeline_wizard/components/step_nav.vue
+54
-0
spec/frontend/pipeline_wizard/components/step_nav_spec.js
spec/frontend/pipeline_wizard/components/step_nav_spec.js
+79
-0
No files found.
app/assets/javascripts/pipeline_wizard/components/step_nav.vue
0 → 100644
View file @
79416de2
<
script
>
import
{
GlButton
}
from
'
@gitlab/ui
'
;
export
default
{
name
:
'
StepNav
'
,
components
:
{
GlButton
,
},
props
:
{
showBackButton
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
showNextButton
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
nextButtonEnabled
:
{
type
:
Boolean
,
required
:
false
,
default
:
true
,
},
},
};
</
script
>
<
template
>
<div>
<slot
name=
"before"
></slot>
<gl-button
v-if=
"showBackButton"
category=
"secondary"
data-testid=
"back-button"
@
click=
"$emit('back')"
>
{{
__
(
'
Back
'
)
}}
</gl-button>
<gl-button
v-if=
"showNextButton"
:disabled=
"!nextButtonEnabled"
category=
"primary"
data-testid=
"next-button"
variant=
"confirm"
@
click=
"$emit('next')"
>
{{
__
(
'
Next
'
)
}}
</gl-button>
<slot
name=
"after"
></slot>
</div>
</
template
>
<
style
scoped
></
style
>
spec/frontend/pipeline_wizard/components/step_nav_spec.js
0 → 100644
View file @
79416de2
import
{
mountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
StepNav
from
'
~/pipeline_wizard/components/step_nav.vue
'
;
describe
(
'
Pipeline Wizard - Step Navigation Component
'
,
()
=>
{
const
defaultProps
=
{
showBackButton
:
true
,
showNextButton
:
true
};
let
wrapper
;
let
prevButton
;
let
nextButton
;
const
createComponent
=
(
props
=
{})
=>
{
wrapper
=
mountExtended
(
StepNav
,
{
propsData
:
{
...
defaultProps
,
...
props
,
},
});
prevButton
=
wrapper
.
findByTestId
(
'
back-button
'
);
nextButton
=
wrapper
.
findByTestId
(
'
next-button
'
);
};
afterEach
(()
=>
{
wrapper
.
destroy
();
});
it
.
each
`
scenario | showBackButton | showNextButton
${
'
does not show prev button
'
}
|
${
false
}
|
${
false
}
${
'
has prev, but not next
'
}
|
${
true
}
|
${
false
}
${
'
has next, but not prev
'
}
|
${
false
}
|
${
true
}
${
'
has both next and prev
'
}
|
${
true
}
|
${
true
}
`
(
'
$scenario
'
,
async
({
showBackButton
,
showNextButton
})
=>
{
createComponent
({
showBackButton
,
showNextButton
});
expect
(
prevButton
.
exists
()).
toBe
(
showBackButton
);
expect
(
nextButton
.
exists
()).
toBe
(
showNextButton
);
});
it
(
'
shows the expected button text
'
,
()
=>
{
createComponent
();
expect
(
prevButton
.
text
()).
toBe
(
'
Back
'
);
expect
(
nextButton
.
text
()).
toBe
(
'
Next
'
);
});
it
(
'
emits "back" events when clicking prev button
'
,
async
()
=>
{
createComponent
();
await
prevButton
.
trigger
(
'
click
'
);
expect
(
wrapper
.
emitted
().
back
.
length
).
toBe
(
1
);
});
it
(
'
emits "next" events when clicking next button
'
,
async
()
=>
{
createComponent
();
await
nextButton
.
trigger
(
'
click
'
);
expect
(
wrapper
.
emitted
().
next
.
length
).
toBe
(
1
);
});
it
(
'
enables the next button if nextButtonEnabled ist set to true
'
,
async
()
=>
{
createComponent
({
nextButtonEnabled
:
true
});
expect
(
nextButton
.
attributes
(
'
disabled
'
)).
not
.
toBe
(
'
disabled
'
);
});
it
(
'
disables the next button if nextButtonEnabled ist set to false
'
,
async
()
=>
{
createComponent
({
nextButtonEnabled
:
false
});
expect
(
nextButton
.
attributes
(
'
disabled
'
)).
toBe
(
'
disabled
'
);
});
it
(
'
does not emit "next" event when clicking next button while nextButtonEnabled ist set to false
'
,
async
()
=>
{
createComponent
({
nextButtonEnabled
:
false
});
await
nextButton
.
trigger
(
'
click
'
);
expect
(
wrapper
.
emitted
().
next
).
toBe
(
undefined
);
});
});
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