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
e8a7fbc5
Commit
e8a7fbc5
authored
Mar 19, 2020
by
Vitaly Slobodin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate ee/add_slack_app to Jest
Closes
https://gitlab.com/gitlab-org/gitlab/-/issues/194265
parent
5ac9eb84
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
45 deletions
+33
-45
ee/spec/frontend/add_gitlab_slack_application/components/add_gitlab_slack_application_spec.js
...plication/components/add_gitlab_slack_application_spec.js
+33
-45
No files found.
ee/spec/
javascripts
/add_gitlab_slack_application/components/add_gitlab_slack_application_spec.js
→
ee/spec/
frontend
/add_gitlab_slack_application/components/add_gitlab_slack_application_spec.js
View file @
e8a7fbc5
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
addGitlabSlackApplication
from
'
ee/add_gitlab_slack_application/components/add_gitlab_slack_application.vue
'
;
import
addGitlabSlackApplication
from
'
ee/add_gitlab_slack_application/components/add_gitlab_slack_application.vue
'
;
import
GitlabSlackService
from
'
ee/add_gitlab_slack_application/services/gitlab_slack_service
'
;
import
GitlabSlackService
from
'
ee/add_gitlab_slack_application/services/gitlab_slack_service
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
{
redirectTo
}
from
'
~/lib/utils/url_utility
'
;
jest
.
mock
(
'
~/lib/utils/url_utility
'
);
describe
(
'
AddGitlabSlackApplication
'
,
()
=>
{
describe
(
'
AddGitlabSlackApplication
'
,
()
=>
{
const
redirectLink
=
'
//redirectLink
'
;
const
redirectLink
=
'
//redirectLink
'
;
...
@@ -34,35 +37,31 @@ describe('AddGitlabSlackApplication', () => {
...
@@ -34,35 +37,31 @@ describe('AddGitlabSlackApplication', () => {
const
AddGitlabSlackApplication
=
Vue
.
extend
(
addGitlabSlackApplication
);
const
AddGitlabSlackApplication
=
Vue
.
extend
(
addGitlabSlackApplication
);
it
(
'
opens popup when button is clicked
'
,
done
=>
{
it
(
'
opens popup when button is clicked
'
,
()
=>
{
const
vm
=
mountComponent
(
AddGitlabSlackApplication
,
DEFAULT_PROPS
);
const
vm
=
mountComponent
(
AddGitlabSlackApplication
,
DEFAULT_PROPS
);
vm
.
$el
.
querySelector
(
'
.js-popup-button
'
).
click
();
vm
.
$el
.
querySelector
(
'
.js-popup-button
'
).
click
();
vm
.
$nextTick
()
return
vm
.
$nextTick
().
then
(()
=>
{
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-popup
'
)).
toBeDefined
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-popup
'
)).
toBeDefined
();
});
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
hides popup when button is clicked
'
,
done
=>
{
it
(
'
hides popup when button is clicked
'
,
()
=>
{
const
vm
=
mountComponent
(
AddGitlabSlackApplication
,
DEFAULT_PROPS
);
const
vm
=
mountComponent
(
AddGitlabSlackApplication
,
DEFAULT_PROPS
);
vm
.
popupOpen
=
true
;
vm
.
popupOpen
=
true
;
vm
.
$nextTick
()
return
vm
.
$nextTick
()
.
then
(()
=>
vm
.
$el
.
querySelector
(
'
.js-popup-button
'
).
click
())
.
then
(()
=>
vm
.
$el
.
querySelector
(
'
.js-popup-button
'
).
click
())
.
then
(
vm
.
$nextTick
)
.
then
(
vm
.
$nextTick
)
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-popup
'
)).
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-popup
'
)).
toBeNull
();
})
});
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
popup has a project select when signed in
'
,
done
=>
{
it
(
'
popup has a project select when signed in
'
,
()
=>
{
const
vm
=
mountComponent
(
AddGitlabSlackApplication
,
{
const
vm
=
mountComponent
(
AddGitlabSlackApplication
,
{
...
DEFAULT_PROPS
,
...
DEFAULT_PROPS
,
isSignedIn
:
true
,
isSignedIn
:
true
,
...
@@ -70,15 +69,12 @@ describe('AddGitlabSlackApplication', () => {
...
@@ -70,15 +69,12 @@ describe('AddGitlabSlackApplication', () => {
vm
.
popupOpen
=
true
;
vm
.
popupOpen
=
true
;
vm
.
$nextTick
()
return
vm
.
$nextTick
().
then
(()
=>
{
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-project-select
'
)).
toBeDefined
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-project-select
'
)).
toBeDefined
();
});
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
popup has a message when there is no projects
'
,
done
=>
{
it
(
'
popup has a message when there is no projects
'
,
()
=>
{
const
vm
=
mountComponent
(
AddGitlabSlackApplication
,
{
const
vm
=
mountComponent
(
AddGitlabSlackApplication
,
{
...
DEFAULT_PROPS
,
...
DEFAULT_PROPS
,
projects
:
[],
projects
:
[],
...
@@ -87,17 +83,14 @@ describe('AddGitlabSlackApplication', () => {
...
@@ -87,17 +83,14 @@ describe('AddGitlabSlackApplication', () => {
vm
.
popupOpen
=
true
;
vm
.
popupOpen
=
true
;
vm
.
$nextTick
()
return
vm
.
$nextTick
().
then
(()
=>
{
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-no-projects
'
).
textContent
).
toMatch
(
expect
(
vm
.
$el
.
querySelector
(
'
.js-no-projects
'
).
textContent
).
toMatch
(
"
You don't have any projects available.
"
,
"
You don't have any projects available.
"
,
);
);
});
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
popup has a sign in link when logged out
'
,
done
=>
{
it
(
'
popup has a sign in link when logged out
'
,
()
=>
{
const
vm
=
mountComponent
(
AddGitlabSlackApplication
,
{
const
vm
=
mountComponent
(
AddGitlabSlackApplication
,
{
...
DEFAULT_PROPS
,
...
DEFAULT_PROPS
,
});
});
...
@@ -105,36 +98,31 @@ describe('AddGitlabSlackApplication', () => {
...
@@ -105,36 +98,31 @@ describe('AddGitlabSlackApplication', () => {
vm
.
popupOpen
=
true
;
vm
.
popupOpen
=
true
;
vm
.
selectedProjectId
=
4
;
vm
.
selectedProjectId
=
4
;
vm
.
$nextTick
()
return
vm
.
$nextTick
().
then
(()
=>
{
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-gitlab-slack-sign-in-link
'
).
href
).
toMatch
(
expect
(
vm
.
$el
.
querySelector
(
'
.js-gitlab-slack-sign-in-link
'
).
href
).
toMatch
(
new
RegExp
(
signInPath
,
'
i
'
),
new
RegExp
(
signInPath
,
'
i
'
),
);
);
});
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
redirects user to external link when submitted
'
,
done
=>
{
it
(
'
redirects user to external link when submitted
'
,
()
=>
{
const
vm
=
mountComponent
(
AddGitlabSlackApplication
,
{
const
vm
=
mountComponent
(
AddGitlabSlackApplication
,
{
...
DEFAULT_PROPS
,
...
DEFAULT_PROPS
,
isSignedIn
:
true
,
isSignedIn
:
true
,
});
});
const
addToSlackPromise
=
Promise
.
resolve
({
data
:
{
add_to_slack_link
:
redirectLink
}
});
const
addToSlackPromise
=
Promise
.
resolve
({
data
:
{
add_to_slack_link
:
redirectLink
}
});
spyOn
(
GitlabSlackService
,
'
addToSlack
'
).
and
.
returnValue
(
addToSlackPromise
);
jest
.
spyOn
(
GitlabSlackService
,
'
addToSlack
'
).
mockReturnValue
(
addToSlackPromise
);
const
redirectTo
=
spyOnDependency
(
addGitlabSlackApplication
,
'
redirectTo
'
);
vm
.
popupOpen
=
true
;
vm
.
popupOpen
=
true
;
vm
.
$nextTick
()
return
vm
.
$nextTick
()
.
then
(()
=>
vm
.
$el
.
querySelector
(
'
.js-add-button
'
).
click
())
.
then
(()
=>
vm
.
$el
.
querySelector
(
'
.js-add-button
'
).
click
())
.
then
(
vm
.
$nextTick
)
.
then
(
vm
.
$nextTick
)
.
then
(
addToSlackPromise
)
.
then
(
addToSlackPromise
)
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
redirectTo
).
toHaveBeenCalledWith
(
redirectLink
);
expect
(
redirectTo
).
toHaveBeenCalledWith
(
redirectLink
);
})
});
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
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