UNCLASSIFIED
Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Platform One
P
Party Bus
Launchboard
launchboard-fe
Commits
4d9f6c67
Commit
4d9f6c67
authored
Feb 24, 2021
by
Keith Becker
Browse files
Merge remote-tracking branch 'origin/BULL-529' into BULL-529
parents
e15e7370
fe61cabe
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
28 deletions
+47
-28
src/components/EditableInput.vue
src/components/EditableInput.vue
+0
-2
src/store/action-types.js
src/store/action-types.js
+1
-1
tests/unit/components/EditableInput.spec.js
tests/unit/components/EditableInput.spec.js
+28
-14
tests/unit/components/LaunchboardSettings.spec.js
tests/unit/components/LaunchboardSettings.spec.js
+9
-5
tests/unit/components/ProjectsSummary.spec.js
tests/unit/components/ProjectsSummary.spec.js
+9
-6
No files found.
src/components/EditableInput.vue
View file @
4d9f6c67
...
@@ -115,8 +115,6 @@ export default {
...
@@ -115,8 +115,6 @@ export default {
.
getComputedStyle
(
this
.
$refs
.
defaultSlot
)
.
getComputedStyle
(
this
.
$refs
.
defaultSlot
)
.
getPropertyValue
(
"
font-size
"
);
.
getPropertyValue
(
"
font-size
"
);
console
.
log
(
"
+++ startEditing
"
,
width
,
fontSize
);
// set focus to the input element
// set focus to the input element
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
const
editInput
=
this
.
getEditingInput
();
const
editInput
=
this
.
getEditingInput
();
...
...
src/store/action-types.js
View file @
4d9f6c67
export
const
CALL_SET_USER_PREFERENCE
=
"
user_preferences/callSetUserProjects
"
;
export
const
CALL_SET_USER_PREFERENCE
=
"
user_preferences/callSetUserProjects
"
;
tests/unit/components/EditableInput.spec.js
View file @
4d9f6c67
...
@@ -8,7 +8,11 @@ const localVue = createLocalVue();
...
@@ -8,7 +8,11 @@ const localVue = createLocalVue();
localVue
.
use
(
Vuex
);
localVue
.
use
(
Vuex
);
describe
(
"
components/EditableInput
"
,
()
=>
{
describe
(
"
components/EditableInput
"
,
()
=>
{
test
(
"
EditableInput
"
,
()
=>
{
afterEach
(()
=>
{
jest
.
restoreAllMocks
();
});
it
(
"
should mount EditableInput with no errors
"
,
()
=>
{
// render the component
// render the component
const
wrapper
=
shallowMount
(
EditableInput
,
{
const
wrapper
=
shallowMount
(
EditableInput
,
{
mocks
:
{
mocks
:
{
...
@@ -76,7 +80,7 @@ describe("components/EditableInput", () => {
...
@@ -76,7 +80,7 @@ describe("components/EditableInput", () => {
const
input
=
wrapper
.
vm
.
getEditingInput
();
const
input
=
wrapper
.
vm
.
getEditingInput
();
expect
(
input
).
toEqual
(
null
);
expect
(
input
).
toEqual
(
null
);
});
});
it
(
"
should start editing
"
,
()
=>
{
it
(
"
should start editing
"
,
async
()
=>
{
// render the component
// render the component
const
wrapper
=
shallowMount
(
EditableInput
,
{
const
wrapper
=
shallowMount
(
EditableInput
,
{
mocks
:
{
mocks
:
{
...
@@ -90,11 +94,21 @@ describe("components/EditableInput", () => {
...
@@ -90,11 +94,21 @@ describe("components/EditableInput", () => {
vuetify
,
vuetify
,
});
});
const
mockInput
=
{
focus
:
jest
.
fn
(),
style
:
{},
};
wrapper
.
vm
.
$refs
.
editingElementWrapper
=
{
getElementsByTagName
:
jest
.
fn
().
mockReturnValue
([
mockInput
]),
};
wrapper
.
vm
.
startEditing
();
wrapper
.
vm
.
startEditing
();
await
wrapper
.
vm
.
$nextTick
();
expect
(
mockInput
.
focus
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
isEditing
).
toEqual
(
true
);
expect
(
wrapper
.
vm
.
isEditing
).
toEqual
(
true
);
expect
(
wrapper
.
vm
.
hover
).
toEqual
(
false
);
expect
(
wrapper
.
vm
.
hover
).
toEqual
(
false
);
});
});
it
(
"
should update value
"
,
()
=>
{
it
(
"
should update value
"
,
async
()
=>
{
// render the component
// render the component
const
wrapper
=
shallowMount
(
EditableInput
,
{
const
wrapper
=
shallowMount
(
EditableInput
,
{
mocks
:
{
mocks
:
{
...
@@ -104,17 +118,19 @@ describe("components/EditableInput", () => {
...
@@ -104,17 +118,19 @@ describe("components/EditableInput", () => {
},
},
},
},
},
},
props
:
{
value
:
"
mockValue
"
,
},
localVue
,
localVue
,
vuetify
,
vuetify
,
});
});
wrapper
.
vm
.
$emit
=
jest
.
fn
();
wrapper
.
vm
.
$emit
=
jest
.
fn
();
wrapper
.
vm
.
value
=
"
test
"
;
await
wrapper
.
setProps
({
value
:
"
newMockValue
"
});
wrapper
.
vm
.
model
=
"
value
"
;
wrapper
.
vm
.
updateValue
();
wrapper
.
vm
.
updateValue
();
expect
(
wrapper
.
vm
.
$emit
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
$emit
).
toHaveBeenCalled
();
});
});
it
(
"
should
update value same value
"
,
()
=>
{
it
(
"
should
not emit change value when it hasn't changed
"
,
async
()
=>
{
// render the component
// render the component
const
wrapper
=
shallowMount
(
EditableInput
,
{
const
wrapper
=
shallowMount
(
EditableInput
,
{
mocks
:
{
mocks
:
{
...
@@ -129,10 +145,10 @@ describe("components/EditableInput", () => {
...
@@ -129,10 +145,10 @@ describe("components/EditableInput", () => {
});
});
wrapper
.
vm
.
$emit
=
jest
.
fn
();
wrapper
.
vm
.
$emit
=
jest
.
fn
();
wrapper
.
vm
.
value
=
"
test
"
;
await
wrapper
.
setProps
({
value
:
"
mockValue
"
})
;
wrapper
.
vm
.
model
=
"
test
"
;
await
wrapper
.
setData
({
model
:
"
mockValue
"
})
;
wrapper
.
vm
.
updateValue
();
wrapper
.
vm
.
updateValue
();
expect
(
wrapper
.
vm
.
$emit
).
toHaveBeenCalled
Times
(
0
);
expect
(
wrapper
.
vm
.
$emit
).
not
.
toHaveBeenCalled
With
(
"
change
"
);
});
});
it
(
"
should reset
"
,
()
=>
{
it
(
"
should reset
"
,
()
=>
{
// render the component
// render the component
...
@@ -152,7 +168,7 @@ describe("components/EditableInput", () => {
...
@@ -152,7 +168,7 @@ describe("components/EditableInput", () => {
expect
(
wrapper
.
vm
.
hover
).
toEqual
(
false
);
expect
(
wrapper
.
vm
.
hover
).
toEqual
(
false
);
expect
(
wrapper
.
vm
.
isEditing
).
toEqual
(
false
);
expect
(
wrapper
.
vm
.
isEditing
).
toEqual
(
false
);
});
});
it
(
"
should cancel
"
,
()
=>
{
it
(
"
should cancel
"
,
async
()
=>
{
// render the component
// render the component
const
wrapper
=
shallowMount
(
EditableInput
,
{
const
wrapper
=
shallowMount
(
EditableInput
,
{
mocks
:
{
mocks
:
{
...
@@ -167,7 +183,7 @@ describe("components/EditableInput", () => {
...
@@ -167,7 +183,7 @@ describe("components/EditableInput", () => {
});
});
wrapper
.
vm
.
reset
=
jest
.
fn
();
wrapper
.
vm
.
reset
=
jest
.
fn
();
wrapper
.
vm
.
value
=
"
test
"
;
await
wrapper
.
setProps
({
value
:
"
test
"
})
;
wrapper
.
vm
.
cancel
();
wrapper
.
vm
.
cancel
();
expect
(
wrapper
.
vm
.
reset
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
reset
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
model
).
toEqual
(
wrapper
.
vm
.
value
);
expect
(
wrapper
.
vm
.
model
).
toEqual
(
wrapper
.
vm
.
value
);
...
@@ -187,9 +203,7 @@ describe("components/EditableInput", () => {
...
@@ -187,9 +203,7 @@ describe("components/EditableInput", () => {
});
});
wrapper
.
vm
.
$refs
.
editingElementWrapper
=
{
wrapper
.
vm
.
$refs
.
editingElementWrapper
=
{
getElementsByTagName
:
()
=>
{
getElementsByTagName
:
()
=>
[
"
test
"
],
return
[
"
test
"
];
},
};
};
const
editInput
=
wrapper
.
vm
.
getEditingInput
();
const
editInput
=
wrapper
.
vm
.
getEditingInput
();
expect
(
editInput
).
toEqual
(
"
test
"
);
expect
(
editInput
).
toEqual
(
"
test
"
);
...
...
tests/unit/components/LaunchboardSettings.spec.js
View file @
4d9f6c67
...
@@ -3,6 +3,7 @@ import Vuex from "vuex";
...
@@ -3,6 +3,7 @@ import Vuex from "vuex";
import
Vuetify
from
"
vuetify
"
;
import
Vuetify
from
"
vuetify
"
;
import
{
shallowMount
,
createLocalVue
}
from
"
@vue/test-utils
"
;
import
{
shallowMount
,
createLocalVue
}
from
"
@vue/test-utils
"
;
import
LaunchboardSettings
from
"
@/components/LaunchboardSettings.vue
"
;
import
LaunchboardSettings
from
"
@/components/LaunchboardSettings.vue
"
;
import
{
CALL_SET_USER_PREFERENCE
}
from
"
@/store/action-types
"
;
const
vuetify
=
new
Vuetify
();
const
vuetify
=
new
Vuetify
();
const
localVue
=
createLocalVue
();
const
localVue
=
createLocalVue
();
...
@@ -115,6 +116,7 @@ describe("LaunchboardSettings", () => {
...
@@ -115,6 +116,7 @@ describe("LaunchboardSettings", () => {
expect
(
wrapper
.
vm
.
changeLoadingColor
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
changeLoadingColor
).
toHaveBeenCalled
();
});
});
it
(
"
should call updateUserPreference
"
,
async
()
=>
{
it
(
"
should call updateUserPreference
"
,
async
()
=>
{
const
dispatch
=
jest
.
fn
();
const
wrapper
=
shallowMount
(
LaunchboardSettings
,
{
const
wrapper
=
shallowMount
(
LaunchboardSettings
,
{
mocks
:
{
mocks
:
{
$store
:
{
$store
:
{
...
@@ -127,6 +129,7 @@ describe("LaunchboardSettings", () => {
...
@@ -127,6 +129,7 @@ describe("LaunchboardSettings", () => {
error
:
{},
error
:
{},
projects
:
{
list
:
[]
},
projects
:
{
list
:
[]
},
},
},
dispatch
,
},
},
},
},
data
:
()
=>
({
data
:
()
=>
({
...
@@ -142,13 +145,14 @@ describe("LaunchboardSettings", () => {
...
@@ -142,13 +145,14 @@ describe("LaunchboardSettings", () => {
vuetify
,
vuetify
,
});
});
wrapper
.
vm
.
$store
.
dispatch
=
jest
.
fn
().
mockImplementation
((
pref
,
res
)
=>
{
const
mockPreference
=
{
darkMode
:
true
};
expect
(
typeof
res
).
toEqual
(
"
object
"
);
});
wrapper
.
vm
.
darkMode
=
true
;
wrapper
.
vm
.
changeLoadingColor
=
jest
.
fn
();
wrapper
.
vm
.
changeLoadingColor
=
jest
.
fn
();
wrapper
.
vm
.
updateUserPreference
();
await
wrapper
.
vm
.
updateUserPreference
(
mockPreference
);
expect
(
wrapper
.
vm
.
$store
.
dispatch
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
$store
.
dispatch
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
$store
.
dispatch
).
toHaveBeenCalledWith
(
CALL_SET_USER_PREFERENCE
,
mockPreference
);
expect
(
wrapper
.
vm
.
changeLoadingColor
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
changeLoadingColor
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
darkMode
).
toEqual
(
true
);
expect
(
wrapper
.
vm
.
darkMode
).
toEqual
(
true
);
});
});
...
...
tests/unit/components/ProjectsSummary.spec.js
View file @
4d9f6c67
...
@@ -10,10 +10,12 @@ localVue.use(Vuex);
...
@@ -10,10 +10,12 @@ localVue.use(Vuex);
describe
(
"
ProjectsSummary
"
,
()
=>
{
describe
(
"
ProjectsSummary
"
,
()
=>
{
afterEach
(()
=>
{
afterEach
(()
=>
{
jest
.
clear
AllMocks
();
jest
.
reset
AllMocks
();
});
});
it
(
"
should load component
"
,
async
()
=>
{
it
(
"
should load component
"
,
()
=>
{
ProjectService
.
getProjectsSummary
=
jest
.
fn
();
// render the component
// render the component
const
wrapper
=
shallowMount
(
ProjectsSummary
,
{
const
wrapper
=
shallowMount
(
ProjectsSummary
,
{
mocks
:
{
mocks
:
{
...
@@ -32,7 +34,8 @@ describe("ProjectsSummary", () => {
...
@@ -32,7 +34,8 @@ describe("ProjectsSummary", () => {
expect
(
wrapper
.
find
(
"
.error
"
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
"
.error
"
).
exists
()).
toBe
(
false
);
});
});
it
(
"
should filter by favorited projects
"
,
async
()
=>
{
it
(
"
should filter by favorited projects
"
,
()
=>
{
ProjectService
.
getProjectsSummary
=
jest
.
fn
();
// render the component
// render the component
const
wrapper
=
shallowMount
(
ProjectsSummary
,
{
const
wrapper
=
shallowMount
(
ProjectsSummary
,
{
mocks
:
{
mocks
:
{
...
@@ -64,7 +67,7 @@ describe("ProjectsSummary", () => {
...
@@ -64,7 +67,7 @@ describe("ProjectsSummary", () => {
]);
]);
});
});
it
(
"
should refresh projects
"
,
async
()
=>
{
it
(
"
should refresh projects
"
,
()
=>
{
ProjectService
.
getProjectsSummary
=
jest
.
fn
().
mockResolvedValue
([
ProjectService
.
getProjectsSummary
=
jest
.
fn
().
mockResolvedValue
([
{
id
:
"
1
"
,
links
:
{},
latestPipeline
:
{},
favorite
:
false
},
{
id
:
"
1
"
,
links
:
{},
latestPipeline
:
{},
favorite
:
false
},
{
id
:
"
2
"
,
links
:
{},
latestPipeline
:
{},
favorite
:
true
},
{
id
:
"
2
"
,
links
:
{},
latestPipeline
:
{},
favorite
:
true
},
...
@@ -99,7 +102,7 @@ describe("ProjectsSummary", () => {
...
@@ -99,7 +102,7 @@ describe("ProjectsSummary", () => {
expect
(
wrapper
.
vm
.
filteredProjects
).
toEqual
([]);
expect
(
wrapper
.
vm
.
filteredProjects
).
toEqual
([]);
});
});
it
(
"
should refresh with empty projects and trigger empty string
"
,
async
()
=>
{
it
(
"
should refresh with empty projects and trigger empty string
"
,
()
=>
{
ProjectService
.
getProjectsSummary
=
jest
.
fn
().
mockResolvedValue
([]);
ProjectService
.
getProjectsSummary
=
jest
.
fn
().
mockResolvedValue
([]);
// render the component
// render the component
const
wrapper
=
shallowMount
(
ProjectsSummary
,
{
const
wrapper
=
shallowMount
(
ProjectsSummary
,
{
...
@@ -130,7 +133,7 @@ describe("ProjectsSummary", () => {
...
@@ -130,7 +133,7 @@ describe("ProjectsSummary", () => {
expect
(
wrapper
.
vm
.
filteredProjects
).
toEqual
([]);
expect
(
wrapper
.
vm
.
filteredProjects
).
toEqual
([]);
});
});
it
(
"
should refresh with error
"
,
async
()
=>
{
it
(
"
should refresh with error
"
,
()
=>
{
ProjectService
.
getProjectsSummary
=
jest
.
fn
();
ProjectService
.
getProjectsSummary
=
jest
.
fn
();
// render the component
// render the component
const
wrapper
=
shallowMount
(
ProjectsSummary
,
{
const
wrapper
=
shallowMount
(
ProjectsSummary
,
{
...
...
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