Skip to content

Commit 912ac50

Browse files
heiskrchiedo
andauthored
End AB test on moving helpfulness prompt to bottom (github#16552)
* End AB test on moving helpfulness prompt to bottom * Move helpfulness to bottom of page only * Update helpfulness.js Co-authored-by: Chiedo John <2156688+chiedo@users.noreply.github.com>
1 parent da45595 commit 912ac50

File tree

5 files changed

+24
-56
lines changed

5 files changed

+24
-56
lines changed

includes/article.html

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ <h3 id="in-this-article" class="f5 mb-2"><a class="link-gray-dark" href="#in-thi
5555
{% endfor %}
5656
</ul>
5757
{% endif %}
58-
<div class="d-none d-xl-block{% if miniTocItems.size > 1 %} border-top border-gray-light mt-4{% endif %}">
59-
{% assign helpId = 'xl' %}
60-
{% include helpfulness %}
61-
{% include contribution %}
62-
</div>
6358
</div>
6459
</div>
6560
<div id="article-contents" class="article-grid-body">
@@ -70,8 +65,7 @@ <h3 id="in-this-article" class="f5 mb-2"><a class="link-gray-dark" href="#in-thi
7065
</div>
7166
</div>
7267

73-
<div class="d-block d-xl-none border-top border-gray-light mt-4 markdown-body">
74-
{% assign helpId = 'sm' %}
68+
<div class="d-block border-top border-gray-light mt-4 markdown-body">
7569
{% include helpfulness %}
7670
{% include contribution %}
7771
</div>

includes/helpfulness.html

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% unless enterpriseServerReleases.isOldestReleaseDeprecated and currentVersion contains enterpriseServerReleases.oldestSupported %}
2-
<form class="js-helpfulness mt-4 f5" id="helpfulness-{{ helpId }}">
2+
<form class="js-helpfulness mt-4 f5">
33
<h4
44
data-help-start
55
data-help-yes
@@ -19,24 +19,24 @@
1919
>
2020
<input
2121
hidden
22-
id="helpfulness-yes-{{ helpId }}"
22+
id="helpfulness-yes"
2323
type="radio"
2424
name="helpfulness-vote"
2525
value="Yes"
2626
aria-label="{% data ui.helpfulness.yes %}"
2727
/>
28-
<label class="btn x-radio-label" for="helpfulness-yes-{{ helpId }}">
28+
<label class="btn x-radio-label" for="helpfulness-yes">
2929
{% octicon "thumbsup" height="24" %}
3030
</label>
3131
<input
3232
hidden
33-
id="helpfulness-no-{{ helpId }}"
33+
id="helpfulness-no"
3434
type="radio"
3535
name="helpfulness-vote"
3636
value="No"
3737
aria-label="{% data ui.helpfulness.no %}"
3838
/>
39-
<label class="btn x-radio-label" for="helpfulness-no-{{ helpId }}">
39+
<label class="btn x-radio-label" for="helpfulness-no">
4040
{% octicon "thumbsdown" height="24" %}
4141
</label>
4242
</p>
@@ -55,7 +55,7 @@
5555
<p hidden data-help-no>
5656
<label
5757
class="d-block mb-1 f6"
58-
for="helpfulness-category-{{ helpId }}"
58+
for="helpfulness-category"
5959
>
6060
{% data ui.helpfulness.category_label %}
6161
<span class="text-normal text-gray-light float-right ml-1">
@@ -65,7 +65,7 @@
6565
<select
6666
class="form-control select-sm width-full"
6767
name="helpfulness-category"
68-
id="helpfulness-category-{{ helpId }}"
68+
id="helpfulness-category"
6969
>
7070
<option value="">
7171
{% data ui.helpfulness.category_default %}
@@ -87,7 +87,7 @@
8787
<p hidden data-help-no>
8888
<label
8989
class="d-block mb-1 f6"
90-
for="helpfulness-comment-{{ helpId }}"
90+
for="helpfulness-comment"
9191
>
9292
<span>{% data ui.helpfulness.comment_label %}</span>
9393
<span class="text-normal text-gray-light float-right ml-1">
@@ -97,13 +97,13 @@
9797
<textarea
9898
class="form-control input-sm width-full"
9999
name="helpfulness-comment"
100-
id="helpfulness-comment-{{ helpId }}"
100+
id="helpfulness-comment"
101101
></textarea>
102102
</p>
103103
<p>
104104
<label
105105
class="d-block mb-1 f6"
106-
for="helpfulness-email-{{ helpId }}"
106+
for="helpfulness-email"
107107
hidden
108108
data-help-no
109109
>
@@ -116,7 +116,7 @@
116116
type="email"
117117
class="form-control input-sm width-full"
118118
name="helpfulness-email"
119-
id="helpfulness-email-{{ helpId }}"
119+
id="helpfulness-email"
120120
placeholder="{% data ui.helpfulness.email_placeholder %}"
121121
hidden
122122
data-help-yes
@@ -137,4 +137,4 @@
137137
{% data ui.helpfulness.feedback %}
138138
</p>
139139
</form>
140-
{% endunless %}
140+
{% endunless %}

