Retrying an A/B testing does not set the repetition count in some cases
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Apr 2017 04:37:38 +0000 (04:37 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Apr 2017 04:37:38 +0000 (04:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=170695

Reviewed by Joseph Pecoraro.

When selecting an existing A/B test group, the analysis task page automatically sets the repetition count
of its retry to be that of the original test group. However, this information wasn't being passed correctly
to the code that actually created a test group. As a result, the retried test group's repetition count does
not match that of the original group or the number shown to the user on UI.

Fixed the bug by updating this._repetitionCount in setRepetitionCount.

* browser-tests/index.html:
* browser-tests/test-group-form-tests.js: Added. Added tests.
(.createTestGroupFormWithContext): Added.
* public/v3/components/test-group-form.js:
(TestGroupForm.prototype.setRepetitionCount):
(TestGroupForm.formContent):
(TestGroupForm):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215257 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/browser-tests/index.html
Websites/perf.webkit.org/browser-tests/test-group-form-tests.js [new file with mode: 0644]
Websites/perf.webkit.org/public/v3/components/test-group-form.js

index 692275d3d6431b4e1c199ea4ef33600e92a9853c..d3743c1ee1190403c354afbcd01dcc6c8590a662 100644 (file)
@@ -1,3 +1,25 @@
+2017-04-11  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Retrying an A/B testing does not set the repetition count in some cases
+        https://bugs.webkit.org/show_bug.cgi?id=170695
+
+        Reviewed by Joseph Pecoraro.
+
+        When selecting an existing A/B test group, the analysis task page automatically sets the repetition count
+        of its retry to be that of the original test group. However, this information wasn't being passed correctly
+        to the code that actually created a test group. As a result, the retried test group's repetition count does
+        not match that of the original group or the number shown to the user on UI.
+
+        Fixed the bug by updating this._repetitionCount in setRepetitionCount.
+
+        * browser-tests/index.html:
+        * browser-tests/test-group-form-tests.js: Added. Added tests.
+        (.createTestGroupFormWithContext): Added.
+        * public/v3/components/test-group-form.js:
+        (TestGroupForm.prototype.setRepetitionCount):
+        (TestGroupForm.formContent):
+        (TestGroupForm):
+
 2017-04-10  Ryosuke Niwa  <rniwa@webkit.org>
 
         Add the UI for scheduling a A/B testing with a custom root
index f17b70e3e683fdcbf2671efa83bb3f6de0ec9a2e..a3260ad22b696844ea9005bc6698b00e92d7fbdc 100644 (file)
@@ -23,6 +23,7 @@ mocha.setup('bdd');
 <script src="chart-status-evaluator-tests.js"></script>
 <script src="chart-revision-range-tests.js"></script>
 <script src="commit-log-viewer-tests.js"></script>
+<script src="test-group-form-tests.js"></script>
 <script>
 
 afterEach(() => {
diff --git a/Websites/perf.webkit.org/browser-tests/test-group-form-tests.js b/Websites/perf.webkit.org/browser-tests/test-group-form-tests.js
new file mode 100644 (file)
index 0000000..2653567
--- /dev/null
@@ -0,0 +1,67 @@
+
+describe('TestGroupFormTests', () => {
+    const scripts = ['instrumentation.js', 'components/base.js', 'components/test-group-form.js'];
+
+    function createTestGroupFormWithContext(context)
+    {
+        return context.importScripts(scripts, 'ComponentBase', 'TestGroupForm').then((symbols) => {
+            const testGroupForm = new context.symbols.TestGroupForm;
+            context.document.body.appendChild(testGroupForm.element());
+            return testGroupForm;
+        });
+    }
+
+    it('must dispatch "startTesting" action with the number of repetitions the user clicks on "Start A/B testing"', () => {
+        const context = new BrowsingContext();
+        return createTestGroupFormWithContext(context).then((testGroupForm) => {
+            const calls = [];
+            testGroupForm.listenToAction('startTesting', (...args) => calls.push(args));
+            expect(calls).to.eql({});
+            testGroupForm.content('start-button').click();
+            expect(calls).to.eql([[4]]);
+        });
+    });
+
+    it('must update the repetition count when the user selected a different count', () => {
+        const context = new BrowsingContext();
+        return createTestGroupFormWithContext(context).then((testGroupForm) => {
+            const calls = [];
+            testGroupForm.listenToAction('startTesting', (...args) => calls.push(args));
+            expect(calls).to.eql({});
+            testGroupForm.content('start-button').click();
+            expect(calls).to.eql([[4]]);
+            const countForm = testGroupForm.content('repetition-count');
+            countForm.value = '6';
+            countForm.dispatchEvent(new Event('change')); 
+            testGroupForm.content('start-button').click();
+            expect(calls).to.eql([[4], [6]]);
+        });
+    });
+
+    describe('setRepetitionCount', () => {
+        it('must update the visible repetition count', () => {
+            const context = new BrowsingContext();
+            return createTestGroupFormWithContext(context).then((testGroupForm) => {
+                expect(testGroupForm.content('repetition-count').value).to.be('4');
+                testGroupForm.setRepetitionCount(2);
+                return waitForComponentsToRender(context).then(() => {
+                    expect(testGroupForm.content('repetition-count').value).to.be('2');
+                });
+            });
+        });
+
+        it('must update the repetition count passed to "startTesting" action', () => {
+            const context = new BrowsingContext();
+            return createTestGroupFormWithContext(context).then((testGroupForm) => {
+                const calls = [];
+                testGroupForm.listenToAction('startTesting', (...args) => calls.push(args));
+                expect(calls).to.eql({});
+                testGroupForm.content().querySelector('button').click();
+                expect(calls).to.eql([[4]]);
+                testGroupForm.setRepetitionCount(8);
+                testGroupForm.content().querySelector('button').click();
+                expect(calls).to.eql([[4], [8]]);
+            });
+        });
+    });
+});
index ac818f72e7d6fe5bb3cabceb63df198abe602272..7e0ac0aff2dfa25d2c2d0f1c8a007cb8cd0c0871 100644 (file)
@@ -10,6 +10,7 @@ class TestGroupForm extends ComponentBase {
     setRepetitionCount(count)
     {
         this.content('repetition-count').value = count;
+        this._repetitionCount = count;
     }
 
     didConstructShadowTree()
@@ -39,7 +40,7 @@ class TestGroupForm extends ComponentBase {
                 <option>1</option>
                 <option>2</option>
                 <option>3</option>
-                <option>4</option>
+                <option selected>4</option>
                 <option>5</option>
                 <option>6</option>
                 <option>7</option>