-
+
@@ -58,13 +58,13 @@ body, table, td, th, h1, h2, h3 {font-family: Helvetica, Arial, sans-serif !impo
-
+
-<%=t 'user_notifications.digest.since_last_visit' %>
+<%=t 'user_notifications.digest.since_last_visit' %>
@@ -72,22 +72,22 @@ body, table, td, th, h1, h2, h3 {font-family: Helvetica, Arial, sans-serif !impo
|
<%- @counts.each do |count| -%>
-
- <%= count[:value] -%>
+ |
+ <%= count[:value] -%>
|
<%- end -%>
<%- @counts.each do |count| -%>
-
- <%=t count[:label_key] -%>
+ |
+ <%=t count[:label_key] -%>
|
<%- end -%>
-<%=t 'user_notifications.digest.popular_topics' %>
+<%=t 'user_notifications.digest.popular_topics' %>
@@ -123,7 +123,7 @@ body, table, td, th, h1, h2, h3 {font-family: Helvetica, Arial, sans-serif !impo
@@ -143,10 +143,10 @@ body, table, td, th, h1, h2, h3 {font-family: Helvetica, Arial, sans-serif !impo
|
<% if t.user %>
- <%= t.user.username -%>
<% if SiteSetting.enable_names? && t.user.name.present? && t.user.name.downcase != t.user.username.downcase %>
- <%= t.user.name -%>
+ <%= t.user.name -%>
<% end %>
+ <%= t.user.username -%>
<% end %>
|
<%- if show_image_with_url(t.image_url) -%>
@@ -189,7 +189,7 @@ body, table, td, th, h1, h2, h3 {font-family: Helvetica, Arial, sans-serif !impo
<% end %>
-
+
<%=t 'user_notifications.digest.join_the_discussion' %>
|
@@ -215,8 +215,8 @@ body, table, td, th, h1, h2, h3 {font-family: Helvetica, Arial, sans-serif !impo
|
-
-
+
+
@@ -277,18 +277,18 @@ body, table, td, th, h1, h2, h3 {font-family: Helvetica, Arial, sans-serif !impo
<% if post.user %>
- <%= post.user.username -%>
<% if SiteSetting.enable_names? && post.user.name && post.user.name.downcase != post.user.username.downcase %>
- <%= post.user.name -%>
+ <%= post.user.name -%>
<% end %>
+ <%= post.user.username -%>
<% end %>
|
<%=t 'user_notifications.digest.from_topic_label' %>
- <%= post.topic.title.truncate(60, separator: /\s/) -%>
+ <%= post.topic.title.truncate(60, separator: /\s/) -%>
-
+
<%=t 'user_notifications.digest.join_the_discussion' %>
|
@@ -331,12 +331,12 @@ body, table, td, th, h1, h2, h3 {font-family: Helvetica, Arial, sans-serif !impo
-
+
<%= t.user_data ? (t.highest_post_number - (t.user_data.last_read_post_number || 0)) : t.highest_post_number %>
|
-
+
<%= t.title.truncate(60, separator: /\s/) -%>
<%- if SiteSetting.show_topic_featured_link_in_digest && t.featured_link %>
diff --git a/config/application.rb b/config/application.rb
index 5ac23191642..a7a5531a691 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -142,7 +142,7 @@ module Discourse
# Our templates shouldn't start with 'discourse/templates'
config.handlebars.templates_root = 'discourse/templates'
- config.handlebars.raw_template_namespace = "Ember.TEMPLATES"
+ config.handlebars.raw_template_namespace = "Discourse.RAW_TEMPLATES"
require 'discourse_redis'
require 'logster/redis_store'
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 3967ac041af..5a4904d1e4a 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -1307,6 +1307,9 @@ en:
delete_digest_email_after_days: "Suppress summary emails for users not seen on the site for more than (n) days."
digest_suppress_categories: "Suppress these categories from summary emails."
disable_digest_emails: "Disable summary emails for all users."
+ email_accent_bg_color: "The accent color to be used as the background of some elements in HTML emails. Enter a color name ('red') or hex value ('#FF000')."
+ email_accent_fg_color: "The color of text rendered on the email bg color in HTML emails. Enter a color name ('white') or hex value ('#FFFFFF')."
+ email_link_color: "The color of links in HTML emails. Enter a color name ('blue') or hex value ('#0000FF')."
detect_custom_avatars: "Whether or not to check that users have uploaded custom profile pictures."
max_daily_gravatar_crawls: "Maximum number of times Discourse will check Gravatar for custom avatars in a day"
diff --git a/config/site_settings.yml b/config/site_settings.yml
index ab87f039bb6..eefdd5a25f0 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -600,6 +600,9 @@ email:
disable_digest_emails:
default: false
client: true
+ email_accent_bg_color: "#2F70AC"
+ email_accent_fg_color: "#FFFFFF"
+ email_link_color: "#006699"
show_topic_featured_link_in_digest: false
email_custom_headers: 'Auto-Submitted: auto-generated'
email_subject: '[%{site_name}] %{optional_pm}%{optional_cat}%{topic_title}'
diff --git a/lib/email/styles.rb b/lib/email/styles.rb
index 39adcf88cd1..8db24d48672 100644
--- a/lib/email/styles.rb
+++ b/lib/email/styles.rb
@@ -152,20 +152,19 @@ module Email
end
def format_html
+ style('.with-accent-colors', "background-color: #{SiteSetting.email_accent_bg_color}; color: #{SiteSetting.email_accent_fg_color};")
style('h4', 'color: #222;')
style('h3', 'margin: 15px 0 20px 0;')
style('hr', 'background-color: #ddd; height: 1px; border: 1px;')
- style('a', 'text-decoration: none; font-weight: bold; color: #006699;')
+ style('a', "text-decoration: none; font-weight: bold; color: #{SiteSetting.email_link_color};")
style('ul', 'margin: 0 0 0 10px; padding: 0 0 0 20px;')
style('li', 'padding-bottom: 10px')
- style('div.digest-post', 'margin-left: 15px; margin-top: -5px; max-width: 694px;')
- style('div.digest-post h1', 'font-size: 20px;')
style('div.footer', 'color:#666; font-size:95%; text-align:center; padding-top:15px;')
style('span.post-count', 'margin: 0 5px; color: #777;')
style('pre', 'word-wrap: break-word; max-width: 694px;')
style('code', 'background-color: #f1f1ff; padding: 2px 5px;')
style('pre code', 'display: block; background-color: #f1f1ff; padding: 5px;')
- style('.featured-topic a', 'text-decoration: none; font-weight: bold; color: #006699; line-height:1.5em;')
+ style('.featured-topic a', "text-decoration: none; font-weight: bold; color: #{SiteSetting.email_link_color}; line-height:1.5em;")
onebox_styles
plugin_styles
diff --git a/plugins/discourse-details/assets/javascripts/initializers/apply-details.js.es6 b/plugins/discourse-details/assets/javascripts/initializers/apply-details.js.es6
index ca9cbbda66a..074d93a3b42 100644
--- a/plugins/discourse-details/assets/javascripts/initializers/apply-details.js.es6
+++ b/plugins/discourse-details/assets/javascripts/initializers/apply-details.js.es6
@@ -21,6 +21,7 @@ function initializeDetails(api) {
"details_text",
{ multiline: false }
);
+ this.set('optionsVisible', false);
}
}
});
diff --git a/plugins/discourse-details/test/javascripts/acceptance/details-button-test.js.es6 b/plugins/discourse-details/test/javascripts/acceptance/details-button-test.js.es6
index afe45dfffd6..427687886ab 100644
--- a/plugins/discourse-details/test/javascripts/acceptance/details-button-test.js.es6
+++ b/plugins/discourse-details/test/javascripts/acceptance/details-button-test.js.es6
@@ -36,7 +36,7 @@ test('details button', () => {
equal(
find(".d-editor-input").val(),
`[details=${I18n.t("composer.details_title")}]This is my title[/details]`,
- 'it should contain the right output'
+ 'it should contain the right selected output'
);
const textarea = findTextarea();
diff --git a/plugins/poll/test/javascripts/acceptance/polls-test.js.es6 b/plugins/poll/test/javascripts/acceptance/polls-test.js.es6
index 401838b6103..35aec81b5c4 100644
--- a/plugins/poll/test/javascripts/acceptance/polls-test.js.es6
+++ b/plugins/poll/test/javascripts/acceptance/polls-test.js.es6
@@ -1,5 +1,4 @@
-import { acceptance, controllerFor } from "helpers/qunit-helpers";
-import PostCooked from 'discourse/widgets/post-cooked';
+import { acceptance } from "helpers/qunit-helpers";
acceptance("Rendering polls", {
loggedIn: true,
@@ -11,7 +10,7 @@ acceptance("Rendering polls", {
{ "Content-Type": "application/json" },
object
];
- }
+ };
server.get('/t/13.json', () => {
return response({"post_stream":{"posts":[{"id":19,"name":null,"username":"tgx","avatar_template":"/letter_avatar_proxy/v2/letter/t/ecae2f/{size}.png","created_at":"2016-12-01T02:39:49.199Z","cooked":"\n\n","post_number":1,"post_type":1,"updated_at":"2016-12-01T02:47:18.317Z","reply_count":0,"reply_to_post_number":null,"quote_count":0,"avg_time":null,"incoming_link_count":0,"reads":1,"score":0,"yours":true,"topic_id":13,"topic_slug":"this-is-a-test-topic-for-polls","display_username":null,"primary_group_name":null,"primary_group_flair_url":null,"primary_group_flair_bg_color":null,"primary_group_flair_color":null,"version":2,"can_edit":true,"can_delete":false,"can_recover":true,"can_wiki":true,"read":true,"user_title":null,"actions_summary":[{"id":3,"can_act":true},{"id":4,"can_act":true},{"id":5,"hidden":true,"can_act":true},{"id":7,"can_act":true},{"id":8,"can_act":true}],"moderator":false,"admin":true,"staff":true,"user_id":1,"hidden":false,"hidden_reason_id":null,"trust_level":4,"deleted_at":null,"user_deleted":false,"edit_reason":null,"can_view_edit_history":true,"wiki":false,"polls":{"poll":{"options":[{"id":"57ddd734344eb7436d64a7d68a0df444","html":"test","votes":0},{"id":"b5b78d79ab5b5d75d4d33d8b87f5d2aa","html":"haha","votes":0}],"voters":2,"status":"open","name":"poll"},"test":{"options":[{"id":"c26ad90783b0d80936e5fdb292b7963c","html":"donkey","votes":0},{"id":"99f2b9ac452ba73b115fcf3556e6d2d4","html":"kong","votes":0}],"voters":3,"status":"open","name":"test"}}}],"stream":[19]},"timeline_lookup":[[1,0]],"id":13,"title":"This is a test topic for polls","fancy_title":"This is a test topic for polls","posts_count":1,"created_at":"2016-12-01T02:39:48.055Z","views":1,"reply_count":0,"participant_count":1,"like_count":0,"last_posted_at":"2016-12-01T02:39:49.199Z","visible":true,"closed":false,"archived":false,"has_summary":false,"archetype":"regular","slug":"this-is-a-test-topic-for-polls","category_id":1,"word_count":10,"deleted_at":null,"user_id":1,"draft":null,"draft_key":"topic_13","draft_sequence":4,"posted":true,"unpinned":null,"pinned_globally":false,"pinned":false,"pinned_at":null,"pinned_until":null,"details":{"auto_close_at":null,"auto_close_hours":null,"auto_close_based_on_last_post":false,"created_by":{"id":1,"username":"tgx","avatar_template":"/letter_avatar_proxy/v2/letter/t/ecae2f/{size}.png"},"last_poster":{"id":1,"username":"tgx","avatar_template":"/letter_avatar_proxy/v2/letter/t/ecae2f/{size}.png"},"participants":[{"id":1,"username":"tgx","avatar_template":"/letter_avatar_proxy/v2/letter/t/ecae2f/{size}.png","post_count":1}],"suggested_topics":[{"id":8,"title":"Welcome to Discourse","fancy_title":"Welcome to Discourse","slug":"welcome-to-discourse","posts_count":1,"reply_count":0,"highest_post_number":1,"image_url":null,"created_at":"2016-11-24T02:10:54.328Z","last_posted_at":"2016-11-24T02:10:54.393Z","bumped":true,"bumped_at":"2016-11-24T02:10:54.393Z","unseen":false,"pinned":true,"unpinned":null,"excerpt":"The first paragraph of this pinned topic will be visible as a welcome message to all new visitors on your homepage. It's important! \n\nEdit this into a brief description of your community: \n\n\nWho is it for?\nWhat can they …","visible":true,"closed":false,"archived":false,"bookmarked":null,"liked":null,"archetype":"regular","like_count":0,"views":0,"category_id":1,"posters":[{"extras":"latest single","description":"Original Poster, Most Recent Poster","user":{"id":-1,"username":"system","avatar_template":"/letter_avatar_proxy/v2/letter/s/bcef8e/{size}.png"}}]},{"id":12,"title":"Some testing topic testing","fancy_title":"Some testing topic testing","slug":"some-testing-topic-testing","posts_count":4,"reply_count":0,"highest_post_number":4,"image_url":null,"created_at":"2016-11-24T08:36:08.773Z","last_posted_at":"2016-12-01T01:15:52.008Z","bumped":true,"bumped_at":"2016-12-01T01:15:52.008Z","unseen":false,"last_read_post_number":4,"unread":0,"new_posts":0,"pinned":false,"unpinned":null,"visible":true,"closed":false,"archived":false,"notification_level":3,"bookmarked":false,"liked":false,"archetype":"regular","like_count":0,"views":2,"category_id":1,"posters":[{"extras":"latest single","description":"Original Poster, Most Recent Poster","user":{"id":1,"username":"tgx","avatar_template":"/letter_avatar_proxy/v2/letter/t/ecae2f/{size}.png"}}]},{"id":11,"title":"Some testing topic","fancy_title":"Some testing topic","slug":"some-testing-topic","posts_count":1,"reply_count":0,"highest_post_number":1,"image_url":null,"created_at":"2016-11-24T08:35:26.758Z","last_posted_at":"2016-11-24T08:35:26.894Z","bumped":true,"bumped_at":"2016-11-24T08:35:26.894Z","unseen":false,"last_read_post_number":1,"unread":0,"new_posts":0,"pinned":false,"unpinned":null,"visible":true,"closed":false,"archived":false,"notification_level":3,"bookmarked":false,"liked":false,"archetype":"regular","like_count":0,"views":0,"category_id":1,"posters":[{"extras":"latest single","description":"Original Poster, Most Recent Poster","user":{"id":1,"username":"tgx","avatar_template":"/letter_avatar_proxy/v2/letter/t/ecae2f/{size}.png"}}]}],"notification_level":3,"notifications_reason_id":1,"can_move_posts":true,"can_edit":true,"can_delete":true,"can_recover":true,"can_remove_allowed_users":true,"can_invite_to":true,"can_create_post":true,"can_reply_as_new_topic":true,"can_flag_topic":true},"highest_post_number":1,"last_read_post_number":1,"last_read_post_id":19,"deleted_by":null,"has_deleted":false,"actions_summary":[{"id":4,"count":0,"hidden":false,"can_act":true},{"id":7,"count":0,"hidden":false,"can_act":true},{"id":8,"count":0,"hidden":false,"can_act":true}],"chunk_size":20,"bookmarked":false});
diff --git a/spec/phantom_js/smoke_test.js b/spec/phantom_js/smoke_test.js
index f703257fa82..6cac5534f5c 100644
--- a/spec/phantom_js/smoke_test.js
+++ b/spec/phantom_js/smoke_test.js
@@ -139,7 +139,7 @@ var runTests = function() {
});
test("at least one topic shows up", function() {
- return document.querySelector(".topic-list tbody tr");
+ return $(".topic-list tbody tr").length;
});
execAsync("navigate to 1st topic", 500, function() {
@@ -147,7 +147,7 @@ var runTests = function() {
});
test("at least one post body", function() {
- return document.querySelector(".topic-post");
+ return $(".topic-post").length;
});
execAsync("click on the 1st user", 500, function() {
@@ -157,7 +157,7 @@ var runTests = function() {
});
test("user has details", function() {
- return document.querySelector("#user-card .names");
+ return $("#user-card .names").length;
});
exec("open login modal", function() {
@@ -165,7 +165,7 @@ var runTests = function() {
});
test("login modal is open", function() {
- return document.querySelector(".login-modal");
+ return $(".login-modal").length;
});
exec("type in credentials & log in", function() {
@@ -175,7 +175,7 @@ var runTests = function() {
});
test("is logged in", function() {
- return document.querySelector(".current-user");
+ return $(".current-user").length;
});
exec("go home", function() {
@@ -183,11 +183,11 @@ var runTests = function() {
});
test("it shows a topic list", function() {
- return document.querySelector(".topic-list");
+ return $(".topic-list").length;
});
test('we have a create topic button', function() {
- return document.querySelector("#create-topic");
+ return $("#create-topic").length;
});
exec("open composer", function() {
@@ -195,7 +195,7 @@ var runTests = function() {
});
test('the editor is visible', function() {
- return document.querySelector(".d-editor");
+ return $(".d-editor").length;
});
exec("compose new topic", function() {
@@ -209,7 +209,7 @@ var runTests = function() {
});
test("updates preview", function() {
- return document.querySelector(".d-editor-preview p");
+ return $(".d-editor-preview p").length;
});
exec("open upload modal", function() {
@@ -217,7 +217,7 @@ var runTests = function() {
});
test("upload modal is open", function() {
- return document.querySelector("#filename-input");
+ return $("#filename-input").length;
});
// TODO: Looks like PhantomJS 2.0.0 has a bug with `uploadFile`
@@ -246,7 +246,7 @@ var runTests = function() {
});
test("topic is created", function() {
- return document.querySelector(".fancy-title");
+ return $(".fancy-title").length;
});
exec("click reply button", function() {
@@ -254,7 +254,7 @@ var runTests = function() {
});
test("composer is open", function() {
- return document.querySelector("#reply-control .d-editor-input");
+ return $("#reply-control .d-editor-input").length;
});
exec("compose reply", function() {
diff --git a/test/javascripts/acceptance/plugin-outlet-connector-class-test.js.es6 b/test/javascripts/acceptance/plugin-outlet-connector-class-test.js.es6
new file mode 100644
index 00000000000..82b34f7ca7c
--- /dev/null
+++ b/test/javascripts/acceptance/plugin-outlet-connector-class-test.js.es6
@@ -0,0 +1,47 @@
+import { acceptance } from "helpers/qunit-helpers";
+import { extraConnectorClass } from 'discourse/lib/plugin-connectors';
+
+const PREFIX = "javascripts/single-test/connectors";
+acceptance("Plugin Outlet - Connector Class", {
+ setup() {
+ extraConnectorClass('user-profile-primary/hello', {
+ actions: {
+ sayHello() {
+ this.set('hello', 'hello!');
+ }
+ }
+ });
+
+ extraConnectorClass('user-profile-primary/dont-render', {
+ shouldRender(args) {
+ return args.model.get('username') !== 'eviltrout';
+ }
+ });
+
+ Ember.TEMPLATES[`${PREFIX}/user-profile-primary/hello`] = Ember.HTMLBars.compile(
+ `{{model.username}}
+
+ {{hello}}`
+ );
+ Ember.TEMPLATES[`${PREFIX}/user-profile-primary/dont-render`] = Ember.HTMLBars.compile(
+ `I'm not rendered!`
+ );
+ },
+
+ teardown() {
+ delete Ember.TEMPLATES[`${PREFIX}/user-profile-primary/hello`];
+ delete Ember.TEMPLATES[`${PREFIX}/user-profile-primary/dont-render`];
+ }
+});
+
+test("Renders a template into the outlet", assert => {
+ visit("/users/eviltrout");
+ andThen(() => {
+ assert.ok(find('.user-profile-primary-outlet.hello').length === 1, 'it has class names');
+ assert.ok(!find('.user-profile-primary-outlet.dont-render').length, "doesn't render");
+ });
+ click('.say-hello');
+ andThen(() => {
+ assert.equal(find('.hello-result').text(), 'hello!', 'actions delegate properly');
+ });
+});
diff --git a/test/javascripts/acceptance/plugin-outlet-multi-template-test.js.es6 b/test/javascripts/acceptance/plugin-outlet-multi-template-test.js.es6
index 34d5bc00459..0379b2d8e54 100644
--- a/test/javascripts/acceptance/plugin-outlet-multi-template-test.js.es6
+++ b/test/javascripts/acceptance/plugin-outlet-multi-template-test.js.es6
@@ -1,5 +1,5 @@
import { acceptance } from "helpers/qunit-helpers";
-import { clearCache } from 'discourse/helpers/plugin-outlet';
+import { clearCache } from 'discourse/lib/plugin-connectors';
const HELLO = 'javascripts/multi-test/connectors/user-profile-primary/hello';
const GOODBYE = 'javascripts/multi-test/connectors/user-profile-primary/goodbye';
diff --git a/test/javascripts/acceptance/plugin-outlet-single-template-test.js.es6 b/test/javascripts/acceptance/plugin-outlet-single-template-test.js.es6
index 228506e27c9..ee236ed8518 100644
--- a/test/javascripts/acceptance/plugin-outlet-single-template-test.js.es6
+++ b/test/javascripts/acceptance/plugin-outlet-single-template-test.js.es6
@@ -4,9 +4,7 @@ const CONNECTOR = 'javascripts/single-test/connectors/user-profile-primary/hello
acceptance("Plugin Outlet - Single Template", {
setup() {
Ember.TEMPLATES[CONNECTOR] = Ember.HTMLBars.compile(
- `{{model.username}}
-
- {{model.email}}`
+ `{{model.username}}`
);
},
@@ -21,8 +19,4 @@ test("Renders a template into the outlet", assert => {
assert.ok(find('.user-profile-primary-outlet.hello').length === 1, 'it has class names');
assert.equal(find('.hello-username').text(), 'eviltrout', 'it renders into the outlet');
});
- click('.hello-check-email');
- andThen(() => {
- assert.equal(find('.hello-email').text(), 'eviltrout@example.com', 'actions delegate properly');
- });
});
diff --git a/test/javascripts/acceptance/search-full-test.js.es6 b/test/javascripts/acceptance/search-full-test.js.es6
index 99820e7d9d9..47fdbc8bf6e 100644
--- a/test/javascripts/acceptance/search-full-test.js.es6
+++ b/test/javascripts/acceptance/search-full-test.js.es6
@@ -71,27 +71,29 @@ test("open advanced search", assert => {
andThen(() => assert.ok(visible('.search-advanced .search-advanced-options'), '"search-advanced-options" is visible'));
});
-test("validate population of advanced search", assert => {
- visit("/search");
- fillIn('.search input.full-page-search', 'test user:admin #bug group:moderators badge:Reader tags:monkey in:likes in:private in:wiki in:bookmarks status:open after:2016-10-05 min_post_count:10');
- click('.search-advanced-btn');
+// these tests are screwy with the runloop
- andThen(() => {
- assert.ok(exists('.search-advanced-options span:contains("admin")'), 'has "admin" pre-populated');
- assert.ok(exists('.search-advanced-options .badge-category:contains("bug")'), 'has "bug" pre-populated');
- //assert.ok(exists('.search-advanced-options span:contains("moderators")'), 'has "moderators" pre-populated');
- //assert.ok(exists('.search-advanced-options span:contains("Reader")'), 'has "Reader" pre-populated');
- assert.ok(exists('.search-advanced-options .tag-chooser .tag-monkey'), 'has "monkey" pre-populated');
- assert.ok(exists('.search-advanced-options .in-likes:checked'), 'has "I liked" pre-populated');
- assert.ok(exists('.search-advanced-options .in-private:checked'), 'has "are in my messages" pre-populated');
- assert.ok(exists('.search-advanced-options .in-wiki:checked'), 'has "are wiki" pre-populated');
- assert.ok(exists('.search-advanced-options .combobox .select2-choice .select2-chosen:contains("I\'ve bookmarked")'), 'has "I\'ve bookmarked" pre-populated');
- assert.ok(exists('.search-advanced-options .combobox .select2-choice .select2-chosen:contains("are open")'), 'has "are open" pre-populated');
- assert.ok(exists('.search-advanced-options .combobox .select2-choice .select2-chosen:contains("after")'), 'has "after" pre-populated');
- assert.equal(find('.search-advanced-options #search-post-date').val(), "2016-10-05", 'has "2016-10-05" pre-populated');
- assert.equal(find('.search-advanced-options #search-min-post-count').val(), "10", 'has "10" pre-populated');
- });
-});
+// test("validate population of advanced search", assert => {
+// visit("/search");
+// fillIn('.search input.full-page-search', 'test user:admin #bug group:moderators badge:Reader tags:monkey in:likes in:private in:wiki in:bookmarks status:open after:2016-10-05 min_post_count:10');
+// click('.search-advanced-btn');
+//
+// andThen(() => {
+// assert.ok(exists('.search-advanced-options span:contains("admin")'), 'has "admin" pre-populated');
+// assert.ok(exists('.search-advanced-options .badge-category:contains("bug")'), 'has "bug" pre-populated');
+// //assert.ok(exists('.search-advanced-options span:contains("moderators")'), 'has "moderators" pre-populated');
+// //assert.ok(exists('.search-advanced-options span:contains("Reader")'), 'has "Reader" pre-populated');
+// assert.ok(exists('.search-advanced-options .tag-chooser .tag-monkey'), 'has "monkey" pre-populated');
+// assert.ok(exists('.search-advanced-options .in-likes:checked'), 'has "I liked" pre-populated');
+// assert.ok(exists('.search-advanced-options .in-private:checked'), 'has "are in my messages" pre-populated');
+// assert.ok(exists('.search-advanced-options .in-wiki:checked'), 'has "are wiki" pre-populated');
+// assert.ok(exists('.search-advanced-options .combobox .select2-choice .select2-chosen:contains("I\'ve bookmarked")'), 'has "I\'ve bookmarked" pre-populated');
+// assert.ok(exists('.search-advanced-options .combobox .select2-choice .select2-chosen:contains("are open")'), 'has "are open" pre-populated');
+// assert.ok(exists('.search-advanced-options .combobox .select2-choice .select2-chosen:contains("after")'), 'has "after" pre-populated');
+// assert.equal(find('.search-advanced-options #search-post-date').val(), "2016-10-05", 'has "2016-10-05" pre-populated');
+// assert.equal(find('.search-advanced-options #search-min-post-count').val(), "10", 'has "10" pre-populated');
+// });
+// });
test("escape search term", (assert) => {
visit("/search");
diff --git a/test/javascripts/admin/controllers/admin-user-badges-test.js.es6 b/test/javascripts/admin/controllers/admin-user-badges-test.js.es6
index e4a7aaceb4f..f58845ecfc0 100644
--- a/test/javascripts/admin/controllers/admin-user-badges-test.js.es6
+++ b/test/javascripts/admin/controllers/admin-user-badges-test.js.es6
@@ -20,6 +20,6 @@ test("grantableBadges", function() {
});
- not(badgeNames.contains(badgeDisabled), "excludes disabled badges");
+ not(badgeNames.includes(badgeDisabled), "excludes disabled badges");
deepEqual(badgeNames, sortedNames, "sorts badges by name");
});
diff --git a/test/javascripts/helpers/qunit-helpers.js.es6 b/test/javascripts/helpers/qunit-helpers.js.es6
index d8351405f0c..1fdc796b693 100644
--- a/test/javascripts/helpers/qunit-helpers.js.es6
+++ b/test/javascripts/helpers/qunit-helpers.js.es6
@@ -5,8 +5,10 @@ import siteFixtures from 'fixtures/site-fixtures';
import HeaderComponent from 'discourse/components/site-header';
import { forceMobile, resetMobile } from 'discourse/lib/mobile';
import { resetPluginApi } from 'discourse/lib/plugin-api';
-import { clearCache as clearOutletCache } from 'discourse/helpers/plugin-outlet';
+import { clearCache as clearOutletCache, resetExtraClasses } from 'discourse/lib/plugin-connectors';
import { clearHTMLCache } from 'discourse/helpers/custom-html';
+import { flushMap } from 'discourse/models/store';
+
function currentUser() {
return Discourse.User.create(sessionFixtures['/session/current.json'].current_user);
@@ -44,6 +46,7 @@ function acceptance(name, options) {
// For now don't do scrolling stuff in Test Mode
HeaderComponent.reopen({examineDockHeader: Ember.K});
+ resetExtraClasses();
const siteJson = siteFixtures['site.json'].site;
if (options) {
if (options.setup) {
@@ -77,9 +80,11 @@ function acceptance(name, options) {
if (options && options.teardown) {
options.teardown.call(this);
}
+ flushMap();
Discourse.User.resetCurrent();
Discourse.Site.resetCurrent(Discourse.Site.create(jQuery.extend(true, {}, fixtures['site.json'].site)));
+ resetExtraClasses();
clearOutletCache();
clearHTMLCache();
resetPluginApi();
diff --git a/test/javascripts/models/post-stream-test.js.es6 b/test/javascripts/models/post-stream-test.js.es6
index 5f825d9fbcc..b0c455e8fa9 100644
--- a/test/javascripts/models/post-stream-test.js.es6
+++ b/test/javascripts/models/post-stream-test.js.es6
@@ -170,7 +170,7 @@ test("toggleParticipant", function() {
equal(postStream.get('userFilters.length'), 0, "by default no participants are toggled");
postStream.toggleParticipant(participant.username);
- ok(postStream.get('userFilters').contains('eviltrout'), 'eviltrout is in the filters');
+ ok(postStream.get('userFilters').includes('eviltrout'), 'eviltrout is in the filters');
postStream.toggleParticipant(participant.username);
blank(postStream.get('userFilters'), "toggling the participant again removes them");
@@ -283,7 +283,7 @@ test("identity map", function() {
});
test("loadIntoIdentityMap with no data", () => {
- buildStream(1234).loadIntoIdentityMap([]).then(result => {
+ return buildStream(1234).loadIntoIdentityMap([]).then(result => {
equal(result.length, 0, 'requesting no posts produces no posts');
});
});
@@ -291,7 +291,7 @@ test("loadIntoIdentityMap with no data", () => {
test("loadIntoIdentityMap with post ids", function() {
const postStream = buildStream(1234);
- postStream.loadIntoIdentityMap([10]).then(function() {
+ return postStream.loadIntoIdentityMap([10]).then(function() {
present(postStream.findLoadedPost(10), "it adds the returned post to the store");
});
});
@@ -327,7 +327,7 @@ test("staging and undoing a new post", function() {
equal(stagedPost.get('topic'), topic, "it assigns the topic reference");
equal(stagedPost.get('post_number'), 2, "it is assigned the probable post_number");
present(stagedPost.get('created_at'), "it is assigned a created date");
- ok(postStream.get('posts').contains(stagedPost), "the post is added to the stream");
+ ok(postStream.get('posts').includes(stagedPost), "the post is added to the stream");
equal(stagedPost.get('id'), -1, "the post has a magical -1 id");
// Undoing a created post (there was an error)
@@ -337,7 +337,7 @@ test("staging and undoing a new post", function() {
equal(topic.get('highest_post_number'), 1, "it reverts the highest_post_number");
equal(topic.get('posts_count'), 1, "it reverts the post count");
equal(postStream.get('filteredPostsCount'), 1, "it retains the filteredPostsCount");
- ok(!postStream.get('posts').contains(stagedPost), "the post is removed from the stream");
+ ok(!postStream.get('posts').includes(stagedPost), "the post is removed from the stream");
ok(postStream.get('lastAppended'), original, "it doesn't consider undid post lastAppended");
});
@@ -367,7 +367,7 @@ test("staging and committing a post", function() {
ok(postStream.get('lastAppended'), original, "staging a post doesn't change the lastAppended");
postStream.commitPost(stagedPost);
- ok(postStream.get('posts').contains(stagedPost), "the post is still in the stream");
+ ok(postStream.get('posts').includes(stagedPost), "the post is still in the stream");
ok(!postStream.get('loading'), "it is no longer loading");
equal(postStream.get('filteredPostsCount'), 2, "it increases the filteredPostsCount");
diff --git a/test/javascripts/models/result-set-test.js.es6 b/test/javascripts/models/result-set-test.js.es6
index c846fd88720..18c9aa0c80f 100644
--- a/test/javascripts/models/result-set-test.js.es6
+++ b/test/javascripts/models/result-set-test.js.es6
@@ -15,7 +15,7 @@ test('defaults', function() {
test('pagination support', function() {
const store = createStore();
- store.findAll('widget').then(function(rs) {
+ return store.findAll('widget').then(function(rs) {
equal(rs.get('length'), 2);
equal(rs.get('totalRows'), 4);
ok(rs.get('loadMoreUrl'), 'has a url to load more');
@@ -36,7 +36,7 @@ test('pagination support', function() {
test('refresh support', function() {
const store = createStore();
- store.findAll('widget').then(function(rs) {
+ return store.findAll('widget').then(function(rs) {
equal(rs.get('refreshUrl'), '/widgets?refresh=true', 'it has the refresh url');
const promise = rs.refresh();
diff --git a/test/javascripts/test_helper.js b/test/javascripts/test_helper.js
index 69855950146..f82d4b70653 100644
--- a/test/javascripts/test_helper.js
+++ b/test/javascripts/test_helper.js
@@ -30,9 +30,9 @@
//= require sinon-1.7.1
//= require sinon-qunit-1.0.0
-//= require helpers/qunit-helpers
//= require helpers/assertions
+//= require helpers/qunit-helpers
//= require_tree ./fixtures
//= require_tree ./lib
//= require_tree .
diff --git a/test/javascripts/widgets/actions-summary-test.js.es6 b/test/javascripts/widgets/actions-summary-test.js.es6
index 9b7f9cea233..6542d17b12c 100644
--- a/test/javascripts/widgets/actions-summary-test.js.es6
+++ b/test/javascripts/widgets/actions-summary-test.js.es6
@@ -23,7 +23,7 @@ widgetTest('listing actions', {
});
widgetTest('undo', {
- template: '{{mount-widget widget="actions-summary" args=args undoPostAction="undoPostAction"}}',
+ template: '{{mount-widget widget="actions-summary" args=args undoPostAction=undoPostAction}}',
setup() {
this.set('args', {
actionsSummary: [
@@ -31,7 +31,7 @@ widgetTest('undo', {
]
});
- this.on('undoPostAction', () => this.undid = true);
+ this.set('undoPostAction', () => this.undid = true);
},
test(assert) {
assert.equal(this.$('.post-actions .post-action').length, 1);
diff --git a/vendor/assets/javascripts/ember-qunit.js b/vendor/assets/javascripts/ember-qunit.js
index 759edca9be9..cf41920e2e6 100644
--- a/vendor/assets/javascripts/ember-qunit.js
+++ b/vendor/assets/javascripts/ember-qunit.js
@@ -111,81 +111,82 @@ var define, requireModule, require, requirejs;
};
})();
-define('ember-qunit', ['exports', 'ember-qunit/module-for', 'ember-qunit/module-for-component', 'ember-qunit/module-for-model', 'ember-qunit/test', 'ember-qunit/only', 'ember-test-helpers'], function (exports, moduleFor, moduleForComponent, moduleForModel, test, only, ember_test_helpers) {
-
+define('ember-qunit', ['exports', 'ember-qunit/module-for', 'ember-qunit/module-for-component', 'ember-qunit/module-for-model', 'ember-qunit/adapter', 'ember-test-helpers', 'qunit'], function (exports, _emberQunitModuleFor, _emberQunitModuleForComponent, _emberQunitModuleForModel, _emberQunitAdapter, _emberTestHelpers, _qunit) {
'use strict';
-
-
- exports.moduleFor = moduleFor['default'];
- exports.moduleForComponent = moduleForComponent['default'];
- exports.moduleForModel = moduleForModel['default'];
- exports.test = test['default'];
- exports.only = only['default'];
- exports.setResolver = ember_test_helpers.setResolver;
-
+ exports.module = _qunit.module;
+ exports.test = _qunit.test;
+ exports.skip = _qunit.skip;
+ exports.only = _qunit.only;
+ exports.moduleFor = _emberQunitModuleFor['default'];
+ exports.moduleForComponent = _emberQunitModuleForComponent['default'];
+ exports.moduleForModel = _emberQunitModuleForModel['default'];
+ exports.setResolver = _emberTestHelpers.setResolver;
+ exports.QUnitAdapter = _emberQunitAdapter['default'];
});
-define('ember-qunit/module-for-component', ['exports', 'ember-qunit/qunit-module', 'ember-test-helpers'], function (exports, qunit_module, ember_test_helpers) {
-
+define('ember-qunit/adapter', ['exports', 'ember', 'qunit'], function (exports, _ember, _qunit) {
+ 'use strict';
+
+ exports['default'] = _ember['default'].Test.Adapter.extend({
+ init: function init() {
+ this.doneCallbacks = [];
+ },
+
+ asyncStart: function asyncStart() {
+ this.doneCallbacks.push(_qunit['default'].config.current.assert.async());
+ },
+
+ asyncEnd: function asyncEnd() {
+ this.doneCallbacks.pop()();
+ },
+
+ exception: function exception(error) {
+ _qunit['default'].config.current.assert.ok(false, _ember['default'].inspect(error));
+ }
+ });
+});
+define('ember-qunit/module-for-component', ['exports', './qunit-module', 'ember-test-helpers'], function (exports, _qunitModule, _emberTestHelpers) {
'use strict';
- function moduleForComponent(name, description, callbacks) {
- qunit_module.createModule(ember_test_helpers.TestModuleForComponent, name, description, callbacks);
- }
exports['default'] = moduleForComponent;
+ function moduleForComponent(name, description, callbacks) {
+ _qunitModule.createModule(_emberTestHelpers.TestModuleForComponent, name, description, callbacks);
+ }
});
-define('ember-qunit/module-for-model', ['exports', 'ember-qunit/qunit-module', 'ember-test-helpers'], function (exports, qunit_module, ember_test_helpers) {
-
+define('ember-qunit/module-for-model', ['exports', './qunit-module', 'ember-test-helpers'], function (exports, _qunitModule, _emberTestHelpers) {
'use strict';
- function moduleForModel(name, description, callbacks) {
- qunit_module.createModule(ember_test_helpers.TestModuleForModel, name, description, callbacks);
- }
exports['default'] = moduleForModel;
+ function moduleForModel(name, description, callbacks) {
+ _qunitModule.createModule(_emberTestHelpers.TestModuleForModel, name, description, callbacks);
+ }
});
-define('ember-qunit/module-for', ['exports', 'ember-qunit/qunit-module', 'ember-test-helpers'], function (exports, qunit_module, ember_test_helpers) {
-
+define('ember-qunit/module-for', ['exports', './qunit-module', 'ember-test-helpers'], function (exports, _qunitModule, _emberTestHelpers) {
'use strict';
- function moduleFor(name, description, callbacks) {
- qunit_module.createModule(ember_test_helpers.TestModule, name, description, callbacks);
- }
exports['default'] = moduleFor;
-});
-define('ember-qunit/only', ['exports', 'ember-qunit/test-wrapper', 'qunit'], function (exports, testWrapper, qunit) {
-
- 'use strict';
-
- function only(/* testName, expected, callback, async */) {
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; ++_key) {
- args[_key] = arguments[_key];
- }
- args.unshift(qunit.only);
- testWrapper['default'].apply(null, args);
+ function moduleFor(name, description, callbacks) {
+ _qunitModule.createModule(_emberTestHelpers.TestModule, name, description, callbacks);
}
- exports['default'] = only;
-
});
-define('ember-qunit/qunit-module', ['exports', 'qunit'], function (exports, qunit) {
-
+define('ember-qunit/qunit-module', ['exports', 'ember', 'qunit'], function (exports, _ember, _qunit) {
'use strict';
exports.createModule = createModule;
function beforeEachCallback(callbacks) {
- if (typeof callbacks !== 'object') { return; }
- if (!callbacks) { return; }
+ if (typeof callbacks !== 'object') {
+ return;
+ }
+ if (!callbacks) {
+ return;
+ }
var beforeEach;
- if (callbacks.setup) {
- beforeEach = callbacks.setup;
- delete callbacks.setup;
- }
-
if (callbacks.beforeEach) {
beforeEach = callbacks.beforeEach;
delete callbacks.beforeEach;
@@ -195,16 +196,15 @@ define('ember-qunit/qunit-module', ['exports', 'qunit'], function (exports, quni
}
function afterEachCallback(callbacks) {
- if (typeof callbacks !== 'object') { return; }
- if (!callbacks) { return; }
+ if (typeof callbacks !== 'object') {
+ return;
+ }
+ if (!callbacks) {
+ return;
+ }
var afterEach;
- if (callbacks.teardown) {
- afterEach = callbacks.teardown;
- delete callbacks.teardown;
- }
-
if (callbacks.afterEach) {
afterEach = callbacks.afterEach;
delete callbacks.afterEach;
@@ -214,129 +214,349 @@ define('ember-qunit/qunit-module', ['exports', 'qunit'], function (exports, quni
}
function createModule(Constructor, name, description, callbacks) {
- var beforeEach = beforeEachCallback(callbacks || description);
- var afterEach = afterEachCallback(callbacks || description);
+ var _beforeEach = beforeEachCallback(callbacks || description);
+ var _afterEach = afterEachCallback(callbacks || description);
var module = new Constructor(name, description, callbacks);
- qunit.module(module.name, {
- setup: function(assert) {
- var done = assert.async();
- return module.setup().then(function() {
- if (beforeEach) {
- beforeEach.call(module.context, assert);
+ _qunit.module(module.name, {
+ beforeEach: function beforeEach() {
+ var _this = this,
+ _arguments = arguments;
+
+ // provide the test context to the underlying module
+ module.setContext(this);
+
+ return module.setup.apply(module, arguments).then(function () {
+ if (_beforeEach) {
+ return _beforeEach.apply(_this, _arguments);
}
- })['finally'](done);
+ });
},
- teardown: function(assert) {
- if (afterEach) {
- afterEach.call(module.context, assert);
+ afterEach: function afterEach() {
+ var _arguments2 = arguments;
+
+ var result = undefined;
+
+ if (_afterEach) {
+ result = _afterEach.apply(this, arguments);
}
- var done = assert.async();
- return module.teardown()['finally'](done);
+
+ return _ember['default'].RSVP.resolve(result).then(function () {
+ return module.teardown.apply(module, _arguments2);
+ });
}
});
}
-
});
-define('ember-qunit/test-wrapper', ['exports', 'ember', 'ember-test-helpers'], function (exports, Ember, ember_test_helpers) {
-
+define('ember-test-helpers', ['exports', 'ember', 'ember-test-helpers/test-module', 'ember-test-helpers/test-module-for-acceptance', 'ember-test-helpers/test-module-for-integration', 'ember-test-helpers/test-module-for-component', 'ember-test-helpers/test-module-for-model', 'ember-test-helpers/test-context', 'ember-test-helpers/test-resolver'], function (exports, _ember, _emberTestHelpersTestModule, _emberTestHelpersTestModuleForAcceptance, _emberTestHelpersTestModuleForIntegration, _emberTestHelpersTestModuleForComponent, _emberTestHelpersTestModuleForModel, _emberTestHelpersTestContext, _emberTestHelpersTestResolver) {
'use strict';
- function testWrapper(qunit /*, testName, expected, callback, async */) {
- var callback;
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; ++_key) {
- args[_key - 1] = arguments[_key];
+ _ember['default'].testing = true;
+
+ exports.TestModule = _emberTestHelpersTestModule['default'];
+ exports.TestModuleForAcceptance = _emberTestHelpersTestModuleForAcceptance['default'];
+ exports.TestModuleForIntegration = _emberTestHelpersTestModuleForIntegration['default'];
+ exports.TestModuleForComponent = _emberTestHelpersTestModuleForComponent['default'];
+ exports.TestModuleForModel = _emberTestHelpersTestModuleForModel['default'];
+ exports.getContext = _emberTestHelpersTestContext.getContext;
+ exports.setContext = _emberTestHelpersTestContext.setContext;
+ exports.unsetContext = _emberTestHelpersTestContext.unsetContext;
+ exports.setResolver = _emberTestHelpersTestResolver.setResolver;
+});
+define('ember-test-helpers/-legacy-overrides', ['exports', 'ember', './has-ember-version'], function (exports, _ember, _hasEmberVersion) {
+ 'use strict';
+
+ exports.preGlimmerSetupIntegrationForComponent = preGlimmerSetupIntegrationForComponent;
+
+ function preGlimmerSetupIntegrationForComponent() {
+ var module = this;
+ var context = this.context;
+
+ this.actionHooks = {};
+
+ context.dispatcher = this.container.lookup('event_dispatcher:main') || _ember['default'].EventDispatcher.create();
+ context.dispatcher.setup({}, '#ember-testing');
+ context.actions = module.actionHooks;
+
+ (this.registry || this.container).register('component:-test-holder', _ember['default'].Component.extend());
+
+ context.render = function (template) {
+ // in case `this.render` is called twice, make sure to teardown the first invocation
+ module.teardownComponent();
+
+ if (!template) {
+ throw new Error("in a component integration test you must pass a template to `render()`");
+ }
+ if (_ember['default'].isArray(template)) {
+ template = template.join('');
+ }
+ if (typeof template === 'string') {
+ template = _ember['default'].Handlebars.compile(template);
+ }
+ module.component = module.container.lookupFactory('component:-test-holder').create({
+ layout: template
+ });
+
+ module.component.set('context', context);
+ module.component.set('controller', context);
+
+ _ember['default'].run(function () {
+ module.component.appendTo('#ember-testing');
+ });
+
+ context._element = module.component.element;
+ };
+
+ context.$ = function () {
+ return module.component.$.apply(module.component, arguments);
+ };
+
+ context.set = function (key, value) {
+ var ret = _ember['default'].run(function () {
+ return _ember['default'].set(context, key, value);
+ });
+
+ if (_hasEmberVersion['default'](2, 0)) {
+ return ret;
+ }
+ };
+
+ context.setProperties = function (hash) {
+ var ret = _ember['default'].run(function () {
+ return _ember['default'].setProperties(context, hash);
+ });
+
+ if (_hasEmberVersion['default'](2, 0)) {
+ return ret;
+ }
+ };
+
+ context.get = function (key) {
+ return _ember['default'].get(context, key);
+ };
+
+ context.getProperties = function () {
+ var args = Array.prototype.slice.call(arguments);
+ return _ember['default'].getProperties(context, args);
+ };
+
+ context.on = function (actionName, handler) {
+ module.actionHooks[actionName] = handler;
+ };
+
+ context.send = function (actionName) {
+ var hook = module.actionHooks[actionName];
+ if (!hook) {
+ throw new Error("integration testing template received unexpected action " + actionName);
+ }
+ hook.apply(module, Array.prototype.slice.call(arguments, 1));
+ };
+
+ context.clearRender = function () {
+ module.teardownComponent();
+ };
+ }
+});
+define('ember-test-helpers/abstract-test-module', ['exports', './wait', './test-context', 'ember'], function (exports, _wait, _testContext, _ember) {
+ 'use strict';
+
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
+
+ // calling this `merge` here because we cannot
+ // actually assume it is like `Object.assign`
+ // with > 2 args
+ var merge = _ember['default'].assign || _ember['default'].merge;
+
+ var _default = (function () {
+ function _default(name, options) {
+ _classCallCheck(this, _default);
+
+ this.context = undefined;
+ this.name = name;
+ this.callbacks = options || {};
+
+ this.initSetupSteps();
+ this.initTeardownSteps();
}
- function wrapper() {
- var context = ember_test_helpers.getContext();
+ _default.prototype.setup = function setup(assert) {
+ var _this = this;
- var result = callback.apply(context, arguments);
+ return this.invokeSteps(this.setupSteps, this, assert).then(function () {
+ _this.contextualizeCallbacks();
+ return _this.invokeSteps(_this.contextualizedSetupSteps, _this.context, assert);
+ });
+ };
- function failTestOnPromiseRejection(reason) {
- var message;
- if (reason instanceof Error) {
- message = reason.stack;
- if (reason.message && message.indexOf(reason.message) < 0) {
- // PhantomJS has a `stack` that does not contain the actual
- // exception message.
- message = Ember['default'].inspect(reason) + "\n" + message;
- }
- } else {
- message = Ember['default'].inspect(reason);
- }
- ok(false, message);
+ _default.prototype.teardown = function teardown(assert) {
+ var _this2 = this;
+
+ return this.invokeSteps(this.contextualizedTeardownSteps, this.context, assert).then(function () {
+ return _this2.invokeSteps(_this2.teardownSteps, _this2, assert);
+ }).then(function () {
+ _this2.cache = null;
+ _this2.cachedCalls = null;
+ });
+ };
+
+ _default.prototype.initSetupSteps = function initSetupSteps() {
+ this.setupSteps = [];
+ this.contextualizedSetupSteps = [];
+
+ if (this.callbacks.beforeSetup) {
+ this.setupSteps.push(this.callbacks.beforeSetup);
+ delete this.callbacks.beforeSetup;
}
- Ember['default'].run(function(){
- QUnit.stop();
- Ember['default'].RSVP.Promise.resolve(result)['catch'](failTestOnPromiseRejection)['finally'](QUnit.start);
+ this.setupSteps.push(this.setupContext);
+ this.setupSteps.push(this.setupTestElements);
+ this.setupSteps.push(this.setupAJAXListeners);
+
+ if (this.callbacks.setup) {
+ this.contextualizedSetupSteps.push(this.callbacks.setup);
+ delete this.callbacks.setup;
+ }
+ };
+
+ _default.prototype.invokeSteps = function invokeSteps(steps, context, assert) {
+ steps = steps.slice();
+
+ function nextStep() {
+ var step = steps.shift();
+ if (step) {
+ // guard against exceptions, for example missing components referenced from needs.
+ return new _ember['default'].RSVP.Promise(function (resolve) {
+ resolve(step.call(context, assert));
+ }).then(nextStep);
+ } else {
+ return _ember['default'].RSVP.resolve();
+ }
+ }
+ return nextStep();
+ };
+
+ _default.prototype.contextualizeCallbacks = function contextualizeCallbacks() {};
+
+ _default.prototype.initTeardownSteps = function initTeardownSteps() {
+ this.teardownSteps = [];
+ this.contextualizedTeardownSteps = [];
+
+ if (this.callbacks.teardown) {
+ this.contextualizedTeardownSteps.push(this.callbacks.teardown);
+ delete this.callbacks.teardown;
+ }
+
+ this.teardownSteps.push(this.teardownContext);
+ this.teardownSteps.push(this.teardownTestElements);
+ this.teardownSteps.push(this.teardownAJAXListeners);
+
+ if (this.callbacks.afterTeardown) {
+ this.teardownSteps.push(this.callbacks.afterTeardown);
+ delete this.callbacks.afterTeardown;
+ }
+ };
+
+ _default.prototype.setupTestElements = function setupTestElements() {
+ var testEl = document.querySelector('#ember-testing');
+ if (!testEl) {
+ var element = document.createElement('div');
+ element.setAttribute('id', 'ember-testing');
+
+ document.body.appendChild(element);
+ this.fixtureResetValue = '';
+ } else {
+ this.fixtureResetValue = testEl.innerHTML;
+ }
+ };
+
+ _default.prototype.setupContext = function setupContext(options) {
+ var context = this.getContext();
+
+ merge(context, {
+ dispatcher: null,
+ inject: {}
});
- }
+ merge(context, options);
- if (args.length === 2) {
- callback = args.splice(1, 1, wrapper)[0];
- } else {
- callback = args.splice(2, 1, wrapper)[0];
- }
+ this.setToString();
+ _testContext.setContext(context);
+ this.context = context;
+ };
- qunit.apply(null, args);
- }
- exports['default'] = testWrapper;
+ _default.prototype.setContext = function setContext(context) {
+ this.context = context;
+ };
+ _default.prototype.getContext = function getContext() {
+ if (this.context) {
+ return this.context;
+ }
+
+ return this.context = _testContext.getContext() || {};
+ };
+
+ _default.prototype.setToString = function setToString() {
+ var _this3 = this;
+
+ this.context.toString = function () {
+ if (_this3.subjectName) {
+ return 'test context for: ' + _this3.subjectName;
+ }
+
+ if (_this3.name) {
+ return 'test context for: ' + _this3.name;
+ }
+ };
+ };
+
+ _default.prototype.setupAJAXListeners = function setupAJAXListeners() {
+ _wait._setupAJAXHooks();
+ };
+
+ _default.prototype.teardownAJAXListeners = function teardownAJAXListeners() {
+ _wait._teardownAJAXHooks();
+ };
+
+ _default.prototype.teardownTestElements = function teardownTestElements() {
+ document.getElementById('ember-testing').innerHTML = this.fixtureResetValue;
+
+ // Ember 2.0.0 removed Ember.View as public API, so only do this when
+ // Ember.View is present
+ if (_ember['default'].View && _ember['default'].View.views) {
+ _ember['default'].View.views = {};
+ }
+ };
+
+ _default.prototype.teardownContext = function teardownContext() {
+ var context = this.context;
+ this.context = undefined;
+ _testContext.unsetContext();
+
+ if (context && context.dispatcher && !context.dispatcher.isDestroyed) {
+ _ember['default'].run(function () {
+ context.dispatcher.destroy();
+ });
+ }
+ };
+
+ return _default;
+ })();
+
+ exports['default'] = _default;
});
-define('ember-qunit/test', ['exports', 'ember-qunit/test-wrapper', 'qunit'], function (exports, testWrapper, qunit) {
-
- 'use strict';
-
- function test(/* testName, expected, callback, async */) {
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; ++_key) {
- args[_key] = arguments[_key];
- }
- args.unshift(qunit.test);
- testWrapper['default'].apply(null, args);
- }
- exports['default'] = test;
-
-});
-define('ember-test-helpers', ['exports', 'ember', 'ember-test-helpers/test-module', 'ember-test-helpers/test-module-for-component', 'ember-test-helpers/test-module-for-model', 'ember-test-helpers/test-context', 'ember-test-helpers/test-resolver'], function (exports, Ember, TestModule, TestModuleForComponent, TestModuleForModel, test_context, test_resolver) {
-
- 'use strict';
-
- Ember['default'].testing = true;
-
- exports.TestModule = TestModule['default'];
- exports.TestModuleForComponent = TestModuleForComponent['default'];
- exports.TestModuleForModel = TestModuleForModel['default'];
- exports.getContext = test_context.getContext;
- exports.setContext = test_context.setContext;
- exports.setResolver = test_resolver.setResolver;
-
-});
-define('ember-test-helpers/build-registry', ['exports', 'ember'], function (exports, Ember) {
+define('ember-test-helpers/build-registry', ['exports', 'ember'], function (exports, _ember) {
+ /* globals global, self, requirejs, require */
'use strict';
function exposeRegistryMethodsWithoutDeprecations(container) {
- var methods = [
- 'register',
- 'unregister',
- 'resolve',
- 'normalize',
- 'typeInjection',
- 'injection',
- 'factoryInjection',
- 'factoryTypeInjection',
- 'has',
- 'options',
- 'optionsForType'
- ];
+ var methods = ['register', 'unregister', 'resolve', 'normalize', 'typeInjection', 'injection', 'factoryInjection', 'factoryTypeInjection', 'has', 'options', 'optionsForType'];
function exposeRegistryMethod(container, method) {
if (method in container) {
- container[method] = function() {
+ container[method] = function () {
return container._registry[method].apply(container._registry, arguments);
};
}
@@ -347,18 +567,20 @@ define('ember-test-helpers/build-registry', ['exports', 'ember'], function (expo
}
}
- var Owner = (function() {
- if (Ember['default']._RegistryProxyMixin && Ember['default']._ContainerProxyMixin) {
- return Ember['default'].Object.extend(Ember['default']._RegistryProxyMixin, Ember['default']._ContainerProxyMixin);
+ var Owner = (function () {
+ if (_ember['default']._RegistryProxyMixin && _ember['default']._ContainerProxyMixin) {
+ return _ember['default'].Object.extend(_ember['default']._RegistryProxyMixin, _ember['default']._ContainerProxyMixin);
}
- return Ember['default'].Object.extend();
+ return _ember['default'].Object.extend();
})();
- exports['default'] = function(resolver) {
+ exports['default'] = function (resolver) {
var fallbackRegistry, registry, container;
- var namespace = Ember['default'].Object.create({
- Resolver: { create: function() { return resolver; } }
+ var namespace = _ember['default'].Object.create({
+ Resolver: { create: function create() {
+ return resolver;
+ } }
});
function register(name, factory) {
@@ -369,14 +591,18 @@ define('ember-test-helpers/build-registry', ['exports', 'ember'], function (expo
}
}
- if (Ember['default'].Application.buildRegistry) {
- fallbackRegistry = Ember['default'].Application.buildRegistry(namespace);
- fallbackRegistry.register('component-lookup:main', Ember['default'].ComponentLookup);
+ if (_ember['default'].Application.buildRegistry) {
+ fallbackRegistry = _ember['default'].Application.buildRegistry(namespace);
+ fallbackRegistry.register('component-lookup:main', _ember['default'].ComponentLookup);
- registry = new Ember['default'].Registry({
+ registry = new _ember['default'].Registry({
fallback: fallbackRegistry
});
+ if (_ember['default'].ApplicationInstance && _ember['default'].ApplicationInstance.setupRegistry) {
+ _ember['default'].ApplicationInstance.setupRegistry(registry);
+ }
+
// these properties are set on the fallback registry by `buildRegistry`
// and on the primary registry within the ApplicationInstance constructor
// but we need to manually recreate them since ApplicationInstance's are not
@@ -395,8 +621,8 @@ define('ember-test-helpers/build-registry', ['exports', 'ember'], function (expo
exposeRegistryMethodsWithoutDeprecations(container);
} else {
- container = Ember['default'].Application.buildContainer(namespace);
- container.register('component-lookup:main', Ember['default'].ComponentLookup);
+ container = _ember['default'].Application.buildContainer(namespace);
+ container.register('component-lookup:main', _ember['default'].ComponentLookup);
}
// Ember 1.10.0 did not properly add `view:toplevel` or `view:default`
@@ -404,18 +630,26 @@ define('ember-test-helpers/build-registry', ['exports', 'ember'], function (expo
//
// Ember 2.0.0 removed Ember.View as public API, so only do this when
// Ember.View is present
- if (Ember['default'].View) {
- register('view:toplevel', Ember['default'].View.extend());
+ if (_ember['default'].View) {
+ register('view:toplevel', _ember['default'].View.extend());
}
// Ember 2.0.0 removed Ember._MetamorphView from the Ember global, so only
// do this when present
- if (Ember['default']._MetamorphView) {
- register('view:default', Ember['default']._MetamorphView);
+ if (_ember['default']._MetamorphView) {
+ register('view:default', _ember['default']._MetamorphView);
}
var globalContext = typeof global === 'object' && global || self;
- if (globalContext.DS) {
+ if (requirejs.entries['ember-data/setup-container']) {
+ // ember-data is a proper ember-cli addon since 2.3; if no 'import
+ // 'ember-data'' is present somewhere in the tests, there is also no `DS`
+ // available on the globalContext and hence ember-data wouldn't be setup
+ // correctly for the tests; that's why we import and call setupContainer
+ // here; also see https://github.com/emberjs/data/issues/4071 for context
+ var setupContainer = require('ember-data/setup-container')['default'];
+ setupContainer(registry || container);
+ } else if (globalContext.DS) {
var DS = globalContext.DS;
if (DS._setupContainer) {
DS._setupContainer(registry || container);
@@ -434,30 +668,26 @@ define('ember-test-helpers/build-registry', ['exports', 'ember'], function (expo
registry: registry,
container: container
};
- }
-
+ };
});
-define('ember-test-helpers/has-ember-version', ['exports', 'ember'], function (exports, Ember) {
-
+define('ember-test-helpers/has-ember-version', ['exports', 'ember'], function (exports, _ember) {
'use strict';
- function hasEmberVersion(major, minor) {
- var numbers = Ember['default'].VERSION.split('-')[0].split('.');
- var actualMajor = parseInt(numbers[0], 10);
- var actualMinor = parseInt(numbers[1], 10);
- return actualMajor > major || (actualMajor === major && actualMinor >= minor);
- }
exports['default'] = hasEmberVersion;
+ function hasEmberVersion(major, minor) {
+ var numbers = _ember['default'].VERSION.split('-')[0].split('.');
+ var actualMajor = parseInt(numbers[0], 10);
+ var actualMinor = parseInt(numbers[1], 10);
+ return actualMajor > major || actualMajor === major && actualMinor >= minor;
+ }
});
-define('ember-test-helpers/test-context', ['exports'], function (exports) {
-
- 'use strict';
+define("ember-test-helpers/test-context", ["exports"], function (exports) {
+ "use strict";
exports.setContext = setContext;
exports.getContext = getContext;
exports.unsetContext = unsetContext;
-
var __test_context__;
function setContext(context) {
@@ -471,16 +701,82 @@ define('ember-test-helpers/test-context', ['exports'], function (exports) {
function unsetContext() {
__test_context__ = undefined;
}
-
});
-define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-helpers/test-module', 'ember', 'ember-test-helpers/test-resolver'], function (exports, TestModule, Ember, test_resolver) {
-
+define('ember-test-helpers/test-module-for-acceptance', ['exports', './abstract-test-module', 'ember', './test-context'], function (exports, _abstractTestModule, _ember, _testContext) {
'use strict';
- exports['default'] = TestModule['default'].extend({
- isComponentTestModule: true,
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
+
+ function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+ var _default = (function (_AbstractTestModule) {
+ _inherits(_default, _AbstractTestModule);
+
+ function _default() {
+ _classCallCheck(this, _default);
+
+ _AbstractTestModule.apply(this, arguments);
+ }
+
+ _default.prototype.setupContext = function setupContext() {
+ _AbstractTestModule.prototype.setupContext.call(this, { application: this.createApplication() });
+ };
+
+ _default.prototype.teardownContext = function teardownContext() {
+ _ember['default'].run(function () {
+ _testContext.getContext().application.destroy();
+ });
+
+ _AbstractTestModule.prototype.teardownContext.call(this);
+ };
+
+ _default.prototype.createApplication = function createApplication() {
+ var _callbacks = this.callbacks;
+ var Application = _callbacks.Application;
+ var config = _callbacks.config;
+
+ var application = undefined;
+
+ _ember['default'].run(function () {
+ application = Application.create(config);
+ application.setupForTesting();
+ application.injectTestHelpers();
+ });
+
+ return application;
+ };
+
+ return _default;
+ })(_abstractTestModule['default']);
+
+ exports['default'] = _default;
+});
+define('ember-test-helpers/test-module-for-component', ['exports', './test-module', 'ember', './has-ember-version', './-legacy-overrides'], function (exports, _testModule, _ember, _hasEmberVersion, _legacyOverrides) {
+ 'use strict';
+
+ exports.setupComponentIntegrationTest = _setupComponentIntegrationTest;
+
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
+
+ function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+ var ACTION_KEY = undefined;
+ if (_hasEmberVersion['default'](2, 0)) {
+ ACTION_KEY = 'actions';
+ } else {
+ ACTION_KEY = '_actions';
+ }
+
+ var isPreGlimmer = !_hasEmberVersion['default'](1, 13);
+
+ var getOwner = _ember['default'].getOwner;
+
+ var _default = (function (_TestModule) {
+ _inherits(_default, _TestModule);
+
+ function _default(componentName, description, callbacks) {
+ _classCallCheck(this, _default);
- init: function(componentName, description, callbacks) {
// Allow `description` to be omitted
if (!callbacks && typeof description === 'object') {
callbacks = description;
@@ -489,30 +785,21 @@ define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-h
callbacks = {};
}
+ var integrationOption = callbacks.integration;
+
+ _TestModule.call(this, 'component:' + componentName, description, callbacks);
+
this.componentName = componentName;
- if (callbacks.needs || callbacks.unit || callbacks.integration === false) {
+ if (callbacks.needs || callbacks.unit || integrationOption === false) {
this.isUnitTest = true;
- } else if (callbacks.integration) {
+ } else if (integrationOption) {
this.isUnitTest = false;
} else {
- Ember['default'].deprecate(
- "the component:" + componentName + " test module is implicitly running in unit test mode, " +
- "which will change to integration test mode by default in an upcoming version of " +
- "ember-test-helpers. Add `unit: true` or a `needs:[]` list to explicitly opt in to unit " +
- "test mode.",
- false,
- { id: 'ember-test-helpers.test-module-for-component.test-type', until: '0.6.0' }
- );
+ _ember['default'].deprecate("the component:" + componentName + " test module is implicitly running in unit test mode, " + "which will change to integration test mode by default in an upcoming version of " + "ember-test-helpers. Add `unit: true` or a `needs:[]` list to explicitly opt in to unit " + "test mode.", false, { id: 'ember-test-helpers.test-module-for-component.test-type', until: '0.6.0' });
this.isUnitTest = true;
}
- if (description) {
- this._super.call(this, 'component:' + componentName, description, callbacks);
- } else {
- this._super.call(this, 'component:' + componentName, callbacks);
- }
-
if (!this.isUnitTest && !this.isLegacy) {
callbacks.integration = true;
}
@@ -520,35 +807,40 @@ define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-h
if (this.isUnitTest || this.isLegacy) {
this.setupSteps.push(this.setupComponentUnitTest);
} else {
- this.callbacks.subject = function() {
- throw new Error("component integration tests do not support `subject()`.");
+ this.callbacks.subject = function () {
+ throw new Error("component integration tests do not support `subject()`. Instead, render the component as if it were HTML: `this.render('');`. For more information, read: http://guides.emberjs.com/v2.2.0/testing/testing-components/");
};
this.setupSteps.push(this.setupComponentIntegrationTest);
this.teardownSteps.unshift(this.teardownComponent);
}
- if (Ember['default'].View && Ember['default'].View.views) {
+ if (_ember['default'].View && _ember['default'].View.views) {
this.setupSteps.push(this._aliasViewRegistry);
this.teardownSteps.unshift(this._resetViewRegistry);
}
- },
+ }
- _aliasViewRegistry: function() {
- this._originalGlobalViewRegistry = Ember['default'].View.views;
+ _default.prototype.initIntegration = function initIntegration(options) {
+ this.isLegacy = options.integration === 'legacy';
+ this.isIntegration = options.integration !== 'legacy';
+ };
+
+ _default.prototype._aliasViewRegistry = function _aliasViewRegistry() {
+ this._originalGlobalViewRegistry = _ember['default'].View.views;
var viewRegistry = this.container.lookup('-view-registry:main');
if (viewRegistry) {
- Ember['default'].View.views = viewRegistry;
+ _ember['default'].View.views = viewRegistry;
}
- },
+ };
- _resetViewRegistry: function() {
- Ember['default'].View.views = this._originalGlobalViewRegistry;
- },
+ _default.prototype._resetViewRegistry = function _resetViewRegistry() {
+ _ember['default'].View.views = this._originalGlobalViewRegistry;
+ };
- setupComponentUnitTest: function() {
+ _default.prototype.setupComponentUnitTest = function setupComponentUnitTest() {
var _this = this;
- var resolver = test_resolver.getResolver();
+ var resolver = this.resolver;
var context = this.context;
var layoutName = 'template:components/' + this.componentName;
@@ -561,114 +853,51 @@ define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-h
thingToRegisterWith.injection(this.subjectName, 'layout', layoutName);
}
- context.dispatcher = this.container.lookup('event_dispatcher:main') || Ember['default'].EventDispatcher.create();
+ context.dispatcher = this.container.lookup('event_dispatcher:main') || _ember['default'].EventDispatcher.create();
context.dispatcher.setup({}, '#ember-testing');
- this.callbacks.render = function() {
+ context._element = null;
+
+ this.callbacks.render = function () {
var subject;
- Ember['default'].run(function(){
+ _ember['default'].run(function () {
subject = context.subject();
subject.appendTo('#ember-testing');
});
- _this.teardownSteps.unshift(function() {
- Ember['default'].run(function() {
- Ember['default'].tryInvoke(subject, 'destroy');
+ context._element = subject.element;
+
+ _this.teardownSteps.unshift(function () {
+ _ember['default'].run(function () {
+ _ember['default'].tryInvoke(subject, 'destroy');
});
});
};
- this.callbacks.append = function() {
- Ember['default'].deprecate(
- 'this.append() is deprecated. Please use this.render() or this.$() instead.',
- false,
- { id: 'ember-test-helpers.test-module-for-component.append', until: '0.6.0' }
- );
+ this.callbacks.append = function () {
+ _ember['default'].deprecate('this.append() is deprecated. Please use this.render() or this.$() instead.', false, { id: 'ember-test-helpers.test-module-for-component.append', until: '0.6.0' });
return context.$();
};
- context.$ = function() {
+ context.$ = function () {
this.render();
var subject = this.subject();
return subject.$.apply(subject, arguments);
};
- },
+ };
- setupComponentIntegrationTest: function() {
- var module = this;
- var context = this.context;
+ _default.prototype.setupComponentIntegrationTest = function setupComponentIntegrationTest() {
+ if (isPreGlimmer) {
+ return _legacyOverrides.preGlimmerSetupIntegrationForComponent.apply(this, arguments);
+ } else {
+ return _setupComponentIntegrationTest.apply(this, arguments);
+ }
+ };
- this.actionHooks = {};
-
- context.dispatcher = this.container.lookup('event_dispatcher:main') || Ember['default'].EventDispatcher.create();
- context.dispatcher.setup({}, '#ember-testing');
- context.actions = module.actionHooks;
-
- (this.registry || this.container).register('component:-test-holder', Ember['default'].Component.extend());
-
- context.render = function(template) {
- if (!template) {
- throw new Error("in a component integration test you must pass a template to `render()`");
- }
- if (Ember['default'].isArray(template)) {
- template = template.join('');
- }
- if (typeof template === 'string') {
- template = Ember['default'].Handlebars.compile(template);
- }
- module.component = module.container.lookupFactory('component:-test-holder').create({
- layout: template
- });
-
- module.component.set('context' ,context);
- module.component.set('controller', context);
-
- Ember['default'].run(function() {
- module.component.appendTo('#ember-testing');
- });
- };
-
- context.$ = function() {
- return module.component.$.apply(module.component, arguments);
- };
-
- context.set = function(key, value) {
- Ember['default'].run(function() {
- Ember['default'].set(context, key, value);
- });
- };
-
- context.setProperties = function(hash) {
- Ember['default'].run(function() {
- Ember['default'].setProperties(context, hash);
- });
- };
-
- context.get = function(key) {
- return Ember['default'].get(context, key);
- };
-
- context.getProperties = function() {
- var args = Array.prototype.slice.call(arguments);
- return Ember['default'].getProperties(context, args);
- };
-
- context.on = function(actionName, handler) {
- module.actionHooks[actionName] = handler;
- };
- context.send = function(actionName) {
- var hook = module.actionHooks[actionName];
- if (!hook) {
- throw new Error("integration testing template received unexpected action " + actionName);
- }
- hook.apply(module, Array.prototype.slice.call(arguments, 1));
- };
- },
-
- setupContext: function() {
- this._super.call(this);
+ _default.prototype.setupContext = function setupContext() {
+ _TestModule.prototype.setupContext.call(this);
// only setup the injection if we are running against a version
// of Ember that has `-view-registry:main` (Ember >= 1.12)
@@ -677,35 +906,409 @@ define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-h
}
if (!this.isUnitTest && !this.isLegacy) {
- this.context.factory = function() {};
+ this.context.factory = function () {};
}
- },
+ };
- teardownComponent: function() {
+ _default.prototype.teardownComponent = function teardownComponent() {
var component = this.component;
if (component) {
- Ember['default'].run(function() {
+ _ember['default'].run(component, 'destroy');
+ this.component = null;
+ }
+ };
+
+ return _default;
+ })(_testModule['default']);
+
+ exports['default'] = _default;
+
+ function _setupComponentIntegrationTest() {
+ var module = this;
+ var context = this.context;
+
+ this.actionHooks = context[ACTION_KEY] = {};
+ context.dispatcher = this.container.lookup('event_dispatcher:main') || _ember['default'].EventDispatcher.create();
+ context.dispatcher.setup({}, '#ember-testing');
+
+ var hasRendered = false;
+ var OutletView = module.container.lookupFactory('view:-outlet');
+ var OutletTemplate = module.container.lookup('template:-outlet');
+ var toplevelView = module.component = OutletView.create();
+ var hasOutletTemplate = !!OutletTemplate;
+ var outletState = {
+ render: {
+ owner: getOwner ? getOwner(module.container) : undefined,
+ into: undefined,
+ outlet: 'main',
+ name: 'application',
+ controller: module.context,
+ ViewClass: undefined,
+ template: OutletTemplate
+ },
+
+ outlets: {}
+ };
+
+ var element = document.getElementById('ember-testing');
+ var templateId = 0;
+
+ if (hasOutletTemplate) {
+ _ember['default'].run(function () {
+ toplevelView.setOutletState(outletState);
+ });
+ }
+
+ context.render = function (template) {
+ if (!template) {
+ throw new Error("in a component integration test you must pass a template to `render()`");
+ }
+ if (_ember['default'].isArray(template)) {
+ template = template.join('');
+ }
+ if (typeof template === 'string') {
+ template = _ember['default'].Handlebars.compile(template);
+ }
+
+ var templateFullName = 'template:-undertest-' + ++templateId;
+ this.registry.register(templateFullName, template);
+ var stateToRender = {
+ owner: getOwner ? getOwner(module.container) : undefined,
+ into: undefined,
+ outlet: 'main',
+ name: 'index',
+ controller: module.context,
+ ViewClass: undefined,
+ template: module.container.lookup(templateFullName),
+ outlets: {}
+ };
+
+ if (hasOutletTemplate) {
+ stateToRender.name = 'index';
+ outletState.outlets.main = { render: stateToRender, outlets: {} };
+ } else {
+ stateToRender.name = 'application';
+ outletState = { render: stateToRender, outlets: {} };
+ }
+
+ _ember['default'].run(function () {
+ toplevelView.setOutletState(outletState);
+ });
+
+ if (!hasRendered) {
+ _ember['default'].run(module.component, 'appendTo', '#ember-testing');
+ hasRendered = true;
+ }
+
+ // ensure the element is based on the wrapping toplevel view
+ // Ember still wraps the main application template with a
+ // normal tagged view
+ context._element = element = document.querySelector('#ember-testing > .ember-view');
+ };
+
+ context.$ = function (selector) {
+ // emulates Ember internal behavor of `this.$` in a component
+ // https://github.com/emberjs/ember.js/blob/v2.5.1/packages/ember-views/lib/views/states/has_element.js#L18
+ return selector ? _ember['default'].$(selector, element) : _ember['default'].$(element);
+ };
+
+ context.set = function (key, value) {
+ var ret = _ember['default'].run(function () {
+ return _ember['default'].set(context, key, value);
+ });
+
+ if (_hasEmberVersion['default'](2, 0)) {
+ return ret;
+ }
+ };
+
+ context.setProperties = function (hash) {
+ var ret = _ember['default'].run(function () {
+ return _ember['default'].setProperties(context, hash);
+ });
+
+ if (_hasEmberVersion['default'](2, 0)) {
+ return ret;
+ }
+ };
+
+ context.get = function (key) {
+ return _ember['default'].get(context, key);
+ };
+
+ context.getProperties = function () {
+ var args = Array.prototype.slice.call(arguments);
+ return _ember['default'].getProperties(context, args);
+ };
+
+ context.on = function (actionName, handler) {
+ module.actionHooks[actionName] = handler;
+ };
+
+ context.send = function (actionName) {
+ var hook = module.actionHooks[actionName];
+ if (!hook) {
+ throw new Error("integration testing template received unexpected action " + actionName);
+ }
+ hook.apply(module.context, Array.prototype.slice.call(arguments, 1));
+ };
+
+ context.clearRender = function () {
+ _ember['default'].run(function () {
+ toplevelView.setOutletState({
+ render: {
+ owner: module.container,
+ into: undefined,
+ outlet: 'main',
+ name: 'application',
+ controller: module.context,
+ ViewClass: undefined,
+ template: undefined
+ },
+ outlets: {}
+ });
+ });
+ };
+ }
+});
+define('ember-test-helpers/test-module-for-integration', ['exports', 'ember', './abstract-test-module', './test-resolver', './build-registry', './has-ember-version', './-legacy-overrides', './test-module-for-component'], function (exports, _ember, _abstractTestModule, _testResolver, _buildRegistry, _hasEmberVersion, _legacyOverrides, _testModuleForComponent) {
+ 'use strict';
+
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
+
+ function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+ var ACTION_KEY = undefined;
+ if (_hasEmberVersion['default'](2, 0)) {
+ ACTION_KEY = 'actions';
+ } else {
+ ACTION_KEY = '_actions';
+ }
+
+ var isPreGlimmer = !_hasEmberVersion['default'](1, 13);
+
+ var _default = (function (_AbstractTestModule) {
+ _inherits(_default, _AbstractTestModule);
+
+ function _default() {
+ _classCallCheck(this, _default);
+
+ _AbstractTestModule.apply(this, arguments);
+ this.resolver = this.callbacks.resolver || _testResolver.getResolver();
+ }
+
+ _default.prototype.initSetupSteps = function initSetupSteps() {
+ this.setupSteps = [];
+ this.contextualizedSetupSteps = [];
+
+ if (this.callbacks.beforeSetup) {
+ this.setupSteps.push(this.callbacks.beforeSetup);
+ delete this.callbacks.beforeSetup;
+ }
+
+ this.setupSteps.push(this.setupContainer);
+ this.setupSteps.push(this.setupContext);
+ this.setupSteps.push(this.setupTestElements);
+ this.setupSteps.push(this.setupAJAXListeners);
+ this.setupSteps.push(this.setupComponentIntegrationTest);
+
+ if (_ember['default'].View && _ember['default'].View.views) {
+ this.setupSteps.push(this._aliasViewRegistry);
+ }
+
+ if (this.callbacks.setup) {
+ this.contextualizedSetupSteps.push(this.callbacks.setup);
+ delete this.callbacks.setup;
+ }
+ };
+
+ _default.prototype.initTeardownSteps = function initTeardownSteps() {
+ this.teardownSteps = [];
+ this.contextualizedTeardownSteps = [];
+
+ if (this.callbacks.teardown) {
+ this.contextualizedTeardownSteps.push(this.callbacks.teardown);
+ delete this.callbacks.teardown;
+ }
+
+ this.teardownSteps.push(this.teardownContainer);
+ this.teardownSteps.push(this.teardownContext);
+ this.teardownSteps.push(this.teardownAJAXListeners);
+ this.teardownSteps.push(this.teardownComponent);
+
+ if (_ember['default'].View && _ember['default'].View.views) {
+ this.teardownSteps.push(this._resetViewRegistry);
+ }
+
+ this.teardownSteps.push(this.teardownTestElements);
+
+ if (this.callbacks.afterTeardown) {
+ this.teardownSteps.push(this.callbacks.afterTeardown);
+ delete this.callbacks.afterTeardown;
+ }
+ };
+
+ _default.prototype.setupContainer = function setupContainer() {
+ var resolver = this.resolver;
+ var items = _buildRegistry['default'](resolver);
+
+ this.container = items.container;
+ this.registry = items.registry;
+
+ if (_hasEmberVersion['default'](1, 13)) {
+ var thingToRegisterWith = this.registry || this.container;
+ var router = resolver.resolve('router:main');
+ router = router || _ember['default'].Router.extend();
+ thingToRegisterWith.register('router:main', router);
+ }
+ };
+
+ _default.prototype.setupContext = function setupContext() {
+ var subjectName = this.subjectName;
+ var container = this.container;
+
+ var factory = function factory() {
+ return container.lookupFactory(subjectName);
+ };
+
+ _AbstractTestModule.prototype.setupContext.call(this, {
+ container: this.container,
+ registry: this.registry,
+ factory: factory,
+ register: function register() {
+ var target = this.registry || this.container;
+ return target.register.apply(target, arguments);
+ }
+ });
+
+ var context = this.context;
+
+ if (_ember['default'].setOwner) {
+ _ember['default'].setOwner(context, this.container.owner);
+ }
+
+ if (_ember['default'].inject) {
+ var keys = (Object.keys || _ember['default'].keys)(_ember['default'].inject);
+ keys.forEach(function (typeName) {
+ context.inject[typeName] = function (name, opts) {
+ var alias = opts && opts.as || name;
+ _ember['default'].run(function () {
+ _ember['default'].set(context, alias, context.container.lookup(typeName + ':' + name));
+ });
+ };
+ });
+ }
+
+ // only setup the injection if we are running against a version
+ // of Ember that has `-view-registry:main` (Ember >= 1.12)
+ if (this.container.lookupFactory('-view-registry:main')) {
+ (this.registry || this.container).injection('component', '_viewRegistry', '-view-registry:main');
+ }
+ };
+
+ _default.prototype.setupComponentIntegrationTest = function setupComponentIntegrationTest() {
+ if (isPreGlimmer) {
+ return _legacyOverrides.preGlimmerSetupIntegrationForComponent.apply(this, arguments);
+ } else {
+ return _testModuleForComponent.setupComponentIntegrationTest.apply(this, arguments);
+ }
+ };
+
+ _default.prototype.teardownComponent = function teardownComponent() {
+ var component = this.component;
+ if (component) {
+ _ember['default'].run(function () {
component.destroy();
});
}
- }
- });
+ };
+ _default.prototype.teardownContainer = function teardownContainer() {
+ var container = this.container;
+ _ember['default'].run(function () {
+ container.destroy();
+ });
+ };
+
+ // allow arbitrary named factories, like rspec let
+
+ _default.prototype.contextualizeCallbacks = function contextualizeCallbacks() {
+ var callbacks = this.callbacks;
+ var context = this.context;
+
+ this.cache = this.cache || {};
+ this.cachedCalls = this.cachedCalls || {};
+
+ var keys = (Object.keys || _ember['default'].keys)(callbacks);
+ var keysLength = keys.length;
+
+ if (keysLength) {
+ for (var i = 0; i < keysLength; i++) {
+ this._contextualizeCallback(context, keys[i], context);
+ }
+ }
+ };
+
+ _default.prototype._contextualizeCallback = function _contextualizeCallback(context, key, callbackContext) {
+ var _this = this;
+ var callbacks = this.callbacks;
+ var factory = context.factory;
+
+ context[key] = function (options) {
+ if (_this.cachedCalls[key]) {
+ return _this.cache[key];
+ }
+
+ var result = callbacks[key].call(callbackContext, options, factory());
+
+ _this.cache[key] = result;
+ _this.cachedCalls[key] = true;
+
+ return result;
+ };
+ };
+
+ _default.prototype._aliasViewRegistry = function _aliasViewRegistry() {
+ this._originalGlobalViewRegistry = _ember['default'].View.views;
+ var viewRegistry = this.container.lookup('-view-registry:main');
+
+ if (viewRegistry) {
+ _ember['default'].View.views = viewRegistry;
+ }
+ };
+
+ _default.prototype._resetViewRegistry = function _resetViewRegistry() {
+ _ember['default'].View.views = this._originalGlobalViewRegistry;
+ };
+
+ return _default;
+ })(_abstractTestModule['default']);
+
+ exports['default'] = _default;
});
-define('ember-test-helpers/test-module-for-model', ['exports', 'ember-test-helpers/test-module', 'ember'], function (exports, TestModule, Ember) {
+define('ember-test-helpers/test-module-for-model', ['exports', './test-module', 'ember'], function (exports, _testModule, _ember) {
+ /* global DS, require, requirejs */ // added here to prevent an import from erroring when ED is not present
'use strict';
- exports['default'] = TestModule['default'].extend({
- init: function(modelName, description, callbacks) {
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
+
+ function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+ var _default = (function (_TestModule) {
+ _inherits(_default, _TestModule);
+
+ function _default(modelName, description, callbacks) {
+ _classCallCheck(this, _default);
+
+ _TestModule.call(this, 'model:' + modelName, description, callbacks);
+
this.modelName = modelName;
- this._super.call(this, 'model:' + modelName, description, callbacks);
-
this.setupSteps.push(this.setupModel);
- },
+ }
- setupModel: function() {
+ _default.prototype.setupModel = function setupModel() {
var container = this.container;
var defaultSubject = this.defaultSubject;
var callbacks = this.callbacks;
@@ -713,38 +1316,57 @@ define('ember-test-helpers/test-module-for-model', ['exports', 'ember-test-helpe
var adapterFactory = container.lookupFactory('adapter:application');
if (!adapterFactory) {
- adapterFactory = DS.JSONAPIAdapter || DS.FixtureAdapter;
+ if (requirejs.entries['ember-data/adapters/json-api']) {
+ adapterFactory = require('ember-data/adapters/json-api')['default'];
+ }
+
+ // when ember-data/adapters/json-api is provided via ember-cli shims
+ // using Ember Data 1.x the actual JSONAPIAdapter isn't found, but the
+ // above require statement returns a bizzaro object with only a `default`
+ // property (circular reference actually)
+ if (!adapterFactory || !adapterFactory.create) {
+ adapterFactory = DS.JSONAPIAdapter || DS.FixtureAdapter;
+ }
var thingToRegisterWith = this.registry || this.container;
thingToRegisterWith.register('adapter:application', adapterFactory);
}
- callbacks.store = function(){
+ callbacks.store = function () {
var container = this.container;
- var store = container.lookup('service:store') || container.lookup('store:main');
- return store;
+ return container.lookup('service:store') || container.lookup('store:main');
};
if (callbacks.subject === defaultSubject) {
- callbacks.subject = function(options) {
+ callbacks.subject = function (options) {
var container = this.container;
- return Ember['default'].run(function() {
+ return _ember['default'].run(function () {
var store = container.lookup('service:store') || container.lookup('store:main');
return store.createRecord(modelName, options);
});
};
}
- }
- });
+ };
+ return _default;
+ })(_testModule['default']);
+
+ exports['default'] = _default;
});
-define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helpers/test-context', 'klassy', 'ember-test-helpers/test-resolver', 'ember-test-helpers/build-registry', 'ember-test-helpers/has-ember-version', 'ember-test-helpers/wait'], function (exports, Ember, test_context, klassy, test_resolver, buildRegistry, hasEmberVersion, wait) {
-
+define('ember-test-helpers/test-module', ['exports', 'ember', './abstract-test-module', './test-resolver', './build-registry', './has-ember-version'], function (exports, _ember, _abstractTestModule, _testResolver, _buildRegistry, _hasEmberVersion) {
'use strict';
- exports['default'] = klassy.Klass.extend({
- init: function(subjectName, description, callbacks) {
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
+
+ function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+ var _default = (function (_AbstractTestModule) {
+ _inherits(_default, _AbstractTestModule);
+
+ function _default(subjectName, description, callbacks) {
+ _classCallCheck(this, _default);
+
// Allow `description` to be omitted, in which case it should
// default to `subjectName`
if (!callbacks && typeof description === 'object') {
@@ -752,53 +1374,50 @@ define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helper
description = subjectName;
}
+ _AbstractTestModule.call(this, description || subjectName, callbacks);
+
this.subjectName = subjectName;
this.description = description || subjectName;
- this.name = description || subjectName;
- this.callbacks = callbacks || {};
+ this.resolver = this.callbacks.resolver || _testResolver.getResolver();
if (this.callbacks.integration && this.callbacks.needs) {
throw new Error("cannot declare 'integration: true' and 'needs' in the same module");
}
if (this.callbacks.integration) {
- if (this.isComponentTestModule) {
- this.isLegacy = (callbacks.integration === 'legacy');
- this.isIntegration = (callbacks.integration !== 'legacy');
- } else {
- if (callbacks.integration === 'legacy') {
- throw new Error('`integration: \'legacy\'` is only valid for component tests.');
- }
- this.isIntegration = true;
- }
-
+ this.initIntegration(callbacks);
delete callbacks.integration;
}
this.initSubject();
this.initNeeds();
- this.initSetupSteps();
- this.initTeardownSteps();
- },
+ }
- initSubject: function() {
+ _default.prototype.initIntegration = function initIntegration(options) {
+ if (options.integration === 'legacy') {
+ throw new Error('`integration: \'legacy\'` is only valid for component tests.');
+ }
+ this.isIntegration = true;
+ };
+
+ _default.prototype.initSubject = function initSubject() {
this.callbacks.subject = this.callbacks.subject || this.defaultSubject;
- },
+ };
- initNeeds: function() {
+ _default.prototype.initNeeds = function initNeeds() {
this.needs = [this.subjectName];
if (this.callbacks.needs) {
this.needs = this.needs.concat(this.callbacks.needs);
delete this.callbacks.needs;
}
- },
+ };
- initSetupSteps: function() {
+ _default.prototype.initSetupSteps = function initSetupSteps() {
this.setupSteps = [];
this.contextualizedSetupSteps = [];
if (this.callbacks.beforeSetup) {
- this.setupSteps.push( this.callbacks.beforeSetup );
+ this.setupSteps.push(this.callbacks.beforeSetup);
delete this.callbacks.beforeSetup;
}
@@ -808,17 +1427,17 @@ define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helper
this.setupSteps.push(this.setupAJAXListeners);
if (this.callbacks.setup) {
- this.contextualizedSetupSteps.push( this.callbacks.setup );
+ this.contextualizedSetupSteps.push(this.callbacks.setup);
delete this.callbacks.setup;
}
- },
+ };
- initTeardownSteps: function() {
+ _default.prototype.initTeardownSteps = function initTeardownSteps() {
this.teardownSteps = [];
this.contextualizedTeardownSteps = [];
if (this.callbacks.teardown) {
- this.contextualizedTeardownSteps.push( this.callbacks.teardown );
+ this.contextualizedTeardownSteps.push(this.callbacks.teardown);
delete this.callbacks.teardown;
}
@@ -829,203 +1448,176 @@ define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helper
this.teardownSteps.push(this.teardownAJAXListeners);
if (this.callbacks.afterTeardown) {
- this.teardownSteps.push( this.callbacks.afterTeardown );
+ this.teardownSteps.push(this.callbacks.afterTeardown);
delete this.callbacks.afterTeardown;
}
- },
+ };
- setup: function() {
- var self = this;
- return self.invokeSteps(self.setupSteps).then(function() {
- self.contextualizeCallbacks();
- return self.invokeSteps(self.contextualizedSetupSteps, self.context);
- });
- },
-
- teardown: function() {
- var self = this;
- return self.invokeSteps(self.contextualizedTeardownSteps, self.context).then(function() {
- return self.invokeSteps(self.teardownSteps);
- }).then(function() {
- self.cache = null;
- self.cachedCalls = null;
- });
- },
-
- invokeSteps: function(steps, _context) {
- var context = _context;
- if (!context) {
- context = this;
- }
- steps = steps.slice();
- function nextStep() {
- var step = steps.shift();
- if (step) {
- // guard against exceptions, for example missing components referenced from needs.
- return new Ember['default'].RSVP.Promise(function(ok) {
- ok(step.call(context));
- }).then(nextStep);
- } else {
- return Ember['default'].RSVP.resolve();
- }
- }
- return nextStep();
- },
-
- setupContainer: function() {
+ _default.prototype.setupContainer = function setupContainer() {
if (this.isIntegration || this.isLegacy) {
this._setupIntegratedContainer();
} else {
this._setupIsolatedContainer();
}
- },
+ };
- setupContext: function() {
+ _default.prototype.setupContext = function setupContext() {
var subjectName = this.subjectName;
var container = this.container;
- var factory = function() {
+ var factory = function factory() {
return container.lookupFactory(subjectName);
};
- test_context.setContext({
- container: this.container,
+ _AbstractTestModule.prototype.setupContext.call(this, {
+ container: this.container,
registry: this.registry,
- factory: factory,
- dispatcher: null,
- register: function() {
+ factory: factory,
+ register: function register() {
var target = this.registry || this.container;
return target.register.apply(target, arguments);
- },
- inject: {}
+ }
});
- var context = this.context = test_context.getContext();
-
- if (Ember['default'].setOwner) {
- Ember['default'].setOwner(context, this.container.owner);
+ if (_ember['default'].setOwner) {
+ _ember['default'].setOwner(this.context, this.container.owner);
}
- if (Ember['default'].inject) {
- var keys = (Object.keys || Ember['default'].keys)(Ember['default'].inject);
- keys.forEach(function(typeName) {
- context.inject[typeName] = function(name, opts) {
- var alias = (opts && opts.as) || name;
- Ember['default'].set(context, alias, context.container.lookup(typeName + ':' + name));
+ this.setupInject();
+ };
+
+ _default.prototype.setupInject = function setupInject() {
+ var module = this;
+ var context = this.context;
+
+ if (_ember['default'].inject) {
+ var keys = (Object.keys || _ember['default'].keys)(_ember['default'].inject);
+
+ keys.forEach(function (typeName) {
+ context.inject[typeName] = function (name, opts) {
+ var alias = opts && opts.as || name;
+ _ember['default'].run(function () {
+ _ember['default'].set(context, alias, module.container.lookup(typeName + ':' + name));
+ });
};
});
}
- },
+ };
- setupTestElements: function() {
- if (Ember['default'].$('#ember-testing').length === 0) {
- Ember['default'].$('').appendTo(document.body);
- }
- },
-
- setupAJAXListeners: function() {
- wait._setupAJAXHooks();
- },
-
- teardownSubject: function() {
+ _default.prototype.teardownSubject = function teardownSubject() {
var subject = this.cache.subject;
if (subject) {
- Ember['default'].run(function() {
- Ember['default'].tryInvoke(subject, 'destroy');
+ _ember['default'].run(function () {
+ _ember['default'].tryInvoke(subject, 'destroy');
});
}
- },
+ };
- teardownContainer: function() {
+ _default.prototype.teardownContainer = function teardownContainer() {
var container = this.container;
- Ember['default'].run(function() {
+ _ember['default'].run(function () {
container.destroy();
});
- },
+ };
- teardownContext: function() {
- var context = this.context;
- this.context = undefined;
- test_context.unsetContext();
-
- if (context.dispatcher && !context.dispatcher.isDestroyed) {
- Ember['default'].run(function() {
- context.dispatcher.destroy();
- });
- }
- },
-
- teardownTestElements: function() {
- Ember['default'].$('#ember-testing').empty();
-
- // Ember 2.0.0 removed Ember.View as public API, so only do this when
- // Ember.View is present
- if (Ember['default'].View && Ember['default'].View.views) {
- Ember['default'].View.views = {};
- }
- },
-
- teardownAJAXListeners: function() {
- wait._teardownAJAXHooks();
- },
-
- defaultSubject: function(options, factory) {
+ _default.prototype.defaultSubject = function defaultSubject(options, factory) {
return factory.create(options);
- },
+ };
// allow arbitrary named factories, like rspec let
- contextualizeCallbacks: function() {
- var _this = this;
+
+ _default.prototype.contextualizeCallbacks = function contextualizeCallbacks() {
var callbacks = this.callbacks;
- var context = this.context;
- var factory = context.factory;
+ var context = this.context;
this.cache = this.cache || {};
this.cachedCalls = this.cachedCalls || {};
- var keys = (Object.keys || Ember['default'].keys)(callbacks);
+ var keys = (Object.keys || _ember['default'].keys)(callbacks);
+ var keysLength = keys.length;
- for (var i = 0, l = keys.length; i < l; i++) {
- (function(key) {
-
- context[key] = function(options) {
- if (_this.cachedCalls[key]) { return _this.cache[key]; }
-
- var result = callbacks[key].call(_this, options, factory());
-
- _this.cache[key] = result;
- _this.cachedCalls[key] = true;
-
- return result;
- };
-
- })(keys[i]);
+ if (keysLength) {
+ var deprecatedContext = this._buildDeprecatedContext(this, context);
+ for (var i = 0; i < keysLength; i++) {
+ this._contextualizeCallback(context, keys[i], deprecatedContext);
+ }
}
- },
+ };
- _setupContainer: function(isolated) {
- var resolver = test_resolver.getResolver();
+ _default.prototype._contextualizeCallback = function _contextualizeCallback(context, key, callbackContext) {
+ var _this = this;
+ var callbacks = this.callbacks;
+ var factory = context.factory;
- var items = buildRegistry['default'](!isolated ? resolver : Object.create(resolver, {
+ context[key] = function (options) {
+ if (_this.cachedCalls[key]) {
+ return _this.cache[key];
+ }
+
+ var result = callbacks[key].call(callbackContext, options, factory());
+
+ _this.cache[key] = result;
+ _this.cachedCalls[key] = true;
+
+ return result;
+ };
+ };
+
+ /*
+ Builds a version of the passed in context that contains deprecation warnings
+ for accessing properties that exist on the module.
+ */
+
+ _default.prototype._buildDeprecatedContext = function _buildDeprecatedContext(module, context) {
+ var deprecatedContext = Object.create(context);
+
+ var keysForDeprecation = Object.keys(module);
+
+ for (var i = 0, l = keysForDeprecation.length; i < l; i++) {
+ this._proxyDeprecation(module, deprecatedContext, keysForDeprecation[i]);
+ }
+
+ return deprecatedContext;
+ };
+
+ /*
+ Defines a key on an object to act as a proxy for deprecating the original.
+ */
+
+ _default.prototype._proxyDeprecation = function _proxyDeprecation(obj, proxy, key) {
+ if (typeof proxy[key] === 'undefined') {
+ Object.defineProperty(proxy, key, {
+ get: function get() {
+ _ember['default'].deprecate('Accessing the test module property "' + key + '" from a callback is deprecated.', false, { id: 'ember-test-helpers.test-module.callback-context', until: '0.6.0' });
+ return obj[key];
+ }
+ });
+ }
+ };
+
+ _default.prototype._setupContainer = function _setupContainer(isolated) {
+ var resolver = this.resolver;
+
+ var items = _buildRegistry['default'](!isolated ? resolver : Object.create(resolver, {
resolve: {
- value: function() {}
+ value: function value() {}
}
}));
this.container = items.container;
this.registry = items.registry;
- if (hasEmberVersion['default'](1, 13)) {
+ if (_hasEmberVersion['default'](1, 13)) {
var thingToRegisterWith = this.registry || this.container;
var router = resolver.resolve('router:main');
- router = router || Ember['default'].Router.extend();
+ router = router || _ember['default'].Router.extend();
thingToRegisterWith.register('router:main', router);
}
- },
+ };
- _setupIsolatedContainer: function() {
- var resolver = test_resolver.getResolver();
+ _default.prototype._setupIsolatedContainer = function _setupIsolatedContainer() {
+ var resolver = this.resolver;
this._setupContainer(true);
var thingToRegisterWith = this.registry || this.container;
@@ -1037,24 +1629,24 @@ define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helper
}
if (!this.registry) {
- this.container.resolver = function() {};
+ this.container.resolver = function () {};
}
- },
+ };
- _setupIntegratedContainer: function() {
+ _default.prototype._setupIntegratedContainer = function _setupIntegratedContainer() {
this._setupContainer();
- }
+ };
- });
+ return _default;
+ })(_abstractTestModule['default']);
+ exports['default'] = _default;
});
define('ember-test-helpers/test-resolver', ['exports'], function (exports) {
-
'use strict';
exports.setResolver = setResolver;
exports.getResolver = getResolver;
-
var __resolver__;
function setResolver(resolver) {
@@ -1062,17 +1654,23 @@ define('ember-test-helpers/test-resolver', ['exports'], function (exports) {
}
function getResolver() {
- if (__resolver__ == null) throw new Error('you must set a resolver with `testResolver.set(resolver)`');
+ if (__resolver__ == null) {
+ throw new Error('you must set a resolver with `testResolver.set(resolver)`');
+ }
+
return __resolver__;
}
-
});
-define('ember-test-helpers/wait', ['exports', 'ember'], function (exports, Ember) {
+define('ember-test-helpers/wait', ['exports', 'ember'], function (exports, _ember) {
+ /* globals self */
'use strict';
exports._teardownAJAXHooks = _teardownAJAXHooks;
exports._setupAJAXHooks = _setupAJAXHooks;
+ exports['default'] = wait;
+
+ var jQuery = _ember['default'].$;
var requests;
function incrementAjaxPendingRequests(_, xhr) {
@@ -1080,7 +1678,7 @@ define('ember-test-helpers/wait', ['exports', 'ember'], function (exports, Ember
}
function decrementAjaxPendingRequests(_, xhr) {
- for (var i = 0;i < requests.length;i++) {
+ for (var i = 0; i < requests.length; i++) {
if (xhr === requests[i]) {
requests.splice(i, 1);
}
@@ -1088,6 +1686,10 @@ define('ember-test-helpers/wait', ['exports', 'ember'], function (exports, Ember
}
function _teardownAJAXHooks() {
+ if (!jQuery) {
+ return;
+ }
+
jQuery(document).off('ajaxSend', incrementAjaxPendingRequests);
jQuery(document).off('ajaxComplete', decrementAjaxPendingRequests);
}
@@ -1095,18 +1697,44 @@ define('ember-test-helpers/wait', ['exports', 'ember'], function (exports, Ember
function _setupAJAXHooks() {
requests = [];
+ if (!jQuery) {
+ return;
+ }
+
jQuery(document).on('ajaxSend', incrementAjaxPendingRequests);
jQuery(document).on('ajaxComplete', decrementAjaxPendingRequests);
}
+ var _internalCheckWaiters;
+ if (_ember['default'].__loader.registry['ember-testing/test/waiters']) {
+ _internalCheckWaiters = _ember['default'].__loader.require('ember-testing/test/waiters').checkWaiters;
+ }
+
+ function checkWaiters() {
+ if (_internalCheckWaiters) {
+ return _internalCheckWaiters();
+ } else if (_ember['default'].Test.waiters) {
+ if (_ember['default'].Test.waiters.any(function (_ref) {
+ var context = _ref[0];
+ var callback = _ref[1];
+ return !callback.call(context);
+ })) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
function wait(_options) {
var options = _options || {};
var waitForTimers = options.hasOwnProperty('waitForTimers') ? options.waitForTimers : true;
var waitForAJAX = options.hasOwnProperty('waitForAJAX') ? options.waitForAJAX : true;
+ var waitForWaiters = options.hasOwnProperty('waitForWaiters') ? options.waitForWaiters : true;
- return new Ember['default'].RSVP.Promise(function(resolve) {
- var watcher = self.setInterval(function() {
- if (waitForTimers && (Ember['default'].run.hasScheduledTimers() || Ember['default'].run.currentRunLoop)) {
+ return new _ember['default'].RSVP.Promise(function (resolve) {
+ var watcher = self.setInterval(function () {
+ if (waitForTimers && (_ember['default'].run.hasScheduledTimers() || _ember['default'].run.currentRunLoop)) {
return;
}
@@ -1114,188 +1742,34 @@ define('ember-test-helpers/wait', ['exports', 'ember'], function (exports, Ember
return;
}
+ if (waitForWaiters && checkWaiters()) {
+ return;
+ }
+
// Stop polling
self.clearInterval(watcher);
// Synchronously resolve the promise
- Ember['default'].run(null, resolve);
+ _ember['default'].run(null, resolve);
}, 10);
});
}
- exports['default'] = wait;
-
});
-define('klassy', ['exports'], function (exports) {
+define("qunit", ["exports"], function (exports) {
+ /* globals QUnit */
- 'use strict';
+ "use strict";
- /**
- Extend a class with the properties and methods of one or more other classes.
-
- When a method is replaced with another method, it will be wrapped in a
- function that makes the replaced method accessible via `this._super`.
-
- @method extendClass
- @param {Object} destination The class to merge into
- @param {Object} source One or more source classes
- */
- var extendClass = function(destination) {
- var sources = Array.prototype.slice.call(arguments, 1);
- var source;
-
- for (var i = 0, l = sources.length; i < l; i++) {
- source = sources[i];
-
- for (var p in source) {
- if (source.hasOwnProperty(p) &&
- destination[p] &&
- typeof destination[p] === 'function' &&
- typeof source[p] === 'function') {
-
- /* jshint loopfunc:true */
- destination[p] =
- (function(destinationFn, sourceFn) {
- var wrapper = function() {
- var prevSuper = this._super;
- this._super = destinationFn;
-
- var ret = sourceFn.apply(this, arguments);
-
- this._super = prevSuper;
-
- return ret;
- };
- wrapper.wrappedFunction = sourceFn;
- return wrapper;
- })(destination[p], source[p]);
-
- } else {
- destination[p] = source[p];
- }
- }
- }
- };
-
- // `subclassing` is a state flag used by `defineClass` to track when a class is
- // being subclassed. It allows constructors to avoid calling `init`, which can
- // be expensive and cause undesirable side effects.
- var subclassing = false;
-
- /**
- Define a new class with the properties and methods of one or more other classes.
-
- The new class can be based on a `SuperClass`, which will be inserted into its
- prototype chain.
-
- Furthermore, one or more mixins (object that contain properties and/or methods)
- may be specified, which will be applied in order. When a method is replaced
- with another method, it will be wrapped in a function that makes the previous
- method accessible via `this._super`.
-
- @method defineClass
- @param {Object} SuperClass A base class to extend. If `mixins` are to be included
- without a `SuperClass`, pass `null` for SuperClass.
- @param {Object} mixins One or more objects that contain properties and methods
- to apply to the new class.
- */
- var defineClass = function(SuperClass) {
- var Klass = function() {
- if (!subclassing && this.init) {
- this.init.apply(this, arguments);
- }
- };
-
- if (SuperClass) {
- subclassing = true;
- Klass.prototype = new SuperClass();
- subclassing = false;
- }
-
- if (arguments.length > 1) {
- var extendArgs = Array.prototype.slice.call(arguments, 1);
- extendArgs.unshift(Klass.prototype);
- extendClass.apply(Klass.prototype, extendArgs);
- }
-
- Klass.constructor = Klass;
-
- Klass.extend = function() {
- var args = Array.prototype.slice.call(arguments, 0);
- args.unshift(Klass);
- return defineClass.apply(Klass, args);
- };
-
- return Klass;
- };
-
- /**
- A base class that can be extended.
-
- @example
-
- ```javascript
- var CelestialObject = Klass.extend({
- init: function(name) {
- this._super();
- this.name = name;
- this.isCelestialObject = true;
- },
- greeting: function() {
- return 'Hello from ' + this.name;
- }
- });
-
- var Planet = CelestialObject.extend({
- init: function(name) {
- this._super.apply(this, arguments);
- this.isPlanet = true;
- },
- greeting: function() {
- return this._super() + '!';
- },
- });
-
- var earth = new Planet('Earth');
-
- console.log(earth instanceof Klass); // true
- console.log(earth instanceof CelestialObject); // true
- console.log(earth instanceof Planet); // true
-
- console.log(earth.isCelestialObject); // true
- console.log(earth.isPlanet); // true
-
- console.log(earth.greeting()); // 'Hello from Earth!'
- ```
-
- @class Klass
- */
- var Klass = defineClass(null, {
- init: function() {}
- });
-
- exports.Klass = Klass;
- exports.defineClass = defineClass;
- exports.extendClass = extendClass;
-
-});
-define('qunit', ['exports'], function (exports) {
-
- 'use strict';
-
- /* globals test:true */
-
- var module = QUnit.module;
- var test = QUnit.test;
- var skip = QUnit.skip;
- var only = QUnit.only;
-
- exports['default'] = QUnit;
-
- exports.module = module;
- exports.test = test;
- exports.skip = skip;
- exports.only = only;
+ var _module = QUnit.module;
+ exports.module = _module;
+ var test = QUnit.test;
+ exports.test = test;
+ var skip = QUnit.skip;
+ exports.skip = skip;
+ var only = QUnit.only;
+ exports.only = only;
+ exports["default"] = QUnit;
});
define("ember", ["exports"], function(__exports__) {
__exports__["default"] = window.Ember;
| | |