javascripts/experiment.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,4 @@ export default function () {
4141
// const xbucket = bucket(testName)
4242
// if (xbucket === TREATMENT) { ... }
4343
// x.addEventListener('click', () => { sendSuccess(testName) })
44-
45-
const testName = 'helpfulness-prompt-to-bottom'
46-
const xbucket = bucket(testName)
47-
48-
if (xbucket === TREATMENT) {
49-
const bigHelpfulness = document.querySelector('#helpfulness-xl')
50-
const smallHelpfulness = document.querySelector('#helpfulness-sm')
51-
52-
// Check that helpfulness prompt is present on this page
53-
if (!(bigHelpfulness && smallHelpfulness)) {
54-
return
55-
}
56-
57-
// Remove the -xl prompts
58-
bigHelpfulness.parentElement.parentElement.removeChild(bigHelpfulness.parentElement)
59-
60-
// Always show the -sm prompt
61-
smallHelpfulness.parentElement.classList.remove('d-xl-none')
62-
}
63-
64-
const votes = Array.from(document.querySelectorAll('.js-helpfulness [type=radio]'))
65-
votes.forEach(voteEl => {
66-
voteEl.addEventListener('change', () => { sendSuccess(testName) })
67-
})
6844
}

javascripts/helpfulness.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import { sendEvent } from './events'
22

33
export default function helpfulness () {
4-
const forms = Array.from(document.querySelectorAll('.js-helpfulness'))
4+
const form = document.querySelector('.js-helpfulness')
55
const texts = Array.from(document.querySelectorAll('.js-helpfulness input, .js-helpfulness textarea'))
66
const votes = Array.from(document.querySelectorAll('.js-helpfulness [type=radio]'))
7-
if (!forms.length || !texts.length || !votes.length) return
7+
if (!form || !texts.length || !votes.length) return
88

9-
forms.forEach(form => {
10-
form.addEventListener('submit', async evt => {
11-
evt.preventDefault()
12-
await submitForm(evt.target)
13-
updateDisplay(form, 'end')
14-
})
9+
form.addEventListener('submit', async evt => {
10+
evt.preventDefault()
11+
await submitForm(evt.target)
12+
updateDisplay(form, 'end')
1513
})
1614

1715
votes.forEach(voteEl => {

tests/browser/browser.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,20 +134,20 @@ describe('helpfulness', () => {
134134
})
135135

136136
// When I click the "Yes" button
137-
await page.click('#helpfulness-sm [for=helpfulness-yes-sm]')
137+
await page.click('.js-helpfulness [for=helpfulness-yes]')
138138
// (sent a POST request to /events)
139139
// I see the request for my email
140-
await page.waitForSelector('#helpfulness-sm [type="email"]')
140+
await page.waitForSelector('.js-helpfulness [type="email"]')
141141

142142
// When I fill in my email and submit the form
143-
await page.type('#helpfulness-sm [type="email"]', 'test@example.com')
143+
await page.type('.js-helpfulness [type="email"]', 'test@example.com')
144144

145145
await sleep(1000)
146146

147-
await page.click('#helpfulness-sm [type="submit"]')
147+
await page.click('.js-helpfulness [type="submit"]')
148148
// (sent a PUT request to /events/{id})
149149
// I see the feedback
150-
await page.waitForSelector('#helpfulness-sm [data-help-end]')
150+
await page.waitForSelector('.js-helpfulness [data-help-end]')
151151
})
152152
})
153153

0 commit comments

Comments
 (0)