def test_delete_a_draft_1_0_measure(driver, test_app_editor, live_server, stub_topic_page, stub_subtopic_page, stub_published_measure_page): # GIVEN we create a version 1.0 measure login(driver, live_server, test_app_editor) navigate_to_topic_page(driver, live_server, stub_topic_page) measure = create_measure_with_minimal_content(driver, live_server, stub_subtopic_page, stub_topic_page) # WHEN we go to the topic page topic_page = TopicPage(driver, live_server, stub_topic_page) topic_page.get() topic_page.expand_accordion_for_subtopic(stub_subtopic_page) # THEN measure is listed assert topic_page.measure_is_listed(measure) is True # WHEN we walk through the delete process topic_page.click_delete_button(measure) topic_page.select_yes_radio(measure) topic_page.click_confirm_delete(measure) topic_page.get() assert topic_page.measure_is_listed(measure) is False
def test_delete_a_draft_1_0_measure(driver, live_server): rdu_user = UserFactory(user_type=TypeOfUser.RDU_USER, active=True) measure_version = MeasureVersionFactory(status="APPROVED") assert Measure.query.count() == 1 # GIVEN we create a version 1.0 measure driver_login(driver, live_server, rdu_user) navigate_to_topic_page(driver, live_server, measure_version.measure.subtopic.topic) measure = create_measure_with_minimal_content( driver, live_server, measure_version.measure.subtopic, measure_version.measure.subtopic.topic) assert Measure.query.count() == 2 # WHEN we go to the topic page topic_page = TopicPage(driver, live_server, measure_version.measure.subtopic.topic) topic_page.get() # No longer required; accordion remembers the expanded state from earlier in the test. # topic_page.expand_accordion_for_subtopic(measure_version.measure.subtopic) # THEN measure is listed assert topic_page.measure_is_listed(measure) is True driver.find_element_by_link_text(measure.title).click() # WHEN we walk through the delete process driver.find_element_by_xpath( f"//a[contains(., 'Delete page: {measure.title}')]").click() driver.find_element_by_xpath('//button[text()="Yes, delete"]').click() topic_page.get() # This test has been passing when the final .get() returned a 500 error page. # TODO: Check the page didn't error and is the actual page we expect to not find the thing in # TODO: Maybe assert 200 responses after all get()s in functional tests? assert topic_page.measure_is_listed(measure) is False assert Measure.query.count() == 1