Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
94e11e1e
Commit
94e11e1e
authored
Aug 26, 2015
by
Eric Fischer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9463 from edx/efischer/js-flakes
Revert "Fix for flaky TeamDiscussionView js tests"
parents
6a1be48e
4d974730
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
186 deletions
+115
-186
lms/djangoapps/teams/static/teams/js/spec/views/team_discussion_spec.js
+115
-185
lms/djangoapps/teams/static/teams/js/views/team_discussion.js
+0
-1
No files found.
lms/djangoapps/teams/static/teams/js/spec/views/team_discussion_spec.js
View file @
94e11e1e
...
@@ -38,109 +38,84 @@ define([
...
@@ -38,109 +38,84 @@ define([
};
};
createPost
=
function
(
requests
,
view
,
title
,
body
,
threadID
)
{
createPost
=
function
(
requests
,
view
,
title
,
body
,
threadID
)
{
runs
(
function
()
{
title
=
title
||
"Test title"
;
title
=
title
||
"Test title"
;
body
=
body
||
"Test body"
;
body
=
body
||
"Test body"
;
threadID
=
threadID
||
"999"
;
threadID
=
threadID
||
"999"
;
view
.
$
(
'.new-post-button'
).
click
();
view
.
$
(
'.new-post-button'
).
click
();
view
.
$
(
'.js-post-title'
).
val
(
title
);
view
.
$
(
'.js-post-title'
).
val
(
title
);
view
.
$
(
'.js-post-body textarea'
).
val
(
body
);
view
.
$
(
'.js-post-body textarea'
).
val
(
body
);
view
.
$
(
'.submit'
).
click
();
AjaxHelpers
.
expectRequest
(
requests
,
'POST'
,
interpolate
(
'/courses/%(courseID)s/discussion/%(discussionID)s/threads/create?ajax=1'
,
{
courseID
:
TeamSpecHelpers
.
testCourseID
,
discussionID
:
TeamSpecHelpers
.
testTeamDiscussionID
},
true
),
interpolate
(
'thread_type=discussion&title=%(title)s&body=%(body)s&anonymous=false&anonymous_to_peers=false&auto_subscribe=true'
,
{
title
:
title
.
replace
(
/ /g
,
'+'
),
body
:
body
.
replace
(
/ /g
,
'+'
)
},
true
)
);
AjaxHelpers
.
respondWithJson
(
requests
,
{
content
:
TeamSpecHelpers
.
createMockPostResponse
({
id
:
threadID
,
title
:
title
,
body
:
body
}),
annotated_content_info
:
TeamSpecHelpers
.
createAnnotatedContentInfo
()
});
});
waitsFor
(
function
()
{
return
$
(
'.submit'
).
length
;
},
"Submit button never appeared"
,
1000
);
runs
(
function
()
{
view
.
$
(
'.submit'
).
click
();
AjaxHelpers
.
expectRequest
(
requests
,
'POST'
,
interpolate
(
'/courses/%(courseID)s/discussion/%(discussionID)s/threads/create?ajax=1'
,
{
courseID
:
TeamSpecHelpers
.
testCourseID
,
discussionID
:
TeamSpecHelpers
.
testTeamDiscussionID
},
true
),
interpolate
(
'thread_type=discussion&title=%(title)s&body=%(body)s&anonymous=false&anonymous_to_peers=false&auto_subscribe=true'
,
{
title
:
title
.
replace
(
/ /g
,
'+'
),
body
:
body
.
replace
(
/ /g
,
'+'
)
},
true
)
);
AjaxHelpers
.
respondWithJson
(
requests
,
{
content
:
TeamSpecHelpers
.
createMockPostResponse
({
id
:
threadID
,
title
:
title
,
body
:
body
}),
annotated_content_info
:
TeamSpecHelpers
.
createAnnotatedContentInfo
()
});
});
};
};
expandReplies
=
function
(
requests
,
view
,
threadID
)
{
expandReplies
=
function
(
requests
,
view
,
threadID
)
{
waitsFor
(
function
()
{
view
.
$
(
'.forum-thread-expand'
).
first
().
click
();
return
$
(
'.forum-thread-expand'
).
length
;
AjaxHelpers
.
expectRequest
(
},
"Forum expando link never appeared"
,
1000
);
requests
,
'GET'
,
interpolate
(
runs
(
function
()
{
'/courses/%(courseID)s/discussion/forum/%(discussionID)s/threads/%(threadID)s?ajax=1&resp_skip=0&resp_limit=25'
,
view
.
$
(
'.forum-thread-expand'
).
first
().
click
();
{
AjaxHelpers
.
expectRequest
(
courseID
:
TeamSpecHelpers
.
testCourseID
,
requests
,
'GET'
,
discussionID
:
TeamSpecHelpers
.
testTeamDiscussionID
,
interpolate
(
threadID
:
threadID
||
"999"
'/courses/%(courseID)s/discussion/forum/%(discussionID)s/threads/%(threadID)s?ajax=1&resp_skip=0&resp_limit=25'
,
},
{
true
courseID
:
TeamSpecHelpers
.
testCourseID
,
)
discussionID
:
TeamSpecHelpers
.
testTeamDiscussionID
,
);
threadID
:
threadID
||
"999"
AjaxHelpers
.
respondWithJson
(
requests
,
{
},
content
:
TeamSpecHelpers
.
createMockThreadResponse
(),
true
annotated_content_info
:
TeamSpecHelpers
.
createAnnotatedContentInfo
()
)
});
);
AjaxHelpers
.
respondWithJson
(
requests
,
{
content
:
TeamSpecHelpers
.
createMockThreadResponse
(),
annotated_content_info
:
TeamSpecHelpers
.
createAnnotatedContentInfo
()
});
});
};
};
postReply
=
function
(
requests
,
view
,
reply
,
threadID
)
{
postReply
=
function
(
requests
,
view
,
reply
,
threadID
)
{
var
replyForm
;
var
replyForm
=
view
.
$
(
'.discussion-reply-new'
).
first
();
runs
(
function
()
{
replyForm
.
find
(
'.reply-body textarea'
).
val
(
reply
);
replyForm
=
view
.
$
(
'.discussion-reply-new'
).
first
();
replyForm
.
find
(
'.discussion-submit-post'
).
click
();
});
AjaxHelpers
.
expectRequest
(
requests
,
'POST'
,
waitsFor
(
function
()
{
interpolate
(
return
replyForm
.
find
(
'.discussion-submit-post'
).
length
;
'/courses/%(courseID)s/discussion/threads/%(threadID)s/reply?ajax=1'
,
},
"submit reply button never appeared"
,
1000
);
{
courseID
:
TeamSpecHelpers
.
testCourseID
,
runs
(
function
()
{
threadID
:
threadID
||
"999"
replyForm
.
find
(
'.reply-body textarea'
).
val
(
reply
);
},
replyForm
.
find
(
'.discussion-submit-post'
).
click
();
true
AjaxHelpers
.
expectRequest
(
),
requests
,
'POST'
,
'body='
+
reply
.
replace
(
/ /g
,
'+'
)
interpolate
(
);
'/courses/%(courseID)s/discussion/threads/%(threadID)s/reply?ajax=1'
,
AjaxHelpers
.
respondWithJson
(
requests
,
{
{
content
:
TeamSpecHelpers
.
createMockThreadResponse
({
courseID
:
TeamSpecHelpers
.
testCourseID
,
body
:
reply
,
threadID
:
threadID
||
"999"
comments_count
:
1
},
}),
true
"annotated_content_info"
:
TeamSpecHelpers
.
createAnnotatedContentInfo
()
),
'body='
+
reply
.
replace
(
/ /g
,
'+'
)
);
AjaxHelpers
.
respondWithJson
(
requests
,
{
content
:
TeamSpecHelpers
.
createMockThreadResponse
({
body
:
reply
,
comments_count
:
1
}),
"annotated_content_info"
:
TeamSpecHelpers
.
createAnnotatedContentInfo
()
});
});
});
};
};
...
@@ -152,26 +127,17 @@ define([
...
@@ -152,26 +127,17 @@ define([
it
(
'can create a new post'
,
function
()
{
it
(
'can create a new post'
,
function
()
{
var
requests
=
AjaxHelpers
.
requests
(
this
),
var
requests
=
AjaxHelpers
.
requests
(
this
),
view
,
view
=
createDiscussionView
(
requests
)
,
testTitle
=
'New Post'
,
testTitle
=
'New Post'
,
testBody
=
'New post body'
,
testBody
=
'New post body'
,
newThreadElement
;
newThreadElement
;
runs
(
function
()
{
createPost
(
requests
,
view
,
testTitle
,
testBody
);
view
=
createDiscussionView
(
requests
);
createPost
(
requests
,
view
,
testTitle
,
testBody
);
});
waitsFor
(
function
()
{
return
$
(
'.discussion-thread'
).
length
;
},
"Discussion thread never appeared"
,
1000
);
runs
(
function
()
{
// Expect the first thread to be the new post
// Expect the first thread to be the new post
expect
(
view
.
$
(
'.discussion-thread'
).
length
).
toEqual
(
4
);
expect
(
view
.
$
(
'.discussion-thread'
).
length
).
toEqual
(
4
);
newThreadElement
=
view
.
$
(
'.discussion-thread'
).
first
();
newThreadElement
=
view
.
$
(
'.discussion-thread'
).
first
();
expect
(
newThreadElement
.
find
(
'.post-header-content h1'
).
text
().
trim
()).
toEqual
(
testTitle
);
expect
(
newThreadElement
.
find
(
'.post-header-content h1'
).
text
().
trim
()).
toEqual
(
testTitle
);
expect
(
newThreadElement
.
find
(
'.post-body'
).
text
().
trim
()).
toEqual
(
testBody
);
expect
(
newThreadElement
.
find
(
'.post-body'
).
text
().
trim
()).
toEqual
(
testBody
);
});
});
});
it
(
'can post a reply'
,
function
()
{
it
(
'can post a reply'
,
function
()
{
...
@@ -179,95 +145,59 @@ define([
...
@@ -179,95 +145,59 @@ define([
view
=
createDiscussionView
(
requests
),
view
=
createDiscussionView
(
requests
),
testReply
=
"Test reply"
,
testReply
=
"Test reply"
,
testThreadID
=
"1"
;
testThreadID
=
"1"
;
runs
(
function
()
{
expandReplies
(
requests
,
view
,
testThreadID
);
expandReplies
(
requests
,
view
,
testThreadID
);
postReply
(
requests
,
view
,
testReply
,
testThreadID
);
postReply
(
requests
,
view
,
testReply
,
testThreadID
);
expect
(
view
.
$
(
'.discussion-response .response-body'
).
text
().
trim
()).
toBe
(
testReply
);
});
waitsFor
(
function
()
{
return
view
.
$
(
'.discussion-response .response-body'
).
length
;
},
"Discussion response never made visible"
,
1000
);
runs
(
function
()
{
expect
(
view
.
$
(
'.discussion-response .response-body'
).
text
().
trim
()).
toBe
(
testReply
);
});
});
});
it
(
'can post a reply to a new post'
,
function
()
{
it
(
'can post a reply to a new post'
,
function
()
{
var
requests
=
AjaxHelpers
.
requests
(
this
),
var
requests
=
AjaxHelpers
.
requests
(
this
),
view
=
createDiscussionView
(
requests
,
[]),
view
=
createDiscussionView
(
requests
,
[]),
testReply
=
"Test reply"
;
testReply
=
"Test reply"
;
runs
(
function
()
{
createPost
(
requests
,
view
);
createPost
(
requests
,
view
);
expandReplies
(
requests
,
view
);
expandReplies
(
requests
,
view
);
postReply
(
requests
,
view
,
testReply
);
postReply
(
requests
,
view
,
testReply
);
expect
(
view
.
$
(
'.discussion-response .response-body'
).
text
().
trim
()).
toBe
(
testReply
);
});
waitsFor
(
function
()
{
return
view
.
$
(
'.discussion-response .response-body'
).
length
;
},
"Discussion response never made visible"
,
1000
);
runs
(
function
()
{
expect
(
view
.
$
(
'.discussion-response .response-body'
).
text
().
trim
()).
toBe
(
testReply
);
});
});
});
it
(
'cannot move an existing thread to a different topic'
,
function
()
{
it
(
'cannot move an existing thread to a different topic'
,
function
()
{
var
requests
=
AjaxHelpers
.
requests
(
this
),
var
requests
=
AjaxHelpers
.
requests
(
this
),
view
,
view
=
createDiscussionView
(
requests
)
,
postTopicButton
,
updatedThreadElement
,
postTopicButton
,
updatedThreadElement
,
updatedTitle
=
'Updated title'
,
updatedTitle
=
'Updated title'
,
updatedBody
=
'Updated body'
,
updatedBody
=
'Updated body'
,
testThreadID
=
"1"
;
testThreadID
=
"1"
;
runs
(
function
()
{
expandReplies
(
requests
,
view
,
testThreadID
);
view
=
createDiscussionView
(
requests
);
view
.
$
(
'.action-more .icon'
).
first
().
click
();
expandReplies
(
requests
,
view
,
testThreadID
);
view
.
$
(
'.action-edit'
).
first
().
click
();
});
postTopicButton
=
view
.
$
(
'.post-topic'
);
expect
(
postTopicButton
.
length
).
toBe
(
0
);
waitsFor
(
function
()
{
view
.
$
(
'.js-post-post-title'
).
val
(
updatedTitle
);
return
view
.
$
(
'.action-more .icon'
).
length
;
view
.
$
(
'.js-post-body textarea'
).
val
(
updatedBody
);
},
"Expanding replies never finished"
,
1000
);
view
.
$
(
'.submit'
).
click
();
AjaxHelpers
.
expectRequest
(
runs
(
function
()
{
requests
,
'POST'
,
view
.
$
(
'.action-more .icon'
).
first
().
click
();
interpolate
(
view
.
$
(
'.action-edit'
).
first
().
click
();
'/courses/%(courseID)s/discussion/%(discussionID)s/threads/create?ajax=1'
,
postTopicButton
=
view
.
$
(
'.post-topic'
);
{
expect
(
postTopicButton
.
length
).
toBe
(
0
);
courseID
:
TeamSpecHelpers
.
testCourseID
,
view
.
$
(
'.js-post-post-title'
).
val
(
updatedTitle
);
discussionID
:
TeamSpecHelpers
.
testTeamDiscussionID
view
.
$
(
'.js-post-body textarea'
).
val
(
updatedBody
);
},
true
),
'thread_type=discussion&title=&body=Updated+body&anonymous=false&anonymous_to_peers=false&auto_subscribe=true'
);
AjaxHelpers
.
respondWithJson
(
requests
,
{
content
:
TeamSpecHelpers
.
createMockPostResponse
({
id
:
"999"
,
title
:
updatedTitle
,
body
:
updatedBody
}),
annotated_content_info
:
TeamSpecHelpers
.
createAnnotatedContentInfo
()
});
});
waitsFor
(
function
()
{
// Expect the thread to have been updated
return
$
(
'.submit'
).
length
;
updatedThreadElement
=
view
.
$
(
'.discussion-thread'
).
first
();
},
"submit button never appeared"
,
1000
);
expect
(
updatedThreadElement
.
find
(
'.post-header-content h1'
).
text
().
trim
()).
toEqual
(
updatedTitle
);
expect
(
updatedThreadElement
.
find
(
'.post-body'
).
text
().
trim
()).
toEqual
(
updatedBody
);
runs
(
function
()
{
view
.
$
(
'.submit'
).
click
();
AjaxHelpers
.
expectRequest
(
requests
,
'POST'
,
interpolate
(
'/courses/%(courseID)s/discussion/%(discussionID)s/threads/create?ajax=1'
,
{
courseID
:
TeamSpecHelpers
.
testCourseID
,
discussionID
:
TeamSpecHelpers
.
testTeamDiscussionID
},
true
),
'thread_type=discussion&title=&body=Updated+body&anonymous=false&anonymous_to_peers=false&auto_subscribe=true'
);
AjaxHelpers
.
respondWithJson
(
requests
,
{
content
:
TeamSpecHelpers
.
createMockPostResponse
({
id
:
"999"
,
title
:
updatedTitle
,
body
:
updatedBody
}),
annotated_content_info
:
TeamSpecHelpers
.
createAnnotatedContentInfo
()
});
// Expect the thread to have been updated
updatedThreadElement
=
view
.
$
(
'.discussion-thread'
).
first
();
expect
(
updatedThreadElement
.
find
(
'.post-header-content h1'
).
text
().
trim
()).
toEqual
(
updatedTitle
);
expect
(
updatedThreadElement
.
find
(
'.post-body'
).
text
().
trim
()).
toEqual
(
updatedBody
);
});
});
});
it
(
'cannot move a new thread to a different topic'
,
function
()
{
it
(
'cannot move a new thread to a different topic'
,
function
()
{
...
...
lms/djangoapps/teams/static/teams/js/views/team_discussion.js
View file @
94e11e1e
...
@@ -8,7 +8,6 @@
...
@@ -8,7 +8,6 @@
var
TeamDiscussionView
=
Backbone
.
View
.
extend
({
var
TeamDiscussionView
=
Backbone
.
View
.
extend
({
initialize
:
function
()
{
initialize
:
function
()
{
window
.
$$course_id
=
this
.
$el
.
data
(
"course-id"
);
window
.
$$course_id
=
this
.
$el
.
data
(
"course-id"
);
this
.
render
();
},
},
render
:
function
()
{
render
:
function
()
{
...
...
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