From a65b426b8afae60446e636d0fbb864dd58f1ecaf Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 19 Oct 2020 16:39:04 -0400 Subject: [PATCH] REFACTOR: Convert many more acceptance tests to the new format --- .../tests/acceptance/composer-actions-test.js | 1067 ++++++-------- .../acceptance/composer-attachment-test.js | 52 +- .../acceptance/composer-edit-conflict-test.js | 108 +- .../acceptance/composer-hyperlink-test.js | 186 +-- .../tests/acceptance/composer-onebox-test.js | 36 +- .../tests/acceptance/composer-tags-test.js | 100 +- .../acceptance/composer-topic-links-test.js | 324 +++-- .../acceptance/composer-uncategorized-test.js | 160 +-- .../create-account-external-test.js | 56 +- .../create-account-user-fields-test.js | 82 +- .../tests/acceptance/custom-html-set-test.js | 50 +- .../acceptance/custom-html-template-test.js | 24 +- .../tests/acceptance/dashboard-test.js | 273 ++-- .../tests/acceptance/email-notice-test.js | 64 +- .../tests/acceptance/emoji-picker-test.js | 261 ++-- .../discourse/tests/acceptance/emoji-test.js | 42 +- .../acceptance/enforce-second-factor-test.js | 150 +- .../tests/acceptance/flag-post-test.js | 154 +- .../tests/acceptance/forgot-password-test.js | 140 +- .../acceptance/group-card-mobile-test.js | 24 - .../tests/acceptance/group-card-test.js | 21 - .../tests/acceptance/group-index-test.js | 88 +- .../group-manage-categories-test.js | 52 +- .../group-manage-interaction-test.js | 148 +- .../discourse/tests/fixtures/topic.js | 1239 ++++++++++------- .../discourse/tests/helpers/qunit-helpers.js | 7 +- 26 files changed, 2413 insertions(+), 2495 deletions(-) delete mode 100644 app/assets/javascripts/discourse/tests/acceptance/group-card-mobile-test.js delete mode 100644 app/assets/javascripts/discourse/tests/acceptance/group-card-test.js diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-actions-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-actions-test.js index f1888576851..13cbb7ce3d7 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-actions-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-actions-test.js @@ -11,671 +11,432 @@ import { toggleCheckDraftPopup } from "discourse/controllers/composer"; import Draft from "discourse/models/draft"; import { Promise } from "rsvp"; -acceptance("Composer Actions", { - loggedIn: true, - settings: { - enable_whispers: true, - }, - site: { - can_tag_topics: true, - }, - pretend(server) { - server.get("/t/130.json", () => { - return [ - 200, - { "Content-Type": "application/json" }, - { - post_stream: { - posts: [ - { - id: 133, - name: null, - username: "bianca", - avatar_template: - "/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png", - created_at: "2020-07-05T09:28:36.371Z", - cooked: - "

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas a varius ipsum. Nunc euismod, metus non vulputate malesuada, ligula metus pharetra tortor, vel sodales arcu lacus sed mauris. Nam semper, orci vitae fringilla placerat, dui tellus convallis felis, ultricies laoreet sapien mi et metus. Mauris facilisis, mi fermentum rhoncus feugiat, dolor est vehicula leo, id porta leo ex non enim. In a ligula vel tellus commodo scelerisque non in ex. Pellentesque semper leo quam, nec varius est viverra eget. Donec vehicula sem et massa faucibus tempus.

", - post_number: 1, - post_type: 1, - updated_at: "2020-07-05T09:28:36.371Z", - reply_count: 0, - reply_to_post_number: null, - quote_count: 0, - incoming_link_count: 0, - reads: 1, - readers_count: 0, - score: 0, - yours: true, - topic_id: 130, - topic_slug: "lorem-ipsum-dolor-sit-amet", - display_username: null, - primary_group_name: null, - primary_group_flair_url: null, - primary_group_flair_bg_color: null, - primary_group_flair_color: null, - version: 1, - can_edit: true, - can_delete: false, - can_recover: false, - can_wiki: true, - read: true, - user_title: "Tester", - title_is_group: false, - actions_summary: [ - { - id: 3, - can_act: true, - }, - { - id: 4, - can_act: true, - }, - { - id: 8, - can_act: true, - }, - { - id: 7, - can_act: true, - }, - ], - moderator: false, - admin: true, - staff: true, - user_id: 1, - hidden: false, - trust_level: 0, - deleted_at: null, - user_deleted: false, - edit_reason: null, - can_view_edit_history: true, - wiki: false, - reviewable_id: 0, - reviewable_score_count: 0, - reviewable_score_pending_count: 0, - }, - ], - stream: [133], - }, - timeline_lookup: [[1, 0]], - related_messages: [], - suggested_topics: [], - id: 130, - title: "Lorem ipsum dolor sit amet", - fancy_title: "Lorem ipsum dolor sit amet", - posts_count: 1, - created_at: "2020-07-05T09:28:36.260Z", - views: 1, - reply_count: 0, - like_count: 0, - last_posted_at: "2020-07-05T09:28:36.371Z", - visible: true, - closed: false, - archived: false, - has_summary: false, - archetype: "private_message", - slug: "lorem-ipsum-dolor-sit-amet", - category_id: null, - word_count: 86, - deleted_at: null, - user_id: 1, - featured_link: null, - pinned_globally: false, - pinned_at: null, - pinned_until: null, - image_url: null, - draft: null, - draft_key: "topic_130", - draft_sequence: 0, - posted: true, - unpinned: null, - pinned: false, - current_post_number: 1, - highest_post_number: 1, - last_read_post_number: 1, - last_read_post_id: 133, - deleted_by: null, - has_deleted: false, - actions_summary: [ - { - id: 4, - count: 0, - hidden: false, - can_act: true, - }, - { - id: 8, - count: 0, - hidden: false, - can_act: true, - }, - { - id: 7, - count: 0, - hidden: false, - can_act: true, - }, - ], - chunk_size: 20, - bookmarked: false, - message_archived: false, - topic_timer: null, - message_bus_last_id: 5, - participant_count: 1, - pm_with_non_human_user: false, - show_read_indicator: false, - requested_group_name: null, - thumbnails: null, - tags_disable_ads: false, - details: { - notification_level: 3, - notifications_reason_id: 1, - can_move_posts: true, - can_edit: true, - can_delete: true, - can_remove_allowed_users: true, - can_invite_to: true, - can_invite_via_email: true, - can_create_post: true, - can_reply_as_new_topic: true, - can_flag_topic: true, - can_convert_topic: true, - can_review_topic: true, - can_remove_self_id: 1, - participants: [ - { - id: 1, - username: "bianca", - name: null, - avatar_template: - "/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png", - post_count: 1, - primary_group_name: null, - primary_group_flair_url: null, - primary_group_flair_color: null, - primary_group_flair_bg_color: null, - }, - ], - allowed_users: [ - { - id: 7, - username: "foo", - name: null, - avatar_template: - "/letter_avatar_proxy/v4/letter/f/b19c9b/{size}.png", - }, - ], - created_by: { - id: 1, - username: "bianca", - name: null, - avatar_template: - "/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png", - }, - last_poster: { - id: 1, - username: "bianca", - name: null, - avatar_template: - "/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png", - }, - allowed_groups: [ - { - id: 43, - automatic: false, - name: "foo_group", - user_count: 4, - mentionable_level: 0, - messageable_level: 99, - visibility_level: 0, - automatic_membership_email_domains: "", - primary_group: false, - title: null, - grant_trust_level: null, - incoming_email: null, - has_messages: true, - flair_url: null, - flair_bg_color: "", - flair_color: "", - bio_raw: null, - bio_cooked: null, - bio_excerpt: null, - public_admission: false, - public_exit: false, - allow_membership_requests: false, - full_name: null, - default_notification_level: 3, - membership_request_template: null, - members_visibility_level: 0, - can_see_members: true, - publish_read_state: false, - }, - ], - }, - }, - ]; - }); - }, -}); +acceptance("Composer Actions", function (needs) { + needs.user(); + needs.settings({ enable_whispers: true }); + needs.site({ can_tag_topics: true }); -test("creating new topic and then reply_as_private_message keeps attributes", async (assert) => { - await visit("/"); - await click("button#create-topic"); + test("creating new topic and then reply_as_private_message keeps attributes", async (assert) => { + await visit("/"); + await click("button#create-topic"); - await fillIn("#reply-title", "this is the title"); - await fillIn(".d-editor-input", "this is the reply"); - - const composerActions = selectKit(".composer-actions"); - await composerActions.expand(); - await composerActions.selectRowByValue("reply_as_private_message"); - - assert.ok(find("#reply-title").val(), "this is the title"); - assert.ok(find(".d-editor-input").val(), "this is the reply"); -}); - -test("replying to post", async (assert) => { - const composerActions = selectKit(".composer-actions"); - - await visit("/t/internationalization-localization/280"); - await click("article#post_3 button.reply"); - await composerActions.expand(); - - assert.equal(composerActions.rowByIndex(0).value(), "reply_as_new_topic"); - assert.equal( - composerActions.rowByIndex(1).value(), - "reply_as_private_message" - ); - assert.equal(composerActions.rowByIndex(2).value(), "reply_to_topic"); - assert.equal(composerActions.rowByIndex(3).value(), "toggle_whisper"); - assert.equal(composerActions.rowByIndex(4).value(), "toggle_topic_bump"); - assert.equal(composerActions.rowByIndex(5).value(), undefined); -}); - -test("replying to post - reply_as_private_message", async (assert) => { - const composerActions = selectKit(".composer-actions"); - - await visit("/t/internationalization-localization/280"); - await click("article#post_3 button.reply"); - - await composerActions.expand(); - await composerActions.selectRowByValue("reply_as_private_message"); - - assert.equal(find(".users-input .item:eq(0)").text(), "codinghorror"); - assert.ok( - find(".d-editor-input").val().indexOf("Continuing the discussion") >= 0 - ); -}); - -test("replying to post - reply_to_topic", async (assert) => { - const composerActions = selectKit(".composer-actions"); - - await visit("/t/internationalization-localization/280"); - await click("article#post_3 button.reply"); - await fillIn( - ".d-editor-input", - "test replying to topic when initially replied to post" - ); - - await composerActions.expand(); - await composerActions.selectRowByValue("reply_to_topic"); - - assert.equal( - find(".action-title .topic-link").text().trim(), - "Internationalization / localization" - ); - assert.equal( - find(".action-title .topic-link").attr("href"), - "/t/internationalization-localization/280" - ); - assert.equal( - find(".d-editor-input").val(), - "test replying to topic when initially replied to post" - ); -}); - -test("replying to post - toggle_whisper", async (assert) => { - const composerActions = selectKit(".composer-actions"); - - await visit("/t/internationalization-localization/280"); - await click("article#post_3 button.reply"); - await fillIn( - ".d-editor-input", - "test replying as whisper to topic when initially not a whisper" - ); - - await composerActions.expand(); - await composerActions.selectRowByValue("toggle_whisper"); - - assert.ok( - find(".composer-fields .whisper .d-icon-far-eye-slash").length === 1 - ); -}); - -test("replying to post - reply_as_new_topic", async (assert) => { - sandbox - .stub(Draft, "get") - .returns(Promise.resolve({ draft: "", draft_sequence: 0 })); - const composerActions = selectKit(".composer-actions"); - const categoryChooser = selectKit(".title-wrapper .category-chooser"); - const categoryChooserReplyArea = selectKit(".reply-area .category-chooser"); - const quote = "test replying as new topic when initially replied to post"; - - await visit("/t/internationalization-localization/280"); - - await click("#topic-title .d-icon-pencil-alt"); - await categoryChooser.expand(); - await categoryChooser.selectRowByValue(4); - await click("#topic-title .submit-edit"); - - await click("article#post_3 button.reply"); - await fillIn(".d-editor-input", quote); - - await composerActions.expand(); - await composerActions.selectRowByValue("reply_as_new_topic"); - - assert.equal(categoryChooserReplyArea.header().name(), "faq"); - assert.equal( - find(".action-title").text().trim(), - I18n.t("topic.create_long") - ); - assert.ok(find(".d-editor-input").val().includes(quote)); - sandbox.restore(); -}); - -test("reply_as_new_topic without a new_topic draft", async (assert) => { - await visit("/t/internationalization-localization/280"); - await click(".create.reply"); - const composerActions = selectKit(".composer-actions"); - await composerActions.expand(); - await composerActions.selectRowByValue("reply_as_new_topic"); - assert.equal(exists(find(".bootbox")), false); -}); - -test("reply_as_new_group_message", async (assert) => { - await visit("/t/lorem-ipsum-dolor-sit-amet/130"); - await click(".create.reply"); - const composerActions = selectKit(".composer-actions"); - await composerActions.expand(); - await composerActions.selectRowByValue("reply_as_new_group_message"); - - const items = []; - find(".users-input .item").each((_, item) => - items.push(item.textContent.trim()) - ); - - assert.deepEqual(items, ["foo", "foo_group"]); -}); - -test("hide component if no content", async (assert) => { - await visit("/"); - await click("button#create-topic"); - - const composerActions = selectKit(".composer-actions"); - await composerActions.expand(); - await composerActions.selectRowByValue("reply_as_private_message"); - - assert.ok(composerActions.el().hasClass("is-hidden")); - assert.equal(composerActions.el().children().length, 0); - - await click("button#create-topic"); - await composerActions.expand(); - assert.equal(composerActions.rows().length, 2); -}); - -test("interactions", async (assert) => { - const composerActions = selectKit(".composer-actions"); - const quote = "Life is like riding a bicycle."; - - await visit("/t/internationalization-localization/280"); - await click("article#post_3 button.reply"); - await fillIn(".d-editor-input", quote); - await composerActions.expand(); - await composerActions.selectRowByValue("reply_to_topic"); - - assert.equal( - find(".action-title").text().trim(), - "Internationalization / localization" - ); - assert.equal(find(".d-editor-input").val(), quote); - - await composerActions.expand(); - - assert.equal(composerActions.rowByIndex(0).value(), "reply_as_new_topic"); - assert.equal(composerActions.rowByIndex(1).value(), "reply_to_post"); - assert.equal( - composerActions.rowByIndex(2).value(), - "reply_as_private_message" - ); - assert.equal(composerActions.rowByIndex(3).value(), "toggle_whisper"); - assert.equal(composerActions.rowByIndex(4).value(), "toggle_topic_bump"); - assert.equal(composerActions.rows().length, 5); - - await composerActions.selectRowByValue("reply_to_post"); - await composerActions.expand(); - - assert.ok(exists(find(".action-title img.avatar"))); - assert.equal(find(".action-title .user-link").text().trim(), "codinghorror"); - assert.equal(find(".d-editor-input").val(), quote); - assert.equal(composerActions.rowByIndex(0).value(), "reply_as_new_topic"); - assert.equal( - composerActions.rowByIndex(1).value(), - "reply_as_private_message" - ); - assert.equal(composerActions.rowByIndex(2).value(), "reply_to_topic"); - assert.equal(composerActions.rowByIndex(3).value(), "toggle_whisper"); - assert.equal(composerActions.rowByIndex(4).value(), "toggle_topic_bump"); - assert.equal(composerActions.rows().length, 5); - - await composerActions.selectRowByValue("reply_as_new_topic"); - await composerActions.expand(); - - assert.equal( - find(".action-title").text().trim(), - I18n.t("topic.create_long") - ); - assert.ok(find(".d-editor-input").val().includes(quote)); - assert.equal(composerActions.rowByIndex(0).value(), "reply_to_post"); - assert.equal( - composerActions.rowByIndex(1).value(), - "reply_as_private_message" - ); - assert.equal(composerActions.rowByIndex(2).value(), "reply_to_topic"); - assert.equal(composerActions.rowByIndex(3).value(), "shared_draft"); - assert.equal(composerActions.rows().length, 4); - - await composerActions.selectRowByValue("reply_as_private_message"); - await composerActions.expand(); - - assert.equal( - find(".action-title").text().trim(), - I18n.t("topic.private_message") - ); - assert.ok( - find(".d-editor-input").val().indexOf("Continuing the discussion") === 0 - ); - assert.equal(composerActions.rowByIndex(0).value(), "reply_as_new_topic"); - assert.equal(composerActions.rowByIndex(1).value(), "reply_to_post"); - assert.equal(composerActions.rowByIndex(2).value(), "reply_to_topic"); - assert.equal(composerActions.rows().length, 3); -}); - -test("replying to post - toggle_topic_bump", async (assert) => { - const composerActions = selectKit(".composer-actions"); - - await visit("/t/internationalization-localization/280"); - await click("article#post_3 button.reply"); - - assert.ok( - find(".composer-fields .no-bump").length === 0, - "no-bump text is not visible" - ); - - await composerActions.expand(); - await composerActions.selectRowByValue("toggle_topic_bump"); - - assert.ok( - find(".composer-fields .no-bump").length === 1, - "no-bump icon is visible" - ); - - await composerActions.expand(); - await composerActions.selectRowByValue("toggle_topic_bump"); - - assert.ok( - find(".composer-fields .no-bump").length === 0, - "no-bump icon is not visible" - ); -}); - -test("replying to post as staff", async (assert) => { - const composerActions = selectKit(".composer-actions"); - - updateCurrentUser({ admin: true }); - await visit("/t/internationalization-localization/280"); - await click("article#post_3 button.reply"); - await composerActions.expand(); - - assert.equal(composerActions.rows().length, 5); - assert.equal(composerActions.rowByIndex(4).value(), "toggle_topic_bump"); -}); - -test("replying to post as TL3 user", async (assert) => { - const composerActions = selectKit(".composer-actions"); - - updateCurrentUser({ moderator: false, admin: false, trust_level: 3 }); - await visit("/t/internationalization-localization/280"); - await click("article#post_3 button.reply"); - await composerActions.expand(); - - assert.equal(composerActions.rows().length, 3); - Array.from(composerActions.rows()).forEach((row) => { - assert.notEqual( - row.value, - "toggle_topic_bump", - "toggle button is not visible" - ); - }); -}); - -test("replying to post as TL4 user", async (assert) => { - const composerActions = selectKit(".composer-actions"); - - updateCurrentUser({ moderator: false, admin: false, trust_level: 4 }); - await visit("/t/internationalization-localization/280"); - await click("article#post_3 button.reply"); - await composerActions.expand(); - - assert.equal(composerActions.rows().length, 4); - assert.equal(composerActions.rowByIndex(3).value(), "toggle_topic_bump"); -}); - -test("replying to first post - reply_as_private_message", async (assert) => { - const composerActions = selectKit(".composer-actions"); - - await visit("/t/internationalization-localization/280"); - await click("article#post_1 button.reply"); - - await composerActions.expand(); - await composerActions.selectRowByValue("reply_as_private_message"); - - assert.equal(find(".users-input .item:eq(0)").text(), "uwe_keim"); - assert.ok( - find(".d-editor-input").val().indexOf("Continuing the discussion") >= 0 - ); -}); - -test("editing post", async (assert) => { - const composerActions = selectKit(".composer-actions"); - - await visit("/t/internationalization-localization/280"); - await click("article#post_1 button.show-more-actions"); - await click("article#post_1 button.edit"); - await composerActions.expand(); - - assert.equal(composerActions.rows().length, 1); - assert.equal(composerActions.rowByIndex(0).value(), "reply_to_post"); -}); - -acceptance("Composer Actions With New Topic Draft", { - loggedIn: true, - settings: { - enable_whispers: true, - }, - site: { - can_tag_topics: true, - }, - beforeEach() { - _clearSnapshots(); - }, - afterEach() { - _clearSnapshots(); - }, -}); - -const stubDraftResponse = () => { - sandbox.stub(Draft, "get").returns( - Promise.resolve({ - draft: - '{"reply":"dum de dum da ba.","action":"createTopic","title":"dum da ba dum dum","categoryId":null,"archetypeId":"regular","metaData":null,"composerTime":540879,"typingTime":3400}', - draft_sequence: 0, - }) - ); -}; - -test("shared draft", async (assert) => { - stubDraftResponse(); - try { - toggleCheckDraftPopup(true); + await fillIn("#reply-title", "this is the title"); + await fillIn(".d-editor-input", "this is the reply"); const composerActions = selectKit(".composer-actions"); - const tags = selectKit(".mini-tag-chooser"); - - await visit("/"); - await click("#create-topic"); - - await fillIn( - "#reply-title", - "This is the new text for the title using 'quotes'" - ); - - await fillIn(".d-editor-input", "This is the new text for the post"); - await tags.expand(); - await tags.selectRowByValue("monkey"); await composerActions.expand(); - await composerActions.selectRowByValue("shared_draft"); + await composerActions.selectRowByValue("reply_as_private_message"); - assert.equal(tags.header().value(), "monkey", "tags are not reset"); + assert.ok(find("#reply-title").val(), "this is the title"); + assert.ok(find(".d-editor-input").val(), "this is the reply"); + }); + test("replying to post", async (assert) => { + const composerActions = selectKit(".composer-actions"); + + await visit("/t/internationalization-localization/280"); + await click("article#post_3 button.reply"); + await composerActions.expand(); + + assert.equal(composerActions.rowByIndex(0).value(), "reply_as_new_topic"); assert.equal( - find("#reply-title").val(), - "This is the new text for the title using 'quotes'" + composerActions.rowByIndex(1).value(), + "reply_as_private_message" + ); + assert.equal(composerActions.rowByIndex(2).value(), "reply_to_topic"); + assert.equal(composerActions.rowByIndex(3).value(), "toggle_whisper"); + assert.equal(composerActions.rowByIndex(4).value(), "toggle_topic_bump"); + assert.equal(composerActions.rowByIndex(5).value(), undefined); + }); + + test("replying to post - reply_as_private_message", async (assert) => { + const composerActions = selectKit(".composer-actions"); + + await visit("/t/internationalization-localization/280"); + await click("article#post_3 button.reply"); + + await composerActions.expand(); + await composerActions.selectRowByValue("reply_as_private_message"); + + assert.equal(find(".users-input .item:eq(0)").text(), "codinghorror"); + assert.ok( + find(".d-editor-input").val().indexOf("Continuing the discussion") >= 0 + ); + }); + + test("replying to post - reply_to_topic", async (assert) => { + const composerActions = selectKit(".composer-actions"); + + await visit("/t/internationalization-localization/280"); + await click("article#post_3 button.reply"); + await fillIn( + ".d-editor-input", + "test replying to topic when initially replied to post" ); + await composerActions.expand(); + await composerActions.selectRowByValue("reply_to_topic"); + assert.equal( - find("#reply-control .btn-primary.create .d-button-label").text(), - I18n.t("composer.create_shared_draft") + find(".action-title .topic-link").text().trim(), + "Internationalization / localization" + ); + assert.equal( + find(".action-title .topic-link").attr("href"), + "/t/internationalization-localization/280" + ); + assert.equal( + find(".d-editor-input").val(), + "test replying to topic when initially replied to post" + ); + }); + + test("replying to post - toggle_whisper", async (assert) => { + const composerActions = selectKit(".composer-actions"); + + await visit("/t/internationalization-localization/280"); + await click("article#post_3 button.reply"); + await fillIn( + ".d-editor-input", + "test replying as whisper to topic when initially not a whisper" ); - assert.ok(find("#reply-control.composing-shared-draft").length === 1); + await composerActions.expand(); + await composerActions.selectRowByValue("toggle_whisper"); + + assert.ok( + find(".composer-fields .whisper .d-icon-far-eye-slash").length === 1 + ); + }); + + test("replying to post - reply_as_new_topic", async (assert) => { + sandbox + .stub(Draft, "get") + .returns(Promise.resolve({ draft: "", draft_sequence: 0 })); + const composerActions = selectKit(".composer-actions"); + const categoryChooser = selectKit(".title-wrapper .category-chooser"); + const categoryChooserReplyArea = selectKit(".reply-area .category-chooser"); + const quote = "test replying as new topic when initially replied to post"; + + await visit("/t/internationalization-localization/280"); + + await click("#topic-title .d-icon-pencil-alt"); + await categoryChooser.expand(); + await categoryChooser.selectRowByValue(4); + await click("#topic-title .submit-edit"); + + await click("article#post_3 button.reply"); + await fillIn(".d-editor-input", quote); + + await composerActions.expand(); + await composerActions.selectRowByValue("reply_as_new_topic"); + + assert.equal(categoryChooserReplyArea.header().name(), "faq"); + assert.equal( + find(".action-title").text().trim(), + I18n.t("topic.create_long") + ); + assert.ok(find(".d-editor-input").val().includes(quote)); + sandbox.restore(); + }); + + test("reply_as_new_topic without a new_topic draft", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click(".create.reply"); + const composerActions = selectKit(".composer-actions"); + await composerActions.expand(); + await composerActions.selectRowByValue("reply_as_new_topic"); + assert.equal(exists(find(".bootbox")), false); + }); + + test("reply_as_new_group_message", async (assert) => { + await visit("/t/lorem-ipsum-dolor-sit-amet/130"); + await click(".create.reply"); + const composerActions = selectKit(".composer-actions"); + await composerActions.expand(); + await composerActions.selectRowByValue("reply_as_new_group_message"); + + const items = []; + find(".users-input .item").each((_, item) => + items.push(item.textContent.trim()) + ); + + assert.deepEqual(items, ["foo", "foo_group"]); + }); + + test("hide component if no content", async (assert) => { + await visit("/"); + await click("button#create-topic"); + + const composerActions = selectKit(".composer-actions"); + await composerActions.expand(); + await composerActions.selectRowByValue("reply_as_private_message"); + + assert.ok(composerActions.el().hasClass("is-hidden")); + assert.equal(composerActions.el().children().length, 0); + + await click("button#create-topic"); + await composerActions.expand(); + assert.equal(composerActions.rows().length, 2); + }); + + test("interactions", async (assert) => { + const composerActions = selectKit(".composer-actions"); + const quote = "Life is like riding a bicycle."; + + await visit("/t/internationalization-localization/280"); + await click("article#post_3 button.reply"); + await fillIn(".d-editor-input", quote); + await composerActions.expand(); + await composerActions.selectRowByValue("reply_to_topic"); + + assert.equal( + find(".action-title").text().trim(), + "Internationalization / localization" + ); + assert.equal(find(".d-editor-input").val(), quote); + + await composerActions.expand(); + + assert.equal(composerActions.rowByIndex(0).value(), "reply_as_new_topic"); + assert.equal(composerActions.rowByIndex(1).value(), "reply_to_post"); + assert.equal( + composerActions.rowByIndex(2).value(), + "reply_as_private_message" + ); + assert.equal(composerActions.rowByIndex(3).value(), "toggle_whisper"); + assert.equal(composerActions.rowByIndex(4).value(), "toggle_topic_bump"); + assert.equal(composerActions.rows().length, 5); + + await composerActions.selectRowByValue("reply_to_post"); + await composerActions.expand(); + + assert.ok(exists(find(".action-title img.avatar"))); + assert.equal( + find(".action-title .user-link").text().trim(), + "codinghorror" + ); + assert.equal(find(".d-editor-input").val(), quote); + assert.equal(composerActions.rowByIndex(0).value(), "reply_as_new_topic"); + assert.equal( + composerActions.rowByIndex(1).value(), + "reply_as_private_message" + ); + assert.equal(composerActions.rowByIndex(2).value(), "reply_to_topic"); + assert.equal(composerActions.rowByIndex(3).value(), "toggle_whisper"); + assert.equal(composerActions.rowByIndex(4).value(), "toggle_topic_bump"); + assert.equal(composerActions.rows().length, 5); + + await composerActions.selectRowByValue("reply_as_new_topic"); + await composerActions.expand(); + + assert.equal( + find(".action-title").text().trim(), + I18n.t("topic.create_long") + ); + assert.ok(find(".d-editor-input").val().includes(quote)); + assert.equal(composerActions.rowByIndex(0).value(), "reply_to_post"); + assert.equal( + composerActions.rowByIndex(1).value(), + "reply_as_private_message" + ); + assert.equal(composerActions.rowByIndex(2).value(), "reply_to_topic"); + assert.equal(composerActions.rowByIndex(3).value(), "shared_draft"); + assert.equal(composerActions.rows().length, 4); + + await composerActions.selectRowByValue("reply_as_private_message"); + await composerActions.expand(); + + assert.equal( + find(".action-title").text().trim(), + I18n.t("topic.private_message") + ); + assert.ok( + find(".d-editor-input").val().indexOf("Continuing the discussion") === 0 + ); + assert.equal(composerActions.rowByIndex(0).value(), "reply_as_new_topic"); + assert.equal(composerActions.rowByIndex(1).value(), "reply_to_post"); + assert.equal(composerActions.rowByIndex(2).value(), "reply_to_topic"); + assert.equal(composerActions.rows().length, 3); + }); + + test("replying to post - toggle_topic_bump", async (assert) => { + const composerActions = selectKit(".composer-actions"); + + await visit("/t/internationalization-localization/280"); + await click("article#post_3 button.reply"); + + assert.ok( + find(".composer-fields .no-bump").length === 0, + "no-bump text is not visible" + ); + + await composerActions.expand(); + await composerActions.selectRowByValue("toggle_topic_bump"); + + assert.ok( + find(".composer-fields .no-bump").length === 1, + "no-bump icon is visible" + ); + + await composerActions.expand(); + await composerActions.selectRowByValue("toggle_topic_bump"); + + assert.ok( + find(".composer-fields .no-bump").length === 0, + "no-bump icon is not visible" + ); + }); + + test("replying to post as staff", async (assert) => { + const composerActions = selectKit(".composer-actions"); + + updateCurrentUser({ admin: true }); + await visit("/t/internationalization-localization/280"); + await click("article#post_3 button.reply"); + await composerActions.expand(); + + assert.equal(composerActions.rows().length, 5); + assert.equal(composerActions.rowByIndex(4).value(), "toggle_topic_bump"); + }); + + test("replying to post as TL3 user", async (assert) => { + const composerActions = selectKit(".composer-actions"); + + updateCurrentUser({ moderator: false, admin: false, trust_level: 3 }); + await visit("/t/internationalization-localization/280"); + await click("article#post_3 button.reply"); + await composerActions.expand(); + + assert.equal(composerActions.rows().length, 3); + Array.from(composerActions.rows()).forEach((row) => { + assert.notEqual( + row.value, + "toggle_topic_bump", + "toggle button is not visible" + ); + }); + }); + + test("replying to post as TL4 user", async (assert) => { + const composerActions = selectKit(".composer-actions"); + + updateCurrentUser({ moderator: false, admin: false, trust_level: 4 }); + await visit("/t/internationalization-localization/280"); + await click("article#post_3 button.reply"); + await composerActions.expand(); + + assert.equal(composerActions.rows().length, 4); + assert.equal(composerActions.rowByIndex(3).value(), "toggle_topic_bump"); + }); + + test("replying to first post - reply_as_private_message", async (assert) => { + const composerActions = selectKit(".composer-actions"); + + await visit("/t/internationalization-localization/280"); + await click("article#post_1 button.reply"); + + await composerActions.expand(); + await composerActions.selectRowByValue("reply_as_private_message"); + + assert.equal(find(".users-input .item:eq(0)").text(), "uwe_keim"); + assert.ok( + find(".d-editor-input").val().indexOf("Continuing the discussion") >= 0 + ); + }); + + test("editing post", async (assert) => { + const composerActions = selectKit(".composer-actions"); + + await visit("/t/internationalization-localization/280"); + await click("article#post_1 button.show-more-actions"); + await click("article#post_1 button.edit"); + await composerActions.expand(); + + assert.equal(composerActions.rows().length, 1); + assert.equal(composerActions.rowByIndex(0).value(), "reply_to_post"); + }); + + acceptance("Composer Actions With New Topic Draft", { + loggedIn: true, + settings: { + enable_whispers: true, + }, + site: { + can_tag_topics: true, + }, + beforeEach() { + _clearSnapshots(); + }, + afterEach() { + _clearSnapshots(); + }, + }); + + const stubDraftResponse = () => { + sandbox.stub(Draft, "get").returns( + Promise.resolve({ + draft: + '{"reply":"dum de dum da ba.","action":"createTopic","title":"dum da ba dum dum","categoryId":null,"archetypeId":"regular","metaData":null,"composerTime":540879,"typingTime":3400}', + draft_sequence: 0, + }) + ); + }; + + test("shared draft", async (assert) => { + stubDraftResponse(); + try { + toggleCheckDraftPopup(true); + + const composerActions = selectKit(".composer-actions"); + const tags = selectKit(".mini-tag-chooser"); + + await visit("/"); + await click("#create-topic"); + + await fillIn( + "#reply-title", + "This is the new text for the title using 'quotes'" + ); + + await fillIn(".d-editor-input", "This is the new text for the post"); + await tags.expand(); + await tags.selectRowByValue("monkey"); + await composerActions.expand(); + await composerActions.selectRowByValue("shared_draft"); + + assert.equal(tags.header().value(), "monkey", "tags are not reset"); + + assert.equal( + find("#reply-title").val(), + "This is the new text for the title using 'quotes'" + ); + + assert.equal( + find("#reply-control .btn-primary.create .d-button-label").text(), + I18n.t("composer.create_shared_draft") + ); + + assert.ok(find("#reply-control.composing-shared-draft").length === 1); + await click(".modal-footer .btn.btn-default"); + } finally { + toggleCheckDraftPopup(false); + } + sandbox.restore(); + }); + + test("reply_as_new_topic with new_topic draft", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click(".create.reply"); + const composerActions = selectKit(".composer-actions"); + await composerActions.expand(); + stubDraftResponse(); + await composerActions.selectRowByValue("reply_as_new_topic"); + assert.equal( + find(".bootbox .modal-body").text(), + I18n.t("composer.composer_actions.reply_as_new_topic.confirm") + ); await click(".modal-footer .btn.btn-default"); - } finally { - toggleCheckDraftPopup(false); - } - sandbox.restore(); -}); - -test("reply_as_new_topic with new_topic draft", async (assert) => { - await visit("/t/internationalization-localization/280"); - await click(".create.reply"); - const composerActions = selectKit(".composer-actions"); - await composerActions.expand(); - stubDraftResponse(); - await composerActions.selectRowByValue("reply_as_new_topic"); - assert.equal( - find(".bootbox .modal-body").text(), - I18n.t("composer.composer_actions.reply_as_new_topic.confirm") - ); - await click(".modal-footer .btn.btn-default"); - sandbox.restore(); + sandbox.restore(); + }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-attachment-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-attachment-test.js index 8c87e46466d..b3c92d5be09 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-attachment-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-attachment-test.js @@ -2,7 +2,7 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; -function setupPretender(server, helper) { +function pretender(server, helper) { server.post("/uploads/lookup-urls", () => { return helper.response([ { @@ -28,35 +28,29 @@ async function writeInComposer(assert) { await fillIn(".d-editor-input", "[test|attachment](upload://asdsad.png)"); } -acceptance("Composer Attachment", { - loggedIn: true, - pretend(server, helper) { - setupPretender(server, helper); - }, +acceptance("Composer Attachment", function (needs) { + needs.user(); + needs.pretender(pretender); + + test("attachments are cooked properly", async (assert) => { + await writeInComposer(assert); + assert.equal( + find(".d-editor-preview:visible").html().trim(), + '

test

' + ); + }); }); -test("attachments are cooked properly", async (assert) => { - await writeInComposer(assert); - assert.equal( - find(".d-editor-preview:visible").html().trim(), - '

test

' - ); -}); +acceptance("Composer Attachment - Secure Media Enabled", function (needs) { + needs.user(); + needs.settings({ secure_media: true }); + needs.pretender(pretender); -acceptance("Composer Attachment - Secure Media Enabled", { - loggedIn: true, - settings: { - secure_media: true, - }, - pretend(server, helper) { - setupPretender(server, helper); - }, -}); - -test("attachments are cooked properly when secure media is enabled", async (assert) => { - await writeInComposer(assert); - assert.equal( - find(".d-editor-preview:visible").html().trim(), - '

test

' - ); + test("attachments are cooked properly when secure media is enabled", async (assert) => { + await writeInComposer(assert); + assert.equal( + find(".d-editor-preview:visible").html().trim(), + '

test

' + ); + }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-edit-conflict-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-edit-conflict-test.js index d3a2a2b1e0b..efd98e41f37 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-edit-conflict-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-edit-conflict-test.js @@ -2,72 +2,54 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; import I18n from "I18n"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; -import pretender from "discourse/tests/helpers/create-pretender"; -acceptance("Composer - Edit conflict", { - loggedIn: true, -}); +acceptance("Composer - Edit conflict", function (needs) { + needs.user(); -test("Edit a post that causes an edit conflict", async (assert) => { - await visit("/t/internationalization-localization/280"); - await click(".topic-post:eq(0) button.show-more-actions"); - await click(".topic-post:eq(0) button.edit"); - await fillIn(".d-editor-input", "this will 409"); - await click("#reply-control button.create"); - assert.equal( - find("#reply-control button.create").text().trim(), - I18n.t("composer.overwrite_edit"), - "it shows the overwrite button" - ); - assert.ok( - find("#draft-status .d-icon-user-edit"), - "error icon should be there" - ); - await click(".modal .btn-primary"); -}); - -function handleDraftPretender(assert) { - pretender.post("/draft.json", (request) => { - if ( - request.requestBody.indexOf("%22reply%22%3A%22%22") === -1 && - request.requestBody.indexOf("Any+plans+to+support+localization") !== -1 - ) { - assert.notEqual(request.requestBody.indexOf("originalText"), -1); - } - if ( - request.requestBody.indexOf( - "draft_key=topic_280&sequence=4&data=%7B%22reply%22%3A%22hello+world+hello+world+hello+world+hello+world+hello+world%22%2C%22action%22%3A%22reply%22%2C%22categoryId%22%3A2%2C%22archetypeId%22%3A%22regular%22%2C%22metaData" - ) !== -1 - ) { - assert.equal( - request.requestBody.indexOf("originalText"), - -1, - request.requestBody - ); - } - return [200, { "Content-Type": "application/json" }, { success: true }]; + let lastBody; + needs.pretender((server, helper) => { + server.post("/draft.json", (request) => { + lastBody = request.requestBody; + return helper.response({ success: true }); + }); }); -} -test("Should not send originalText when posting a new reply", async (assert) => { - handleDraftPretender(assert); + test("Edit a post that causes an edit conflict", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click(".topic-post:eq(0) button.show-more-actions"); + await click(".topic-post:eq(0) button.edit"); + await fillIn(".d-editor-input", "this will 409"); + await click("#reply-control button.create"); + assert.equal( + find("#reply-control button.create").text().trim(), + I18n.t("composer.overwrite_edit"), + "it shows the overwrite button" + ); + assert.ok( + find("#draft-status .d-icon-user-edit"), + "error icon should be there" + ); + await click(".modal .btn-primary"); + }); - await visit("/t/internationalization-localization/280"); - await click(".topic-post:eq(0) button.reply"); - await fillIn( - ".d-editor-input", - "hello world hello world hello world hello world hello world" - ); -}); - -test("Should send originalText when editing a reply", async (assert) => { - handleDraftPretender(assert); - - await visit("/t/internationalization-localization/280"); - await click(".topic-post:eq(0) button.show-more-actions"); - await click(".topic-post:eq(0) button.edit"); - await fillIn( - ".d-editor-input", - "hello world hello world hello world hello world hello world" - ); + test("Should not send originalText when posting a new reply", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click(".topic-post:eq(0) button.reply"); + await fillIn( + ".d-editor-input", + "hello world hello world hello world hello world hello world" + ); + assert.ok(lastBody.indexOf("originalText") === -1); + }); + + test("Should send originalText when editing a reply", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click(".topic-post:eq(0) button.show-more-actions"); + await click(".topic-post:eq(0) button.edit"); + await fillIn( + ".d-editor-input", + "hello world hello world hello world hello world hello world" + ); + assert.ok(lastBody.indexOf("originalText") > -1); + }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-hyperlink-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-hyperlink-test.js index 7f54fa79548..c449ba87970 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-hyperlink-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-hyperlink-test.js @@ -2,97 +2,97 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; -acceptance("Composer - Hyperlink", { - loggedIn: true, -}); - -test("add a hyperlink to a reply", async (assert) => { - await visit("/t/internationalization-localization/280"); - await click(".topic-post:first-child button.reply"); - await fillIn(".d-editor-input", "This is a link to "); - - assert.ok( - !exists(".insert-link.modal-body"), - "no hyperlink modal by default" - ); - - await click(".d-editor button.link"); - assert.ok(exists(".insert-link.modal-body"), "hyperlink modal visible"); - - await fillIn(".modal-body .link-url", "google.com"); - await fillIn(".modal-body .link-text", "Google"); - await click(".modal-footer button.btn-primary"); - - assert.equal( - find(".d-editor-input").val(), - "This is a link to [Google](https://google.com)", - "adds link with url and text, prepends 'https://'" - ); - - assert.ok( - !exists(".insert-link.modal-body"), - "modal dismissed after submitting link" - ); - - await fillIn(".d-editor-input", "Reset textarea contents."); - - await click(".d-editor button.link"); - await fillIn(".modal-body .link-url", "google.com"); - await fillIn(".modal-body .link-text", "Google"); - await click(".modal-footer button.btn-danger"); - - assert.equal( - find(".d-editor-input").val(), - "Reset textarea contents.", - "doesn’t insert anything after cancelling" - ); - - assert.ok( - !exists(".insert-link.modal-body"), - "modal dismissed after cancelling" - ); - - const textarea = find("#reply-control .d-editor-input")[0]; - textarea.selectionStart = 0; - textarea.selectionEnd = 6; - await click(".d-editor button.link"); - - await fillIn(".modal-body .link-url", "somelink.com"); - await click(".modal-footer button.btn-primary"); - - assert.equal( - find(".d-editor-input").val(), - "[Reset](https://somelink.com) textarea contents.", - "adds link to a selected text" - ); - - await fillIn(".d-editor-input", ""); - - await click(".d-editor button.link"); - await fillIn(".modal-body .link-url", "http://google.com"); - await keyEvent(".modal-body .link-url", "keyup", 32); - assert.ok( - !exists(".internal-link-results"), - "does not show internal links search dropdown when inputting a url" - ); - - await fillIn(".modal-body .link-url", "local"); - await keyEvent(".modal-body .link-url", "keyup", 32); - assert.ok( - exists(".internal-link-results"), - "shows internal links search dropdown when entering keywords" - ); - - await keyEvent(".insert-link", "keydown", 40); - await keyEvent(".insert-link", "keydown", 13); - - assert.ok( - !exists(".internal-link-results"), - "search dropdown dismissed after selecting an internal link" - ); - - assert.ok( - find(".link-url").val().includes("http"), - "replaces link url field with internal link" - ); +acceptance("Composer - Hyperlink", function (needs) { + needs.user(); + + test("add a hyperlink to a reply", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click(".topic-post:first-child button.reply"); + await fillIn(".d-editor-input", "This is a link to "); + + assert.ok( + !exists(".insert-link.modal-body"), + "no hyperlink modal by default" + ); + + await click(".d-editor button.link"); + assert.ok(exists(".insert-link.modal-body"), "hyperlink modal visible"); + + await fillIn(".modal-body .link-url", "google.com"); + await fillIn(".modal-body .link-text", "Google"); + await click(".modal-footer button.btn-primary"); + + assert.equal( + find(".d-editor-input").val(), + "This is a link to [Google](https://google.com)", + "adds link with url and text, prepends 'https://'" + ); + + assert.ok( + !exists(".insert-link.modal-body"), + "modal dismissed after submitting link" + ); + + await fillIn(".d-editor-input", "Reset textarea contents."); + + await click(".d-editor button.link"); + await fillIn(".modal-body .link-url", "google.com"); + await fillIn(".modal-body .link-text", "Google"); + await click(".modal-footer button.btn-danger"); + + assert.equal( + find(".d-editor-input").val(), + "Reset textarea contents.", + "doesn’t insert anything after cancelling" + ); + + assert.ok( + !exists(".insert-link.modal-body"), + "modal dismissed after cancelling" + ); + + const textarea = find("#reply-control .d-editor-input")[0]; + textarea.selectionStart = 0; + textarea.selectionEnd = 6; + await click(".d-editor button.link"); + + await fillIn(".modal-body .link-url", "somelink.com"); + await click(".modal-footer button.btn-primary"); + + assert.equal( + find(".d-editor-input").val(), + "[Reset](https://somelink.com) textarea contents.", + "adds link to a selected text" + ); + + await fillIn(".d-editor-input", ""); + + await click(".d-editor button.link"); + await fillIn(".modal-body .link-url", "http://google.com"); + await keyEvent(".modal-body .link-url", "keyup", 32); + assert.ok( + !exists(".internal-link-results"), + "does not show internal links search dropdown when inputting a url" + ); + + await fillIn(".modal-body .link-url", "local"); + await keyEvent(".modal-body .link-url", "keyup", 32); + assert.ok( + exists(".internal-link-results"), + "shows internal links search dropdown when entering keywords" + ); + + await keyEvent(".insert-link", "keydown", 40); + await keyEvent(".insert-link", "keydown", 13); + + assert.ok( + !exists(".internal-link-results"), + "search dropdown dismissed after selecting an internal link" + ); + + assert.ok( + find(".link-url").val().includes("http"), + "replaces link url field with internal link" + ); + }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-onebox-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-onebox-test.js index 2d61904f741..ee00777fa21 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-onebox-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-onebox-test.js @@ -2,21 +2,20 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; -acceptance("Composer - Onebox", { - loggedIn: true, - settings: { +acceptance("Composer - Onebox", function (needs) { + needs.user(); + needs.settings({ max_oneboxes_per_post: 2, enable_markdown_linkify: true, - }, -}); + }); -test("Preview update should respect max_oneboxes_per_post site setting", async (assert) => { - await visit("/t/internationalization-localization/280"); - await click("#topic-footer-buttons .btn.create"); + test("Preview update should respect max_oneboxes_per_post site setting", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click("#topic-footer-buttons .btn.create"); - await fillIn( - ".d-editor-input", - ` + await fillIn( + ".d-editor-input", + ` http://www.example.com/has-title.html This is another test http://www.example.com/has-title.html @@ -26,18 +25,19 @@ This is another test http://www.example.com/no-title.html This is another test http://www.example.com/has-title.html http://www.example.com/has-title.html - ` - ); + ` + ); - assert.equal( - find(".d-editor-preview:visible").html().trim(), - ` + assert.equal( + find(".d-editor-preview:visible").html().trim(), + `


This is another test This is a great title

http://www.example.com/no-title.html

This is another test http://www.example.com/no-title.html
This is another test This is a great title

- `.trim() - ); + `.trim() + ); + }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-tags-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-tags-test.js index b02123c83ab..07b5209ad25 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-tags-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-tags-test.js @@ -7,57 +7,55 @@ import { } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; -acceptance("Composer - Tags", { - loggedIn: true, - pretend(pretenderServer, helper) { - pretenderServer.post("/uploads/lookup-urls", () => { +acceptance("Composer - Tags", function (needs) { + needs.user(); + needs.pretender((server, helper) => { + server.post("/uploads/lookup-urls", () => { return helper.response([]); }); - }, - site: { - can_tag_topics: true, - }, -}); - -test("staff bypass tag validation rule", async (assert) => { - await visit("/"); - await click("#create-topic"); - - await fillIn("#reply-title", "this is my new topic title"); - await fillIn(".d-editor-input", "this is the *content* of a post"); - - Category.findById(2).set("minimum_required_tags", 1); - - const categoryChooser = selectKit(".category-chooser"); - await categoryChooser.expand(); - await categoryChooser.selectRowByValue(2); - - await click("#reply-control button.create"); - assert.notEqual(currentURL(), "/"); -}); - -test("users do not bypass tag validation rule", async (assert) => { - await visit("/"); - await click("#create-topic"); - - await fillIn("#reply-title", "this is my new topic title"); - await fillIn(".d-editor-input", "this is the *content* of a post"); - - Category.findById(2).set("minimum_required_tags", 1); - - const categoryChooser = selectKit(".category-chooser"); - await categoryChooser.expand(); - await categoryChooser.selectRowByValue(2); - - updateCurrentUser({ moderator: false, admin: false, trust_level: 1 }); - - await click("#reply-control button.create"); - assert.equal(currentURL(), "/"); - - const tags = selectKit(".mini-tag-chooser"); - await tags.expand(); - await tags.selectRowByValue("monkey"); - - await click("#reply-control button.create"); - assert.notEqual(currentURL(), "/"); + }); + needs.site({ can_tag_topics: true }); + + test("staff bypass tag validation rule", async (assert) => { + await visit("/"); + await click("#create-topic"); + + await fillIn("#reply-title", "this is my new topic title"); + await fillIn(".d-editor-input", "this is the *content* of a post"); + + Category.findById(2).set("minimum_required_tags", 1); + + const categoryChooser = selectKit(".category-chooser"); + await categoryChooser.expand(); + await categoryChooser.selectRowByValue(2); + + await click("#reply-control button.create"); + assert.notEqual(currentURL(), "/"); + }); + + test("users do not bypass tag validation rule", async (assert) => { + await visit("/"); + await click("#create-topic"); + + await fillIn("#reply-title", "this is my new topic title"); + await fillIn(".d-editor-input", "this is the *content* of a post"); + + Category.findById(2).set("minimum_required_tags", 1); + + const categoryChooser = selectKit(".category-chooser"); + await categoryChooser.expand(); + await categoryChooser.selectRowByValue(2); + + updateCurrentUser({ moderator: false, admin: false, trust_level: 1 }); + + await click("#reply-control button.create"); + assert.equal(currentURL(), "/"); + + const tags = selectKit(".mini-tag-chooser"); + await tags.expand(); + await tags.selectRowByValue("monkey"); + + await click("#reply-control button.create"); + assert.notEqual(currentURL(), "/"); + }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-topic-links-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-topic-links-test.js index 0afc0ca7e22..9f3c6622bfe 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-topic-links-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-topic-links-test.js @@ -1,172 +1,170 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { - acceptance, - updateCurrentUser, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; -acceptance("Composer topic featured links", { - loggedIn: true, - settings: { +acceptance("Composer topic featured links", function (needs) { + needs.user(); + needs.settings({ topic_featured_link_enabled: true, max_topic_title_length: 80, enable_markdown_linkify: true, - }, + }); + + test("onebox with title", async (assert) => { + await visit("/"); + await click("#create-topic"); + await fillIn("#reply-title", "http://www.example.com/has-title.html"); + assert.ok( + find(".d-editor-preview").html().trim().indexOf("onebox") > 0, + "it pastes the link into the body and previews it" + ); + assert.ok( + exists(".d-editor-textarea-wrapper .popup-tip.good"), + "the body is now good" + ); + assert.equal( + find(".title-input input").val(), + "An interesting article", + "title is from the oneboxed article" + ); + }); + + test("onebox result doesn't include a title", async (assert) => { + await visit("/"); + await click("#create-topic"); + await fillIn("#reply-title", "http://www.example.com/no-title.html"); + assert.ok( + find(".d-editor-preview").html().trim().indexOf("onebox") > 0, + "it pastes the link into the body and previews it" + ); + assert.ok( + exists(".d-editor-textarea-wrapper .popup-tip.good"), + "the body is now good" + ); + assert.equal( + find(".title-input input").val(), + "http://www.example.com/no-title.html", + "title is unchanged" + ); + }); + + test("no onebox result", async (assert) => { + await visit("/"); + await click("#create-topic"); + await fillIn("#reply-title", "http://www.example.com/nope-onebox.html"); + assert.ok( + find(".d-editor-preview").html().trim().indexOf("onebox") > 0, + "it pastes the link into the body and previews it" + ); + assert.ok( + exists(".d-editor-textarea-wrapper .popup-tip.good"), + "link is pasted into body" + ); + assert.equal( + find(".title-input input").val(), + "http://www.example.com/nope-onebox.html", + "title is unchanged" + ); + }); + + test("ignore internal links", async (assert) => { + await visit("/"); + await click("#create-topic"); + const title = "http://" + window.location.hostname + "/internal-page.html"; + await fillIn("#reply-title", title); + assert.equal( + find(".d-editor-preview").html().trim().indexOf("onebox"), + -1, + "onebox preview doesn't show" + ); + assert.equal( + find(".d-editor-input").val().length, + 0, + "link isn't put into the post" + ); + assert.equal(find(".title-input input").val(), title, "title is unchanged"); + }); + + test("link is longer than max title length", async (assert) => { + await visit("/"); + await click("#create-topic"); + await fillIn( + "#reply-title", + "http://www.example.com/has-title-and-a-url-that-is-more-than-80-characters-because-thats-good-for-seo-i-guess.html" + ); + assert.ok( + find(".d-editor-preview").html().trim().indexOf("onebox") > 0, + "it pastes the link into the body and previews it" + ); + assert.ok( + exists(".d-editor-textarea-wrapper .popup-tip.good"), + "the body is now good" + ); + assert.equal( + find(".title-input input").val(), + "An interesting article", + "title is from the oneboxed article" + ); + }); + + test("onebox with title but extra words in title field", async (assert) => { + await visit("/"); + await click("#create-topic"); + await fillIn("#reply-title", "http://www.example.com/has-title.html test"); + assert.equal( + find(".d-editor-preview").html().trim().indexOf("onebox"), + -1, + "onebox preview doesn't show" + ); + assert.equal( + find(".d-editor-input").val().length, + 0, + "link isn't put into the post" + ); + assert.equal( + find(".title-input input").val(), + "http://www.example.com/has-title.html test", + "title is unchanged" + ); + }); }); -test("onebox with title", async (assert) => { - await visit("/"); - await click("#create-topic"); - await fillIn("#reply-title", "http://www.example.com/has-title.html"); - assert.ok( - find(".d-editor-preview").html().trim().indexOf("onebox") > 0, - "it pastes the link into the body and previews it" - ); - assert.ok( - exists(".d-editor-textarea-wrapper .popup-tip.good"), - "the body is now good" - ); - assert.equal( - find(".title-input input").val(), - "An interesting article", - "title is from the oneboxed article" - ); -}); +acceptance( + "Composer topic featured links when uncategorized is not allowed", + function (needs) { + needs.user({ moderator: true, admin: false, trust_level: 1 }); + needs.settings({ + topic_featured_link_enabled: true, + max_topic_title_length: 80, + enable_markdown_linkify: true, + allow_uncategorized_topics: false, + }); -test("onebox result doesn't include a title", async (assert) => { - await visit("/"); - await click("#create-topic"); - await fillIn("#reply-title", "http://www.example.com/no-title.html"); - assert.ok( - find(".d-editor-preview").html().trim().indexOf("onebox") > 0, - "it pastes the link into the body and previews it" - ); - assert.ok( - exists(".d-editor-textarea-wrapper .popup-tip.good"), - "the body is now good" - ); - assert.equal( - find(".title-input input").val(), - "http://www.example.com/no-title.html", - "title is unchanged" - ); -}); - -test("no onebox result", async (assert) => { - await visit("/"); - await click("#create-topic"); - await fillIn("#reply-title", "http://www.example.com/nope-onebox.html"); - assert.ok( - find(".d-editor-preview").html().trim().indexOf("onebox") > 0, - "it pastes the link into the body and previews it" - ); - assert.ok( - exists(".d-editor-textarea-wrapper .popup-tip.good"), - "link is pasted into body" - ); - assert.equal( - find(".title-input input").val(), - "http://www.example.com/nope-onebox.html", - "title is unchanged" - ); -}); - -test("ignore internal links", async (assert) => { - await visit("/"); - await click("#create-topic"); - const title = "http://" + window.location.hostname + "/internal-page.html"; - await fillIn("#reply-title", title); - assert.equal( - find(".d-editor-preview").html().trim().indexOf("onebox"), - -1, - "onebox preview doesn't show" - ); - assert.equal( - find(".d-editor-input").val().length, - 0, - "link isn't put into the post" - ); - assert.equal(find(".title-input input").val(), title, "title is unchanged"); -}); - -test("link is longer than max title length", async (assert) => { - await visit("/"); - await click("#create-topic"); - await fillIn( - "#reply-title", - "http://www.example.com/has-title-and-a-url-that-is-more-than-80-characters-because-thats-good-for-seo-i-guess.html" - ); - assert.ok( - find(".d-editor-preview").html().trim().indexOf("onebox") > 0, - "it pastes the link into the body and previews it" - ); - assert.ok( - exists(".d-editor-textarea-wrapper .popup-tip.good"), - "the body is now good" - ); - assert.equal( - find(".title-input input").val(), - "An interesting article", - "title is from the oneboxed article" - ); -}); - -test("onebox with title but extra words in title field", async (assert) => { - await visit("/"); - await click("#create-topic"); - await fillIn("#reply-title", "http://www.example.com/has-title.html test"); - assert.equal( - find(".d-editor-preview").html().trim().indexOf("onebox"), - -1, - "onebox preview doesn't show" - ); - assert.equal( - find(".d-editor-input").val().length, - 0, - "link isn't put into the post" - ); - assert.equal( - find(".title-input input").val(), - "http://www.example.com/has-title.html test", - "title is unchanged" - ); -}); - -acceptance("Composer topic featured links when uncategorized is not allowed", { - loggedIn: true, - settings: { - topic_featured_link_enabled: true, - max_topic_title_length: 80, - enable_markdown_linkify: true, - allow_uncategorized_topics: false, - }, -}); - -test("Pasting a link enables the text input area", async (assert) => { - updateCurrentUser({ moderator: false, admin: false, trust_level: 1 }); - - await visit("/"); - await click("#create-topic"); - assert.ok( - find(".d-editor-textarea-wrapper.disabled").length, - "textarea is disabled" - ); - await fillIn("#reply-title", "http://www.example.com/has-title.html"); - assert.ok( - find(".d-editor-preview").html().trim().indexOf("onebox") > 0, - "it pastes the link into the body and previews it" - ); - assert.ok( - exists(".d-editor-textarea-wrapper .popup-tip.good"), - "the body is now good" - ); - assert.equal( - find(".title-input input").val(), - "An interesting article", - "title is from the oneboxed article" - ); - assert.ok( - find(".d-editor-textarea-wrapper.disabled").length === 0, - "textarea is enabled" - ); -}); + test("Pasting a link enables the text input area", async (assert) => { + await visit("/"); + await click("#create-topic"); + assert.ok( + find(".d-editor-textarea-wrapper.disabled").length, + "textarea is disabled" + ); + await fillIn("#reply-title", "http://www.example.com/has-title.html"); + assert.ok( + find(".d-editor-preview").html().trim().indexOf("onebox") > 0, + "it pastes the link into the body and previews it" + ); + assert.ok( + exists(".d-editor-textarea-wrapper .popup-tip.good"), + "the body is now good" + ); + assert.equal( + find(".title-input input").val(), + "An interesting article", + "title is from the oneboxed article" + ); + assert.ok( + find(".d-editor-textarea-wrapper.disabled").length === 0, + "textarea is enabled" + ); + }); + } +); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-uncategorized-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-uncategorized-test.js index 8fcd3bac533..fba5c455a6d 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-uncategorized-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-uncategorized-test.js @@ -1,69 +1,62 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; import selectKit from "discourse/tests/helpers/select-kit-helper"; -import { - acceptance, - updateCurrentUser, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance( "Composer disabled, uncategorized not allowed when any topic_template present", - { - loggedIn: true, - settings: { + function (needs) { + needs.user(); + needs.settings({ enable_whispers: true, allow_uncategorized_topics: false, - }, + }); + + test("Disable body until category is selected", async (assert) => { + await visit("/"); + await click("#create-topic"); + assert.ok(exists(".d-editor-input"), "the composer input is visible"); + assert.ok( + exists(".title-input .popup-tip.bad.hide"), + "title errors are hidden by default" + ); + assert.ok( + exists(".d-editor-textarea-wrapper .popup-tip.bad.hide"), + "body errors are hidden by default" + ); + assert.ok( + exists(".d-editor-textarea-wrapper.disabled"), + "textarea is disabled" + ); + + const categoryChooser = selectKit(".category-chooser"); + + await categoryChooser.expand(); + await categoryChooser.selectRowByValue(2); + + assert.ok( + find(".d-editor-textarea-wrapper.disabled").length === 0, + "textarea is enabled" + ); + + await fillIn(".d-editor-input", "Now I can type stuff"); + await categoryChooser.expand(); + await categoryChooser.selectRowByIndex(0); + + assert.ok( + find(".d-editor-textarea-wrapper.disabled").length === 0, + "textarea is still enabled" + ); + }); } ); -test("Disable body until category is selected", async (assert) => { - updateCurrentUser({ moderator: false, admin: false, trust_level: 1 }); - - await visit("/"); - await click("#create-topic"); - assert.ok(exists(".d-editor-input"), "the composer input is visible"); - assert.ok( - exists(".title-input .popup-tip.bad.hide"), - "title errors are hidden by default" - ); - assert.ok( - exists(".d-editor-textarea-wrapper .popup-tip.bad.hide"), - "body errors are hidden by default" - ); - assert.ok( - exists(".d-editor-textarea-wrapper.disabled"), - "textarea is disabled" - ); - - const categoryChooser = selectKit(".category-chooser"); - - await categoryChooser.expand(); - await categoryChooser.selectRowByValue(2); - - assert.ok( - find(".d-editor-textarea-wrapper.disabled").length === 0, - "textarea is enabled" - ); - - await fillIn(".d-editor-input", "Now I can type stuff"); - await categoryChooser.expand(); - await categoryChooser.selectRowByIndex(0); - - assert.ok( - find(".d-editor-textarea-wrapper.disabled").length === 0, - "textarea is still enabled" - ); -}); - acceptance( "Composer enabled, uncategorized not allowed when topic_template not present", - { - loggedIn: true, - settings: { - allow_uncategorized_topics: false, - }, - site: { + function (needs) { + needs.user(); + needs.settings({ allow_uncategorized_topics: false }); + needs.site({ categories: [ { id: 1, @@ -84,37 +77,34 @@ acceptance( topic_template: null, }, ], - }, + }); + test("Enable composer/body if no topic templates present", async (assert) => { + await visit("/"); + await click("#create-topic"); + assert.ok(exists(".d-editor-input"), "the composer input is visible"); + assert.ok( + exists(".category-input .popup-tip.bad.hide"), + "category errors are hidden by default" + ); + assert.ok( + find(".d-editor-textarea-wrapper.disabled").length === 0, + "textarea is enabled" + ); + + await click("#reply-control button.create"); + assert.ok( + exists(".category-input .popup-tip.bad"), + "it shows the choose a category error" + ); + + const categoryChooser = selectKit(".category-chooser"); + await categoryChooser.expand(); + await categoryChooser.selectRowByValue(1); + + assert.ok( + !exists(".category-input .popup-tip.bad"), + "category error removed after selecting category" + ); + }); } ); - -test("Enable composer/body if no topic templates present", async (assert) => { - updateCurrentUser({ moderator: false, admin: false, trust_level: 1 }); - - await visit("/"); - await click("#create-topic"); - assert.ok(exists(".d-editor-input"), "the composer input is visible"); - assert.ok( - exists(".category-input .popup-tip.bad.hide"), - "category errors are hidden by default" - ); - assert.ok( - find(".d-editor-textarea-wrapper.disabled").length === 0, - "textarea is enabled" - ); - - await click("#reply-control button.create"); - assert.ok( - exists(".category-input .popup-tip.bad"), - "it shows the choose a category error" - ); - - const categoryChooser = selectKit(".category-chooser"); - await categoryChooser.expand(); - await categoryChooser.selectRowByValue(1); - - assert.ok( - !exists(".category-input .popup-tip.bad"), - "category error removed after selecting category" - ); -}); diff --git a/app/assets/javascripts/discourse/tests/acceptance/create-account-external-test.js b/app/assets/javascripts/discourse/tests/acceptance/create-account-external-test.js index 7819e93e016..b6ae6b799d1 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/create-account-external-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/create-account-external-test.js @@ -2,8 +2,8 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; -acceptance("Create Account - external auth", { - beforeEach() { +acceptance("Create Account - external auth", function (needs) { + needs.hooks.beforeEach(() => { const node = document.createElement("meta"); node.dataset.authenticationData = JSON.stringify({ auth_provider: "test", @@ -13,33 +13,33 @@ acceptance("Create Account - external auth", { }); node.id = "data-authentication"; document.querySelector("head").appendChild(node); - }, - afterEach() { + }); + needs.hooks.afterEach(() => { document .querySelector("head") .removeChild(document.getElementById("data-authentication")); - }, -}); - -test("when skip is disabled (default)", async (assert) => { - await visit("/"); - - assert.ok( - exists("#discourse-modal div.create-account"), - "it shows the registration modal" - ); - - assert.ok(exists("#new-account-username"), "it shows the fields"); -}); - -test("when skip is enabled", async function (assert) { - this.siteSettings.external_auth_skip_create_confirm = true; - await visit("/"); - - assert.ok( - exists("#discourse-modal div.create-account"), - "it shows the registration modal" - ); - - assert.not(exists("#new-account-username"), "it does not show the fields"); + }); + + test("when skip is disabled (default)", async (assert) => { + await visit("/"); + + assert.ok( + exists("#discourse-modal div.create-account"), + "it shows the registration modal" + ); + + assert.ok(exists("#new-account-username"), "it shows the fields"); + }); + + test("when skip is enabled", async function (assert) { + this.siteSettings.external_auth_skip_create_confirm = true; + await visit("/"); + + assert.ok( + exists("#discourse-modal div.create-account"), + "it shows the registration modal" + ); + + assert.not(exists("#new-account-username"), "it does not show the fields"); + }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/create-account-user-fields-test.js b/app/assets/javascripts/discourse/tests/acceptance/create-account-user-fields-test.js index f8cf499d1ba..45d2a1e3b08 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/create-account-user-fields-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/create-account-user-fields-test.js @@ -2,8 +2,8 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; -acceptance("Create Account - User Fields", { - site: { +acceptance("Create Account - User Fields", function (needs) { + needs.site({ user_fields: [ { id: 34, @@ -24,43 +24,43 @@ acceptance("Create Account - User Fields", { required: false, }, ], - }, -}); - -test("create account with user fields", async (assert) => { - await visit("/"); - await click("header .sign-up-button"); - - assert.ok(exists(".create-account"), "it shows the create account modal"); - assert.ok(exists(".user-field"), "it has at least one user field"); - - await click(".modal-footer .btn-primary"); - assert.ok(exists("#modal-alert"), "it shows the required field alert"); - assert.equal(find("#modal-alert").text(), "Please enter an email address"); - - await fillIn("#new-account-name", "Dr. Good Tuna"); - await fillIn("#new-account-password", "cool password bro"); - // without this double fill, field will sometimes being empty - // got consistent repro by having browser search bar focused when starting test - await fillIn("#new-account-email", "good.tuna@test.com"); - await fillIn("#new-account-email", "good.tuna@test.com"); - await fillIn("#new-account-username", "goodtuna"); - - assert.ok( - exists("#username-validation.good"), - "the username validation is good" - ); - assert.ok( - exists("#account-email-validation.good"), - "the email validation is good" - ); - - await click(".modal-footer .btn-primary"); - assert.equal(find("#modal-alert")[0].style.display, ""); - - await fillIn(".user-field input[type=text]:first", "Barky"); - await click(".user-field input[type=checkbox]"); - - await click(".modal-footer .btn-primary"); - assert.equal(find("#modal-alert")[0].style.display, "none"); + }); + + test("create account with user fields", async (assert) => { + await visit("/"); + await click("header .sign-up-button"); + + assert.ok(exists(".create-account"), "it shows the create account modal"); + assert.ok(exists(".user-field"), "it has at least one user field"); + + await click(".modal-footer .btn-primary"); + assert.ok(exists("#modal-alert"), "it shows the required field alert"); + assert.equal(find("#modal-alert").text(), "Please enter an email address"); + + await fillIn("#new-account-name", "Dr. Good Tuna"); + await fillIn("#new-account-password", "cool password bro"); + // without this double fill, field will sometimes being empty + // got consistent repro by having browser search bar focused when starting test + await fillIn("#new-account-email", "good.tuna@test.com"); + await fillIn("#new-account-email", "good.tuna@test.com"); + await fillIn("#new-account-username", "goodtuna"); + + assert.ok( + exists("#username-validation.good"), + "the username validation is good" + ); + assert.ok( + exists("#account-email-validation.good"), + "the email validation is good" + ); + + await click(".modal-footer .btn-primary"); + assert.equal(find("#modal-alert")[0].style.display, ""); + + await fillIn(".user-field input[type=text]:first", "Barky"); + await click(".user-field input[type=checkbox]"); + + await click(".modal-footer .btn-primary"); + assert.equal(find("#modal-alert")[0].style.display, "none"); + }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/custom-html-set-test.js b/app/assets/javascripts/discourse/tests/acceptance/custom-html-set-test.js index 22434afa3ef..b779c5140d7 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/custom-html-set-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/custom-html-set-test.js @@ -4,29 +4,33 @@ import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import { setCustomHTML } from "discourse/helpers/custom-html"; import PreloadStore from "discourse/lib/preload-store"; -acceptance("CustomHTML set"); - -test("has no custom HTML in the top", async (assert) => { - await visit("/static/faq"); - assert.ok(!exists("span.custom-html-test"), "it has no markup"); -}); - -test("renders set HTML", async (assert) => { - setCustomHTML("top", 'HTML'); - - await visit("/static/faq"); - assert.equal( - find("span.custom-html-test").text(), - "HTML", - "it inserted the markup" - ); -}); - -test("renders preloaded HTML", async (assert) => { - PreloadStore.store("customHTML", { - top: "monster", +acceptance("CustomHTML set", function () { + test("has no custom HTML in the top", async (assert) => { + await visit("/static/faq"); + assert.ok(!exists("span.custom-html-test"), "it has no markup"); }); - await visit("/static/faq"); - assert.equal(find("span.cookie").text(), "monster", "it inserted the markup"); + test("renders set HTML", async (assert) => { + setCustomHTML("top", 'HTML'); + + await visit("/static/faq"); + assert.equal( + find("span.custom-html-test").text(), + "HTML", + "it inserted the markup" + ); + }); + + test("renders preloaded HTML", async (assert) => { + PreloadStore.store("customHTML", { + top: "monster", + }); + + await visit("/static/faq"); + assert.equal( + find("span.cookie").text(), + "monster", + "it inserted the markup" + ); + }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/custom-html-template-test.js b/app/assets/javascripts/discourse/tests/acceptance/custom-html-template-test.js index 47c1abe069d..c4b0d19e5a6 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/custom-html-template-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/custom-html-template-test.js @@ -1,20 +1,24 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; +import Ember from "ember"; -acceptance("CustomHTML template", { - beforeEach() { +acceptance("CustomHTML template", function (needs) { + needs.hooks.beforeEach(() => { Ember.TEMPLATES["top"] = Ember.HTMLBars.compile( `TOP` ); - }, - - afterEach() { + }); + needs.hooks.afterEach(() => { delete Ember.TEMPLATES["top"]; - }, -}); + }); -test("renders custom template", async (assert) => { - await visit("/static/faq"); - assert.equal(find("span.top-span").text(), "TOP", "it inserted the template"); + test("renders custom template", async (assert) => { + await visit("/static/faq"); + assert.equal( + find("span.top-span").text(), + "TOP", + "it inserted the template" + ); + }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/dashboard-test.js b/app/assets/javascripts/discourse/tests/acceptance/dashboard-test.js index 49559bfd583..7d76cd84a9a 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/dashboard-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/dashboard-test.js @@ -3,13 +3,13 @@ import { test } from "qunit"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; -acceptance("Dashboard", { - loggedIn: true, - settings: { +acceptance("Dashboard", function (needs) { + needs.user(); + needs.settings({ dashboard_visible_tabs: "moderation|security|reports", dashboard_general_tab_activity_metrics: "page_view_total_reqs", - }, - site: { + }); + needs.site({ groups: [ { id: 88, @@ -20,138 +20,139 @@ acceptance("Dashboard", { name: "tl2", }, ], - }, + }); + + test("default", async (assert) => { + await visit("/admin"); + + assert.ok(exists(".dashboard"), "has dashboard-next class"); + }); + + test("tabs", async (assert) => { + await visit("/admin"); + + assert.ok(exists(".dashboard .navigation-item.general"), "general tab"); + assert.ok( + exists(".dashboard .navigation-item.moderation"), + "moderation tab" + ); + assert.ok(exists(".dashboard .navigation-item.security"), "security tab"); + assert.ok(exists(".dashboard .navigation-item.reports"), "reports tab"); + }); + + test("general tab", async (assert) => { + await visit("/admin"); + assert.ok(exists(".admin-report.signups"), "signups report"); + assert.ok(exists(".admin-report.posts"), "posts report"); + assert.ok(exists(".admin-report.dau-by-mau"), "dau-by-mau report"); + assert.ok( + exists(".admin-report.daily-engaged-users"), + "daily-engaged-users report" + ); + assert.ok( + exists(".admin-report.new-contributors"), + "new-contributors report" + ); + + assert.equal( + $(".section.dashboard-problems .problem-messages ul li:first-child") + .html() + .trim(), + "Houston...", + "displays problems" + ); + }); + + test("activity metrics", async (assert) => { + await visit("/admin"); + + assert.ok(exists(".admin-report.page-view-total-reqs .today-count")); + assert.ok(exists(".admin-report.page-view-total-reqs .yesterday-count")); + assert.ok(exists(".admin-report.page-view-total-reqs .sevendays-count")); + assert.ok(exists(".admin-report.page-view-total-reqs .thirty-days-count")); + }); + + test("reports tab", async (assert) => { + await visit("/admin"); + await click(".dashboard .navigation-item.reports .navigation-link"); + + assert.equal( + find(".dashboard .reports-index.section .reports-list .report").length, + 1 + ); + + await fillIn(".dashboard .filter-reports-input", "flags"); + + assert.equal( + find(".dashboard .reports-index.section .reports-list .report").length, + 0 + ); + + await click(".dashboard .navigation-item.security .navigation-link"); + await click(".dashboard .navigation-item.reports .navigation-link"); + + assert.equal( + find(".dashboard .reports-index.section .reports-list .report").length, + 1, + "navigating back and forth resets filter" + ); + + await fillIn(".dashboard .filter-reports-input", "activities"); + + assert.equal( + find(".dashboard .reports-index.section .reports-list .report").length, + 1, + "filter is case insensitive" + ); + }); + + test("reports filters", async (assert) => { + await visit( + '/admin/reports/signups_with_groups?end_date=2018-07-16&filters=%7B"group"%3A88%7D&start_date=2018-06-16' + ); + + const groupFilter = selectKit(".group-filter .combo-box"); + + assert.equal( + groupFilter.header().value(), + 88, + "its set the value of the filter from the query params" + ); + }); }); -test("default", async (assert) => { - await visit("/admin"); +acceptance("Dashboard: dashboard_visible_tabs", function (needs) { + needs.user(); + needs.settings({ dashboard_visible_tabs: "general|security|reports" }); - assert.ok(exists(".dashboard"), "has dashboard-next class"); -}); - -test("tabs", async (assert) => { - await visit("/admin"); - - assert.ok(exists(".dashboard .navigation-item.general"), "general tab"); - assert.ok(exists(".dashboard .navigation-item.moderation"), "moderation tab"); - assert.ok(exists(".dashboard .navigation-item.security"), "security tab"); - assert.ok(exists(".dashboard .navigation-item.reports"), "reports tab"); -}); - -test("general tab", async (assert) => { - await visit("/admin"); - assert.ok(exists(".admin-report.signups"), "signups report"); - assert.ok(exists(".admin-report.posts"), "posts report"); - assert.ok(exists(".admin-report.dau-by-mau"), "dau-by-mau report"); - assert.ok( - exists(".admin-report.daily-engaged-users"), - "daily-engaged-users report" - ); - assert.ok( - exists(".admin-report.new-contributors"), - "new-contributors report" - ); - - assert.equal( - $(".section.dashboard-problems .problem-messages ul li:first-child") - .html() - .trim(), - "Houston...", - "displays problems" - ); -}); - -test("activity metrics", async (assert) => { - await visit("/admin"); - - assert.ok(exists(".admin-report.page-view-total-reqs .today-count")); - assert.ok(exists(".admin-report.page-view-total-reqs .yesterday-count")); - assert.ok(exists(".admin-report.page-view-total-reqs .sevendays-count")); - assert.ok(exists(".admin-report.page-view-total-reqs .thirty-days-count")); -}); - -test("reports tab", async (assert) => { - await visit("/admin"); - await click(".dashboard .navigation-item.reports .navigation-link"); - - assert.equal( - find(".dashboard .reports-index.section .reports-list .report").length, - 1 - ); - - await fillIn(".dashboard .filter-reports-input", "flags"); - - assert.equal( - find(".dashboard .reports-index.section .reports-list .report").length, - 0 - ); - - await click(".dashboard .navigation-item.security .navigation-link"); - await click(".dashboard .navigation-item.reports .navigation-link"); - - assert.equal( - find(".dashboard .reports-index.section .reports-list .report").length, - 1, - "navigating back and forth resets filter" - ); - - await fillIn(".dashboard .filter-reports-input", "activities"); - - assert.equal( - find(".dashboard .reports-index.section .reports-list .report").length, - 1, - "filter is case insensitive" - ); -}); - -test("reports filters", async (assert) => { - await visit( - '/admin/reports/signups_with_groups?end_date=2018-07-16&filters=%7B"group"%3A88%7D&start_date=2018-06-16' - ); - - const groupFilter = selectKit(".group-filter .combo-box"); - - assert.equal( - groupFilter.header().value(), - 88, - "its set the value of the filter from the query params" - ); -}); - -acceptance("Dashboard: dashboard_visible_tabs", { - loggedIn: true, - settings: { - dashboard_visible_tabs: "general|security|reports", - }, -}); - -test("visible tabs", async (assert) => { - await visit("/admin"); - - assert.ok(exists(".dashboard .navigation-item.general"), "general tab"); - assert.notOk( - exists(".dashboard .navigation-item.moderation"), - "moderation tab" - ); - assert.ok(exists(".dashboard .navigation-item.security"), "security tab"); - assert.ok(exists(".dashboard .navigation-item.reports"), "reports tab"); -}); - -acceptance("Dashboard: dashboard_hidden_reports", { - loggedIn: true, - settings: { - dashboard_visible_tabs: "reports", - dashboard_hidden_reports: "posts|dau_by_mau", - }, -}); - -test("hidden reports", async (assert) => { - await visit("/admin"); - - assert.ok(exists(".admin-report.signups.is-visible"), "signups report"); - assert.notOk(exists(".admin-report.is-visible.posts"), "posts report"); - assert.notOk( - exists(".admin-report.is-visible.dau-by-mau"), - "dau-by-mau report" - ); + test("visible tabs", async (assert) => { + await visit("/admin"); + + assert.ok(exists(".dashboard .navigation-item.general"), "general tab"); + assert.notOk( + exists(".dashboard .navigation-item.moderation"), + "moderation tab" + ); + assert.ok(exists(".dashboard .navigation-item.security"), "security tab"); + assert.ok(exists(".dashboard .navigation-item.reports"), "reports tab"); + }); + + acceptance("Dashboard: dashboard_hidden_reports", { + loggedIn: true, + settings: { + dashboard_visible_tabs: "reports", + dashboard_hidden_reports: "posts|dau_by_mau", + }, + }); + + test("hidden reports", async (assert) => { + await visit("/admin"); + + assert.ok(exists(".admin-report.signups.is-visible"), "signups report"); + assert.notOk(exists(".admin-report.is-visible.posts"), "posts report"); + assert.notOk( + exists(".admin-report.is-visible.dau-by-mau"), + "dau-by-mau report" + ); + }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/email-notice-test.js b/app/assets/javascripts/discourse/tests/acceptance/email-notice-test.js index 36cbe299c90..e3797bf2a9e 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/email-notice-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/email-notice-test.js @@ -5,40 +5,40 @@ import { updateCurrentUser, } from "discourse/tests/helpers/qunit-helpers"; -acceptance("Email Disabled Banner", { - loggedIn: true, -}); +acceptance("Email Disabled Banner", function (needs) { + needs.user(); -test("when disabled", async function (assert) { - this.siteSettings.disable_emails = "no"; - await visit("/"); - assert.notOk( - exists(".alert-emails-disabled"), - "alert is not displayed when email enabled" - ); -}); + test("when disabled", async function (assert) { + this.siteSettings.disable_emails = "no"; + await visit("/"); + assert.notOk( + exists(".alert-emails-disabled"), + "alert is not displayed when email enabled" + ); + }); -test("when enabled", async function (assert) { - this.siteSettings.disable_emails = "yes"; - await visit("/latest"); - assert.ok( - exists(".alert-emails-disabled"), - "alert is displayed when email disabled" - ); -}); + test("when enabled", async function (assert) { + this.siteSettings.disable_emails = "yes"; + await visit("/latest"); + assert.ok( + exists(".alert-emails-disabled"), + "alert is displayed when email disabled" + ); + }); -test("when non-staff", async function (assert) { - this.siteSettings.disable_emails = "non-staff"; - await visit("/"); - assert.ok( - exists(".alert-emails-disabled"), - "alert is displayed when email disabled for non-staff" - ); + test("when non-staff", async function (assert) { + this.siteSettings.disable_emails = "non-staff"; + await visit("/"); + assert.ok( + exists(".alert-emails-disabled"), + "alert is displayed when email disabled for non-staff" + ); - updateCurrentUser({ moderator: true }); - await visit("/"); - assert.ok( - exists(".alert-emails-disabled"), - "alert is displayed to staff when email disabled for non-staff" - ); + updateCurrentUser({ moderator: true }); + await visit("/"); + assert.ok( + exists(".alert-emails-disabled"), + "alert is displayed to staff when email disabled for non-staff" + ); + }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js b/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js index 32b83409230..5989f9d9706 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js @@ -2,137 +2,138 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; -acceptance("EmojiPicker", { - loggedIn: true, - beforeEach() { +acceptance("EmojiPicker", function (needs) { + needs.user(); + + needs.hooks.beforeEach(function () { this.emojiStore = this.container.lookup("service:emoji-store"); this.emojiStore.reset(); - }, - afterEach() { + }); + needs.hooks.afterEach(function () { this.emojiStore.reset(); - }, -}); - -test("emoji picker can be opened/closed", async (assert) => { - await visit("/t/internationalization-localization/280"); - await click("#topic-footer-buttons .btn.create"); - - await click("button.emoji.btn"); - assert.ok(exists(".emoji-picker.opened"), "it opens the picker"); - - await click("button.emoji.btn"); - assert.notOk(exists(".emoji-picker.opened"), "it closes the picker"); -}); - -test("emoji picker triggers event when picking emoji", async (assert) => { - await visit("/t/internationalization-localization/280"); - await click("#topic-footer-buttons .btn.create"); - await click("button.emoji.btn"); - await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); - - assert.equal( - find(".d-editor-input").val(), - ":grinning:", - "it adds the emoji code in the editor when selected" - ); -}); - -test("emoji picker adds leading whitespace before emoji", async (assert) => { - await visit("/t/internationalization-localization/280"); - await click("#topic-footer-buttons .btn.create"); - - // Whitespace should be added on text - await fillIn(".d-editor-input", "This is a test input"); - await click("button.emoji.btn"); - await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); - assert.equal( - find(".d-editor-input").val(), - "This is a test input :grinning:", - "it adds the emoji code and a leading whitespace when there is text" - ); - - // Whitespace should not be added on whitespace - await fillIn(".d-editor-input", "This is a test input "); - await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); - - assert.equal( - find(".d-editor-input").val(), - "This is a test input :grinning:", - "it adds the emoji code and no leading whitespace when user already entered whitespace" - ); -}); - -test("emoji picker has a list of recently used emojis", async (assert) => { - await visit("/t/internationalization-localization/280"); - await click("#topic-footer-buttons .btn.create"); - await click("button.emoji.btn"); - await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); - - assert.ok( - exists( - ".emoji-picker .section.recent .section-group img.emoji[title='grinning']" - ), - "it shows recent selected emoji" - ); - - assert.ok( - exists('.emoji-picker .category-button[data-section="recent"]'), - "it shows recent category icon" - ); - - await click(".emoji-picker .trash-recent"); - - assert.notOk( - exists( - ".emoji-picker .section.recent .section-group img.emoji[title='grinning']" - ), - "it has cleared recent emojis" - ); - - assert.notOk( - exists('.emoji-picker .section[data-section="recent"]'), - "it hides recent section" - ); - - assert.notOk( - exists('.emoji-picker .category-button[data-section="recent"]'), - "it hides recent category icon" - ); -}); - -test("emoji picker correctly orders recently used emojis", async (assert) => { - await visit("/t/internationalization-localization/280"); - await click("#topic-footer-buttons .btn.create"); - await click("button.emoji.btn"); - await click(".emoji-picker-emoji-area img.emoji[title='sunglasses']"); - await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); - - assert.equal( - find('.section[data-section="recent"] .section-group img.emoji').length, - 2, - "it has multiple recent emojis" - ); - - assert.equal( - /grinning/.test( - find(".section.recent .section-group img.emoji").first().attr("src") - ), - true, - "it puts the last used emoji in first" - ); -}); - -test("emoji picker persists state", async (assert) => { - await visit("/t/internationalization-localization/280"); - await click("#topic-footer-buttons .btn.create"); - await click("button.emoji.btn"); - await click(".emoji-picker button.diversity-scale.medium-dark"); - await click("button.emoji.btn"); - await click("button.emoji.btn"); - - assert.ok( - exists(".emoji-picker button.diversity-scale.medium-dark .d-icon"), - true, - "it stores diversity scale" - ); + }); + + test("emoji picker can be opened/closed", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click("#topic-footer-buttons .btn.create"); + + await click("button.emoji.btn"); + assert.ok(exists(".emoji-picker.opened"), "it opens the picker"); + + await click("button.emoji.btn"); + assert.notOk(exists(".emoji-picker.opened"), "it closes the picker"); + }); + + test("emoji picker triggers event when picking emoji", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click("#topic-footer-buttons .btn.create"); + await click("button.emoji.btn"); + await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); + + assert.equal( + find(".d-editor-input").val(), + ":grinning:", + "it adds the emoji code in the editor when selected" + ); + }); + + test("emoji picker adds leading whitespace before emoji", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click("#topic-footer-buttons .btn.create"); + + // Whitespace should be added on text + await fillIn(".d-editor-input", "This is a test input"); + await click("button.emoji.btn"); + await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); + assert.equal( + find(".d-editor-input").val(), + "This is a test input :grinning:", + "it adds the emoji code and a leading whitespace when there is text" + ); + + // Whitespace should not be added on whitespace + await fillIn(".d-editor-input", "This is a test input "); + await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); + + assert.equal( + find(".d-editor-input").val(), + "This is a test input :grinning:", + "it adds the emoji code and no leading whitespace when user already entered whitespace" + ); + }); + + test("emoji picker has a list of recently used emojis", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click("#topic-footer-buttons .btn.create"); + await click("button.emoji.btn"); + await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); + + assert.ok( + exists( + ".emoji-picker .section.recent .section-group img.emoji[title='grinning']" + ), + "it shows recent selected emoji" + ); + + assert.ok( + exists('.emoji-picker .category-button[data-section="recent"]'), + "it shows recent category icon" + ); + + await click(".emoji-picker .trash-recent"); + + assert.notOk( + exists( + ".emoji-picker .section.recent .section-group img.emoji[title='grinning']" + ), + "it has cleared recent emojis" + ); + + assert.notOk( + exists('.emoji-picker .section[data-section="recent"]'), + "it hides recent section" + ); + + assert.notOk( + exists('.emoji-picker .category-button[data-section="recent"]'), + "it hides recent category icon" + ); + }); + + test("emoji picker correctly orders recently used emojis", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click("#topic-footer-buttons .btn.create"); + await click("button.emoji.btn"); + await click(".emoji-picker-emoji-area img.emoji[title='sunglasses']"); + await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); + + assert.equal( + find('.section[data-section="recent"] .section-group img.emoji').length, + 2, + "it has multiple recent emojis" + ); + + assert.equal( + /grinning/.test( + find(".section.recent .section-group img.emoji").first().attr("src") + ), + true, + "it puts the last used emoji in first" + ); + }); + + test("emoji picker persists state", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click("#topic-footer-buttons .btn.create"); + await click("button.emoji.btn"); + await click(".emoji-picker button.diversity-scale.medium-dark"); + await click("button.emoji.btn"); + await click("button.emoji.btn"); + + assert.ok( + exists(".emoji-picker button.diversity-scale.medium-dark .d-icon"), + true, + "it stores diversity scale" + ); + }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js b/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js index 6f04c31551b..93f576484c6 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js @@ -3,26 +3,28 @@ import { test } from "qunit"; import { IMAGE_VERSION as v } from "pretty-text/emoji/version"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; -acceptance("Emoji", { loggedIn: true }); +acceptance("Emoji", function (needs) { + needs.user(); -test("emoji is cooked properly", async (assert) => { - await visit("/t/internationalization-localization/280"); - await click("#topic-footer-buttons .btn.create"); + test("emoji is cooked properly", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click("#topic-footer-buttons .btn.create"); - await fillIn(".d-editor-input", "this is an emoji :blonde_woman:"); - assert.equal( - find(".d-editor-preview:visible").html().trim(), - `

this is an emoji :blonde_woman:

` - ); -}); - -test("skin toned emoji is cooked properly", async (assert) => { - await visit("/t/internationalization-localization/280"); - await click("#topic-footer-buttons .btn.create"); - - await fillIn(".d-editor-input", "this is an emoji :blonde_woman:t5:"); - assert.equal( - find(".d-editor-preview:visible").html().trim(), - `

this is an emoji :blonde_woman:t5:

` - ); + await fillIn(".d-editor-input", "this is an emoji :blonde_woman:"); + assert.equal( + find(".d-editor-preview:visible").html().trim(), + `

this is an emoji :blonde_woman:

` + ); + }); + + test("skin toned emoji is cooked properly", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click("#topic-footer-buttons .btn.create"); + + await fillIn(".d-editor-input", "this is an emoji :blonde_woman:t5:"); + assert.equal( + find(".d-editor-preview:visible").html().trim(), + `

this is an emoji :blonde_woman:t5:

` + ); + }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/enforce-second-factor-test.js b/app/assets/javascripts/discourse/tests/acceptance/enforce-second-factor-test.js index eaaaecafd51..8a752a5c97e 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/enforce-second-factor-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/enforce-second-factor-test.js @@ -5,85 +5,85 @@ import { updateCurrentUser, } from "discourse/tests/helpers/qunit-helpers"; -acceptance("Enforce Second Factor", { - loggedIn: true, - pretend(server, helper) { +acceptance("Enforce Second Factor", function (needs) { + needs.user(); + needs.pretender((server, helper) => { server.post("/u/second_factors.json", () => { return helper.response({ success: "OK", password_required: "true", }); }); - }, -}); - -test("as an admin", async function (assert) { - await visit("/u/eviltrout/preferences/second-factor"); - this.siteSettings.enforce_second_factor = "staff"; - - await visit("/u/eviltrout/summary"); - - assert.equal( - find(".control-label").text(), - "Password", - "it will not transition from second-factor preferences" - ); - - await click("#toggle-hamburger-menu"); - await click("a.admin-link"); - - assert.equal( - find(".control-label").text(), - "Password", - "it stays at second-factor preferences" - ); -}); - -test("as a user", async function (assert) { - updateCurrentUser({ moderator: false, admin: false }); - - await visit("/u/eviltrout/preferences/second-factor"); - this.siteSettings.enforce_second_factor = "all"; - - await visit("/u/eviltrout/summary"); - - assert.equal( - find(".control-label").text(), - "Password", - "it will not transition from second-factor preferences" - ); - - await click("#toggle-hamburger-menu"); - await click("a.about-link"); - - assert.equal( - find(".control-label").text(), - "Password", - "it stays at second-factor preferences" - ); -}); - -test("as an anonymous user", async function (assert) { - updateCurrentUser({ moderator: false, admin: false, is_anonymous: true }); - - await visit("/u/eviltrout/preferences/second-factor"); - this.siteSettings.enforce_second_factor = "all"; - this.siteSettings.allow_anonymous_posting = true; - - await visit("/u/eviltrout/summary"); - - assert.notEqual( - find(".control-label").text(), - "Password", - "it will transition from second-factor preferences" - ); - - await click("#toggle-hamburger-menu"); - await click("a.about-link"); - - assert.notEqual( - find(".control-label").text(), - "Password", - "it is possible to navigate to other pages" - ); + }); + + test("as an admin", async function (assert) { + await visit("/u/eviltrout/preferences/second-factor"); + this.siteSettings.enforce_second_factor = "staff"; + + await visit("/u/eviltrout/summary"); + + assert.equal( + find(".control-label").text(), + "Password", + "it will not transition from second-factor preferences" + ); + + await click("#toggle-hamburger-menu"); + await click("a.admin-link"); + + assert.equal( + find(".control-label").text(), + "Password", + "it stays at second-factor preferences" + ); + }); + + test("as a user", async function (assert) { + updateCurrentUser({ moderator: false, admin: false }); + + await visit("/u/eviltrout/preferences/second-factor"); + this.siteSettings.enforce_second_factor = "all"; + + await visit("/u/eviltrout/summary"); + + assert.equal( + find(".control-label").text(), + "Password", + "it will not transition from second-factor preferences" + ); + + await click("#toggle-hamburger-menu"); + await click("a.about-link"); + + assert.equal( + find(".control-label").text(), + "Password", + "it stays at second-factor preferences" + ); + }); + + test("as an anonymous user", async function (assert) { + updateCurrentUser({ moderator: false, admin: false, is_anonymous: true }); + + await visit("/u/eviltrout/preferences/second-factor"); + this.siteSettings.enforce_second_factor = "all"; + this.siteSettings.allow_anonymous_posting = true; + + await visit("/u/eviltrout/summary"); + + assert.notEqual( + find(".control-label").text(), + "Password", + "it will transition from second-factor preferences" + ); + + await click("#toggle-hamburger-menu"); + await click("a.about-link"); + + assert.notEqual( + find(".control-label").text(), + "Password", + "it is possible to navigate to other pages" + ); + }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/flag-post-test.js b/app/assets/javascripts/discourse/tests/acceptance/flag-post-test.js index 95ba0726368..69c837d527f 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/flag-post-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/flag-post-test.js @@ -3,17 +3,21 @@ import selectKit from "discourse/tests/helpers/select-kit-helper"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import userFixtures from "discourse/tests/fixtures/user-fixtures"; -acceptance("flagging", { - loggedIn: true, - afterEach() { - sandbox.restore(); - }, - pretend(pretenderServer, helper) { +async function openFlagModal() { + if (exists(".topic-post:first-child button.show-more-actions")) { + await click(".topic-post:first-child button.show-more-actions"); + } + await click(".topic-post:first-child button.create-flag"); +} + +acceptance("flagging", function (needs) { + needs.user(); + needs.pretender((server, helper) => { const userResponse = Object.assign({}, userFixtures["/u/charlie.json"]); - pretenderServer.get("/u/uwe_keim.json", () => { + server.get("/u/uwe_keim.json", () => { return helper.response(userResponse); }); - pretenderServer.get("/admin/users/255.json", () => { + server.get("/admin/users/255.json", () => { return helper.response({ id: 255, automatic: false, @@ -38,7 +42,7 @@ acceptance("flagging", { full_name: null, }); }); - pretenderServer.get("/admin/users/5.json", () => { + server.get("/admin/users/5.json", () => { return helper.response({ id: 5, automatic: false, @@ -63,82 +67,74 @@ acceptance("flagging", { full_name: null, }); }); - pretenderServer.put("admin/users/5/silence", () => { + server.put("admin/users/5/silence", () => { return helper.response({ silenced: true, }); }); - pretenderServer.post("post_actions", () => { + server.post("post_actions", () => { return helper.response({ response: true, }); }); - }, -}); - -async function openFlagModal() { - if (exists(".topic-post:first-child button.show-more-actions")) { - await click(".topic-post:first-child button.show-more-actions"); - } - - await click(".topic-post:first-child button.create-flag"); -} - -test("Flag modal opening", async (assert) => { - await visit("/t/internationalization-localization/280"); - await openFlagModal(); - assert.ok(exists(".flag-modal-body"), "it shows the flag modal"); -}); - -test("Flag take action dropdown exists", async (assert) => { - await visit("/t/internationalization-localization/280"); - await openFlagModal(); - await click("#radio_inappropriate"); - await selectKit(".reviewable-action-dropdown").expand(); - assert.ok( - exists("[data-value='agree_and_silence']"), - "it shows the silence action option" - ); - await click("[data-value='agree_and_silence']"); - assert.ok(exists(".silence-user-modal"), "it shows the silence modal"); -}); - -test("Can silence from take action", async (assert) => { - await visit("/t/internationalization-localization/280"); - await openFlagModal(); - await click("#radio_inappropriate"); - await selectKit(".reviewable-action-dropdown").expand(); - await click("[data-value='agree_and_silence']"); - - const silenceUntilCombobox = selectKit(".silence-until .combobox"); - await silenceUntilCombobox.expand(); - await silenceUntilCombobox.selectRowByValue("tomorrow"); - await fillIn(".silence-reason", "for breaking the rules"); - await click(".perform-silence"); - assert.equal(find(".bootbox.modal:visible").length, 0); -}); - -test("Gets dismissable warning from canceling incomplete silence from take action", async (assert) => { - await visit("/t/internationalization-localization/280"); - await openFlagModal(); - await click("#radio_inappropriate"); - await selectKit(".reviewable-action-dropdown").expand(); - await click("[data-value='agree_and_silence']"); - - const silenceUntilCombobox = selectKit(".silence-until .combobox"); - await silenceUntilCombobox.expand(); - await silenceUntilCombobox.selectRowByValue("tomorrow"); - await fillIn(".silence-reason", "for breaking the rules"); - await click(".d-modal-cancel"); - assert.equal(find(".bootbox.modal:visible").length, 1); - - await click(".modal-footer .btn-default"); - assert.equal(find(".bootbox.modal:visible").length, 0); - assert.ok(exists(".silence-user-modal"), "it shows the silence modal"); - - await click(".d-modal-cancel"); - assert.equal(find(".bootbox.modal:visible").length, 1); - - await click(".modal-footer .btn-primary"); - assert.equal(find(".bootbox.modal:visible").length, 0); + }); + + test("Flag modal opening", async (assert) => { + await visit("/t/internationalization-localization/280"); + await openFlagModal(); + assert.ok(exists(".flag-modal-body"), "it shows the flag modal"); + }); + + test("Flag take action dropdown exists", async (assert) => { + await visit("/t/internationalization-localization/280"); + await openFlagModal(); + await click("#radio_inappropriate"); + await selectKit(".reviewable-action-dropdown").expand(); + assert.ok( + exists("[data-value='agree_and_silence']"), + "it shows the silence action option" + ); + await click("[data-value='agree_and_silence']"); + assert.ok(exists(".silence-user-modal"), "it shows the silence modal"); + }); + + test("Can silence from take action", async (assert) => { + await visit("/t/internationalization-localization/280"); + await openFlagModal(); + await click("#radio_inappropriate"); + await selectKit(".reviewable-action-dropdown").expand(); + await click("[data-value='agree_and_silence']"); + + const silenceUntilCombobox = selectKit(".silence-until .combobox"); + await silenceUntilCombobox.expand(); + await silenceUntilCombobox.selectRowByValue("tomorrow"); + await fillIn(".silence-reason", "for breaking the rules"); + await click(".perform-silence"); + assert.equal(find(".bootbox.modal:visible").length, 0); + }); + + test("Gets dismissable warning from canceling incomplete silence from take action", async (assert) => { + await visit("/t/internationalization-localization/280"); + await openFlagModal(); + await click("#radio_inappropriate"); + await selectKit(".reviewable-action-dropdown").expand(); + await click("[data-value='agree_and_silence']"); + + const silenceUntilCombobox = selectKit(".silence-until .combobox"); + await silenceUntilCombobox.expand(); + await silenceUntilCombobox.selectRowByValue("tomorrow"); + await fillIn(".silence-reason", "for breaking the rules"); + await click(".d-modal-cancel"); + assert.equal(find(".bootbox.modal:visible").length, 1); + + await click(".modal-footer .btn-default"); + assert.equal(find(".bootbox.modal:visible").length, 0); + assert.ok(exists(".silence-user-modal"), "it shows the silence modal"); + + await click(".d-modal-cancel"); + assert.equal(find(".bootbox.modal:visible").length, 1); + + await click(".modal-footer .btn-primary"); + assert.equal(find(".bootbox.modal:visible").length, 0); + }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/forgot-password-test.js b/app/assets/javascripts/discourse/tests/acceptance/forgot-password-test.js index 7c0f0ce696e..3ac835d28ea 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/forgot-password-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/forgot-password-test.js @@ -5,79 +5,79 @@ import { acceptance } from "discourse/tests/helpers/qunit-helpers"; let userFound = false; -acceptance("Forgot password", { - pretend(server, helper) { +acceptance("Forgot password", function (needs) { + needs.pretender((server, helper) => { server.post("/session/forgot_password", () => { return helper.response({ user_found: userFound, }); }); - }, -}); - -test("requesting password reset", async (assert) => { - await visit("/"); - await click("header .login-button"); - await click("#forgot-password-link"); - - assert.equal( - find(".forgot-password-reset").attr("disabled"), - "disabled", - "it should disable the button until the field is filled" - ); - - await fillIn("#username-or-email", "someuser"); - await click(".forgot-password-reset"); - - assert.equal( - find(".alert-error").html().trim(), - I18n.t("forgot_password.complete_username_not_found", { - username: "someuser", - }), - "it should display an error for an invalid username" - ); - - await fillIn("#username-or-email", "someuser@gmail.com"); - await click(".forgot-password-reset"); - - assert.equal( - find(".alert-error").html().trim(), - I18n.t("forgot_password.complete_email_not_found", { - email: "someuser@gmail.com", - }), - "it should display an error for an invalid email" - ); - - await fillIn("#username-or-email", "someuser"); - - userFound = true; - - await click(".forgot-password-reset"); - - assert.notOk( - exists(find(".alert-error")), - "it should remove the flash error when succeeding" - ); - - assert.equal( - find(".modal-body").html().trim(), - I18n.t("forgot_password.complete_username_found", { - username: "someuser", - }), - "it should display a success message for a valid username" - ); - - await visit("/"); - await click("header .login-button"); - await click("#forgot-password-link"); - await fillIn("#username-or-email", "someuser@gmail.com"); - await click(".forgot-password-reset"); - - assert.equal( - find(".modal-body").html().trim(), - I18n.t("forgot_password.complete_email_found", { - email: "someuser@gmail.com", - }), - "it should display a success message for a valid email" - ); + }); + + test("requesting password reset", async (assert) => { + await visit("/"); + await click("header .login-button"); + await click("#forgot-password-link"); + + assert.equal( + find(".forgot-password-reset").attr("disabled"), + "disabled", + "it should disable the button until the field is filled" + ); + + await fillIn("#username-or-email", "someuser"); + await click(".forgot-password-reset"); + + assert.equal( + find(".alert-error").html().trim(), + I18n.t("forgot_password.complete_username_not_found", { + username: "someuser", + }), + "it should display an error for an invalid username" + ); + + await fillIn("#username-or-email", "someuser@gmail.com"); + await click(".forgot-password-reset"); + + assert.equal( + find(".alert-error").html().trim(), + I18n.t("forgot_password.complete_email_not_found", { + email: "someuser@gmail.com", + }), + "it should display an error for an invalid email" + ); + + await fillIn("#username-or-email", "someuser"); + + userFound = true; + + await click(".forgot-password-reset"); + + assert.notOk( + exists(find(".alert-error")), + "it should remove the flash error when succeeding" + ); + + assert.equal( + find(".modal-body").html().trim(), + I18n.t("forgot_password.complete_username_found", { + username: "someuser", + }), + "it should display a success message for a valid username" + ); + + await visit("/"); + await click("header .login-button"); + await click("#forgot-password-link"); + await fillIn("#username-or-email", "someuser@gmail.com"); + await click(".forgot-password-reset"); + + assert.equal( + find(".modal-body").html().trim(), + I18n.t("forgot_password.complete_email_found", { + email: "someuser@gmail.com", + }), + "it should display a success message for a valid email" + ); + }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-card-mobile-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-card-mobile-test.js deleted file mode 100644 index 782ef1ac91e..00000000000 --- a/app/assets/javascripts/discourse/tests/acceptance/group-card-mobile-test.js +++ /dev/null @@ -1,24 +0,0 @@ -import { visit } from "@ember/test-helpers"; -import { skip } from "qunit"; -import { acceptance } from "discourse/tests/helpers/qunit-helpers"; -import DiscourseURL from "discourse/lib/url"; - -acceptance("Group Card - Mobile", { mobileView: true }); - -skip("group card", async (assert) => { - await visit("/t/-/301/1"); - assert.ok( - invisible(".group-card"), - "mobile group card is invisible by default" - ); - - await click("a.mention-group:first"); - assert.ok(visible(".group-card"), "mobile group card should appear"); - - sandbox.stub(DiscourseURL, "routeTo"); - await click(".card-content a.group-page-link"); - assert.ok( - DiscourseURL.routeTo.calledWith("/g/discourse"), - "it should navigate to the group page" - ); -}); diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-card-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-card-test.js deleted file mode 100644 index a6c42b1ef9a..00000000000 --- a/app/assets/javascripts/discourse/tests/acceptance/group-card-test.js +++ /dev/null @@ -1,21 +0,0 @@ -import { visit } from "@ember/test-helpers"; -import { skip } from "qunit"; -import { acceptance } from "discourse/tests/helpers/qunit-helpers"; -import DiscourseURL from "discourse/lib/url"; - -acceptance("Group Card"); - -skip("group card", async (assert) => { - await visit("/t/-/301/1"); - assert.ok(invisible(".group-card"), "user card is invisible by default"); - - await click("a.mention-group:first"); - assert.ok(visible(".group-card"), "card should appear"); - - sandbox.stub(DiscourseURL, "routeTo"); - await click(".card-content a.group-page-link"); - assert.ok( - DiscourseURL.routeTo.calledWith("/g/discourse"), - "it should navigate to the group page" - ); -}); diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-index-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-index-test.js index 79ea4af9d29..1c43e9aec33 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-index-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-index-test.js @@ -6,55 +6,57 @@ import { updateCurrentUser, } from "discourse/tests/helpers/qunit-helpers"; -acceptance("Group Members"); +acceptance("Group Members - Anonymous", function () { + test("Viewing Members as anon user", async (assert) => { + await visit("/g/discourse"); -test("Viewing Members as anon user", async (assert) => { - await visit("/g/discourse"); + assert.ok( + count(".avatar-flair .d-icon-adjust") === 1, + "it displays the group's avatar flair" + ); + assert.ok(count(".group-members tr") > 0, "it lists group members"); - assert.ok( - count(".avatar-flair .d-icon-adjust") === 1, - "it displays the group's avatar flair" - ); - assert.ok(count(".group-members tr") > 0, "it lists group members"); + assert.ok( + count(".group-member-dropdown") === 0, + "it does not allow anon user to manage group members" + ); - assert.ok( - count(".group-member-dropdown") === 0, - "it does not allow anon user to manage group members" - ); - - assert.equal( - find(".group-username-filter").attr("placeholder"), - I18n.t("groups.members.filter_placeholder"), - "it should display the right filter placehodler" - ); + assert.equal( + find(".group-username-filter").attr("placeholder"), + I18n.t("groups.members.filter_placeholder"), + "it should display the right filter placehodler" + ); + }); }); -acceptance("Group Members", { loggedIn: true }); +acceptance("Group Members", function (needs) { + needs.user(); -test("Viewing Members as a group owner", async (assert) => { - updateCurrentUser({ moderator: false, admin: false }); + test("Viewing Members as a group owner", async (assert) => { + updateCurrentUser({ moderator: false, admin: false }); - await visit("/g/discourse"); - await click(".group-members-add"); + await visit("/g/discourse"); + await click(".group-members-add"); - assert.equal( - find("#group-add-members-user-selector").length, - 1, - "it should display the add members modal" - ); -}); - -test("Viewing Members as an admin user", async (assert) => { - await visit("/g/discourse"); - - assert.ok( - count(".group-member-dropdown") > 0, - "it allows admin user to manage group members" - ); - - assert.equal( - find(".group-username-filter").attr("placeholder"), - I18n.t("groups.members.filter_placeholder_admin"), - "it should display the right filter placehodler" - ); + assert.equal( + find("#group-add-members-user-selector").length, + 1, + "it should display the add members modal" + ); + }); + + test("Viewing Members as an admin user", async (assert) => { + await visit("/g/discourse"); + + assert.ok( + count(".group-member-dropdown") > 0, + "it allows admin user to manage group members" + ); + + assert.equal( + find(".group-username-filter").attr("placeholder"), + I18n.t("groups.members.filter_placeholder_admin"), + "it should display the right filter placehodler" + ); + }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-manage-categories-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-categories-test.js index 48a7f8b25c9..40da38014b1 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-manage-categories-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-categories-test.js @@ -5,34 +5,36 @@ import { updateCurrentUser, } from "discourse/tests/helpers/qunit-helpers"; -acceptance("Managing Group Category Notification Defaults"); -test("As an anonymous user", async (assert) => { - await visit("/g/discourse/manage/categories"); +acceptance("Managing Group Category Notification Defaults", function () { + test("As an anonymous user", async (assert) => { + await visit("/g/discourse/manage/categories"); - assert.ok( - count(".group-members tr") > 0, - "it should redirect to members page for an anonymous user" - ); + assert.ok( + count(".group-members tr") > 0, + "it should redirect to members page for an anonymous user" + ); + }); }); -acceptance("Managing Group Category Notification Defaults", { loggedIn: true }); +acceptance("Managing Group Category Notification Defaults", function (needs) { + needs.user(); + test("As an admin", async (assert) => { + await visit("/g/discourse/manage/categories"); -test("As an admin", async (assert) => { - await visit("/g/discourse/manage/categories"); + assert.ok( + find(".groups-notifications-form .category-selector").length === 5, + "it should display category inputs" + ); + }); - assert.ok( - find(".groups-notifications-form .category-selector").length === 5, - "it should display category inputs" - ); -}); - -test("As a group owner", async (assert) => { - updateCurrentUser({ moderator: false, admin: false }); - - await visit("/g/discourse/manage/categories"); - - assert.ok( - find(".groups-notifications-form .category-selector").length === 5, - "it should display category inputs" - ); + test("As a group owner", async (assert) => { + updateCurrentUser({ moderator: false, admin: false }); + + await visit("/g/discourse/manage/categories"); + + assert.ok( + find(".groups-notifications-form .category-selector").length === 5, + "it should display category inputs" + ); + }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-manage-interaction-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-interaction-test.js index 0d33b8abdbb..e21261ed728 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-manage-interaction-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-interaction-test.js @@ -5,89 +5,87 @@ import { updateCurrentUser, } from "discourse/tests/helpers/qunit-helpers"; -acceptance("Managing Group Interaction Settings", { - loggedIn: true, - settings: { - email_in: true, - }, -}); +acceptance("Managing Group Interaction Settings", function (needs) { + needs.user(); + needs.settings({ email_in: true }); -test("As an admin", async (assert) => { - updateCurrentUser({ - moderator: false, - admin: true, - can_create_group: true, + test("As an admin", async (assert) => { + updateCurrentUser({ + moderator: false, + admin: true, + can_create_group: true, + }); + + await visit("/g/alternative-group/manage/interaction"); + + assert.equal( + find(".groups-form-visibility-level").length, + 1, + "it should display visibility level selector" + ); + + assert.equal( + find(".groups-form-mentionable-level").length, + 1, + "it should display mentionable level selector" + ); + + assert.equal( + find(".groups-form-messageable-level").length, + 1, + "it should display messageable level selector" + ); + + assert.equal( + find(".groups-form-incoming-email").length, + 1, + "it should display incoming email input" + ); + + assert.equal( + find(".groups-form-default-notification-level").length, + 1, + "it should display default notification level input" + ); }); - await visit("/g/alternative-group/manage/interaction"); + test("As a group owner", async (assert) => { + updateCurrentUser({ + moderator: false, + admin: false, + can_create_group: false, + }); - assert.equal( - find(".groups-form-visibility-level").length, - 1, - "it should display visibility level selector" - ); + await visit("/g/discourse/manage/interaction"); - assert.equal( - find(".groups-form-mentionable-level").length, - 1, - "it should display mentionable level selector" - ); + assert.equal( + find(".groups-form-visibility-level").length, + 0, + "it should not display visibility level selector" + ); - assert.equal( - find(".groups-form-messageable-level").length, - 1, - "it should display messageable level selector" - ); + assert.equal( + find(".groups-form-mentionable-level").length, + 1, + "it should display mentionable level selector" + ); - assert.equal( - find(".groups-form-incoming-email").length, - 1, - "it should display incoming email input" - ); + assert.equal( + find(".groups-form-messageable-level").length, + 1, + "it should display messageable level selector" + ); - assert.equal( - find(".groups-form-default-notification-level").length, - 1, - "it should display default notification level input" - ); -}); + assert.equal( + find(".groups-form-incoming-email").length, + 0, + "it should not display incoming email input" + ); -test("As a group owner", async (assert) => { - updateCurrentUser({ - moderator: false, - admin: false, - can_create_group: false, + assert.equal( + find(".groups-form-default-notification-level").length, + 1, + "it should display default notification level input" + ); }); - - await visit("/g/discourse/manage/interaction"); - - assert.equal( - find(".groups-form-visibility-level").length, - 0, - "it should not display visibility level selector" - ); - - assert.equal( - find(".groups-form-mentionable-level").length, - 1, - "it should display mentionable level selector" - ); - - assert.equal( - find(".groups-form-messageable-level").length, - 1, - "it should display messageable level selector" - ); - - assert.equal( - find(".groups-form-incoming-email").length, - 0, - "it should not display incoming email input" - ); - - assert.equal( - find(".groups-form-default-notification-level").length, - 1, - "it should display default notification level input" - ); }); diff --git a/app/assets/javascripts/discourse/tests/fixtures/topic.js b/app/assets/javascripts/discourse/tests/fixtures/topic.js index 0eaa20ad1d9..2409a38f832 100644 --- a/app/assets/javascripts/discourse/tests/fixtures/topic.js +++ b/app/assets/javascripts/discourse/tests/fixtures/topic.js @@ -1,6 +1,231 @@ import I18n from "I18n"; /*jshint maxlen:10000000 */ export default { + "/t/130.json": { + post_stream: { + posts: [ + { + id: 133, + name: null, + username: "bianca", + avatar_template: "/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png", + created_at: "2020-07-05T09:28:36.371Z", + cooked: + "

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas a varius ipsum. Nunc euismod, metus non vulputate malesuada, ligula metus pharetra tortor, vel sodales arcu lacus sed mauris. Nam semper, orci vitae fringilla placerat, dui tellus convallis felis, ultricies laoreet sapien mi et metus. Mauris facilisis, mi fermentum rhoncus feugiat, dolor est vehicula leo, id porta leo ex non enim. In a ligula vel tellus commodo scelerisque non in ex. Pellentesque semper leo quam, nec varius est viverra eget. Donec vehicula sem et massa faucibus tempus.

", + post_number: 1, + post_type: 1, + updated_at: "2020-07-05T09:28:36.371Z", + reply_count: 0, + reply_to_post_number: null, + quote_count: 0, + incoming_link_count: 0, + reads: 1, + readers_count: 0, + score: 0, + yours: true, + topic_id: 130, + topic_slug: "lorem-ipsum-dolor-sit-amet", + display_username: null, + primary_group_name: null, + primary_group_flair_url: null, + primary_group_flair_bg_color: null, + primary_group_flair_color: null, + version: 1, + can_edit: true, + can_delete: false, + can_recover: false, + can_wiki: true, + read: true, + user_title: "Tester", + title_is_group: false, + actions_summary: [ + { + id: 3, + can_act: true, + }, + { + id: 4, + can_act: true, + }, + { + id: 8, + can_act: true, + }, + { + id: 7, + can_act: true, + }, + ], + moderator: false, + admin: true, + staff: true, + user_id: 1, + hidden: false, + trust_level: 0, + deleted_at: null, + user_deleted: false, + edit_reason: null, + can_view_edit_history: true, + wiki: false, + reviewable_id: 0, + reviewable_score_count: 0, + reviewable_score_pending_count: 0, + }, + ], + stream: [133], + }, + timeline_lookup: [[1, 0]], + related_messages: [], + suggested_topics: [], + id: 130, + title: "Lorem ipsum dolor sit amet", + fancy_title: "Lorem ipsum dolor sit amet", + posts_count: 1, + created_at: "2020-07-05T09:28:36.260Z", + views: 1, + reply_count: 0, + like_count: 0, + last_posted_at: "2020-07-05T09:28:36.371Z", + visible: true, + closed: false, + archived: false, + has_summary: false, + archetype: "private_message", + slug: "lorem-ipsum-dolor-sit-amet", + category_id: null, + word_count: 86, + deleted_at: null, + user_id: 1, + featured_link: null, + pinned_globally: false, + pinned_at: null, + pinned_until: null, + image_url: null, + draft: null, + draft_key: "topic_130", + draft_sequence: 0, + posted: true, + unpinned: null, + pinned: false, + current_post_number: 1, + highest_post_number: 1, + last_read_post_number: 1, + last_read_post_id: 133, + deleted_by: null, + has_deleted: false, + actions_summary: [ + { + id: 4, + count: 0, + hidden: false, + can_act: true, + }, + { + id: 8, + count: 0, + hidden: false, + can_act: true, + }, + { + id: 7, + count: 0, + hidden: false, + can_act: true, + }, + ], + chunk_size: 20, + bookmarked: false, + message_archived: false, + topic_timer: null, + message_bus_last_id: 5, + participant_count: 1, + pm_with_non_human_user: false, + show_read_indicator: false, + requested_group_name: null, + thumbnails: null, + tags_disable_ads: false, + details: { + notification_level: 3, + notifications_reason_id: 1, + can_move_posts: true, + can_edit: true, + can_delete: true, + can_remove_allowed_users: true, + can_invite_to: true, + can_invite_via_email: true, + can_create_post: true, + can_reply_as_new_topic: true, + can_flag_topic: true, + can_convert_topic: true, + can_review_topic: true, + can_remove_self_id: 1, + participants: [ + { + id: 1, + username: "bianca", + name: null, + avatar_template: "/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png", + post_count: 1, + primary_group_name: null, + primary_group_flair_url: null, + primary_group_flair_color: null, + primary_group_flair_bg_color: null, + }, + ], + allowed_users: [ + { + id: 7, + username: "foo", + name: null, + avatar_template: "/letter_avatar_proxy/v4/letter/f/b19c9b/{size}.png", + }, + ], + created_by: { + id: 1, + username: "bianca", + name: null, + avatar_template: "/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png", + }, + last_poster: { + id: 1, + username: "bianca", + name: null, + avatar_template: "/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png", + }, + allowed_groups: [ + { + id: 43, + automatic: false, + name: "foo_group", + user_count: 4, + mentionable_level: 0, + messageable_level: 99, + visibility_level: 0, + automatic_membership_email_domains: "", + primary_group: false, + title: null, + grant_trust_level: null, + incoming_email: null, + has_messages: true, + flair_url: null, + flair_bg_color: "", + flair_color: "", + bio_raw: null, + bio_cooked: null, + bio_excerpt: null, + public_admission: false, + public_exit: false, + allow_membership_requests: false, + full_name: null, + default_notification_level: 3, + membership_request_template: null, + members_visibility_level: 0, + can_see_members: true, + publish_read_state: false, + }, + ], + }, + }, "/t/280/1.json": { pending_posts: [], post_stream: { @@ -39,14 +264,14 @@ export default { internal: true, reflection: true, title: "Language mirrors", - clicks: 3 + clicks: 3, }, { url: "https://meta.discourse.org/t/translation-workflow/6102", internal: true, reflection: true, title: "Translation workflow", - clicks: 2 + clicks: 2, }, { url: @@ -54,7 +279,7 @@ export default { internal: true, reflection: true, title: "Solving XDA-Developer style forums", - clicks: 2 + clicks: 2, }, { url: @@ -63,7 +288,7 @@ export default { reflection: true, title: "Comrades let's join our efforts on ukrainian and russian translations", - clicks: 1 + clicks: 1, }, { url: @@ -72,15 +297,15 @@ export default { reflection: true, title: "Bookmark/last read sometimes doesn't go to the end of a topic", - clicks: 0 + clicks: 0, }, { url: "https://meta.discourse.org/t/roadplan-for-discourse/2939/5", internal: true, reflection: true, title: "Roadplan for Discourse 2013", - clicks: 0 - } + clicks: 0, + }, ], read: true, user_title: null, @@ -89,44 +314,44 @@ export default { id: 2, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: false, @@ -139,7 +364,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 419, @@ -175,8 +400,8 @@ export default { "https://github.com/discourse/discourse/blob/master/config/locales/en.yml", internal: false, reflection: false, - clicks: 118 - } + clicks: 118, + }, ], read: true, user_title: "Great contributor", @@ -185,44 +410,44 @@ export default { id: 2, count: 4, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: false, @@ -235,7 +460,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 1060, @@ -273,7 +498,7 @@ export default { reflection: false, title: "discourse/config/locales at master · discourse/discourse · GitHub", - clicks: 62 + clicks: 62, }, { url: @@ -281,8 +506,8 @@ export default { internal: true, reflection: true, title: "GitHub OneBox Rendering Issue", - clicks: 0 - } + clicks: 0, + }, ], read: true, user_title: "co-founder", @@ -291,44 +516,44 @@ export default { id: 2, count: 4, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 1, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: true, admin: true, @@ -341,7 +566,7 @@ export default { user_deleted: false, edit_reason: "", can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 3623, @@ -377,8 +602,8 @@ export default { internal: true, reflection: true, title: "Hi, support Chinese?", - clicks: 0 - } + clicks: 0, + }, ], read: true, user_title: null, @@ -387,44 +612,44 @@ export default { id: 2, count: 7, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: false, @@ -437,7 +662,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 3651, @@ -475,8 +700,8 @@ export default { reflection: false, title: "internationalization - Why do people use plain english as translation placeholders? - Stack Overflow", - clicks: 63 - } + clicks: 63, + }, ], read: true, user_title: null, @@ -485,44 +710,44 @@ export default { id: 2, count: 2, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: false, @@ -535,7 +760,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 3654, @@ -571,66 +796,66 @@ export default { internal: false, reflection: false, title: "SlexAxton/messageformat.js · GitHub", - clicks: 46 + clicks: 46, }, { url: "https://github.com/SlexAxton", internal: false, reflection: false, title: "SlexAxton (Alex Sexton) · GitHub", - clicks: 10 - } + clicks: 10, + }, ], read: true, user_title: "co-founder", reply_to_user: { username: "pekka", avatar_template: "/images/avatar.png", - uploaded_avatar_id: 5253 + uploaded_avatar_id: 5253, }, actions_summary: [ { id: 2, count: 1, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: true, admin: true, @@ -643,7 +868,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 3655, @@ -679,8 +904,8 @@ export default { internal: false, reflection: false, title: "WordPress › Development < GlotPress", - clicks: 16 - } + clicks: 16, + }, ], read: true, user_title: null, @@ -689,44 +914,44 @@ export default { id: 2, count: 1, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: false, @@ -739,7 +964,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 3658, @@ -776,59 +1001,59 @@ export default { internal: true, reflection: true, title: "What I love about WordPress plugins", - clicks: 0 - } + clicks: 0, + }, ], read: true, user_title: "co-founder", reply_to_user: { username: "pekka", avatar_template: "/images/avatar.png", - uploaded_avatar_id: 5253 + uploaded_avatar_id: 5253, }, actions_summary: [ { id: 2, count: 1, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: true, admin: true, @@ -841,7 +1066,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 3660, @@ -851,7 +1076,7 @@ export default { uploaded_avatar_id: 5253, created_at: "2013-02-07T14:14:12.666Z", cooked: - '\n

repost after a reload thank you!

', + '\n

repost after a reload thank you!

', post_number: 9, post_type: 1, updated_at: "2013-02-07T14:18:09.569Z", @@ -878,44 +1103,44 @@ export default { id: 2, count: 1, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: false, @@ -928,7 +1153,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 3667, @@ -963,51 +1188,51 @@ export default { reply_to_user: { username: "pekka", avatar_template: "/images/avatar.png", - uploaded_avatar_id: 5253 + uploaded_avatar_id: 5253, }, actions_summary: [ { id: 2, count: 1, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: false, @@ -1020,7 +1245,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 3673, @@ -1055,51 +1280,51 @@ export default { reply_to_user: { username: "tms", avatar_template: "/images/avatar.png", - uploaded_avatar_id: 40181 + uploaded_avatar_id: 40181, }, actions_summary: [ { id: 2, count: 1, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: true, admin: true, @@ -1112,7 +1337,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 3675, @@ -1149,44 +1374,44 @@ export default { id: 2, count: 1, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: false, @@ -1199,7 +1424,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 3690, @@ -1236,44 +1461,44 @@ export default { id: 2, count: 3, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: false, @@ -1286,7 +1511,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 3925, @@ -1322,8 +1547,8 @@ export default { internal: false, reflection: false, title: "Easy localization for Rails apps | Locale", - clicks: 69 - } + clicks: 69, + }, ], read: true, user_title: null, @@ -1332,44 +1557,44 @@ export default { id: 2, count: 3, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: false, @@ -1382,7 +1607,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 3938, @@ -1419,44 +1644,44 @@ export default { id: 2, count: 1, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: false, @@ -1469,7 +1694,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 3982, @@ -1506,44 +1731,44 @@ export default { id: 2, count: 1, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: false, @@ -1556,7 +1781,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 3989, @@ -1593,44 +1818,44 @@ export default { id: 2, count: 1, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: false, @@ -1643,7 +1868,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 3996, @@ -1678,51 +1903,51 @@ export default { reply_to_user: { username: "pekka", avatar_template: "/images/avatar.png", - uploaded_avatar_id: 5253 + uploaded_avatar_id: 5253, }, actions_summary: [ { id: 2, count: 7, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: true, admin: true, @@ -1735,7 +1960,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 4009, @@ -1770,51 +1995,51 @@ export default { reply_to_user: { username: "sam", avatar_template: "/images/avatar.png", - uploaded_avatar_id: 5243 + uploaded_avatar_id: 5243, }, actions_summary: [ { id: 2, count: 1, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: false, @@ -1827,7 +2052,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 4012, @@ -1863,8 +2088,8 @@ export default { internal: false, reflection: false, title: "Launchpad Translations", - clicks: 13 - } + clicks: 13, + }, ], read: true, user_title: null, @@ -1873,44 +2098,44 @@ export default { id: 2, count: 1, hidden: false, - can_act: true + can_act: true, }, { id: 3, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 5, count: 0, hidden: true, - can_act: true + can_act: true, }, { id: 6, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: false, @@ -1923,8 +2148,8 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false - } + wiki: false, + }, ], stream: [ 398, @@ -1946,9 +2171,9 @@ export default { 3989, 3996, 4009, - 4012 + 4012, ], - gaps: { before: {}, after: { 398: [4012] } } + gaps: { before: {}, after: { 398: [4012] } }, }, id: 280, title: "Internationalization / localization", @@ -1987,13 +2212,13 @@ export default { id: 255, username: "uwe_keim", uploaded_avatar_id: 5697, - avatar_template: "/images/avatar.png" + avatar_template: "/images/avatar.png", }, last_poster: { id: 14091, username: "Luciano_Fantuzzi", uploaded_avatar_id: 39484, - avatar_template: "/images/avatar.png" + avatar_template: "/images/avatar.png", }, participants: [ { @@ -2001,176 +2226,176 @@ export default { username: "alxndr", uploaded_avatar_id: 5619, avatar_template: "/images/avatar.png", - post_count: 11 + post_count: 11, }, { id: 1, username: "sam", uploaded_avatar_id: 5243, avatar_template: "/images/avatar.png", - post_count: 11 + post_count: 11, }, { id: 7, username: "pekka", uploaded_avatar_id: 5253, avatar_template: "/images/avatar.png", - post_count: 8 + post_count: 8, }, { id: 461, username: "kuba", uploaded_avatar_id: 6049, avatar_template: "/images/avatar.png", - post_count: 7 + post_count: 7, }, { id: 2995, username: "tattoo", uploaded_avatar_id: null, avatar_template: "/images/avatar.png", - post_count: 6 + post_count: 6, }, { id: 2540, username: "jgourdon", uploaded_avatar_id: 9537, avatar_template: "/images/avatar.png", - post_count: 5 + post_count: 5, }, { id: 1860, username: "emk", uploaded_avatar_id: 8400, avatar_template: "/images/avatar.png", - post_count: 4 + post_count: 4, }, { id: 1275, username: "dacap", uploaded_avatar_id: 7401, avatar_template: "/images/avatar.png", - post_count: 4 + post_count: 4, }, { id: 19, username: "eviltrout", uploaded_avatar_id: 5275, avatar_template: "/images/avatar.png", - post_count: 4 + post_count: 4, }, { id: 5, username: "charlie", uploaded_avatar_id: 5275, avatar_template: "/images/avatar.png", - post_count: 1 + post_count: 1, }, { id: 3704, username: "mojzis", uploaded_avatar_id: 31201, avatar_template: "/images/avatar.png", - post_count: 3 + post_count: 3, }, { id: 3190, username: "gururea", uploaded_avatar_id: 10663, avatar_template: "/images/avatar.png", - post_count: 3 + post_count: 3, }, { id: 1895, username: "maciek", uploaded_avatar_id: 8463, avatar_template: "/images/avatar.png", - post_count: 3 + post_count: 3, }, { id: 22, username: "splattne", uploaded_avatar_id: 5280, avatar_template: "/images/avatar.png", - post_count: 2 + post_count: 2, }, { id: 1979, username: "Superuser", uploaded_avatar_id: 8604, avatar_template: "/images/avatar.png", - post_count: 2 + post_count: 2, }, { id: 3818, username: "Tudor", uploaded_avatar_id: 11675, avatar_template: "/images/avatar.png", - post_count: 2 + post_count: 2, }, { id: 32, username: "codinghorror", uploaded_avatar_id: 5297, avatar_template: "/images/avatar.png", - post_count: 2 + post_count: 2, }, { id: 3620, username: "potthast", uploaded_avatar_id: 11363, avatar_template: "/images/avatar.png", - post_count: 2 + post_count: 2, }, { id: 9, username: "tms", uploaded_avatar_id: 40181, avatar_template: "/images/avatar.png", - post_count: 2 + post_count: 2, }, { id: 14091, username: "Luciano_Fantuzzi", uploaded_avatar_id: 39484, avatar_template: "/images/avatar.png", - post_count: 1 + post_count: 1, }, { id: 255, username: "uwe_keim", uploaded_avatar_id: 5697, avatar_template: "/images/avatar.png", - post_count: 1 + post_count: 1, }, { id: 9006, username: "berk", uploaded_avatar_id: 19348, avatar_template: "/images/avatar.png", - post_count: 1 + post_count: 1, }, { id: 754, username: "danneu", uploaded_avatar_id: 6540, avatar_template: "/images/avatar.png", - post_count: 1 + post_count: 1, }, { id: 761, username: "marcoceppi", uploaded_avatar_id: 6552, avatar_template: "/images/avatar.png", - post_count: 1 + post_count: 1, }, { id: 2753, username: "mikl", uploaded_avatar_id: 9918, avatar_template: "/images/avatar.png", - post_count: 1 - } + post_count: 1, + }, ], links: [ { @@ -2182,7 +2407,7 @@ export default { reflection: false, clicks: 118, user_id: 9, - domain: "github.com" + domain: "github.com", }, { url: "http://www.localeapp.com/", @@ -2192,7 +2417,7 @@ export default { reflection: false, clicks: 69, user_id: 1860, - domain: "www.localeapp.com" + domain: "www.localeapp.com", }, { url: @@ -2204,7 +2429,7 @@ export default { reflection: false, clicks: 63, user_id: 7, - domain: "stackoverflow.com" + domain: "stackoverflow.com", }, { url: @@ -2216,7 +2441,7 @@ export default { reflection: false, clicks: 62, user_id: 32, - domain: "github.com" + domain: "github.com", }, { url: "https://github.com/SlexAxton/messageformat.js", @@ -2226,7 +2451,7 @@ export default { reflection: false, clicks: 46, user_id: 1, - domain: "github.com" + domain: "github.com", }, { url: @@ -2237,7 +2462,7 @@ export default { reflection: false, clicks: 25, user_id: 1860, - domain: "www.localeapp.com" + domain: "www.localeapp.com", }, { url: "https://translations.launchpad.net/", @@ -2247,7 +2472,7 @@ export default { reflection: false, clicks: 23, user_id: 761, - domain: "translations.launchpad.net" + domain: "translations.launchpad.net", }, { url: "https://www.transifex.com/", @@ -2257,7 +2482,7 @@ export default { reflection: false, clicks: 22, user_id: 1979, - domain: "www.transifex.com" + domain: "www.transifex.com", }, { url: "https://github.com/berk/tr8n", @@ -2267,7 +2492,7 @@ export default { reflection: false, clicks: 22, user_id: 1, - domain: "github.com" + domain: "github.com", }, { url: "http://translate.wordpress.org/projects/bbpress/dev", @@ -2277,7 +2502,7 @@ export default { reflection: false, clicks: 16, user_id: 7, - domain: "translate.wordpress.org" + domain: "translate.wordpress.org", }, { url: "http://weblate.org", @@ -2287,7 +2512,7 @@ export default { reflection: false, clicks: 15, user_id: 2316, - domain: "weblate.org" + domain: "weblate.org", }, { url: @@ -2299,7 +2524,7 @@ export default { reflection: false, clicks: 14, user_id: 19, - domain: "github.com" + domain: "github.com", }, { url: "https://github.com/discourse/discourse/pull/493", @@ -2310,7 +2535,7 @@ export default { reflection: false, clicks: 12, user_id: 2753, - domain: "github.com" + domain: "github.com", }, { url: "https://github.com/SlexAxton", @@ -2320,7 +2545,7 @@ export default { reflection: false, clicks: 10, user_id: 1, - domain: "github.com" + domain: "github.com", }, { url: @@ -2332,7 +2557,7 @@ export default { reflection: false, clicks: 9, user_id: 3190, - domain: "github.com" + domain: "github.com", }, { url: @@ -2344,7 +2569,7 @@ export default { reflection: false, clicks: 7, user_id: 461, - domain: "github.com" + domain: "github.com", }, { url: "https://github.com/dacap/discourse/tree/spanish", @@ -2354,7 +2579,7 @@ export default { reflection: false, clicks: 7, user_id: 1275, - domain: "github.com" + domain: "github.com", }, { url: @@ -2366,7 +2591,7 @@ export default { reflection: false, clicks: 7, user_id: 461, - domain: "github.com" + domain: "github.com", }, { url: @@ -2378,7 +2603,7 @@ export default { reflection: false, clicks: 6, user_id: 212, - domain: "github.com" + domain: "github.com", }, { url: "http://tr8n.github.com/", @@ -2388,7 +2613,7 @@ export default { reflection: false, clicks: 6, user_id: 212, - domain: "tr8n.github.com" + domain: "tr8n.github.com", }, { url: "http://www.getlocalization.com/", @@ -2399,7 +2624,7 @@ export default { reflection: false, clicks: 6, user_id: 22, - domain: "www.getlocalization.com" + domain: "www.getlocalization.com", }, { url: @@ -2410,7 +2635,7 @@ export default { reflection: false, clicks: 5, user_id: 1995, - domain: "blog.discourse.org" + domain: "blog.discourse.org", }, { url: @@ -2421,7 +2646,7 @@ export default { reflection: false, clicks: 5, user_id: 212, - domain: "github.com" + domain: "github.com", }, { url: "http://translate.sourceforge.net/wiki/virtaal/index", @@ -2431,7 +2656,7 @@ export default { reflection: false, clicks: 4, user_id: 1979, - domain: "translate.sourceforge.net" + domain: "translate.sourceforge.net", }, { url: "https://poeditor.com/", @@ -2441,7 +2666,7 @@ export default { reflection: false, clicks: 4, user_id: 1979, - domain: "poeditor.com" + domain: "poeditor.com", }, { url: "http://en.lichess.org/@/Hellball", @@ -2451,7 +2676,7 @@ export default { reflection: false, clicks: 3, user_id: 1979, - domain: "en.lichess.org" + domain: "en.lichess.org", }, { url: "http://en.wikipedia.org/wiki/T%E2%80%93V_distinction", @@ -2461,7 +2686,7 @@ export default { reflection: false, clicks: 3, user_id: 3620, - domain: "en.wikipedia.org" + domain: "en.wikipedia.org", }, { url: @@ -2472,7 +2697,7 @@ export default { reflection: false, clicks: 3, user_id: 212, - domain: "www.slideshare.net" + domain: "www.slideshare.net", }, { url: "https://meta.discourse.org/t/language-mirrors/2378/2", @@ -2482,7 +2707,7 @@ export default { reflection: true, clicks: 3, user_id: 32, - domain: "meta.discourse.org" + domain: "meta.discourse.org", }, { url: @@ -2494,7 +2719,7 @@ export default { reflection: false, clicks: 3, user_id: 3190, - domain: "www.madanalogy.com" + domain: "www.madanalogy.com", }, { url: "https://github.com/tr8n", @@ -2504,7 +2729,7 @@ export default { reflection: false, clicks: 3, user_id: 9006, - domain: "github.com" + domain: "github.com", }, { url: "http://pootle.locamotion.org/", @@ -2514,7 +2739,7 @@ export default { reflection: false, clicks: 2, user_id: 3190, - domain: "pootle.locamotion.org" + domain: "pootle.locamotion.org", }, { url: "http://www.youtube.com/watch?v=MqqdzJ98q7s", @@ -2525,7 +2750,7 @@ export default { reflection: false, clicks: 2, user_id: 212, - domain: "www.youtube.com" + domain: "www.youtube.com", }, { url: "https://meta.discourse.org/t/translation-workflow/6102", @@ -2535,7 +2760,7 @@ export default { reflection: true, clicks: 2, user_id: 4702, - domain: "meta.discourse.org" + domain: "meta.discourse.org", }, { url: @@ -2546,7 +2771,7 @@ export default { reflection: true, clicks: 2, user_id: 639, - domain: "meta.discourse.org" + domain: "meta.discourse.org", }, { url: "https://tr8nhub.com", @@ -2556,7 +2781,7 @@ export default { reflection: false, clicks: 2, user_id: 9006, - domain: "tr8nhub.com" + domain: "tr8nhub.com", }, { url: "https://meta.discourse.org/t/roadplan-for-discourse/2939/3", @@ -2566,7 +2791,7 @@ export default { reflection: true, clicks: 1, user_id: 2540, - domain: "meta.discourse.org" + domain: "meta.discourse.org", }, { url: "http://sugarjs.com/dates#date_locales", @@ -2576,7 +2801,7 @@ export default { reflection: false, clicks: 1, user_id: 461, - domain: "sugarjs.com" + domain: "sugarjs.com", }, { url: "http://blog.discourse.org/2013/03/localizing-discourse/", @@ -2586,7 +2811,7 @@ export default { reflection: false, clicks: 1, user_id: 893, - domain: "blog.discourse.org" + domain: "blog.discourse.org", }, { url: @@ -2597,7 +2822,7 @@ export default { reflection: false, clicks: 1, user_id: 461, - domain: "github.com" + domain: "github.com", }, { url: "http://transifex.com/projects/p/discourse-pt-br/", @@ -2607,7 +2832,7 @@ export default { reflection: false, clicks: 1, user_id: 893, - domain: "transifex.com" + domain: "transifex.com", }, { url: "https://github.com/discourse/discourse/issues/279", @@ -2617,7 +2842,7 @@ export default { reflection: false, clicks: 1, user_id: 893, - domain: "github.com" + domain: "github.com", }, { url: @@ -2629,7 +2854,7 @@ export default { reflection: true, clicks: 1, user_id: 3417, - domain: "meta.discourse.org" + domain: "meta.discourse.org", }, { url: "https://meta.discourse.org/t/translation-workflow/6102/6", @@ -2639,7 +2864,7 @@ export default { reflection: false, clicks: 0, user_id: 1995, - domain: "meta.discourse.org" + domain: "meta.discourse.org", }, { url: @@ -2651,7 +2876,7 @@ export default { reflection: true, clicks: 0, user_id: 3681, - domain: "meta.discourse.org" + domain: "meta.discourse.org", }, { url: @@ -2663,7 +2888,7 @@ export default { reflection: false, clicks: 0, user_id: 2, - domain: "github.com" + domain: "github.com", }, { url: @@ -2674,7 +2899,7 @@ export default { reflection: true, clicks: 0, user_id: 1, - domain: "meta.discourse.org" + domain: "meta.discourse.org", }, { url: @@ -2685,7 +2910,7 @@ export default { reflection: true, clicks: 0, user_id: 5372, - domain: "meta.discourse.org" + domain: "meta.discourse.org", }, { url: @@ -2697,7 +2922,7 @@ export default { reflection: false, clicks: 0, user_id: 2, - domain: "github.com" + domain: "github.com", }, { url: "https://meta.discourse.org/t/roadplan-for-discourse/2939/5", @@ -2707,7 +2932,7 @@ export default { reflection: true, clicks: 0, user_id: 32, - domain: "meta.discourse.org" + domain: "meta.discourse.org", }, { url: @@ -2718,7 +2943,7 @@ export default { reflection: true, clicks: 0, user_id: 2, - domain: "meta.discourse.org" + domain: "meta.discourse.org", }, { url: "http://guides.rubyonrails.org/i18n.html#the-public-i18n-api", @@ -2728,7 +2953,7 @@ export default { reflection: false, clicks: 0, user_id: 1895, - domain: "guides.rubyonrails.org" + domain: "guides.rubyonrails.org", }, { url: "https://meta.discourse.org/t/hi-support-chinese/4393/6", @@ -2738,7 +2963,7 @@ export default { reflection: true, clicks: 0, user_id: 2014, - domain: "meta.discourse.org" + domain: "meta.discourse.org", }, { url: @@ -2749,8 +2974,8 @@ export default { reflection: false, clicks: 0, user_id: 6626, - domain: "meta.discourse.org" - } + domain: "meta.discourse.org", + }, ], notification_level: 2, notifications_reason_id: 4, @@ -2762,7 +2987,7 @@ export default { can_invite_to: true, can_create_post: true, can_reply_as_new_topic: true, - can_flag_topic: true + can_flag_topic: true, }, highest_post_number: 10, last_read_post_number: 10, @@ -2771,7 +2996,7 @@ export default { 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 } + { id: 8, count: 0, hidden: false, can_act: true }, ], chunk_size: 20, bookmarked: false, @@ -2812,10 +3037,10 @@ export default { user: { id: 1, username: "test", - avatar_template: "/images/avatar.png" - } - } - ] + avatar_template: "/images/avatar.png", + }, + }, + ], }, { id: 27343, @@ -2856,10 +3081,10 @@ export default { user: { id: 1, username: "test", - avatar_template: "/images/avatar.png" - } - } - ] + avatar_template: "/images/avatar.png", + }, + }, + ], }, { id: 27346, @@ -2896,10 +3121,10 @@ export default { user: { id: 1, username: "test", - avatar_template: "/images/avatar.png" - } - } - ] + avatar_template: "/images/avatar.png", + }, + }, + ], }, { id: 19670, @@ -2937,10 +3162,10 @@ export default { user: { id: 1, username: "test", - avatar_template: "/images/avatar.png" - } - } - ] + avatar_template: "/images/avatar.png", + }, + }, + ], }, { id: 7512, @@ -2981,10 +3206,10 @@ export default { user: { id: 1, username: "test", - avatar_template: "/images/avatar.png" - } - } - ] + avatar_template: "/images/avatar.png", + }, + }, + ], }, { id: 25480, @@ -3018,10 +3243,10 @@ export default { user: { id: 1, username: "test", - avatar_template: "/images/avatar.png" - } - } - ] + avatar_template: "/images/avatar.png", + }, + }, + ], }, { id: 26576, @@ -3060,13 +3285,13 @@ export default { user: { id: 1, username: "test", - avatar_template: "/images/avatar.png" - } - } - ] - } + avatar_template: "/images/avatar.png", + }, + }, + ], + }, ], - tags: null + tags: null, }, "/t/28830/1.json": { post_stream: { @@ -3106,8 +3331,8 @@ export default { internal: true, reflection: false, title: "Post reply on different topic no longer works", - clicks: 6 - } + clicks: 6, + }, ], read: true, user_title: "Contributor", @@ -3118,7 +3343,7 @@ export default { { id: 5, count: 0, hidden: true, can_act: false }, { id: 6, count: 0, hidden: false, can_act: false }, { id: 7, count: 0, hidden: false, can_act: false }, - { id: 8, count: 0, hidden: false, can_act: false } + { id: 8, count: 0, hidden: false, can_act: false }, ], moderator: false, admin: false, @@ -3131,7 +3356,7 @@ export default { user_deleted: false, edit_reason: "", can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 118597, @@ -3170,7 +3395,7 @@ export default { { id: 5, count: 0, hidden: true, can_act: false }, { id: 6, count: 0, hidden: false, can_act: false }, { id: 7, count: 0, hidden: false, can_act: false }, - { id: 8, count: 0, hidden: false, can_act: false } + { id: 8, count: 0, hidden: false, can_act: false }, ], moderator: false, admin: false, @@ -3183,7 +3408,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 118601, @@ -3222,7 +3447,7 @@ export default { { id: 5, count: 0, hidden: true, can_act: false }, { id: 6, count: 0, hidden: false, can_act: false }, { id: 7, count: 0, hidden: false, can_act: false }, - { id: 8, count: 0, hidden: false, can_act: false } + { id: 8, count: 0, hidden: false, can_act: false }, ], moderator: false, admin: false, @@ -3235,7 +3460,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 118606, @@ -3274,7 +3499,7 @@ export default { { id: 5, count: 0, hidden: true, can_act: false }, { id: 6, count: 0, hidden: false, can_act: false }, { id: 7, count: 0, hidden: false, can_act: false }, - { id: 8, count: 0, hidden: false, can_act: false } + { id: 8, count: 0, hidden: false, can_act: false }, ], moderator: true, admin: true, @@ -3287,7 +3512,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 118612, @@ -3326,7 +3551,7 @@ export default { { id: 5, count: 0, hidden: true, can_act: false }, { id: 6, count: 0, hidden: false, can_act: false }, { id: 7, count: 0, hidden: false, can_act: false }, - { id: 8, count: 0, hidden: false, can_act: false } + { id: 8, count: 0, hidden: false, can_act: false }, ], moderator: false, admin: false, @@ -3339,10 +3564,10 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false - } + wiki: false, + }, ], - stream: [118591, 118597, 118601, 118606, 118612] + stream: [118591, 118597, 118601, 118606, 118612], }, id: 28830, title: "1.3.0beta9: No rate-limit popups", @@ -3378,13 +3603,13 @@ export default { id: 14169, username: "RaceProUK", uploaded_avatar_id: 40071, - avatar_template: "/images/avatar.png" + avatar_template: "/images/avatar.png", }, last_poster: { id: 10886, username: "Onyx", uploaded_avatar_id: 33015, - avatar_template: "/images/avatar.png" + avatar_template: "/images/avatar.png", }, participants: [ { @@ -3392,36 +3617,36 @@ export default { username: "Yuun", uploaded_avatar_id: null, avatar_template: "/images/avatar.png", - post_count: 1 + post_count: 1, }, { id: 10886, username: "Onyx", uploaded_avatar_id: 33015, avatar_template: "/images/avatar.png", - post_count: 1 + post_count: 1, }, { id: 14169, username: "RaceProUK", uploaded_avatar_id: 40071, avatar_template: "/images/avatar.png", - post_count: 1 + post_count: 1, }, { id: 6626, username: "riking", uploaded_avatar_id: 40212, avatar_template: "/images/avatar.png", - post_count: 1 + post_count: 1, }, { id: 32, username: "codinghorror", uploaded_avatar_id: 5297, avatar_template: "/images/avatar.png", - post_count: 1 - } + post_count: 1, + }, ], suggested_topics: [ { @@ -3449,7 +3674,7 @@ export default { archetype: "regular", like_count: 3, views: 361, - category_id: 1 + category_id: 1, }, { id: 14213, @@ -3478,7 +3703,7 @@ export default { archetype: "regular", like_count: 0, views: 156, - category_id: 1 + category_id: 1, }, { id: 22544, @@ -3504,7 +3729,7 @@ export default { archetype: "regular", like_count: 18, views: 192, - category_id: 1 + category_id: 1, }, { id: 27670, @@ -3530,7 +3755,7 @@ export default { archetype: "regular", like_count: 1, views: 85, - category_id: 1 + category_id: 1, }, { id: 26628, @@ -3556,7 +3781,7 @@ export default { archetype: "regular", like_count: 1, views: 247, - category_id: 1 + category_id: 1, }, { id: 18027, @@ -3582,7 +3807,7 @@ export default { archetype: "regular", like_count: 1, views: 165, - category_id: 1 + category_id: 1, }, { id: 17396, @@ -3609,8 +3834,8 @@ export default { archetype: "regular", like_count: 7, views: 542, - category_id: 1 - } + category_id: 1, + }, ], links: [ { @@ -3622,22 +3847,22 @@ export default { reflection: false, clicks: 6, user_id: 14169, - domain: "meta.discourse.org" - } + domain: "meta.discourse.org", + }, ], notification_level: 1, - can_flag_topic: false + can_flag_topic: false, }, highest_post_number: 5, deleted_by: null, actions_summary: [ { id: 4, count: 0, hidden: false, can_act: false }, { id: 7, count: 0, hidden: false, can_act: false }, - { id: 8, count: 0, hidden: false, can_act: false } + { id: 8, count: 0, hidden: false, can_act: false }, ], chunk_size: 20, bookmarked: null, - tags: null + tags: null, }, "/t/9/1.json": { post_stream: { @@ -3675,7 +3900,7 @@ export default { { id: 4, can_act: true }, { id: 5, hidden: true, can_act: true }, { id: 7, can_act: true }, - { id: 8, can_act: true } + { id: 8, can_act: true }, ], moderator: false, admin: true, @@ -3688,7 +3913,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 19, @@ -3723,7 +3948,7 @@ export default { { id: 4, can_act: true }, { id: 5, hidden: true, can_act: true }, { id: 7, can_act: true }, - { id: 8, can_act: true } + { id: 8, can_act: true }, ], moderator: false, admin: true, @@ -3736,7 +3961,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 20, @@ -3771,7 +3996,7 @@ export default { { id: 4, can_act: true }, { id: 5, hidden: true, can_act: true }, { id: 7, can_act: true }, - { id: 8, can_act: true } + { id: 8, can_act: true }, ], moderator: false, admin: true, @@ -3784,10 +4009,10 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false - } + wiki: false, + }, ], - stream: [18, 19, 20] + stream: [18, 19, 20], }, id: 9, title: "This is a test topic!", @@ -3826,13 +4051,13 @@ export default { id: 1, username: "tgxworld", uploaded_avatar_id: 9, - avatar_template: "/images/avatar.png" + avatar_template: "/images/avatar.png", }, last_poster: { id: 1, username: "tgxworld", uploaded_avatar_id: 9, - avatar_template: "/images/avatar.png" + avatar_template: "/images/avatar.png", }, participants: [ { @@ -3840,8 +4065,8 @@ export default { username: "tgxworld", uploaded_avatar_id: 9, avatar_template: "/images/avatar.png", - post_count: 3 - } + post_count: 3, + }, ], suggested_topics: [ { @@ -3872,7 +4097,7 @@ export default { archetype: "regular", like_count: 0, views: 2, - category_id: 1 + category_id: 1, }, { id: 7, @@ -3902,8 +4127,8 @@ export default { archetype: "regular", like_count: 0, views: 2, - category_id: 1 - } + category_id: 1, + }, ], notification_level: 3, notifications_reason_id: 1, @@ -3915,7 +4140,7 @@ export default { can_invite_to: true, can_create_post: true, can_reply_as_new_topic: true, - can_flag_topic: true + can_flag_topic: true, }, highest_post_number: 3, last_read_post_number: 3, @@ -3924,11 +4149,11 @@ export default { 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 } + { id: 8, count: 0, hidden: false, can_act: true }, ], chunk_size: 20, bookmarked: false, - destination_category_id: 3 + destination_category_id: 3, }, "/t/12/1.json": { suggested_topics: [ @@ -3968,11 +4193,11 @@ export default { user: { id: 1, username: "test", - avatar_template: "/images/avatar.png" - } - } - ] - } + avatar_template: "/images/avatar.png", + }, + }, + ], + }, ], post_stream: { posts: [ @@ -4012,7 +4237,7 @@ export default { { id: 4, can_act: true }, { id: 5, hidden: true, can_act: true }, { id: 7, can_act: true }, - { id: 8, can_act: true } + { id: 8, can_act: true }, ], moderator: false, admin: true, @@ -4026,7 +4251,7 @@ export default { edit_reason: null, can_view_edit_history: true, wiki: false, - can_translate: false + can_translate: false, }, { id: 16, @@ -4064,7 +4289,7 @@ export default { { id: 4, can_act: true }, { id: 5, hidden: true, can_act: true }, { id: 7, can_act: true }, - { id: 8, can_act: true } + { id: 8, can_act: true }, ], moderator: false, admin: true, @@ -4080,10 +4305,10 @@ export default { wiki: false, action_code: "invited_group", action_code_who: "Group", - can_translate: false - } + can_translate: false, + }, ], - stream: [15, 16] + stream: [15, 16], }, timeline_lookup: [[1, 0]], id: 12, @@ -4122,12 +4347,12 @@ export default { created_by: { id: 1, username: "test", - avatar_template: "/images/avatar.png" + avatar_template: "/images/avatar.png", }, last_poster: { id: 1, username: "test", - avatar_template: "/images/avatar.png" + avatar_template: "/images/avatar.png", }, allowed_groups: [ { @@ -4150,12 +4375,12 @@ export default { bio_cooked: null, public: false, allow_membership_requests: false, - full_name: null - } + full_name: null, + }, ], allowed_users: [ { id: 2, username: "someguy", avatar_template: "/images/avatar.png" }, - { id: 1, username: "test", avatar_template: "/images/avatar.png" } + { id: 1, username: "test", avatar_template: "/images/avatar.png" }, ], participants: [ { @@ -4166,8 +4391,8 @@ export default { primary_group_name: null, primary_group_flair_url: null, primary_group_flair_color: null, - primary_group_flair_bg_color: null - } + primary_group_flair_bg_color: null, + }, ], suggested_topics: [ { @@ -4207,11 +4432,11 @@ export default { user: { id: 1, username: "test", - avatar_template: "/images/avatar.png" - } - } - ] - } + avatar_template: "/images/avatar.png", + }, + }, + ], + }, ], notification_level: 3, notifications_reason_id: 1, @@ -4223,7 +4448,7 @@ export default { can_invite_to: true, can_create_post: true, can_reply_as_new_topic: true, - can_flag_topic: true + can_flag_topic: true, }, highest_post_number: 2, last_read_post_number: 2, @@ -4233,12 +4458,12 @@ export default { 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 } + { id: 8, count: 0, hidden: false, can_act: true }, ], chunk_size: 20, bookmarked: false, message_archived: false, - featured_link: null + featured_link: null, }, "/t/299/1.json": { post_stream: { @@ -4276,7 +4501,7 @@ export default { { id: 4, can_act: true }, { id: 5, hidden: true, can_act: true }, { id: 7, can_act: true }, - { id: 8, can_act: true } + { id: 8, can_act: true }, ], moderator: false, admin: true, @@ -4289,7 +4514,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 19, @@ -4324,7 +4549,7 @@ export default { { id: 4, can_act: true }, { id: 5, hidden: true, can_act: true }, { id: 7, can_act: true }, - { id: 8, can_act: true } + { id: 8, can_act: true }, ], moderator: false, admin: true, @@ -4337,7 +4562,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 20, @@ -4372,7 +4597,7 @@ export default { { id: 4, can_act: true }, { id: 5, hidden: true, can_act: true }, { id: 7, can_act: true }, - { id: 8, can_act: true } + { id: 8, can_act: true }, ], moderator: false, admin: true, @@ -4385,10 +4610,10 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false - } + wiki: false, + }, ], - stream: [18, 19, 20] + stream: [18, 19, 20], }, id: 299, title: "Look at this link", @@ -4428,13 +4653,13 @@ export default { id: 1, username: "tgxworld", uploaded_avatar_id: 9, - avatar_template: "/images/avatar.png" + avatar_template: "/images/avatar.png", }, last_poster: { id: 1, username: "tgxworld", uploaded_avatar_id: 9, - avatar_template: "/images/avatar.png" + avatar_template: "/images/avatar.png", }, participants: [ { @@ -4442,8 +4667,8 @@ export default { username: "tgxworld", uploaded_avatar_id: 9, avatar_template: "/images/avatar.png", - post_count: 3 - } + post_count: 3, + }, ], suggested_topics: [ { @@ -4474,7 +4699,7 @@ export default { archetype: "regular", like_count: 0, views: 2, - category_id: 1 + category_id: 1, }, { id: 7, @@ -4504,8 +4729,8 @@ export default { archetype: "regular", like_count: 0, views: 2, - category_id: 1 - } + category_id: 1, + }, ], notification_level: 3, notifications_reason_id: 1, @@ -4517,7 +4742,7 @@ export default { can_invite_to: true, can_create_post: true, can_reply_as_new_topic: true, - can_flag_topic: true + can_flag_topic: true, }, highest_post_number: 3, last_read_post_number: 3, @@ -4526,10 +4751,10 @@ export default { 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 } + { id: 8, count: 0, hidden: false, can_act: true }, ], chunk_size: 20, - bookmarked: false + bookmarked: false, }, "/t/301/1.json": { post_stream: { @@ -4568,7 +4793,7 @@ export default { { id: 4, can_act: true }, { id: 5, hidden: true, can_act: true }, { id: 7, can_act: true }, - { id: 8, can_act: true } + { id: 8, can_act: true }, ], moderator: false, admin: true, @@ -4581,7 +4806,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 19, @@ -4616,7 +4841,7 @@ export default { { id: 4, can_act: true }, { id: 5, hidden: true, can_act: true }, { id: 7, can_act: true }, - { id: 8, can_act: true } + { id: 8, can_act: true }, ], moderator: false, admin: true, @@ -4629,7 +4854,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 20, @@ -4664,7 +4889,7 @@ export default { { id: 4, can_act: true }, { id: 5, hidden: true, can_act: true }, { id: 7, can_act: true }, - { id: 8, can_act: true } + { id: 8, can_act: true }, ], moderator: false, admin: true, @@ -4677,10 +4902,10 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false - } + wiki: false, + }, ], - stream: [18, 19, 20] + stream: [18, 19, 20], }, id: 299, title: "Look at this link", @@ -4720,13 +4945,13 @@ export default { id: 1, username: "tgxworld", uploaded_avatar_id: 9, - avatar_template: "/images/avatar.png" + avatar_template: "/images/avatar.png", }, last_poster: { id: 1, username: "tgxworld", uploaded_avatar_id: 9, - avatar_template: "/images/avatar.png" + avatar_template: "/images/avatar.png", }, participants: [ { @@ -4734,8 +4959,8 @@ export default { username: "tgxworld", uploaded_avatar_id: 9, avatar_template: "/images/avatar.png", - post_count: 3 - } + post_count: 3, + }, ], suggested_topics: [ { @@ -4766,7 +4991,7 @@ export default { archetype: "regular", like_count: 0, views: 2, - category_id: 1 + category_id: 1, }, { id: 7, @@ -4796,8 +5021,8 @@ export default { archetype: "regular", like_count: 0, views: 2, - category_id: 1 - } + category_id: 1, + }, ], notification_level: 3, notifications_reason_id: 1, @@ -4809,7 +5034,7 @@ export default { can_invite_to: true, can_create_post: true, can_reply_as_new_topic: true, - can_flag_topic: true + can_flag_topic: true, }, highest_post_number: 3, last_read_post_number: 3, @@ -4818,10 +5043,10 @@ export default { 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 } + { id: 8, count: 0, hidden: false, can_act: true }, ], chunk_size: 20, - bookmarked: false + bookmarked: false, }, "/t/34/1.json": { post_stream: { @@ -4861,20 +5086,20 @@ export default { actions_summary: [ { id: 3, - can_act: true + can_act: true, }, { id: 4, - can_act: true + can_act: true, }, { id: 8, - can_act: true + can_act: true, }, { id: 7, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: true, @@ -4886,7 +5111,7 @@ export default { user_deleted: false, edit_reason: null, can_view_edit_history: true, - wiki: false + wiki: false, }, { id: 419, @@ -4923,20 +5148,20 @@ export default { actions_summary: [ { id: 3, - can_act: true + can_act: true, }, { id: 4, - can_act: true + can_act: true, }, { id: 8, - can_act: true + can_act: true, }, { id: 7, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: false, @@ -4949,10 +5174,10 @@ export default { edit_reason: null, can_view_edit_history: true, wiki: false, - notice_type: "new-user" - } + notice_type: "new-user", + }, ], - stream: [25, 26, 27] + stream: [25, 26, 27], }, timeline_lookup: [[1, 0]], id: 34, @@ -4990,13 +5215,13 @@ export default { id: 1, username: "tim.lange", name: null, - avatar_template: "/images/avatar.png" + avatar_template: "/images/avatar.png", }, last_poster: { id: 2, username: "vox", name: "Tim Lange", - avatar_template: "/images/avatar.png" + avatar_template: "/images/avatar.png", }, allowed_groups: [], allowed_users: [ @@ -5004,14 +5229,14 @@ export default { id: 2, username: "vox", name: "Tim Lange", - avatar_template: "/images/avatar.png" + avatar_template: "/images/avatar.png", }, { id: 1, username: "tim.lange", name: null, - avatar_template: "/images/avatar.png" - } + avatar_template: "/images/avatar.png", + }, ], participants: [ { @@ -5023,7 +5248,7 @@ export default { primary_group_name: null, primary_group_flair_url: null, primary_group_flair_color: null, - primary_group_flair_bg_color: null + primary_group_flair_bg_color: null, }, { id: 2, @@ -5034,8 +5259,8 @@ export default { primary_group_name: null, primary_group_flair_url: null, primary_group_flair_color: null, - primary_group_flair_bg_color: null - } + primary_group_flair_bg_color: null, + }, ], notification_level: 3, notifications_reason_id: 1, @@ -5049,7 +5274,7 @@ export default { can_create_post: true, can_reply_as_new_topic: true, can_flag_topic: true, - can_convert_topic: true + can_convert_topic: true, }, current_post_number: 1, highest_post_number: 3, @@ -5063,9 +5288,9 @@ export default { id: 8, count: 0, hidden: false, - can_act: true + can_act: true, }, - { id: 7, count: 0, hidden: false, can_act: true } + { id: 7, count: 0, hidden: false, can_act: true }, ], chunk_size: 20, bookmarked: false, @@ -5073,7 +5298,7 @@ export default { topic_timer: null, message_bus_last_id: 7, participant_count: 2, - pm_with_non_human_user: false + pm_with_non_human_user: false, }, "/t/2480/1.json": { post_stream: { @@ -5116,20 +5341,20 @@ export default { actions_summary: [ { id: 3, - can_act: true + can_act: true, }, { id: 4, - can_act: true + can_act: true, }, { id: 8, - can_act: true + can_act: true, }, { id: 7, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: false, @@ -5145,7 +5370,7 @@ export default { wiki: false, reviewable_id: 0, reviewable_score_count: 0, - reviewable_score_pending_count: 0 + reviewable_score_pending_count: 0, }, { id: 42, @@ -5183,28 +5408,28 @@ export default { actions_summary: [ { id: 2, - can_act: true + can_act: true, }, { id: 3, - can_act: true + can_act: true, }, { id: 4, - can_act: true + can_act: true, }, { id: 8, - can_act: true + can_act: true, }, { id: 6, - can_act: true + can_act: true, }, { id: 7, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: false, @@ -5219,7 +5444,7 @@ export default { wiki: false, reviewable_id: 0, reviewable_score_count: 0, - reviewable_score_pending_count: 0 + reviewable_score_pending_count: 0, }, { id: 43, @@ -5258,20 +5483,20 @@ export default { actions_summary: [ { id: 3, - can_act: true + can_act: true, }, { id: 4, - can_act: true + can_act: true, }, { id: 8, - can_act: true + can_act: true, }, { id: 7, - can_act: true - } + can_act: true, + }, ], moderator: false, admin: false, @@ -5287,10 +5512,10 @@ export default { wiki: false, reviewable_id: 0, reviewable_score_count: 0, - reviewable_score_pending_count: 0 - } + reviewable_score_pending_count: 0, + }, ], - stream: [41, 42, 43] + stream: [41, 42, 43], }, timeline_lookup: [[1, 0]], id: 2480, @@ -5333,20 +5558,20 @@ export default { id: 4, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 8, count: 0, hidden: false, - can_act: true + can_act: true, }, { id: 7, count: 0, hidden: false, - can_act: true - } + can_act: true, + }, ], chunk_size: 20, bookmarked: false, @@ -5378,7 +5603,7 @@ export default { primary_group_name: "group_moderators", primary_group_flair_url: "cheese", primary_group_flair_color: "", - primary_group_flair_bg_color: "ff0" + primary_group_flair_bg_color: "ff0", }, { id: 2, @@ -5389,21 +5614,21 @@ export default { primary_group_name: null, primary_group_flair_url: null, primary_group_flair_color: null, - primary_group_flair_bg_color: null - } + primary_group_flair_bg_color: null, + }, ], created_by: { id: 3, username: "group_moderator", name: "", - avatar_template: "/images/avatar.png" + avatar_template: "/images/avatar.png", }, last_poster: { id: 3, username: "group_moderator", name: "", - avatar_template: "/images/avatar.png" - } - } - } + avatar_template: "/images/avatar.png", + }, + }, + }, }; diff --git a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js index 20bdba43c69..d1258fd712a 100644 --- a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js +++ b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js @@ -170,6 +170,7 @@ export function acceptance(name, optionsOrCallback) { let loggedIn = false; let siteChanges; let settingChanges; + let userChanges; const setup = { beforeEach() { @@ -185,6 +186,9 @@ export function acceptance(name, optionsOrCallback) { if (loggedIn) { logIn(); + if (userChanges) { + updateCurrentUser(userChanges); + } } if (settingChanges) { @@ -249,8 +253,9 @@ export function acceptance(name, optionsOrCallback) { }; const needs = { - user() { + user(changes) { loggedIn = true; + userChanges = changes; }, pretender(fn) { addPretenderCallback(name, fn);