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
05e61c36
Commit
05e61c36
authored
Dec 11, 2017
by
Eric Eastwood
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use shared interceptor in note specs
parent
9469979a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
215 additions
and
205 deletions
+215
-205
spec/javascripts/notes/components/issue_note_app_spec.js
spec/javascripts/notes/components/issue_note_app_spec.js
+15
-31
spec/javascripts/notes/mock_data.js
spec/javascripts/notes/mock_data.js
+200
-174
No files found.
spec/javascripts/notes/components/issue_note_app_spec.js
View file @
05e61c36
...
...
@@ -8,28 +8,6 @@ describe('issue_note_app', () => {
let
mountComponent
;
let
vm
;
const
individualNoteInterceptor
=
(
request
,
next
)
=>
{
next
(
request
.
respondWith
(
JSON
.
stringify
(
mockData
.
individualNoteServerResponse
),
{
status
:
200
,
}));
};
const
noteInterceptor
=
(
request
,
next
)
=>
{
if
(
request
.
url
===
'
/gitlab-org/gitlab-ce/issues/26/discussions.json
'
)
{
next
(
request
.
respondWith
(
JSON
.
stringify
(
mockData
.
discussionNoteServerResponse
),
{
status
:
200
,
}));
}
else
if
(
request
.
url
===
'
/gitlab-org/gitlab-ce/noteable/issue/98/notes
'
)
{
next
(
request
.
respondWith
(
JSON
.
stringify
(
mockData
.
notesPollingResponse
),
{
status
:
200
,
}));
}
else
if
(
request
.
method
===
'
PUT
'
&&
request
.
url
===
'
/gitlab-org/gitlab-ce/notes/1471
'
)
{
next
(
request
.
respondWith
(
JSON
.
stringify
(
mockData
.
updatedNoteResponse
),
{
status
:
200
,
}));
}
};
beforeEach
(()
=>
{
const
IssueNotesApp
=
Vue
.
extend
(
issueNotesApp
);
...
...
@@ -85,16 +63,16 @@ describe('issue_note_app', () => {
describe
(
'
render
'
,
()
=>
{
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
individualNoteInterceptor
);
Vue
.
http
.
interceptors
.
push
(
mockData
.
individualNoteInterceptor
);
vm
=
mountComponent
();
});
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
individualNoteInterceptor
);
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
mockData
.
individualNoteInterceptor
);
});
it
(
'
should render list of notes
'
,
(
done
)
=>
{
const
note
=
mockData
.
individualNoteServerResponse
[
0
].
notes
[
0
];
const
note
=
mockData
.
INDIVIDUAL_NOTE_RESPONSE_MAP
.
GET
[
'
/gitlab-org/gitlab-ce/issues/26/discussions.json
'
]
[
0
].
notes
[
0
];
setTimeout
(()
=>
{
expect
(
...
...
@@ -140,13 +118,16 @@ describe('issue_note_app', () => {
describe
(
'
update note
'
,
()
=>
{
describe
(
'
individual note
'
,
()
=>
{
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
n
oteInterceptor
);
Vue
.
http
.
interceptors
.
push
(
mockData
.
individualN
oteInterceptor
);
spyOn
(
service
,
'
updateNote
'
).
and
.
callThrough
();
vm
=
mountComponent
();
});
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
noteInterceptor
);
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
mockData
.
individualNoteInterceptor
,
);
});
it
(
'
renders edit form
'
,
(
done
)
=>
{
...
...
@@ -180,13 +161,16 @@ describe('issue_note_app', () => {
describe
(
'
dicussion note
'
,
()
=>
{
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
n
oteInterceptor
);
Vue
.
http
.
interceptors
.
push
(
mockData
.
discussionN
oteInterceptor
);
spyOn
(
service
,
'
updateNote
'
).
and
.
callThrough
();
vm
=
mountComponent
();
});
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
noteInterceptor
);
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
mockData
.
discussionNoteInterceptor
,
);
});
it
(
'
renders edit form
'
,
(
done
)
=>
{
...
...
@@ -237,12 +221,12 @@ describe('issue_note_app', () => {
describe
(
'
edit form
'
,
()
=>
{
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
individualNoteInterceptor
);
Vue
.
http
.
interceptors
.
push
(
mockData
.
individualNoteInterceptor
);
vm
=
mountComponent
();
});
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
individualNoteInterceptor
);
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
mockData
.
individualNoteInterceptor
);
});
it
(
'
should render markdown docs url
'
,
(
done
)
=>
{
...
...
spec/javascripts/notes/mock_data.js
View file @
05e61c36
...
...
@@ -312,7 +312,9 @@ export const loggedOutnoteableData = {
"
preview_note_path
"
:
"
/gitlab-org/gitlab-ce/preview_markdown?quick_actions_target_id=98&quick_actions_target_type=Issue
"
}
export
const
individualNoteServerResponse
=
[{
export
const
INDIVIDUAL_NOTE_RESPONSE_MAP
=
{
'
GET
'
:
{
'
/gitlab-org/gitlab-ce/issues/26/discussions.json
'
:
[{
"
id
"
:
"
0fb4e0e3f9276e55ff32eb4195add694aece4edd
"
,
"
reply_id
"
:
"
0fb4e0e3f9276e55ff32eb4195add694aece4edd
"
,
"
expanded
"
:
true
,
...
...
@@ -404,19 +406,18 @@ export const individualNoteServerResponse = [{
"
path
"
:
"
/gitlab-org/gitlab-ce/notes/1391
"
}],
"
individual_note
"
:
true
}];
export
const
discussionNoteServerResponse
=
[{
"
id
"
:
"
a3ed36e29b1957efb3b68c53e2d7a2b24b1df052
"
,
"
reply_id
"
:
"
a3ed36e29b1957efb3b68c53e2d7a2b24b1df052
"
,
"
expanded
"
:
true
,
"
notes
"
:
[{
"
id
"
:
1471
,
"
attachment
"
:
{
"
url
"
:
null
,
"
filename
"
:
null
,
"
image
"
:
false
}],
'
/gitlab-org/gitlab-ce/noteable/issue/98/notes
'
:
{
last_fetched_at
:
1512900838
,
notes
:
[],
},
},
'
PUT
'
:
{
'
/gitlab-org/gitlab-ce/notes/1471
'
:
{
"
commands_changes
"
:
null
,
"
valid
"
:
true
,
"
id
"
:
1471
,
"
attachment
"
:
null
,
"
author
"
:
{
"
id
"
:
1
,
"
name
"
:
"
Root
"
,
...
...
@@ -426,7 +427,7 @@ export const discussionNoteServerResponse = [{
"
path
"
:
"
/root
"
},
"
created_at
"
:
"
2017-08-08T16:53:00.666Z
"
,
"
updated_at
"
:
"
2017-08-08T16:53:00.66
6Z
"
,
"
updated_at
"
:
"
2017-12-10T11:03:21.87
6Z
"
,
"
system
"
:
false
,
"
noteable_id
"
:
124
,
"
noteable_type
"
:
"
Issue
"
,
...
...
@@ -435,6 +436,15 @@ export const discussionNoteServerResponse = [{
"
human_access
"
:
"
Owner
"
,
"
note
"
:
"
Adding a comment
"
,
"
note_html
"
:
"
\
u003cp dir=
\"
auto
\"\
u003eAdding a comment
\
u003c/p
\
u003e
"
,
"
last_edited_at
"
:
"
2017-12-10T11:03:21.876Z
"
,
"
last_edited_by
"
:
{
"
id
"
:
1
,
"
name
"
:
'
Root
'
,
"
username
"
:
'
root
'
,
"
state
"
:
'
active
'
,
"
avatar_url
"
:
null
,
"
path
"
:
'
/root
'
,
},
"
current_user
"
:
{
"
can_edit
"
:
true
},
...
...
@@ -444,20 +454,25 @@ export const discussionNoteServerResponse = [{
"
toggle_award_path
"
:
"
/gitlab-org/gitlab-ce/notes/1471/toggle_award_emoji
"
,
"
report_abuse_path
"
:
"
/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F29%23note_1471
\
u0026user_id=1
"
,
"
path
"
:
"
/gitlab-org/gitlab-ce/notes/1471
"
}],
"
individual_note
"
:
false
}];
export
const
notesPollingResponse
=
{
last_fetched_at
:
1512900838
,
notes
:
[],
},
}
};
export
const
updatedNoteResponse
=
{
"
commands_changes
"
:
null
,
"
valid
"
:
true
,
export
const
DISCUSSION_NOTE_RESPONSE_MAP
=
{
...
INDIVIDUAL_NOTE_RESPONSE_MAP
,
'
GET
'
:
{
...
INDIVIDUAL_NOTE_RESPONSE_MAP
.
GET
,
'
/gitlab-org/gitlab-ce/issues/26/discussions.json
'
:
[{
"
id
"
:
"
a3ed36e29b1957efb3b68c53e2d7a2b24b1df052
"
,
"
reply_id
"
:
"
a3ed36e29b1957efb3b68c53e2d7a2b24b1df052
"
,
"
expanded
"
:
true
,
"
notes
"
:
[{
"
id
"
:
1471
,
"
attachment
"
:
null
,
"
attachment
"
:
{
"
url
"
:
null
,
"
filename
"
:
null
,
"
image
"
:
false
},
"
author
"
:
{
"
id
"
:
1
,
"
name
"
:
"
Root
"
,
...
...
@@ -467,7 +482,7 @@ export const updatedNoteResponse = {
"
path
"
:
"
/root
"
},
"
created_at
"
:
"
2017-08-08T16:53:00.666Z
"
,
"
updated_at
"
:
"
2017-12-10T11:03:21.87
6Z
"
,
"
updated_at
"
:
"
2017-08-08T16:53:00.66
6Z
"
,
"
system
"
:
false
,
"
noteable_id
"
:
124
,
"
noteable_type
"
:
"
Issue
"
,
...
...
@@ -476,15 +491,6 @@ export const updatedNoteResponse = {
"
human_access
"
:
"
Owner
"
,
"
note
"
:
"
Adding a comment
"
,
"
note_html
"
:
"
\
u003cp dir=
\"
auto
\"\
u003eAdding a comment
\
u003c/p
\
u003e
"
,
"
last_edited_at
"
:
"
2017-12-10T11:03:21.876Z
"
,
"
last_edited_by
"
:
{
"
id
"
:
1
,
"
name
"
:
'
Root
'
,
"
username
"
:
'
root
'
,
"
state
"
:
'
active
'
,
"
avatar_url
"
:
null
,
"
path
"
:
'
/root
'
,
},
"
current_user
"
:
{
"
can_edit
"
:
true
},
...
...
@@ -494,4 +500,24 @@ export const updatedNoteResponse = {
"
toggle_award_path
"
:
"
/gitlab-org/gitlab-ce/notes/1471/toggle_award_emoji
"
,
"
report_abuse_path
"
:
"
/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F29%23note_1471
\
u0026user_id=1
"
,
"
path
"
:
"
/gitlab-org/gitlab-ce/notes/1471
"
}],
"
individual_note
"
:
false
}],
},
};
export
function
individualNoteInterceptor
(
request
,
next
)
{
const
body
=
INDIVIDUAL_NOTE_RESPONSE_MAP
[
request
.
method
.
toUpperCase
()][
request
.
url
];
next
(
request
.
respondWith
(
JSON
.
stringify
(
body
),
{
status
:
200
,
}));
}
export
function
discussionNoteInterceptor
(
request
,
next
)
{
const
body
=
DISCUSSION_NOTE_RESPONSE_MAP
[
request
.
method
.
toUpperCase
()][
request
.
url
];
next
(
request
.
respondWith
(
JSON
.
stringify
(
body
),
{
status
:
200
,
}));
}
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