<commit_before># -*- coding: utf-8 -*-
describe "NewPostView", ->
    beforeEach ->
        setFixtures(
            """
            <article class="new-post-article" style="display: block;">
                <div class="inner-wrapper">
                    <form class="new-post-form">
                        <div class="left-column" >
                            <div class="form-topic-drop">
                                <a href="#" aria-labelledby="topic-dropdown-label" class="topic_dropdown_button">… / TA Feedba …
                                    <span class="drop-arrow">▾</span></a>

                                <div class="topic_menu_wrapper">
                                    <ul class="topic_menu" role="menu">
                                        <li role="menuitem">
                                            <a href="#"><span class="category-menu-span">Basic Question Types</span></a>
                                            <ul role="menu">
                                                <li role="menuitem"><a href="#" class="topic"
                                                                       data-discussion_id="a22e81688d154e059f9a2012a26b27af"
                                                                       aria-describedby="topic-name-span-a22e81688d154e059f9a2012a26b27af"
                                                                       cohorted="False">Selection from Options</a></li>
                                            </ul>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </article>
            """
        )
        window.$$course_id = "edX/999/test"
        spyOn(DiscussionUtil, "makeWmdEditor")
        @discussion = new Discussion([], {pages: 1})
        @view = new NewPostView(
          el: $(".new-post-article"),
          collection: @discussion,
        )
        @parent_category_text = @view.$el.find( "ul.topic_menu li[role='menuitem'] > a" )[0].text
        @selected_option_text = @view.$el.find( "ul.topic_menu li[role='menuitem'] > a" )[1].text

    describe "Drop down works correct", ->

      it "completely show parent category and sub-category", ->
        complete_text = @parent_category_text + " / " + @selected_option_text
        selected_text_width = @view.getNameWidth(complete_text)
        @view.maxNameWidth = selected_text_width + 1
        @view.$el.find( "ul.topic_menu li[role='menuitem'] > a" )[1].click()
        dropdown_text = @view.$el.find(".form-topic-drop > a").text()
        expect(complete_text+' ▾').toEqual(dropdown_text)

      it "completely show just sub-category", ->
        complete_text = @parent_category_text + " / " + @selected_option_text
        selected_text_width = @view.getNameWidth(complete_text)
        @view.maxNameWidth = selected_text_width - 10
        @view.$el.find( "ul.topic_menu li[role='menuitem'] > a" )[1].click()
        dropdown_text = @view.$el.find(".form-topic-drop > a").text()<commit_msg>update NewPostViewSpec to correctly initialize NewPostView<commit_after># -*- coding: utf-8 -*-
