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
599b6c47
Commit
599b6c47
authored
Apr 23, 2021
by
Mireya Andres
Committed by
Sarah Groff Hennigh-Palermo
Apr 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load correct data when switching branches in pipeline editor
parent
ec5edc5f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
4 deletions
+82
-4
app/assets/javascripts/pipeline_editor/components/file_nav/branch_switcher.vue
...s/pipeline_editor/components/file_nav/branch_switcher.vue
+15
-0
app/assets/javascripts/pipeline_editor/pipeline_editor_app.vue
...ssets/javascripts/pipeline_editor/pipeline_editor_app.vue
+13
-1
spec/frontend/pipeline_editor/components/file-nav/branch_switcher_spec.js
...peline_editor/components/file-nav/branch_switcher_spec.js
+31
-0
spec/frontend/pipeline_editor/pipeline_editor_app_spec.js
spec/frontend/pipeline_editor/pipeline_editor_app_spec.js
+23
-3
No files found.
app/assets/javascripts/pipeline_editor/components/file_nav/branch_switcher.vue
View file @
599b6c47
...
@@ -44,6 +44,20 @@ export default {
...
@@ -44,6 +44,20 @@ export default {
return
this
.
branches
?.
length
>
0
;
return
this
.
branches
?.
length
>
0
;
},
},
},
},
methods
:
{
async
selectBranch
(
newBranch
)
{
if
(
newBranch
===
this
.
currentBranch
)
{
return
;
}
await
this
.
$apollo
.
getClient
().
writeQuery
({
query
:
getCurrentBranch
,
data
:
{
currentBranch
:
newBranch
},
});
this
.
$emit
(
'
refetchContent
'
);
},
},
};
};
</
script
>
</
script
>
...
@@ -57,6 +71,7 @@ export default {
...
@@ -57,6 +71,7 @@ export default {
:key=
"branch.name"
:key=
"branch.name"
:is-checked=
"currentBranch === branch.name"
:is-checked=
"currentBranch === branch.name"
:is-check-item=
"true"
:is-check-item=
"true"
@
click=
"selectBranch(branch.name)"
>
>
<gl-icon
name=
"check"
class=
"gl-visibility-hidden"
/>
<gl-icon
name=
"check"
class=
"gl-visibility-hidden"
/>
{{
branch
.
name
}}
{{
branch
.
name
}}
...
...
app/assets/javascripts/pipeline_editor/pipeline_editor_app.vue
View file @
599b6c47
<
script
>
<
script
>
import
{
GlAlert
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
GlAlert
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
fetchPolicies
}
from
'
~/lib/graphql
'
;
import
httpStatusCodes
from
'
~/lib/utils/http_status
'
;
import
httpStatusCodes
from
'
~/lib/utils/http_status
'
;
import
{
getParameterValues
,
removeParams
}
from
'
~/lib/utils/url_utility
'
;
import
{
getParameterValues
,
removeParams
}
from
'
~/lib/utils/url_utility
'
;
import
{
__
,
s__
}
from
'
~/locale
'
;
import
{
__
,
s__
}
from
'
~/locale
'
;
...
@@ -51,8 +52,8 @@ export default {
...
@@ -51,8 +52,8 @@ export default {
failureType
:
null
,
failureType
:
null
,
failureReasons
:
[],
failureReasons
:
[],
showStartScreen
:
false
,
showStartScreen
:
false
,
isNewCiConfigFile
:
false
,
initialCiFileContent
:
''
,
initialCiFileContent
:
''
,
isNewCiConfigFile
:
false
,
lastCommittedContent
:
''
,
lastCommittedContent
:
''
,
currentCiFileContent
:
''
,
currentCiFileContent
:
''
,
showFailureAlert
:
false
,
showFailureAlert
:
false
,
...
@@ -64,6 +65,7 @@ export default {
...
@@ -64,6 +65,7 @@ export default {
apollo
:
{
apollo
:
{
initialCiFileContent
:
{
initialCiFileContent
:
{
fetchPolicy
:
fetchPolicies
.
NETWORK
,
query
:
getBlobContent
,
query
:
getBlobContent
,
// If it's a brand new file, we don't want to fetch the content.
// If it's a brand new file, we don't want to fetch the content.
// Then when the user commits the first time, the query would run
// Then when the user commits the first time, the query would run
...
@@ -91,6 +93,11 @@ export default {
...
@@ -91,6 +93,11 @@ export default {
error
(
error
)
{
error
(
error
)
{
this
.
handleBlobContentError
(
error
);
this
.
handleBlobContentError
(
error
);
},
},
watchLoading
(
isLoading
)
{
if
(
isLoading
)
{
this
.
setAppStatus
(
EDITOR_APP_STATUS_LOADING
);
}
},
},
},
ciConfigData
:
{
ciConfigData
:
{
query
:
getCiConfigData
,
query
:
getCiConfigData
,
...
@@ -223,6 +230,10 @@ export default {
...
@@ -223,6 +230,10 @@ export default {
dismissSuccess
()
{
dismissSuccess
()
{
this
.
showSuccessAlert
=
false
;
this
.
showSuccessAlert
=
false
;
},
},
async
refetchContent
()
{
this
.
$apollo
.
queries
.
initialCiFileContent
.
skip
=
false
;
await
this
.
$apollo
.
queries
.
initialCiFileContent
.
refetch
();
},
reportFailure
(
type
,
reasons
=
[])
{
reportFailure
(
type
,
reasons
=
[])
{
this
.
setAppStatus
(
EDITOR_APP_STATUS_ERROR
);
this
.
setAppStatus
(
EDITOR_APP_STATUS_ERROR
);
...
@@ -324,6 +335,7 @@ export default {
...
@@ -324,6 +335,7 @@ export default {
@
commit=
"updateOnCommit"
@
commit=
"updateOnCommit"
@
resetContent=
"resetContent"
@
resetContent=
"resetContent"
@
showError=
"showErrorAlert"
@
showError=
"showErrorAlert"
@
refetchContent=
"refetchContent"
@
updateCiConfig=
"updateCiConfig"
@
updateCiConfig=
"updateCiConfig"
/>
/>
<confirm-unsaved-changes-dialog
:has-unsaved-changes=
"hasUnsavedChanges"
/>
<confirm-unsaved-changes-dialog
:has-unsaved-changes=
"hasUnsavedChanges"
/>
...
...
spec/frontend/pipeline_editor/components/file-nav/branch_switcher_spec.js
View file @
599b6c47
...
@@ -120,4 +120,35 @@ describe('Pipeline editor branch switcher', () => {
...
@@ -120,4 +120,35 @@ describe('Pipeline editor branch switcher', () => {
]);
]);
});
});
});
});
describe
(
'
when switching branches
'
,
()
=>
{
beforeEach
(
async
()
=>
{
mockAvailableBranchQuery
.
mockResolvedValue
(
mockProjectBranches
);
createComponentWithApollo
();
await
waitForPromises
();
});
it
(
'
emits the refetchContent event when selecting a different branch
'
,
async
()
=>
{
const
branch
=
findDropdownItems
().
at
(
1
);
expect
(
branch
.
text
()).
not
.
toBe
(
mockDefaultBranch
);
expect
(
wrapper
.
emitted
(
'
refetchContent
'
)).
toBeUndefined
();
await
branch
.
vm
.
$emit
(
'
click
'
);
expect
(
wrapper
.
emitted
(
'
refetchContent
'
)).
toBeDefined
();
expect
(
wrapper
.
emitted
(
'
refetchContent
'
)).
toHaveLength
(
1
);
});
it
(
'
does not emit the refetchContent event when selecting the current branch
'
,
async
()
=>
{
const
branch
=
findDropdownItems
().
at
(
0
);
expect
(
branch
.
text
()).
toBe
(
mockDefaultBranch
);
expect
(
wrapper
.
emitted
(
'
refetchContent
'
)).
toBeUndefined
();
await
branch
.
vm
.
$emit
(
'
click
'
);
expect
(
wrapper
.
emitted
(
'
refetchContent
'
)).
toBeUndefined
();
});
});
});
});
spec/frontend/pipeline_editor/pipeline_editor_app_spec.js
View file @
599b6c47
...
@@ -92,6 +92,11 @@ describe('Pipeline editor app component', () => {
...
@@ -92,6 +92,11 @@ describe('Pipeline editor app component', () => {
const
options
=
{
const
options
=
{
localVue
,
localVue
,
data
()
{
return
{
currentBranch
:
mockDefaultBranch
,
};
},
mocks
:
{},
mocks
:
{},
apolloProvider
:
mockApollo
,
apolloProvider
:
mockApollo
,
};
};
...
@@ -116,9 +121,6 @@ describe('Pipeline editor app component', () => {
...
@@ -116,9 +121,6 @@ describe('Pipeline editor app component', () => {
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
mockBlobContentData
.
mockReset
();
mockCiConfigData
.
mockReset
();
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
...
@@ -337,4 +339,22 @@ describe('Pipeline editor app component', () => {
...
@@ -337,4 +339,22 @@ describe('Pipeline editor app component', () => {
});
});
});
});
});
});
describe
(
'
when refetching content
'
,
()
=>
{
beforeEach
(
async
()
=>
{
await
createComponentWithApollo
();
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
.
queries
.
initialCiFileContent
,
'
refetch
'
)
.
mockImplementation
(
jest
.
fn
());
});
it
(
'
refetches blob content
'
,
async
()
=>
{
expect
(
wrapper
.
vm
.
$apollo
.
queries
.
initialCiFileContent
.
refetch
).
toHaveBeenCalledTimes
(
0
);
await
wrapper
.
vm
.
refetchContent
();
expect
(
wrapper
.
vm
.
$apollo
.
queries
.
initialCiFileContent
.
refetch
).
toHaveBeenCalledTimes
(
1
);
});
});
});
});
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