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
90b68e62
Commit
90b68e62
authored
Mar 21, 2020
by
Vitaly Slobodin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate ee/ide to Jest
Closes
https://gitlab.com/gitlab-org/gitlab/-/issues/194288
parent
4e95c330
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
139 additions
and
179 deletions
+139
-179
ee/spec/frontend/ide/components/terminal/empty_state_spec.js
ee/spec/frontend/ide/components/terminal/empty_state_spec.js
+2
-5
ee/spec/frontend/ide/components/terminal/terminal_spec.js
ee/spec/frontend/ide/components/terminal/terminal_spec.js
+25
-27
ee/spec/frontend/ide/components/terminal/view_spec.js
ee/spec/frontend/ide/components/terminal/view_spec.js
+3
-3
ee/spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js
...ontend/ide/stores/modules/terminal/actions/checks_spec.js
+34
-49
ee/spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js
.../stores/modules/terminal/actions/session_controls_spec.js
+38
-49
ee/spec/frontend/ide/stores/modules/terminal/actions/session_status_spec.js
...de/stores/modules/terminal/actions/session_status_spec.js
+30
-37
ee/spec/frontend/ide/stores/modules/terminal/actions/setup_spec.js
...rontend/ide/stores/modules/terminal/actions/setup_spec.js
+7
-9
ee/spec/frontend/ide/stores/modules/terminal/messages_spec.js
...pec/frontend/ide/stores/modules/terminal/messages_spec.js
+0
-0
No files found.
ee/spec/
javascripts
/ide/components/terminal/empty_state_spec.js
→
ee/spec/
frontend
/ide/components/terminal/empty_state_spec.js
View file @
90b68e62
import
{
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
import
TerminalEmptyState
from
'
ee/ide/components/terminal/empty_state.vue
'
;
import
TerminalEmptyState
from
'
ee/ide/components/terminal/empty_state.vue
'
;
...
@@ -11,10 +11,7 @@ describe('EE IDE TerminalEmptyState', () => {
...
@@ -11,10 +11,7 @@ describe('EE IDE TerminalEmptyState', () => {
let
wrapper
;
let
wrapper
;
const
factory
=
(
options
=
{})
=>
{
const
factory
=
(
options
=
{})
=>
{
const
localVue
=
createLocalVue
();
wrapper
=
shallowMount
(
TerminalEmptyState
,
{
wrapper
=
shallowMount
(
localVue
.
extend
(
TerminalEmptyState
),
{
localVue
,
...
options
,
...
options
,
});
});
};
};
...
...
ee/spec/
javascripts
/ide/components/terminal/terminal_spec.js
→
ee/spec/
frontend
/ide/components/terminal/terminal_spec.js
View file @
90b68e62
...
@@ -4,16 +4,26 @@ import { GlLoadingIcon } from '@gitlab/ui';
...
@@ -4,16 +4,26 @@ import { GlLoadingIcon } from '@gitlab/ui';
import
Terminal
from
'
ee/ide/components/terminal/terminal.vue
'
;
import
Terminal
from
'
ee/ide/components/terminal/terminal.vue
'
;
import
TerminalControls
from
'
ee/ide/components/terminal/terminal_controls.vue
'
;
import
TerminalControls
from
'
ee/ide/components/terminal/terminal_controls.vue
'
;
import
{
STARTING
,
PENDING
,
RUNNING
,
STOPPING
,
STOPPED
}
from
'
ee/ide/constants
'
;
import
{
STARTING
,
PENDING
,
RUNNING
,
STOPPING
,
STOPPED
}
from
'
ee/ide/constants
'
;
import
GLTerminal
from
'
~/terminal/terminal
'
;
const
TEST_TERMINAL_PATH
=
'
terminal/path
'
;
const
TEST_TERMINAL_PATH
=
'
terminal/path
'
;
const
localVue
=
createLocalVue
();
const
localVue
=
createLocalVue
();
localVue
.
use
(
Vuex
);
localVue
.
use
(
Vuex
);
jest
.
mock
(
'
~/terminal/terminal
'
,
()
=>
jest
.
fn
().
mockImplementation
(()
=>
({
dispose
:
jest
.
fn
(),
disable
:
jest
.
fn
(),
addScrollListener
:
jest
.
fn
(),
scrollToTop
:
jest
.
fn
(),
scrollToBottom
:
jest
.
fn
(),
})),
);
describe
(
'
EE IDE Terminal
'
,
()
=>
{
describe
(
'
EE IDE Terminal
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
let
state
;
let
state
;
let
GLTerminalSpy
;
const
factory
=
propsData
=>
{
const
factory
=
propsData
=>
{
const
store
=
new
Vuex
.
Store
({
const
store
=
new
Vuex
.
Store
({
...
@@ -37,15 +47,6 @@ describe('EE IDE Terminal', () => {
...
@@ -37,15 +47,6 @@ describe('EE IDE Terminal', () => {
};
};
beforeEach
(()
=>
{
beforeEach
(()
=>
{
GLTerminalSpy
=
spyOnDependency
(
Terminal
,
'
GLTerminal
'
).
and
.
returnValue
(
jasmine
.
createSpyObj
(
'
GLTerminal
'
,
[
'
dispose
'
,
'
disable
'
,
'
addScrollListener
'
,
'
scrollToTop
'
,
'
scrollToBottom
'
,
]),
);
state
=
{
state
=
{
panelResizing
:
false
,
panelResizing
:
false
,
};
};
...
@@ -91,10 +92,11 @@ describe('EE IDE Terminal', () => {
...
@@ -91,10 +92,11 @@ describe('EE IDE Terminal', () => {
});
});
describe
(
'
terminal controls
'
,
()
=>
{
describe
(
'
terminal controls
'
,
()
=>
{
beforeEach
(
done
=>
{
beforeEach
(
()
=>
{
factory
();
factory
();
wrapper
.
vm
.
createTerminal
();
wrapper
.
vm
.
createTerminal
();
localVue
.
nextTick
(
done
);
return
localVue
.
nextTick
();
});
});
it
(
'
is visible if terminal is created
'
,
()
=>
{
it
(
'
is visible if terminal is created
'
,
()
=>
{
...
@@ -113,7 +115,7 @@ describe('EE IDE Terminal', () => {
...
@@ -113,7 +115,7 @@ describe('EE IDE Terminal', () => {
expect
(
wrapper
.
vm
.
glterminal
.
scrollToBottom
).
toHaveBeenCalled
();
expect
(
wrapper
.
vm
.
glterminal
.
scrollToBottom
).
toHaveBeenCalled
();
});
});
it
(
'
has props set
'
,
done
=>
{
it
(
'
has props set
'
,
()
=>
{
expect
(
wrapper
.
find
(
TerminalControls
).
props
()).
toEqual
({
expect
(
wrapper
.
find
(
TerminalControls
).
props
()).
toEqual
({
canScrollUp
:
false
,
canScrollUp
:
false
,
canScrollDown
:
false
,
canScrollDown
:
false
,
...
@@ -121,16 +123,12 @@ describe('EE IDE Terminal', () => {
...
@@ -121,16 +123,12 @@ describe('EE IDE Terminal', () => {
wrapper
.
setData
({
canScrollUp
:
true
,
canScrollDown
:
true
});
wrapper
.
setData
({
canScrollUp
:
true
,
canScrollDown
:
true
});
localVue
return
localVue
.
nextTick
().
then
(()
=>
{
.
nextTick
()
expect
(
wrapper
.
find
(
TerminalControls
).
props
()).
toEqual
({
.
then
(()
=>
{
canScrollUp
:
true
,
expect
(
wrapper
.
find
(
TerminalControls
).
props
()).
toEqual
({
canScrollDown
:
true
,
canScrollUp
:
true
,
});
canScrollDown
:
true
,
});
});
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
...
@@ -139,8 +137,8 @@ describe('EE IDE Terminal', () => {
...
@@ -139,8 +137,8 @@ describe('EE IDE Terminal', () => {
let
stopTerminal
;
let
stopTerminal
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
createTerminal
=
j
asmine
.
createSpy
(
'
createTerminal
'
);
createTerminal
=
j
est
.
fn
().
mockName
(
'
createTerminal
'
);
stopTerminal
=
j
asmine
.
createSpy
(
'
stopTerminal
'
);
stopTerminal
=
j
est
.
fn
().
mockName
(
'
stopTerminal
'
);
});
});
it
(
'
creates the terminal if running
'
,
()
=>
{
it
(
'
creates the terminal if running
'
,
()
=>
{
...
@@ -169,7 +167,7 @@ describe('EE IDE Terminal', () => {
...
@@ -169,7 +167,7 @@ describe('EE IDE Terminal', () => {
});
});
it
(
'
creates the terminal
'
,
()
=>
{
it
(
'
creates the terminal
'
,
()
=>
{
expect
(
GLTerminal
Spy
).
toHaveBeenCalledWith
(
wrapper
.
vm
.
$refs
.
terminal
);
expect
(
GLTerminal
).
toHaveBeenCalledWith
(
wrapper
.
vm
.
$refs
.
terminal
);
expect
(
wrapper
.
vm
.
glterminal
).
toBeTruthy
();
expect
(
wrapper
.
vm
.
glterminal
).
toBeTruthy
();
});
});
...
@@ -182,7 +180,7 @@ describe('EE IDE Terminal', () => {
...
@@ -182,7 +180,7 @@ describe('EE IDE Terminal', () => {
expect
(
wrapper
.
vm
.
canScrollUp
).
toBe
(
false
);
expect
(
wrapper
.
vm
.
canScrollUp
).
toBe
(
false
);
expect
(
wrapper
.
vm
.
canScrollDown
).
toBe
(
false
);
expect
(
wrapper
.
vm
.
canScrollDown
).
toBe
(
false
);
const
listener
=
wrapper
.
vm
.
glterminal
.
addScrollListener
.
calls
.
argsFor
(
0
)
[
0
];
const
listener
=
wrapper
.
vm
.
glterminal
.
addScrollListener
.
mock
.
calls
[
0
]
[
0
];
listener
({
canScrollUp
:
true
,
canScrollDown
:
true
});
listener
({
canScrollUp
:
true
,
canScrollDown
:
true
});
expect
(
wrapper
.
vm
.
canScrollUp
).
toBe
(
true
);
expect
(
wrapper
.
vm
.
canScrollUp
).
toBe
(
true
);
...
...
ee/spec/
javascripts
/ide/components/terminal/view_spec.js
→
ee/spec/
frontend
/ide/components/terminal/view_spec.js
View file @
90b68e62
...
@@ -29,7 +29,7 @@ describe('EE IDE TerminalView', () => {
...
@@ -29,7 +29,7 @@ describe('EE IDE TerminalView', () => {
},
},
});
});
wrapper
=
shallowMount
(
localVue
.
extend
(
TerminalView
)
,
{
localVue
,
store
});
wrapper
=
shallowMount
(
TerminalView
,
{
localVue
,
store
});
};
};
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
@@ -42,8 +42,8 @@ describe('EE IDE TerminalView', () => {
...
@@ -42,8 +42,8 @@ describe('EE IDE TerminalView', () => {
};
};
actions
=
{
actions
=
{
hideSplash
:
j
asmine
.
createSpy
(
'
hideSplash
'
),
hideSplash
:
j
est
.
fn
().
mockName
(
'
hideSplash
'
),
startSession
:
j
asmine
.
createSpy
(
'
startSession
'
),
startSession
:
j
est
.
fn
().
mockName
(
'
startSession
'
),
};
};
getters
=
{
getters
=
{
...
...
ee/spec/
javascripts
/ide/stores/modules/terminal/actions/checks_spec.js
→
ee/spec/
frontend
/ide/stores/modules/terminal/actions/checks_spec.js
View file @
90b68e62
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
testAction
from
'
spec/
helpers/vuex_action_helper
'
;
import
testAction
from
'
helpers/vuex_action_helper
'
;
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
import
{
CHECK_CONFIG
,
CHECK_RUNNERS
,
RETRY_RUNNERS_INTERVAL
}
from
'
ee/ide/constants
'
;
import
{
CHECK_CONFIG
,
CHECK_RUNNERS
,
RETRY_RUNNERS_INTERVAL
}
from
'
ee/ide/constants
'
;
import
*
as
mutationTypes
from
'
ee/ide/stores/modules/terminal/mutation_types
'
;
import
*
as
mutationTypes
from
'
ee/ide/stores/modules/terminal/mutation_types
'
;
...
@@ -39,30 +39,27 @@ describe('EE IDE store terminal check actions', () => {
...
@@ -39,30 +39,27 @@ describe('EE IDE store terminal check actions', () => {
path_with_namespace
:
TEST_PROJECT_PATH
,
path_with_namespace
:
TEST_PROJECT_PATH
,
},
},
};
};
jasmine
.
clock
().
install
();
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
mock
.
restore
();
mock
.
restore
();
jasmine
.
clock
().
uninstall
();
});
});
describe
(
'
requestConfigCheck
'
,
()
=>
{
describe
(
'
requestConfigCheck
'
,
()
=>
{
it
(
'
handles request loading
'
,
done
=>
{
it
(
'
handles request loading
'
,
()
=>
{
testAction
(
return
testAction
(
actions
.
requestConfigCheck
,
actions
.
requestConfigCheck
,
null
,
null
,
{},
{},
[{
type
:
mutationTypes
.
REQUEST_CHECK
,
payload
:
CHECK_CONFIG
}],
[{
type
:
mutationTypes
.
REQUEST_CHECK
,
payload
:
CHECK_CONFIG
}],
[],
[],
done
,
);
);
});
});
});
});
describe
(
'
receiveConfigCheckSuccess
'
,
()
=>
{
describe
(
'
receiveConfigCheckSuccess
'
,
()
=>
{
it
(
'
handles successful response
'
,
done
=>
{
it
(
'
handles successful response
'
,
()
=>
{
testAction
(
return
testAction
(
actions
.
receiveConfigCheckSuccess
,
actions
.
receiveConfigCheckSuccess
,
null
,
null
,
{},
{},
...
@@ -71,17 +68,16 @@ describe('EE IDE store terminal check actions', () => {
...
@@ -71,17 +68,16 @@ describe('EE IDE store terminal check actions', () => {
{
type
:
mutationTypes
.
RECEIVE_CHECK_SUCCESS
,
payload
:
CHECK_CONFIG
},
{
type
:
mutationTypes
.
RECEIVE_CHECK_SUCCESS
,
payload
:
CHECK_CONFIG
},
],
],
[],
[],
done
,
);
);
});
});
});
});
describe
(
'
receiveConfigCheckError
'
,
()
=>
{
describe
(
'
receiveConfigCheckError
'
,
()
=>
{
it
(
'
handles error response
'
,
done
=>
{
it
(
'
handles error response
'
,
()
=>
{
const
status
=
httpStatus
.
UNPROCESSABLE_ENTITY
;
const
status
=
httpStatus
.
UNPROCESSABLE_ENTITY
;
const
payload
=
{
response
:
{
status
}
};
const
payload
=
{
response
:
{
status
}
};
testAction
(
return
testAction
(
actions
.
receiveConfigCheckError
,
actions
.
receiveConfigCheckError
,
payload
,
payload
,
state
,
state
,
...
@@ -99,15 +95,14 @@ describe('EE IDE store terminal check actions', () => {
...
@@ -99,15 +95,14 @@ describe('EE IDE store terminal check actions', () => {
},
},
],
],
[],
[],
done
,
);
);
});
});
[
httpStatus
.
FORBIDDEN
,
httpStatus
.
NOT_FOUND
].
forEach
(
status
=>
{
[
httpStatus
.
FORBIDDEN
,
httpStatus
.
NOT_FOUND
].
forEach
(
status
=>
{
it
(
`hides tab, when status is
${
status
}
`
,
done
=>
{
it
(
`hides tab, when status is
${
status
}
`
,
()
=>
{
const
payload
=
{
response
:
{
status
}
};
const
payload
=
{
response
:
{
status
}
};
testAction
(
return
testAction
(
actions
.
receiveConfigCheckError
,
actions
.
receiveConfigCheckError
,
payload
,
payload
,
state
,
state
,
...
@@ -116,20 +111,19 @@ describe('EE IDE store terminal check actions', () => {
...
@@ -116,20 +111,19 @@ describe('EE IDE store terminal check actions', () => {
type
:
mutationTypes
.
SET_VISIBLE
,
type
:
mutationTypes
.
SET_VISIBLE
,
payload
:
false
,
payload
:
false
,
},
},
jasmine
.
objectContaining
({
type
:
mutationTypes
.
RECEIVE_CHECK_ERROR
}),
expect
.
objectContaining
({
type
:
mutationTypes
.
RECEIVE_CHECK_ERROR
}),
],
],
[],
[],
done
,
);
);
});
});
});
});
});
});
describe
(
'
fetchConfigCheck
'
,
()
=>
{
describe
(
'
fetchConfigCheck
'
,
()
=>
{
it
(
'
dispatches request and receive
'
,
done
=>
{
it
(
'
dispatches request and receive
'
,
()
=>
{
mock
.
onPost
(
/.*
\/
ide_terminals
\/
check_config/
).
reply
(
200
,
{});
mock
.
onPost
(
/.*
\/
ide_terminals
\/
check_config/
).
reply
(
200
,
{});
testAction
(
return
testAction
(
actions
.
fetchConfigCheck
,
actions
.
fetchConfigCheck
,
null
,
null
,
{
{
...
@@ -138,14 +132,13 @@ describe('EE IDE store terminal check actions', () => {
...
@@ -138,14 +132,13 @@ describe('EE IDE store terminal check actions', () => {
},
},
[],
[],
[{
type
:
'
requestConfigCheck
'
},
{
type
:
'
receiveConfigCheckSuccess
'
}],
[{
type
:
'
requestConfigCheck
'
},
{
type
:
'
receiveConfigCheckSuccess
'
}],
done
,
);
);
});
});
it
(
'
when error, dispatches request and receive
'
,
done
=>
{
it
(
'
when error, dispatches request and receive
'
,
()
=>
{
mock
.
onPost
(
/.*
\/
ide_terminals
\/
check_config/
).
reply
(
400
,
{});
mock
.
onPost
(
/.*
\/
ide_terminals
\/
check_config/
).
reply
(
400
,
{});
testAction
(
return
testAction
(
actions
.
fetchConfigCheck
,
actions
.
fetchConfigCheck
,
null
,
null
,
{
{
...
@@ -155,90 +148,85 @@ describe('EE IDE store terminal check actions', () => {
...
@@ -155,90 +148,85 @@ describe('EE IDE store terminal check actions', () => {
[],
[],
[
[
{
type
:
'
requestConfigCheck
'
},
{
type
:
'
requestConfigCheck
'
},
{
type
:
'
receiveConfigCheckError
'
,
payload
:
jasmine
.
any
(
Error
)
},
{
type
:
'
receiveConfigCheckError
'
,
payload
:
expect
.
any
(
Error
)
},
],
],
done
,
);
);
});
});
});
});
describe
(
'
requestRunnersCheck
'
,
()
=>
{
describe
(
'
requestRunnersCheck
'
,
()
=>
{
it
(
'
handles request loading
'
,
done
=>
{
it
(
'
handles request loading
'
,
()
=>
{
testAction
(
return
testAction
(
actions
.
requestRunnersCheck
,
actions
.
requestRunnersCheck
,
null
,
null
,
{},
{},
[{
type
:
mutationTypes
.
REQUEST_CHECK
,
payload
:
CHECK_RUNNERS
}],
[{
type
:
mutationTypes
.
REQUEST_CHECK
,
payload
:
CHECK_RUNNERS
}],
[],
[],
done
,
);
);
});
});
});
});
describe
(
'
receiveRunnersCheckSuccess
'
,
()
=>
{
describe
(
'
receiveRunnersCheckSuccess
'
,
()
=>
{
it
(
'
handles successful response, with data
'
,
done
=>
{
it
(
'
handles successful response, with data
'
,
()
=>
{
const
payload
=
[{}];
const
payload
=
[{}];
testAction
(
return
testAction
(
actions
.
receiveRunnersCheckSuccess
,
actions
.
receiveRunnersCheckSuccess
,
payload
,
payload
,
state
,
state
,
[{
type
:
mutationTypes
.
RECEIVE_CHECK_SUCCESS
,
payload
:
CHECK_RUNNERS
}],
[{
type
:
mutationTypes
.
RECEIVE_CHECK_SUCCESS
,
payload
:
CHECK_RUNNERS
}],
[],
[],
done
,
);
);
});
});
it
(
'
handles successful response, with empty data
'
,
done
=>
{
it
(
'
handles successful response, with empty data
'
,
()
=>
{
const
commitPayload
=
{
const
commitPayload
=
{
type
:
CHECK_RUNNERS
,
type
:
CHECK_RUNNERS
,
message
:
messages
.
runnersCheckEmpty
(
TEST_RUNNERS_HELP_PATH
),
message
:
messages
.
runnersCheckEmpty
(
TEST_RUNNERS_HELP_PATH
),
};
};
testAction
(
return
testAction
(
actions
.
receiveRunnersCheckSuccess
,
actions
.
receiveRunnersCheckSuccess
,
[],
[],
state
,
state
,
[{
type
:
mutationTypes
.
RECEIVE_CHECK_ERROR
,
payload
:
commitPayload
}],
[{
type
:
mutationTypes
.
RECEIVE_CHECK_ERROR
,
payload
:
commitPayload
}],
[{
type
:
'
retryRunnersCheck
'
}],
[{
type
:
'
retryRunnersCheck
'
}],
done
,
);
);
});
});
});
});
describe
(
'
receiveRunnersCheckError
'
,
()
=>
{
describe
(
'
receiveRunnersCheckError
'
,
()
=>
{
it
(
'
dispatches handle with message
'
,
done
=>
{
it
(
'
dispatches handle with message
'
,
()
=>
{
const
commitPayload
=
{
const
commitPayload
=
{
type
:
CHECK_RUNNERS
,
type
:
CHECK_RUNNERS
,
message
:
messages
.
UNEXPECTED_ERROR_RUNNERS
,
message
:
messages
.
UNEXPECTED_ERROR_RUNNERS
,
};
};
testAction
(
return
testAction
(
actions
.
receiveRunnersCheckError
,
actions
.
receiveRunnersCheckError
,
null
,
null
,
{},
{},
[{
type
:
mutationTypes
.
RECEIVE_CHECK_ERROR
,
payload
:
commitPayload
}],
[{
type
:
mutationTypes
.
RECEIVE_CHECK_ERROR
,
payload
:
commitPayload
}],
[],
[],
done
,
);
);
});
});
});
});
describe
(
'
retryRunnersCheck
'
,
()
=>
{
describe
(
'
retryRunnersCheck
'
,
()
=>
{
it
(
'
dispatches fetch again after timeout
'
,
()
=>
{
it
(
'
dispatches fetch again after timeout
'
,
()
=>
{
const
dispatch
=
j
asmine
.
createSpy
(
'
dispatch
'
);
const
dispatch
=
j
est
.
fn
().
mockName
(
'
dispatch
'
);
actions
.
retryRunnersCheck
({
dispatch
,
state
});
actions
.
retryRunnersCheck
({
dispatch
,
state
});
expect
(
dispatch
).
not
.
toHaveBeenCalled
();
expect
(
dispatch
).
not
.
toHaveBeenCalled
();
j
asmine
.
clock
().
tick
(
RETRY_RUNNERS_INTERVAL
+
1
);
j
est
.
advanceTimersByTime
(
RETRY_RUNNERS_INTERVAL
+
1
);
expect
(
dispatch
).
toHaveBeenCalledWith
(
'
fetchRunnersCheck
'
,
{
background
:
true
});
expect
(
dispatch
).
toHaveBeenCalledWith
(
'
fetchRunnersCheck
'
,
{
background
:
true
});
});
});
it
(
'
does not dispatch fetch if config check is error
'
,
()
=>
{
it
(
'
does not dispatch fetch if config check is error
'
,
()
=>
{
const
dispatch
=
j
asmine
.
createSpy
(
'
dispatch
'
);
const
dispatch
=
j
est
.
fn
().
mockName
(
'
dispatch
'
);
state
.
checks
.
config
=
{
state
.
checks
.
config
=
{
isLoading
:
false
,
isLoading
:
false
,
isValid
:
false
,
isValid
:
false
,
...
@@ -248,52 +236,49 @@ describe('EE IDE store terminal check actions', () => {
...
@@ -248,52 +236,49 @@ describe('EE IDE store terminal check actions', () => {
expect
(
dispatch
).
not
.
toHaveBeenCalled
();
expect
(
dispatch
).
not
.
toHaveBeenCalled
();
j
asmine
.
clock
().
tick
(
RETRY_RUNNERS_INTERVAL
+
1
);
j
est
.
advanceTimersByTime
(
RETRY_RUNNERS_INTERVAL
+
1
);
expect
(
dispatch
).
not
.
toHaveBeenCalled
();
expect
(
dispatch
).
not
.
toHaveBeenCalled
();
});
});
});
});
describe
(
'
fetchRunnersCheck
'
,
()
=>
{
describe
(
'
fetchRunnersCheck
'
,
()
=>
{
it
(
'
dispatches request and receive
'
,
done
=>
{
it
(
'
dispatches request and receive
'
,
()
=>
{
mock
.
onGet
(
/api
\/
.*
\/
projects
\/
.*
\/
runners/
,
{
params
:
{
scope
:
'
active
'
}
}).
reply
(
200
,
[]);
mock
.
onGet
(
/api
\/
.*
\/
projects
\/
.*
\/
runners/
,
{
params
:
{
scope
:
'
active
'
}
}).
reply
(
200
,
[]);
testAction
(
return
testAction
(
actions
.
fetchRunnersCheck
,
actions
.
fetchRunnersCheck
,
{},
{},
rootGetters
,
rootGetters
,
[],
[],
[{
type
:
'
requestRunnersCheck
'
},
{
type
:
'
receiveRunnersCheckSuccess
'
,
payload
:
[]
}],
[{
type
:
'
requestRunnersCheck
'
},
{
type
:
'
receiveRunnersCheckSuccess
'
,
payload
:
[]
}],
done
,
);
);
});
});
it
(
'
does not dispatch request when background is true
'
,
done
=>
{
it
(
'
does not dispatch request when background is true
'
,
()
=>
{
mock
.
onGet
(
/api
\/
.*
\/
projects
\/
.*
\/
runners/
,
{
params
:
{
scope
:
'
active
'
}
}).
reply
(
200
,
[]);
mock
.
onGet
(
/api
\/
.*
\/
projects
\/
.*
\/
runners/
,
{
params
:
{
scope
:
'
active
'
}
}).
reply
(
200
,
[]);
testAction
(
return
testAction
(
actions
.
fetchRunnersCheck
,
actions
.
fetchRunnersCheck
,
{
background
:
true
},
{
background
:
true
},
rootGetters
,
rootGetters
,
[],
[],
[{
type
:
'
receiveRunnersCheckSuccess
'
,
payload
:
[]
}],
[{
type
:
'
receiveRunnersCheckSuccess
'
,
payload
:
[]
}],
done
,
);
);
});
});
it
(
'
dispatches request and receive, when error
'
,
done
=>
{
it
(
'
dispatches request and receive, when error
'
,
()
=>
{
mock
.
onGet
(
/api
\/
.*
\/
projects
\/
.*
\/
runners/
,
{
params
:
{
scope
:
'
active
'
}
}).
reply
(
500
,
[]);
mock
.
onGet
(
/api
\/
.*
\/
projects
\/
.*
\/
runners/
,
{
params
:
{
scope
:
'
active
'
}
}).
reply
(
500
,
[]);
testAction
(
return
testAction
(
actions
.
fetchRunnersCheck
,
actions
.
fetchRunnersCheck
,
{},
{},
rootGetters
,
rootGetters
,
[],
[],
[
[
{
type
:
'
requestRunnersCheck
'
},
{
type
:
'
requestRunnersCheck
'
},
{
type
:
'
receiveRunnersCheckError
'
,
payload
:
jasmine
.
any
(
Error
)
},
{
type
:
'
receiveRunnersCheckError
'
,
payload
:
expect
.
any
(
Error
)
},
],
],
done
,
);
);
});
});
});
});
...
...
ee/spec/
javascripts
/ide/stores/modules/terminal/actions/session_controls_spec.js
→
ee/spec/
frontend
/ide/stores/modules/terminal/actions/session_controls_spec.js
View file @
90b68e62
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
testAction
from
'
spec/
helpers/vuex_action_helper
'
;
import
testAction
from
'
helpers/vuex_action_helper
'
;
import
{
STARTING
,
PENDING
,
STOPPING
,
STOPPED
}
from
'
ee/ide/constants
'
;
import
{
STARTING
,
PENDING
,
STOPPING
,
STOPPED
}
from
'
ee/ide/constants
'
;
import
*
as
messages
from
'
ee/ide/stores/modules/terminal/messages
'
;
import
*
as
messages
from
'
ee/ide/stores/modules/terminal/messages
'
;
import
*
as
mutationTypes
from
'
ee/ide/stores/modules/terminal/mutation_types
'
;
import
*
as
mutationTypes
from
'
ee/ide/stores/modules/terminal/mutation_types
'
;
import
actionsModule
,
*
as
actions
from
'
ee/ide/stores/modules/terminal/actions/session_controls
'
;
import
*
as
actions
from
'
ee/ide/stores/modules/terminal/actions/session_controls
'
;
import
httpStatus
from
'
~/lib/utils/http_status
'
;
import
httpStatus
from
'
~/lib/utils/http_status
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
createFlash
from
'
~/flash
'
;
jest
.
mock
(
'
~/flash
'
);
const
TEST_PROJECT_PATH
=
'
lorem/root
'
;
const
TEST_PROJECT_PATH
=
'
lorem/root
'
;
const
TEST_BRANCH_ID
=
'
master
'
;
const
TEST_BRANCH_ID
=
'
master
'
;
...
@@ -25,11 +28,10 @@ describe('EE IDE store terminal session controls actions', () => {
...
@@ -25,11 +28,10 @@ describe('EE IDE store terminal session controls actions', () => {
let
dispatch
;
let
dispatch
;
let
rootState
;
let
rootState
;
let
rootGetters
;
let
rootGetters
;
let
flashSpy
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
mock
=
new
MockAdapter
(
axios
);
dispatch
=
j
asmine
.
createSpy
(
'
dispatch
'
);
dispatch
=
j
est
.
fn
().
mockName
(
'
dispatch
'
);
rootState
=
{
rootState
=
{
currentBranchId
:
TEST_BRANCH_ID
,
currentBranchId
:
TEST_BRANCH_ID
,
};
};
...
@@ -39,7 +41,6 @@ describe('EE IDE store terminal session controls actions', () => {
...
@@ -39,7 +41,6 @@ describe('EE IDE store terminal session controls actions', () => {
path_with_namespace
:
TEST_PROJECT_PATH
,
path_with_namespace
:
TEST_PROJECT_PATH
,
},
},
};
};
flashSpy
=
spyOnDependency
(
actionsModule
,
'
flash
'
);
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
...
@@ -47,21 +48,20 @@ describe('EE IDE store terminal session controls actions', () => {
...
@@ -47,21 +48,20 @@ describe('EE IDE store terminal session controls actions', () => {
});
});
describe
(
'
requestStartSession
'
,
()
=>
{
describe
(
'
requestStartSession
'
,
()
=>
{
it
(
'
sets session status
'
,
done
=>
{
it
(
'
sets session status
'
,
()
=>
{
testAction
(
return
testAction
(
actions
.
requestStartSession
,
actions
.
requestStartSession
,
null
,
null
,
{},
{},
[{
type
:
mutationTypes
.
SET_SESSION_STATUS
,
payload
:
STARTING
}],
[{
type
:
mutationTypes
.
SET_SESSION_STATUS
,
payload
:
STARTING
}],
[],
[],
done
,
);
);
});
});
});
});
describe
(
'
receiveStartSessionSuccess
'
,
()
=>
{
describe
(
'
receiveStartSessionSuccess
'
,
()
=>
{
it
(
'
sets session and starts polling status
'
,
done
=>
{
it
(
'
sets session and starts polling status
'
,
()
=>
{
testAction
(
return
testAction
(
actions
.
receiveStartSessionSuccess
,
actions
.
receiveStartSessionSuccess
,
TEST_SESSION
,
TEST_SESSION
,
{},
{},
...
@@ -81,7 +81,6 @@ describe('EE IDE store terminal session controls actions', () => {
...
@@ -81,7 +81,6 @@ describe('EE IDE store terminal session controls actions', () => {
},
},
],
],
[{
type
:
'
pollSessionStatus
'
}],
[{
type
:
'
pollSessionStatus
'
}],
done
,
);
);
});
});
});
});
...
@@ -90,11 +89,11 @@ describe('EE IDE store terminal session controls actions', () => {
...
@@ -90,11 +89,11 @@ describe('EE IDE store terminal session controls actions', () => {
it
(
'
flashes message
'
,
()
=>
{
it
(
'
flashes message
'
,
()
=>
{
actions
.
receiveStartSessionError
({
dispatch
});
actions
.
receiveStartSessionError
({
dispatch
});
expect
(
flashSpy
).
toHaveBeenCalledWith
(
messages
.
UNEXPECTED_ERROR_STARTING
);
expect
(
createFlash
).
toHaveBeenCalledWith
(
messages
.
UNEXPECTED_ERROR_STARTING
);
});
});
it
(
'
sets session status
'
,
done
=>
{
it
(
'
sets session status
'
,
()
=>
{
testAction
(
actions
.
receiveStartSessionError
,
null
,
{},
[],
[{
type
:
'
killSession
'
}],
done
);
return
testAction
(
actions
.
receiveStartSessionError
,
null
,
{},
[],
[{
type
:
'
killSession
'
}]
);
});
});
});
});
...
@@ -109,10 +108,10 @@ describe('EE IDE store terminal session controls actions', () => {
...
@@ -109,10 +108,10 @@ describe('EE IDE store terminal session controls actions', () => {
expect
(
dispatch
).
not
.
toHaveBeenCalled
();
expect
(
dispatch
).
not
.
toHaveBeenCalled
();
});
});
it
(
'
dispatches request and receive on success
'
,
done
=>
{
it
(
'
dispatches request and receive on success
'
,
()
=>
{
mock
.
onPost
(
/.*
\/
ide_terminals/
).
reply
(
200
,
TEST_SESSION
);
mock
.
onPost
(
/.*
\/
ide_terminals/
).
reply
(
200
,
TEST_SESSION
);
testAction
(
return
testAction
(
actions
.
startSession
,
actions
.
startSession
,
null
,
null
,
{
...
rootGetters
,
...
rootState
},
{
...
rootGetters
,
...
rootState
},
...
@@ -121,14 +120,13 @@ describe('EE IDE store terminal session controls actions', () => {
...
@@ -121,14 +120,13 @@ describe('EE IDE store terminal session controls actions', () => {
{
type
:
'
requestStartSession
'
},
{
type
:
'
requestStartSession
'
},
{
type
:
'
receiveStartSessionSuccess
'
,
payload
:
TEST_SESSION
},
{
type
:
'
receiveStartSessionSuccess
'
,
payload
:
TEST_SESSION
},
],
],
done
,
);
);
});
});
it
(
'
dispatches request and receive on error
'
,
done
=>
{
it
(
'
dispatches request and receive on error
'
,
()
=>
{
mock
.
onPost
(
/.*
\/
ide_terminals/
).
reply
(
400
);
mock
.
onPost
(
/.*
\/
ide_terminals/
).
reply
(
400
);
testAction
(
return
testAction
(
actions
.
startSession
,
actions
.
startSession
,
null
,
null
,
{
...
rootGetters
,
...
rootState
},
{
...
rootGetters
,
...
rootState
},
...
@@ -137,27 +135,25 @@ describe('EE IDE store terminal session controls actions', () => {
...
@@ -137,27 +135,25 @@ describe('EE IDE store terminal session controls actions', () => {
{
type
:
'
requestStartSession
'
},
{
type
:
'
requestStartSession
'
},
{
type
:
'
receiveStartSessionError
'
,
payload
:
jasmine
.
any
(
Error
)
},
{
type
:
'
receiveStartSessionError
'
,
payload
:
jasmine
.
any
(
Error
)
},
],
],
done
,
);
);
});
});
});
});
describe
(
'
requestStopSession
'
,
()
=>
{
describe
(
'
requestStopSession
'
,
()
=>
{
it
(
'
sets session status
'
,
done
=>
{
it
(
'
sets session status
'
,
()
=>
{
testAction
(
return
testAction
(
actions
.
requestStopSession
,
actions
.
requestStopSession
,
null
,
null
,
{},
{},
[{
type
:
mutationTypes
.
SET_SESSION_STATUS
,
payload
:
STOPPING
}],
[{
type
:
mutationTypes
.
SET_SESSION_STATUS
,
payload
:
STOPPING
}],
[],
[],
done
,
);
);
});
});
});
});
describe
(
'
receiveStopSessionSuccess
'
,
()
=>
{
describe
(
'
receiveStopSessionSuccess
'
,
()
=>
{
it
(
'
kills the session
'
,
done
=>
{
it
(
'
kills the session
'
,
()
=>
{
testAction
(
actions
.
receiveStopSessionSuccess
,
null
,
{},
[],
[{
type
:
'
killSession
'
}],
done
);
return
testAction
(
actions
.
receiveStopSessionSuccess
,
null
,
{},
[],
[{
type
:
'
killSession
'
}]
);
});
});
});
});
...
@@ -165,40 +161,39 @@ describe('EE IDE store terminal session controls actions', () => {
...
@@ -165,40 +161,39 @@ describe('EE IDE store terminal session controls actions', () => {
it
(
'
flashes message
'
,
()
=>
{
it
(
'
flashes message
'
,
()
=>
{
actions
.
receiveStopSessionError
({
dispatch
});
actions
.
receiveStopSessionError
({
dispatch
});
expect
(
flashSpy
).
toHaveBeenCalledWith
(
messages
.
UNEXPECTED_ERROR_STOPPING
);
expect
(
createFlash
).
toHaveBeenCalledWith
(
messages
.
UNEXPECTED_ERROR_STOPPING
);
});
});
it
(
'
kills the session
'
,
done
=>
{
it
(
'
kills the session
'
,
()
=>
{
testAction
(
actions
.
receiveStopSessionError
,
null
,
{},
[],
[{
type
:
'
killSession
'
}],
done
);
return
testAction
(
actions
.
receiveStopSessionError
,
null
,
{},
[],
[{
type
:
'
killSession
'
}]
);
});
});
});
});
describe
(
'
stopSession
'
,
()
=>
{
describe
(
'
stopSession
'
,
()
=>
{
it
(
'
dispatches request and receive on success
'
,
done
=>
{
it
(
'
dispatches request and receive on success
'
,
()
=>
{
mock
.
onPost
(
TEST_SESSION
.
cancel_path
).
reply
(
200
,
{});
mock
.
onPost
(
TEST_SESSION
.
cancel_path
).
reply
(
200
,
{});
const
state
=
{
const
state
=
{
session
:
{
cancelPath
:
TEST_SESSION
.
cancel_path
},
session
:
{
cancelPath
:
TEST_SESSION
.
cancel_path
},
};
};
testAction
(
return
testAction
(
actions
.
stopSession
,
actions
.
stopSession
,
null
,
null
,
state
,
state
,
[],
[],
[{
type
:
'
requestStopSession
'
},
{
type
:
'
receiveStopSessionSuccess
'
}],
[{
type
:
'
requestStopSession
'
},
{
type
:
'
receiveStopSessionSuccess
'
}],
done
,
);
);
});
});
it
(
'
dispatches request and receive on error
'
,
done
=>
{
it
(
'
dispatches request and receive on error
'
,
()
=>
{
mock
.
onPost
(
TEST_SESSION
.
cancel_path
).
reply
(
400
);
mock
.
onPost
(
TEST_SESSION
.
cancel_path
).
reply
(
400
);
const
state
=
{
const
state
=
{
session
:
{
cancelPath
:
TEST_SESSION
.
cancel_path
},
session
:
{
cancelPath
:
TEST_SESSION
.
cancel_path
},
};
};
testAction
(
return
testAction
(
actions
.
stopSession
,
actions
.
stopSession
,
null
,
null
,
state
,
state
,
...
@@ -207,20 +202,18 @@ describe('EE IDE store terminal session controls actions', () => {
...
@@ -207,20 +202,18 @@ describe('EE IDE store terminal session controls actions', () => {
{
type
:
'
requestStopSession
'
},
{
type
:
'
requestStopSession
'
},
{
type
:
'
receiveStopSessionError
'
,
payload
:
jasmine
.
any
(
Error
)
},
{
type
:
'
receiveStopSessionError
'
,
payload
:
jasmine
.
any
(
Error
)
},
],
],
done
,
);
);
});
});
});
});
describe
(
'
killSession
'
,
()
=>
{
describe
(
'
killSession
'
,
()
=>
{
it
(
'
stops polling and sets status
'
,
done
=>
{
it
(
'
stops polling and sets status
'
,
()
=>
{
testAction
(
return
testAction
(
actions
.
killSession
,
actions
.
killSession
,
null
,
null
,
{},
{},
[{
type
:
mutationTypes
.
SET_SESSION_STATUS
,
payload
:
STOPPED
}],
[{
type
:
mutationTypes
.
SET_SESSION_STATUS
,
payload
:
STOPPED
}],
[{
type
:
'
stopPollingSessionStatus
'
}],
[{
type
:
'
stopPollingSessionStatus
'
}],
done
,
);
);
});
});
});
});
...
@@ -242,25 +235,24 @@ describe('EE IDE store terminal session controls actions', () => {
...
@@ -242,25 +235,24 @@ describe('EE IDE store terminal session controls actions', () => {
expect
(
dispatch
).
not
.
toHaveBeenCalled
();
expect
(
dispatch
).
not
.
toHaveBeenCalled
();
});
});
it
(
'
dispatches startSession if retryPath is empty
'
,
done
=>
{
it
(
'
dispatches startSession if retryPath is empty
'
,
()
=>
{
state
.
session
.
retryPath
=
''
;
state
.
session
.
retryPath
=
''
;
testAction
(
return
testAction
(
actions
.
restartSession
,
actions
.
restartSession
,
null
,
null
,
{
...
state
,
...
rootState
},
{
...
state
,
...
rootState
},
[],
[],
[{
type
:
'
startSession
'
}],
[{
type
:
'
startSession
'
}],
done
,
);
);
});
});
it
(
'
dispatches request and receive on success
'
,
done
=>
{
it
(
'
dispatches request and receive on success
'
,
()
=>
{
mock
mock
.
onPost
(
state
.
session
.
retryPath
,
{
branch
:
rootState
.
currentBranchId
,
format
:
'
json
'
})
.
onPost
(
state
.
session
.
retryPath
,
{
branch
:
rootState
.
currentBranchId
,
format
:
'
json
'
})
.
reply
(
200
,
TEST_SESSION
);
.
reply
(
200
,
TEST_SESSION
);
testAction
(
return
testAction
(
actions
.
restartSession
,
actions
.
restartSession
,
null
,
null
,
{
...
state
,
...
rootState
},
{
...
state
,
...
rootState
},
...
@@ -269,16 +261,15 @@ describe('EE IDE store terminal session controls actions', () => {
...
@@ -269,16 +261,15 @@ describe('EE IDE store terminal session controls actions', () => {
{
type
:
'
requestStartSession
'
},
{
type
:
'
requestStartSession
'
},
{
type
:
'
receiveStartSessionSuccess
'
,
payload
:
TEST_SESSION
},
{
type
:
'
receiveStartSessionSuccess
'
,
payload
:
TEST_SESSION
},
],
],
done
,
);
);
});
});
it
(
'
dispatches request and receive on error
'
,
done
=>
{
it
(
'
dispatches request and receive on error
'
,
()
=>
{
mock
mock
.
onPost
(
state
.
session
.
retryPath
,
{
branch
:
rootState
.
currentBranchId
,
format
:
'
json
'
})
.
onPost
(
state
.
session
.
retryPath
,
{
branch
:
rootState
.
currentBranchId
,
format
:
'
json
'
})
.
reply
(
400
);
.
reply
(
400
);
testAction
(
return
testAction
(
actions
.
restartSession
,
actions
.
restartSession
,
null
,
null
,
{
...
state
,
...
rootState
},
{
...
state
,
...
rootState
},
...
@@ -287,23 +278,21 @@ describe('EE IDE store terminal session controls actions', () => {
...
@@ -287,23 +278,21 @@ describe('EE IDE store terminal session controls actions', () => {
{
type
:
'
requestStartSession
'
},
{
type
:
'
requestStartSession
'
},
{
type
:
'
receiveStartSessionError
'
,
payload
:
jasmine
.
any
(
Error
)
},
{
type
:
'
receiveStartSessionError
'
,
payload
:
jasmine
.
any
(
Error
)
},
],
],
done
,
);
);
});
});
[
httpStatus
.
NOT_FOUND
,
httpStatus
.
UNPROCESSABLE_ENTITY
].
forEach
(
status
=>
{
[
httpStatus
.
NOT_FOUND
,
httpStatus
.
UNPROCESSABLE_ENTITY
].
forEach
(
status
=>
{
it
(
`dispatches request and startSession on
${
status
}
`
,
done
=>
{
it
(
`dispatches request and startSession on
${
status
}
`
,
()
=>
{
mock
mock
.
onPost
(
state
.
session
.
retryPath
,
{
branch
:
rootState
.
currentBranchId
,
format
:
'
json
'
})
.
onPost
(
state
.
session
.
retryPath
,
{
branch
:
rootState
.
currentBranchId
,
format
:
'
json
'
})
.
reply
(
status
);
.
reply
(
status
);
testAction
(
return
testAction
(
actions
.
restartSession
,
actions
.
restartSession
,
null
,
null
,
{
...
state
,
...
rootState
},
{
...
state
,
...
rootState
},
[],
[],
[{
type
:
'
requestStartSession
'
},
{
type
:
'
startSession
'
}],
[{
type
:
'
requestStartSession
'
},
{
type
:
'
startSession
'
}],
done
,
);
);
});
});
});
});
...
...
ee/spec/
javascripts
/ide/stores/modules/terminal/actions/session_status_spec.js
→
ee/spec/
frontend
/ide/stores/modules/terminal/actions/session_status_spec.js
View file @
90b68e62
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
testAction
from
'
spec/
helpers/vuex_action_helper
'
;
import
testAction
from
'
helpers/vuex_action_helper
'
;
import
{
PENDING
,
RUNNING
,
STOPPING
,
STOPPED
}
from
'
ee/ide/constants
'
;
import
{
PENDING
,
RUNNING
,
STOPPING
,
STOPPED
}
from
'
ee/ide/constants
'
;
import
*
as
messages
from
'
ee/ide/stores/modules/terminal/messages
'
;
import
*
as
messages
from
'
ee/ide/stores/modules/terminal/messages
'
;
import
*
as
mutationTypes
from
'
ee/ide/stores/modules/terminal/mutation_types
'
;
import
*
as
mutationTypes
from
'
ee/ide/stores/modules/terminal/mutation_types
'
;
import
actionsModule
,
*
as
actions
from
'
ee/ide/stores/modules/terminal/actions/session_status
'
;
import
*
as
actions
from
'
ee/ide/stores/modules/terminal/actions/session_status
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
createFlash
from
'
~/flash
'
;
jest
.
mock
(
'
~/flash
'
);
const
TEST_SESSION
=
{
const
TEST_SESSION
=
{
id
:
7
,
id
:
7
,
...
@@ -19,30 +22,25 @@ describe('EE IDE store terminal session controls actions', () => {
...
@@ -19,30 +22,25 @@ describe('EE IDE store terminal session controls actions', () => {
let
mock
;
let
mock
;
let
dispatch
;
let
dispatch
;
let
commit
;
let
commit
;
let
flashSpy
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
jasmine
.
clock
().
install
();
mock
=
new
MockAdapter
(
axios
);
mock
=
new
MockAdapter
(
axios
);
dispatch
=
jasmine
.
createSpy
(
'
dispatch
'
);
dispatch
=
jest
.
fn
().
mockName
(
'
dispatch
'
);
commit
=
jasmine
.
createSpy
(
'
commit
'
);
commit
=
jest
.
fn
().
mockName
(
'
commit
'
);
flashSpy
=
spyOnDependency
(
actionsModule
,
'
flash
'
);
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
jasmine
.
clock
().
uninstall
();
mock
.
restore
();
mock
.
restore
();
});
});
describe
(
'
pollSessionStatus
'
,
()
=>
{
describe
(
'
pollSessionStatus
'
,
()
=>
{
it
(
'
starts interval to poll status
'
,
done
=>
{
it
(
'
starts interval to poll status
'
,
()
=>
{
testAction
(
return
testAction
(
actions
.
pollSessionStatus
,
actions
.
pollSessionStatus
,
null
,
null
,
{},
{},
[{
type
:
mutationTypes
.
SET_SESSION_STATUS_INTERVAL
,
payload
:
jasmine
.
any
(
Number
)
}],
[{
type
:
mutationTypes
.
SET_SESSION_STATUS_INTERVAL
,
payload
:
expect
.
any
(
Number
)
}],
[{
type
:
'
stopPollingSessionStatus
'
},
{
type
:
'
fetchSessionStatus
'
}],
[{
type
:
'
stopPollingSessionStatus
'
},
{
type
:
'
fetchSessionStatus
'
}],
done
,
);
);
});
});
...
@@ -52,9 +50,9 @@ describe('EE IDE store terminal session controls actions', () => {
...
@@ -52,9 +50,9 @@ describe('EE IDE store terminal session controls actions', () => {
};
};
actions
.
pollSessionStatus
({
state
,
dispatch
,
commit
});
actions
.
pollSessionStatus
({
state
,
dispatch
,
commit
});
dispatch
.
calls
.
reset
();
dispatch
.
mockClear
();
j
asmine
.
clock
().
tick
(
5001
);
j
est
.
advanceTimersByTime
(
5001
);
expect
(
dispatch
).
toHaveBeenCalledWith
(
'
stopPollingSessionStatus
'
);
expect
(
dispatch
).
toHaveBeenCalledWith
(
'
stopPollingSessionStatus
'
);
});
});
...
@@ -65,52 +63,49 @@ describe('EE IDE store terminal session controls actions', () => {
...
@@ -65,52 +63,49 @@ describe('EE IDE store terminal session controls actions', () => {
};
};
actions
.
pollSessionStatus
({
state
,
dispatch
,
commit
});
actions
.
pollSessionStatus
({
state
,
dispatch
,
commit
});
dispatch
.
calls
.
reset
();
dispatch
.
mockClear
();
j
asmine
.
clock
().
tick
(
5001
);
j
est
.
advanceTimersByTime
(
5001
);
expect
(
dispatch
).
toHaveBeenCalledWith
(
'
fetchSessionStatus
'
);
expect
(
dispatch
).
toHaveBeenCalledWith
(
'
fetchSessionStatus
'
);
});
});
});
});
describe
(
'
stopPollingSessionStatus
'
,
()
=>
{
describe
(
'
stopPollingSessionStatus
'
,
()
=>
{
it
(
'
does nothing if sessionStatusInterval is empty
'
,
done
=>
{
it
(
'
does nothing if sessionStatusInterval is empty
'
,
()
=>
{
testAction
(
actions
.
stopPollingSessionStatus
,
null
,
{},
[],
[],
done
);
return
testAction
(
actions
.
stopPollingSessionStatus
,
null
,
{},
[],
[]
);
});
});
it
(
'
clears interval
'
,
done
=>
{
it
(
'
clears interval
'
,
()
=>
{
testAction
(
return
testAction
(
actions
.
stopPollingSessionStatus
,
actions
.
stopPollingSessionStatus
,
null
,
null
,
{
sessionStatusInterval
:
7
},
{
sessionStatusInterval
:
7
},
[{
type
:
mutationTypes
.
SET_SESSION_STATUS_INTERVAL
,
payload
:
0
}],
[{
type
:
mutationTypes
.
SET_SESSION_STATUS_INTERVAL
,
payload
:
0
}],
[],
[],
done
,
);
);
});
});
});
});
describe
(
'
receiveSessionStatusSuccess
'
,
()
=>
{
describe
(
'
receiveSessionStatusSuccess
'
,
()
=>
{
it
(
'
sets session status
'
,
done
=>
{
it
(
'
sets session status
'
,
()
=>
{
testAction
(
return
testAction
(
actions
.
receiveSessionStatusSuccess
,
actions
.
receiveSessionStatusSuccess
,
{
status
:
RUNNING
},
{
status
:
RUNNING
},
{},
{},
[{
type
:
mutationTypes
.
SET_SESSION_STATUS
,
payload
:
RUNNING
}],
[{
type
:
mutationTypes
.
SET_SESSION_STATUS
,
payload
:
RUNNING
}],
[],
[],
done
,
);
);
});
});
[
STOPPING
,
STOPPED
,
'
unexpected
'
].
forEach
(
status
=>
{
[
STOPPING
,
STOPPED
,
'
unexpected
'
].
forEach
(
status
=>
{
it
(
`kills session if status is
${
status
}
`
,
done
=>
{
it
(
`kills session if status is
${
status
}
`
,
()
=>
{
testAction
(
return
testAction
(
actions
.
receiveSessionStatusSuccess
,
actions
.
receiveSessionStatusSuccess
,
{
status
},
{
status
},
{},
{},
[{
type
:
mutationTypes
.
SET_SESSION_STATUS
,
payload
:
status
}],
[{
type
:
mutationTypes
.
SET_SESSION_STATUS
,
payload
:
status
}],
[{
type
:
'
killSession
'
}],
[{
type
:
'
killSession
'
}],
done
,
);
);
});
});
});
});
...
@@ -120,11 +115,11 @@ describe('EE IDE store terminal session controls actions', () => {
...
@@ -120,11 +115,11 @@ describe('EE IDE store terminal session controls actions', () => {
it
(
'
flashes message
'
,
()
=>
{
it
(
'
flashes message
'
,
()
=>
{
actions
.
receiveSessionStatusError
({
dispatch
});
actions
.
receiveSessionStatusError
({
dispatch
});
expect
(
flashSpy
).
toHaveBeenCalledWith
(
messages
.
UNEXPECTED_ERROR_STATUS
);
expect
(
createFlash
).
toHaveBeenCalledWith
(
messages
.
UNEXPECTED_ERROR_STATUS
);
});
});
it
(
'
kills the session
'
,
done
=>
{
it
(
'
kills the session
'
,
()
=>
{
testAction
(
actions
.
receiveSessionStatusError
,
null
,
{},
[],
[{
type
:
'
killSession
'
}],
done
);
return
testAction
(
actions
.
receiveSessionStatusError
,
null
,
{},
[],
[{
type
:
'
killSession
'
}]
);
});
});
});
});
...
@@ -147,29 +142,27 @@ describe('EE IDE store terminal session controls actions', () => {
...
@@ -147,29 +142,27 @@ describe('EE IDE store terminal session controls actions', () => {
expect
(
dispatch
).
not
.
toHaveBeenCalled
();
expect
(
dispatch
).
not
.
toHaveBeenCalled
();
});
});
it
(
'
dispatches success on success
'
,
done
=>
{
it
(
'
dispatches success on success
'
,
()
=>
{
mock
.
onGet
(
state
.
session
.
showPath
).
reply
(
200
,
TEST_SESSION
);
mock
.
onGet
(
state
.
session
.
showPath
).
reply
(
200
,
TEST_SESSION
);
testAction
(
return
testAction
(
actions
.
fetchSessionStatus
,
actions
.
fetchSessionStatus
,
null
,
null
,
state
,
state
,
[],
[],
[{
type
:
'
receiveSessionStatusSuccess
'
,
payload
:
TEST_SESSION
}],
[{
type
:
'
receiveSessionStatusSuccess
'
,
payload
:
TEST_SESSION
}],
done
,
);
);
});
});
it
(
'
dispatches error on error
'
,
done
=>
{
it
(
'
dispatches error on error
'
,
()
=>
{
mock
.
onGet
(
state
.
session
.
showPath
).
reply
(
400
);
mock
.
onGet
(
state
.
session
.
showPath
).
reply
(
400
);
testAction
(
return
testAction
(
actions
.
fetchSessionStatus
,
actions
.
fetchSessionStatus
,
null
,
null
,
state
,
state
,
[],
[],
[{
type
:
'
receiveSessionStatusError
'
,
payload
:
jasmine
.
any
(
Error
)
}],
[{
type
:
'
receiveSessionStatusError
'
,
payload
:
expect
.
any
(
Error
)
}],
done
,
);
);
});
});
});
});
...
...
ee/spec/
javascripts
/ide/stores/modules/terminal/actions/setup_spec.js
→
ee/spec/
frontend
/ide/stores/modules/terminal/actions/setup_spec.js
View file @
90b68e62
import
testAction
from
'
spec/
helpers/vuex_action_helper
'
;
import
testAction
from
'
helpers/vuex_action_helper
'
;
import
*
as
mutationTypes
from
'
ee/ide/stores/modules/terminal/mutation_types
'
;
import
*
as
mutationTypes
from
'
ee/ide/stores/modules/terminal/mutation_types
'
;
import
*
as
actions
from
'
ee/ide/stores/modules/terminal/actions/setup
'
;
import
*
as
actions
from
'
ee/ide/stores/modules/terminal/actions/setup
'
;
describe
(
'
EE IDE store terminal setup actions
'
,
()
=>
{
describe
(
'
EE IDE store terminal setup actions
'
,
()
=>
{
describe
(
'
init
'
,
()
=>
{
describe
(
'
init
'
,
()
=>
{
it
(
'
dispatches checks
'
,
done
=>
{
it
(
'
dispatches checks
'
,
()
=>
{
testAction
(
return
testAction
(
actions
.
init
,
actions
.
init
,
null
,
null
,
{},
{},
[],
[],
[{
type
:
'
fetchConfigCheck
'
},
{
type
:
'
fetchRunnersCheck
'
}],
[{
type
:
'
fetchConfigCheck
'
},
{
type
:
'
fetchRunnersCheck
'
}],
done
,
);
);
});
});
});
});
describe
(
'
hideSplash
'
,
()
=>
{
describe
(
'
hideSplash
'
,
()
=>
{
it
(
'
commits HIDE_SPLASH
'
,
done
=>
{
it
(
'
commits HIDE_SPLASH
'
,
()
=>
{
testAction
(
actions
.
hideSplash
,
null
,
{},
[{
type
:
mutationTypes
.
HIDE_SPLASH
}],
[],
done
);
return
testAction
(
actions
.
hideSplash
,
null
,
{},
[{
type
:
mutationTypes
.
HIDE_SPLASH
}],
[]
);
});
});
});
});
describe
(
'
setPaths
'
,
()
=>
{
describe
(
'
setPaths
'
,
()
=>
{
it
(
'
commits SET_PATHS
'
,
done
=>
{
it
(
'
commits SET_PATHS
'
,
()
=>
{
const
paths
=
{
const
paths
=
{
foo
:
'
bar
'
,
foo
:
'
bar
'
,
lorem
:
'
ipsum
'
,
lorem
:
'
ipsum
'
,
};
};
testAction
(
return
testAction
(
actions
.
setPaths
,
actions
.
setPaths
,
paths
,
paths
,
{},
{},
[{
type
:
mutationTypes
.
SET_PATHS
,
payload
:
paths
}],
[{
type
:
mutationTypes
.
SET_PATHS
,
payload
:
paths
}],
[],
[],
done
,
);
);
});
});
});
});
...
...
ee/spec/
javascripts
/ide/stores/modules/terminal/messages_spec.js
→
ee/spec/
frontend
/ide/stores/modules/terminal/messages_spec.js
View file @
90b68e62
File moved
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