Retrying an A/B testing does not set the repetition count in some cases
[WebKit.git] / Websites / perf.webkit.org / browser-tests / test-group-form-tests.js
1
2 describe('TestGroupFormTests', () => {
3     const scripts = ['instrumentation.js', 'components/base.js', 'components/test-group-form.js'];
4
5     function createTestGroupFormWithContext(context)
6     {
7         return context.importScripts(scripts, 'ComponentBase', 'TestGroupForm').then((symbols) => {
8             const testGroupForm = new context.symbols.TestGroupForm;
9             context.document.body.appendChild(testGroupForm.element());
10             return testGroupForm;
11         });
12     }
13
14     it('must dispatch "startTesting" action with the number of repetitions the user clicks on "Start A/B testing"', () => {
15         const context = new BrowsingContext();
16         return createTestGroupFormWithContext(context).then((testGroupForm) => {
17             const calls = [];
18             testGroupForm.listenToAction('startTesting', (...args) => calls.push(args));
19             expect(calls).to.eql({});
20             testGroupForm.content('start-button').click();
21             expect(calls).to.eql([[4]]);
22         });
23     });
24
25     it('must update the repetition count when the user selected a different count', () => {
26         const context = new BrowsingContext();
27         return createTestGroupFormWithContext(context).then((testGroupForm) => {
28             const calls = [];
29             testGroupForm.listenToAction('startTesting', (...args) => calls.push(args));
30             expect(calls).to.eql({});
31             testGroupForm.content('start-button').click();
32             expect(calls).to.eql([[4]]);
33             const countForm = testGroupForm.content('repetition-count');
34             countForm.value = '6';
35             countForm.dispatchEvent(new Event('change')); 
36             testGroupForm.content('start-button').click();
37             expect(calls).to.eql([[4], [6]]);
38         });
39     });
40
41     describe('setRepetitionCount', () => {
42         it('must update the visible repetition count', () => {
43             const context = new BrowsingContext();
44             return createTestGroupFormWithContext(context).then((testGroupForm) => {
45                 expect(testGroupForm.content('repetition-count').value).to.be('4');
46                 testGroupForm.setRepetitionCount(2);
47                 return waitForComponentsToRender(context).then(() => {
48                     expect(testGroupForm.content('repetition-count').value).to.be('2');
49                 });
50             });
51         });
52
53         it('must update the repetition count passed to "startTesting" action', () => {
54             const context = new BrowsingContext();
55             return createTestGroupFormWithContext(context).then((testGroupForm) => {
56                 const calls = [];
57                 testGroupForm.listenToAction('startTesting', (...args) => calls.push(args));
58                 expect(calls).to.eql({});
59                 testGroupForm.content().querySelector('button').click();
60                 expect(calls).to.eql([[4]]);
61                 testGroupForm.setRepetitionCount(8);
62                 testGroupForm.content().querySelector('button').click();
63                 expect(calls).to.eql([[4], [8]]);
64             });
65         });
66     });
67 });