'Scenario: The user should be able to create new team.
Given I am enrolled in a course with a team configuration and a topic
When I visit the Create Team page for that topic
Then I should see the Create Team header and form
When I fill all the fields present with appropriate data
And I click Create button
Then I expect analytics events to be emitted
And I should see the page for my team
And I should see the message that says "You are member of this team"
And the new team should be added to the list of teams within the topic
And the number of teams should be updated on the topic card
And if I switch to "My Team", the newly created team is displayed'

def test_user_can_create_new_team_successfully(self):

    AutoAuthPage(self.browser, course_id=self.course_id).visit()
    self.browse_teams_page.visit()
    self.verify_and_navigate_to_create_team_page()
    self.fill_create_or_edit_form()
    expected_events = [{'event_type': 'edx.team.created'}, {'event_type': 'edx.team.learner_added', 'event': {'add_method': 'added_on_create'}}]
    with self.assert_events_match_during(event_filter=self.only_team_events, expected_events=expected_events):
        self.team_management_page.submit_form()
    team_page = TeamPage(self.browser, self.course_id)
    team_page.wait_for_page()
    self.assertEqual(team_page.team_name, self.TEAMS_NAME)
    self.assertEqual(team_page.team_description, self.TEAM_DESCRIPTION)
    self.assertEqual(team_page.team_user_membership_text, 'You    are    a    member    of    this    team.')
    self.teams_page.click_specific_topic('Example    Topic')
    self.teams_page.verify_topic_team_count(1)
    self.teams_page.click_all_topics()
    self.teams_page.verify_team_count_in_first_topic(1)
    self.verify_my_team_count(1)
