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
1a52dd7e
Commit
1a52dd7e
authored
Aug 18, 2021
by
mgandres
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for commit sha polling
parent
a0ef8639
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
6 deletions
+47
-6
spec/frontend/pipeline_editor/components/commit/commit_section_spec.js
.../pipeline_editor/components/commit/commit_section_spec.js
+2
-3
spec/frontend/pipeline_editor/pipeline_editor_app_spec.js
spec/frontend/pipeline_editor/pipeline_editor_app_spec.js
+45
-3
No files found.
spec/frontend/pipeline_editor/components/commit/commit_section_spec.js
View file @
1a52dd7e
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
{
GlFormTextarea
,
GlFormInput
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
objectToQuery
,
redirectTo
}
from
'
~/lib/utils/url_utility
'
;
import
CommitForm
from
'
~/pipeline_editor/components/commit/commit_form.vue
'
;
import
CommitSection
from
'
~/pipeline_editor/components/commit/commit_section.vue
'
;
...
...
@@ -100,6 +100,7 @@ describe('Pipeline Editor | Commit section', () => {
await
findCommitForm
().
find
(
'
[data-testid="new-mr-checkbox"]
'
).
setChecked
(
openMergeRequest
);
}
await
findCommitForm
().
find
(
'
[type="submit"]
'
).
trigger
(
'
click
'
);
await
waitForPromises
();
};
const
cancelCommitForm
=
async
()
=>
{
...
...
@@ -157,7 +158,6 @@ describe('Pipeline Editor | Commit section', () => {
beforeEach
(
async
()
=>
{
createComponent
();
await
submitCommit
();
await
nextTick
();
});
it
(
'
calls the mutation with the current branch
'
,
()
=>
{
...
...
@@ -183,7 +183,6 @@ describe('Pipeline Editor | Commit section', () => {
it
(
'
a second commit submits the latest sha, keeping the form updated
'
,
async
()
=>
{
await
submitCommit
();
await
nextTick
();
expect
(
mockMutate
).
toHaveBeenCalledTimes
(
6
);
expect
(
mockMutate
).
toHaveBeenCalledWith
({
...
...
spec/frontend/pipeline_editor/pipeline_editor_app_spec.js
View file @
1a52dd7e
...
...
@@ -158,6 +158,10 @@ describe('Pipeline editor app component', () => {
describe
(
'
when file exists
'
,
()
=>
{
beforeEach
(
async
()
=>
{
await
createComponentWithApollo
();
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
.
queries
.
commitSha
,
'
startPolling
'
)
.
mockImplementation
(
jest
.
fn
());
});
it
(
'
shows pipeline editor home component
'
,
()
=>
{
...
...
@@ -175,18 +179,32 @@ describe('Pipeline editor app component', () => {
sha
:
mockCommitSha
,
});
});
it
(
'
does not poll for the commit sha
'
,
()
=>
{
expect
(
wrapper
.
vm
.
$apollo
.
queries
.
commitSha
.
startPolling
).
toHaveBeenCalledTimes
(
0
);
});
});
describe
(
'
when no CI config file exists
'
,
()
=>
{
it
(
'
shows an empty state and does not show editor home component
'
,
async
()
=>
{
beforeEach
(
async
()
=>
{
mockBlobContentData
.
mockResolvedValue
(
mockBlobContentQueryResponseNoCiFile
);
await
createComponentWithApollo
();
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
.
queries
.
commitSha
,
'
startPolling
'
)
.
mockImplementation
(
jest
.
fn
());
});
it
(
'
shows an empty state and does not show editor home component
'
,
async
()
=>
{
expect
(
findEmptyState
().
exists
()).
toBe
(
true
);
expect
(
findAlert
().
exists
()).
toBe
(
false
);
expect
(
findEditorHome
().
exists
()).
toBe
(
false
);
});
it
(
'
does not poll for the commit sha
'
,
()
=>
{
expect
(
wrapper
.
vm
.
$apollo
.
queries
.
commitSha
.
startPolling
).
toHaveBeenCalledTimes
(
0
);
});
describe
(
'
because of a fetching error
'
,
()
=>
{
it
(
'
shows a unkown error message
'
,
async
()
=>
{
const
loadUnknownFailureText
=
'
The CI configuration was not loaded, please try again.
'
;
...
...
@@ -249,9 +267,9 @@ describe('Pipeline editor app component', () => {
const
updateSuccessMessage
=
'
Your changes have been successfully committed.
'
;
describe
(
'
and the commit mutation succeeds
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
window
.
scrollTo
=
jest
.
fn
();
createComponent
();
await
createComponentWithApollo
();
findEditorHome
().
vm
.
$emit
(
'
commit
'
,
{
type
:
COMMIT_SUCCESS
});
});
...
...
@@ -263,6 +281,30 @@ describe('Pipeline editor app component', () => {
it
(
'
scrolls to the top of the page to bring attention to the confirmation message
'
,
()
=>
{
expect
(
window
.
scrollTo
).
toHaveBeenCalledWith
({
top
:
0
,
behavior
:
'
smooth
'
});
});
it
(
'
polls for commit sha while pipeline data is not yet available
'
,
async
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
.
queries
.
commitSha
,
'
startPolling
'
)
.
mockImplementation
(
jest
.
fn
());
// simulate updating current branch (which triggers commitSha refetch)
// while pipeline data is not yet available
mockLatestCommitShaQuery
.
mockResolvedValue
(
mockEmptyCommitShaResults
);
await
wrapper
.
vm
.
$apollo
.
queries
.
commitSha
.
refetch
();
expect
(
wrapper
.
vm
.
$apollo
.
queries
.
commitSha
.
startPolling
).
toHaveBeenCalledTimes
(
1
);
});
it
(
'
stops polling for commit sha when pipeline data is available
'
,
async
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
.
queries
.
commitSha
,
'
stopPolling
'
)
.
mockImplementation
(
jest
.
fn
());
mockLatestCommitShaQuery
.
mockResolvedValue
(
mockCommitShaResults
);
await
wrapper
.
vm
.
$apollo
.
queries
.
commitSha
.
refetch
();
expect
(
wrapper
.
vm
.
$apollo
.
queries
.
commitSha
.
stopPolling
).
toHaveBeenCalledTimes
(
1
);
});
});
describe
(
'
and the commit mutation fails
'
,
()
=>
{
...
...
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