'Scenario: User can join a Team if not a member already..
Given I am enrolled in a course with a team configuration, a topic,
and a team belonging to that topic
And I visit the Team page for that team
Then I should see Join Team button
And I should not see New Post button
When I click on Join Team button
Then there should be no Join Team button and no message
And an analytics event should be emitted
And I should see the updated information under Team Details
And I should see New Post button
And if I switch to "My Team", the team I have joined is displayed'

def test_join_team(self):

    self._set_team_configuration_and_membership(create_membership=False)
    teams_page = BrowseTeamsPage(self.browser, self.course_id, self.topic)
    teams_page.visit()
    teams_page.view_first_team()
    self.assertTrue(self.team_page.join_team_button_present)
    expected_events = [{'event_type': 'edx.team.learner_added', 'event': {'add_method': 'joined_from_team_view'}}]
    with self.assert_events_match_during(event_filter=self.only_team_events, expected_events=expected_events):
        self.team_page.click_join_team_button()
    self.assertFalse(self.team_page.join_team_button_present)
    self.assertFalse(self.team_page.join_team_message_present)
    self.assert_team_details(num_members=1, is_member=True)
    self.teams_page.click_all_topics()
    self.verify_my_team_count(1)
