|
| 1 | +Feature: gas4() custom event API |
| 2 | + |
| 3 | + Background: |
| 4 | + Given I load an empty browser |
| 5 | + And DAP is configured for agency "GSA" |
| 6 | + |
| 7 | + Scenario: gas4() sends a virtual page_view event |
| 8 | + When I load the test site |
| 9 | + And I execute script "window.gas4('page_view', {page_location: '/virtual/page', page_title: 'Virtual Page'})" |
| 10 | + Then a "page_view" event is sent to DAP with parameters |
| 11 | + | page_location | http://dap-test-site.local/virtual/page | |
| 12 | + | page_title | Virtual Page | |
| 13 | + |
| 14 | + Scenario: gas4() sends a virtual page_view event setting default page title |
| 15 | + When I load the test site |
| 16 | + And I execute script "window.gas4('page_view', {page_location: '/virtual/page'})" |
| 17 | + Then a "page_view" event is sent to DAP with parameters |
| 18 | + | page_location | http://dap-test-site.local/virtual/page | |
| 19 | + | page_title | DAP test site | |
| 20 | + |
| 21 | + Scenario: gas4() sends a file_download event |
| 22 | + When I load the test site |
| 23 | + And I execute script "window.gas4('file_download', {file_name: '/test.pdf', file_extension: 'pdf', link_text: 'Download Test PDF', link_id: 'download-link', link_url: 'https://example.gov/test.pdf', link_domain: 'example.gov', interaction_type: 'Mouse Click'})" |
| 24 | + Then a "file_download" event is sent to DAP with parameters |
| 25 | + | file_name | /test.pdf | |
| 26 | + | file_extension | pdf | |
| 27 | + | link_text | Download Test PDF | |
| 28 | + | link_id | download-link | |
| 29 | + | link_url | https://example.gov/test.pdf | |
| 30 | + | link_domain | example.gov | |
| 31 | + | interaction_type | Mouse Click | |
| 32 | + |
| 33 | + Scenario: gas4() sends a form_start event |
| 34 | + When I load the test site |
| 35 | + And I execute script "window.gas4('form_start', {form_id: 'contact-form', form_name: 'Contact Form', form_destination: '/thank-you', section: 'body'})" |
| 36 | + Then a "form_start" event is sent to DAP with parameters |
| 37 | + | form_id | contact-form | |
| 38 | + | form_name | Contact Form | |
| 39 | + | form_destination | /thank-you | |
| 40 | + | section | body | |
| 41 | + |
| 42 | + Scenario: gas4() sends a form_progress event |
| 43 | + When I load the test site |
| 44 | + And I execute script "window.gas4('form_progress', {form_id: 'contact-form', percent_scrolled: '50'})" |
| 45 | + Then a "form_progress" event is sent to DAP with parameters |
| 46 | + | form_id | contact-form | |
| 47 | + | percent_scrolled | 50 | |
| 48 | + |
| 49 | + Scenario: gas4() sends a form_submit event |
| 50 | + When I load the test site |
| 51 | + And I execute script "window.gas4('form_submit', {form_step: 3, form_submit_text: 'Submit'})" |
| 52 | + Then a "form_submit" event is sent to DAP with parameters |
| 53 | + | form_step | 3 | |
| 54 | + | form_submit_text | Submit | |
| 55 | + |
| 56 | + Scenario: gas4() sends a content_view event |
| 57 | + When I load the test site |
| 58 | + And I execute script "window.gas4('content_view', {content_type: 'article', content_id: '123'})" |
| 59 | + Then a "content_view" event is sent to DAP with parameters |
| 60 | + | content_type | article | |
| 61 | + | content_id | 123 | |
| 62 | + |
| 63 | + Scenario: gas4() sends a share event |
| 64 | + When I load the test site |
| 65 | + And I execute script "window.gas4('share', {method: 'twitter', content_type: 'page', item_id: '123'})" |
| 66 | + Then a "share" event is sent to DAP with parameters |
| 67 | + | method | twitter | |
| 68 | + | content_type | page | |
| 69 | + | item_id | 123 | |
| 70 | + |
| 71 | + Scenario: gas4() sends a social_click event |
| 72 | + When I load the test site |
| 73 | + And I execute script "window.gas4('social_click', {link_url: 'https://twitter.com', social_network: 'twitter'})" |
| 74 | + Then a "social_click" event is sent to DAP with parameters |
| 75 | + | link_url | https://twitter.com | |
| 76 | + | social_network | twitter | |
| 77 | + |
| 78 | + Scenario: gas4() sends an image_click event |
| 79 | + When I load the test site |
| 80 | + And I execute script "window.gas4('image_click', {link_id: 'hero-image', link_url: '/about'})" |
| 81 | + Then a "image_click" event is sent to DAP with parameters |
| 82 | + | link_id | hero-image | |
| 83 | + | link_url | /about | |
| 84 | + |
| 85 | + Scenario: gas4() sends a cta_click event |
| 86 | + When I load the test site |
| 87 | + And I click on element with selector "::-p-text(Learn More)" |
| 88 | + Then a "cta_click" event is sent to DAP with parameters |
| 89 | + | link_text | <link_text> | |
| 90 | + | link_domain | <link_domain> | |
| 91 | + | link_url | <link_url> | |
| 92 | + | link_id | <link_id> | |
| 93 | + | link_classes | <link_classes> | |
| 94 | + | outbound | <outbound> | |
| 95 | + | section | <section> | |
| 96 | + |
| 97 | + Scenario: gas4() sends a navigation_click event |
| 98 | + When I load the test site |
| 99 | + And I click on element with selector "a[href='#home']" |
| 100 | + Then a "navigation_click" event is sent to DAP with parameters |
| 101 | + | link_text | <link_text> | |
| 102 | + | link_domain | <link_domain> | |
| 103 | + | link_url | <link_url> | |
| 104 | + | link_id | <link_id> | |
| 105 | + | link_classes | <link_classes> | |
| 106 | + | outbound | <outbound> | |
| 107 | + | section | <section> | |
| 108 | + | menu_type | <menu_type> | |
| 109 | + |
| 110 | + Scenario: gas4() sends a was_this_helpful_submit event |
| 111 | + When I load the test site |
| 112 | + And I execute script "window.gas4('was_this_helpful_submit', {selection: 'yes', section: 'footer'})" |
| 113 | + Then a "was_this_helpful_submit" event is sent to DAP with parameters |
| 114 | + | selection | yes | |
| 115 | + | section | footer | |
| 116 | + |
| 117 | + Scenario: gas4() sends a faq_click event |
| 118 | + When I load the test site |
| 119 | + And I click on element with selector "button::-p-text(FAQ)" |
| 120 | + Then a "faq_click" event is sent to DAP with parameters |
| 121 | + | selection | selection 1 | |
| 122 | + | section | <section> | |
| 123 | + |
| 124 | + Scenario: gas4() sends an accordion_click event |
| 125 | + When I load the test site |
| 126 | + And I click on element with selector "button::-p-text(Accordion)" |
| 127 | + Then a "accordion_click" event is sent to DAP with parameters |
| 128 | + | selection | selection 1 | |
| 129 | + | section | <section> | |
| 130 | + |
| 131 | + Scenario: gas4() sends an error event |
| 132 | + When I load the test site |
| 133 | + And I execute script "window.gas4('error', {type: '404', url: '/missing-page'})" |
| 134 | + Then a "error" event is sent to DAP with parameters |
| 135 | + | type | 404 | |
| 136 | + | url | /missing-page | |
| 137 | + |
| 138 | + Scenario: gas4() sends a filter event |
| 139 | + When I load the test site |
| 140 | + And I execute script "window.gas4('filter', {filter_selection: 'date', section: 'results'})" |
| 141 | + Then a "filter" event is sent to DAP with parameters |
| 142 | + | filter_selection | date | |
| 143 | + | section | results | |
| 144 | + |
| 145 | + Scenario: gas4() sends a sort event |
| 146 | + When I load the test site |
| 147 | + And I execute script "window.gas4('sort', {sort_selection: 'newest', section: 'results'})" |
| 148 | + Then a "sort" event is sent to DAP with parameters |
| 149 | + | sort_selection | newest | |
| 150 | + | section | results | |
| 151 | + |
| 152 | + Scenario: gas4() with an invalid event name falls back to dap_event |
| 153 | + When I load the test site |
| 154 | + And I execute script "window.gas4('not_a_valid_event', {some_param: 'value'})" |
| 155 | + Then a "dap_event" event is sent to DAP with parameters |
| 156 | + | some_param | value | |
0 commit comments