describe "NewPostView", ->
    beforeEach ->
        setFixtures(
            """
            <article class="new-post-article" style="display: block;">
                <div class="inner-wrapper">
                    <form class="new-post-form">
                        <div class="left-column" >
                        </div>
                    </form>
                </div>
            </article>

            <script aria-hidden="true" type="text/template" id="new-post-tab-template">
                <div class="inner-wrapper">
                    <form class="new-post-form">
                        <div class="left-column">
                            '<%= topic_dropdown_html %>
                            '<%= options_html %>'
                        </div>
                    </form>
                </div>
            </script>

            <script aria-hidden="true" type="text/template" id="new-post-menu-entry-template">
                <li role="menuitem"><a href="#" class="topic" data-discussion_id="<%- id %>" aria-describedby="topic-name-span-<%- id %>" cohorted="<%- is_cohorted %>"><%- text %></a></li>
            </script>

            <script aria-hidden="true" type="text/template" id="new-post-menu-category-template">
                <li role="menuitem">
                    <a href="#"><span class="category-menu-span"><%- text %></span></a>
                    <ul role="menu"><%= entries %></ul>
                </li>
            </script>

            <script aria-hidden="true" type="text/template" id="new-post-topic-dropdown-template">
                <span class="topic-dropdown-label" id="topic-dropdown-label">Create new post about:</span>
                <div class="form-topic-drop">
                    <a href="#" aria-labelledby="topic-dropdown-label" class="topic_dropdown_button">${_("Show All Discussions")}<span class="drop-arrow" aria-hidden="true">▾</span></a>
                    <div class="topic_menu_wrapper">
                        <div class="topic_menu_search" role="menu">
                            <label class="sr" for="browse-topic-newpost">Filter List</label>
                            <input type="text" id="browse-topic-newpost" class="form-topic-drop-search-input" placeholder="Filter discussion areas">
                        </div>
                        <ul class="topic_menu" role="menu"><%= topics_html %></ul>
                    </div>
                </div>
            </script>

            <script aria-hidden="true" type="text/template" id="new-post-options-template">
                <div class="options">
                    <input type="checkbox" name="follow" class="discussion-follow" id="new-post-follow" checked><label for="new-post-follow">follow this post</label>
                    <% if (allow_anonymous) { %>
                    <br>
                    <input type="checkbox" name="anonymous" class="discussion-anonymous" id="new-post-anonymous">
                    <label for="new-post-anonymous">post anonymously</label>
                    <% } %>
                    <% if (allow_anonymous_to_peers) { %>
                    <br>
                    <input type="checkbox" name="anonymous_to_peers" class="discussion-anonymous-to-peers" id="new-post-anonymous-to-peers">
                    <label for="new-post-anonymous-to-peers">post anonymously to classmates</label>
                    <% } %>
                    <% if (cohort_options) { %>
                    <div class="form-group-label choose-cohort">
                        ## Translators: This labels the selector for which group of students can view a post
                        Make visible to:
                        <select class="group-filter-select new-post-group" name="group_id">
                            <option value="">All Groups</option>
                            <% _.each(cohort_options, function(opt) { %>
                                <option value="<%= opt.value %>" <% if (opt.selected) { %>selected<% } %>><%- opt.text %></option>
                            <% }); %>
                        </select>
                    </div>
                    <% } %>
                </div>
            </script>

            <script aria-hidden="true" type="text/template" id="new-post-editor-template">
                <div class="form-row">
                    <label class="sr" for="new-post-title">new post title</label>
                    <input type="text" id="new-post-title" class="new-post-title" name="title" placeholder="Title">
                </div>
                <div class="form-row">
                    <div class="new-post-body" name="body" placeholder="Enter your question or comment…"></div>
                </div>
                <input type="submit" id="new-post-submit" class="submit" value="Add post">
                <a href="#" class="new-post-cancel">Cancel</a>
            </script>
            """
        )
        window.$$course_id = "edX/999/test"
        spyOn(DiscussionUtil, "makeWmdEditor")
        @discussion = new Discussion([], {pages: 1})
        @view = new NewPostView(
          el: $(".new-post-article"),
          collection: @discussion,
          course_settings: new DiscussionCourseSettings({
            "category_map": {
              "subcategories": {
                "Basic Question Types": {
                  "subcategories": {},
                  "children": ["Selection From Options"],
                  "entries": {
                    "Selection From Options": {
                      "sort_key": null,
                      "is_cohorted": true,
                      "id": "cba3e4cd91d0466b9ac50926e495b76f"
                    }
                  },
                },
              },
              "children": ["Basic Question Types"],
              "entries": {}
            },
            "allow_anonymous": true,
            "allow_anonymous_to_peers": true
          }),
          mode: "tab"
        )
        @view.render()
        @parent_category_text = "Basic Question Types"
        @selected_option_text = "Selection From Options"

    describe "Drop down works correct", ->

      it "completely show parent category and sub-category", ->
        complete_text = @parent_category_text + " / " + @selected_option_text
        selected_text_width = @view.getNameWidth(complete_text)
        @view.maxNameWidth = selected_text_width + 1
        @view.$el.find( "ul.topic_menu li[role='menuitem'] > a" )[1].click()
        dropdown_text = @view.$el.find(".form-topic-drop > a").text()
        expect(complete_text+' ▾').toEqual(dropdown_text)

      it "completely show just sub-category", ->
        complete_text = @parent_category_text + " / " + @selected_option_text
        selected_text_width = @view.getNameWidth(complete_text)
        @view.maxNameWidth = selected_text_width - 10
        @view.$el.find( "ul.topic_menu li[role='menuitem'] > a" )[1].click()
        dropdown_text = @view.$el.find(".form-topic-drop > a").text()
{'fraction_non_alphanumeric': 0.14241184492499512, 'fraction_numerical': 0.00827975842587181, 'mean_word_length': 1.5041463414634146, 'pattern_counts': {'":': 14, '<': 142, '<?xml version=': 0, '>': 162, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3750979', 'n_tokens_mistral': 2842, 'n_tokens_neox': 2626, 'n_words': 490}