'Scenario: Static links are rewritten when previewing a course update
Given I have opened a new course in Studio
And I go to the course updates page
When I add a new update with the text "<img src=\'/static/my_img.jpg\'/>"
# Can only do partial text matches because of the quotes with in quotes (and regexp step matching).
Then I should see the asset update to "my_img.jpg"
And I change the update from "/static/my_img.jpg" to "<img src=\'/static/modified.jpg\'/>"
Then I should see the asset update to "modified.jpg"
And when I reload the page
Then I should see the asset update to "modified.jpg"'

def test_asset_change_in_updates(self):

    self.course_updates_page.visit()
    self.assertTrue(self.course_updates_page.is_new_update_button_present())
    self.course_updates_page.click_new_update_button()
    self.course_updates_page.submit_update("<img    src='/static/my_img.jpg'/>")
    self.assertTrue(self.course_updates_page.first_update_contains_html('my_img.jpg'))
    self.course_updates_page.click_edit_update_button()
    self.course_updates_page.submit_update("<img    src='/static/modified.jpg'/>")
    self.assertFalse(self.course_updates_page.first_update_contains_html('my_img.jpg'))
    self.assertTrue(self.course_updates_page.first_update_contains_html('modified.jpg'))
    self.course_updates_page.visit()
    self.assertTrue(self.course_updates_page.first_update_contains_html('modified.jpg'))
