|
6 | 6 |
|
7 | 7 | @given('that a user fills in the contact form with valid input') |
8 | 8 | def step_impl(context): |
9 | | - context.values = { |
10 | | - "sender_email": "test@example.bike", |
11 | | - "subject": "just saying hello", |
12 | | - "message": "Hi bob, havn't talk in a while. All the Best, --Joe", |
13 | | - } |
| 9 | + context.browser.visit(context.get_url('contact')) |
| 10 | + context.browser.fill('sender_email', 'bob@example.com') |
| 11 | + context.browser.fill('subject', 'just saying hello') |
| 12 | + context.browser.fill('message', 'Hi bob, havn\'t talk in a while. All the Best, --Joe') |
14 | 13 |
|
15 | 14 | @when('the user submits the contact form') |
16 | 15 | def step_impl(context): |
17 | | - context.response = context.test.client.post( |
18 | | - context.get_url('/contact/'), |
19 | | - context.values, |
20 | | - follow=True, |
21 | | - ) |
| 16 | + context.browser.find_by_css('input[type=submit]').first.click() |
22 | 17 |
|
23 | 18 | @then('the contact form is successfully submitted') |
24 | 19 | def step_impl(context): |
25 | | - context.test.assertRedirects(context.response, context.get_url('contact_sent')) |
| 20 | + assert context.browser.url == context.get_url('contact_sent') |
26 | 21 |
|
27 | 22 | @given('that a user fills in the contact form with an invalid email') |
28 | 23 | def step_impl(context): |
29 | | - context.values = { |
30 | | - "sender_email": "", |
31 | | - "subject": "just saying hello", |
32 | | - "message": "Hi bob, havn't talk in a while. All the Best, --Joe", |
33 | | - } |
| 24 | + context.browser.visit(context.get_url('contact')) |
| 25 | + context.browser.fill('subject', 'just saying hello') |
| 26 | + context.browser.fill('message', 'Hi bob, havn\'t talk in a while. All the Best, --Joe') |
34 | 27 |
|
35 | 28 | @then('the contact form is not successfully submitted') |
36 | 29 | def step_impl(context): |
37 | | - for context in context.response.context: |
38 | | - assert context['forms']['user_form'].errors |
| 30 | + assert context.browser.url == context.get_url('contact') |
| 31 | + assert context.browser.is_element_present_by_css('.errorlist') |
0 commit comments