Customizable test group form should allow user to supply a revision prefix of a commi...
authordewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Jun 2019 05:12:35 +0000 (05:12 +0000)
committerdewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Jun 2019 05:12:35 +0000 (05:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198940

Reviewed by Ryosuke Niwa.

Customizable test group form should adapt prefix matching when fetching for a commit.

* browser-tests/customizable-test-group-form-tests.js: Updated and added unit tests.
* public/v3/components/customizable-test-group-form.js: Removed loggings those a unintentionally committed.
* public/v3/models/commit-set.js: Adapted prefix matching API when fetching a commit.
(IntermediateCommitSet.prototype._fetchCommitLogAndOwnedCommits):
* unit-tests/commit-set-tests.js: Updated unit tests accordingly.

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

Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/browser-tests/customizable-test-group-form-tests.js
Websites/perf.webkit.org/public/v3/components/customizable-test-group-form.js
Websites/perf.webkit.org/public/v3/models/commit-set.js
Websites/perf.webkit.org/unit-tests/commit-set-tests.js

index 6612490..85ef411 100644 (file)
@@ -1,3 +1,18 @@
+2019-06-17  Dewei Zhu  <dewei_zhu@apple.com>
+
+        Customizable test group form should allow user to supply a revision prefix of a commit and revision starts with 'r'.
+        https://bugs.webkit.org/show_bug.cgi?id=198940
+
+        Reviewed by Ryosuke Niwa.
+
+        Customizable test group form should adapt prefix matching when fetching for a commit.
+
+        * browser-tests/customizable-test-group-form-tests.js: Updated and added unit tests.
+        * public/v3/components/customizable-test-group-form.js: Removed loggings those a unintentionally committed.
+        * public/v3/models/commit-set.js: Adapted prefix matching API when fetching a commit.
+        (IntermediateCommitSet.prototype._fetchCommitLogAndOwnedCommits):
+        * unit-tests/commit-set-tests.js: Updated unit tests accordingly.
+
 2019-06-13  Dewei Zhu  <dewei_zhu@apple.com>
 
         Custom analysis task configurator should allow supplying commit prefix and revision starts 'r'.
index 04408c5..7f5e8c5 100644 (file)
@@ -35,6 +35,18 @@ describe('CustomizableTestGroupFormTests', () => {
         "message": "some message",
     };
 
+    const commitObjectC = {
+        "id": "185336",
+        "revision": "210950",
+        "repository": 1,
+        "previousCommit": null,
+        "ownsCommits": false,
+        "time": 1541494949682,
+        "authorName": "Chris Dumez",
+        "authorEmail": "cdumez@apple.com",
+        "message": "some message",
+    };
+
     function cloneObject(object)
     {
         const clone = {};
@@ -62,8 +74,8 @@ describe('CustomizableTestGroupFormTests', () => {
 
         const requests = context.symbols.MockRemoteAPI.requests;
         expect(requests.length).to.be(2);
-        expect(requests[0].url).to.be('/api/commits/1/210948');
-        expect(requests[1].url).to.be('/api/commits/1/210949');
+        expect(requests[0].url).to.be('/api/commits/1/210948?prefix-match=true');
+        expect(requests[1].url).to.be('/api/commits/1/210949?prefix-match=true');
         requests[0].resolve({commits: [commitObjectA]});
         requests[1].resolve({commits: [commitObjectB]});
 
@@ -90,6 +102,58 @@ describe('CustomizableTestGroupFormTests', () => {
         expect(revisionEditor.value).to.be('210948');
     });
 
+    it('should allow user to only provide prefix of a commit as long as the commit is unique in the repository', async () => {
+        const context = new BrowsingContext();
+        const customizableTestGroupForm = await createCustomizableTestGroupFormWithContext(context);
+        const repository = context.symbols.Repository.ensureSingleton(1, {name: 'WebKit'});
+
+        const commitA = cloneObject(commitObjectA);
+        const commitB = cloneObject(commitObjectB);
+        const commitC = cloneObject(commitObjectC);
+        commitA.repository = repository;
+        commitB.repository = repository;
+        commitC.repository = repository;
+        const webkitCommitA = context.symbols.CommitLog.ensureSingleton(185326, commitA);
+        const webkitCommitB = context.symbols.CommitLog.ensureSingleton(185334, commitB);
+        const commitSetA = context.symbols.CommitSet.ensureSingleton(1, {revisionItems: [{commit: webkitCommitA}]});
+        const commitSetB = context.symbols.CommitSet.ensureSingleton(2, {revisionItems: [{commit: webkitCommitB}]});
+
+        customizableTestGroupForm.setCommitSetMap({A: commitSetA, B: commitSetB});
+        customizableTestGroupForm.content('customize-link').click();
+
+        const requests = context.symbols.MockRemoteAPI.requests;
+        expect(requests.length).to.be(2);
+        expect(requests[0].url).to.be('/api/commits/1/210948?prefix-match=true');
+        expect(requests[1].url).to.be('/api/commits/1/210949?prefix-match=true');
+        requests[0].resolve({commits: [commitObjectA]});
+        requests[1].resolve({commits: [commitObjectB]});
+
+        await waitForComponentsToRender(context);
+
+        const radioButton = customizableTestGroupForm.content('custom-table').querySelector('input[type="radio"][name="A-1-radio"]:not(:checked)');
+        radioButton.click();
+        expect(radioButton.checked).to.be(true);
+
+        let revisionEditors = customizableTestGroupForm.content('custom-table').querySelectorAll('input:not([type="radio"])');
+        expect(revisionEditors.length).to.be(2);
+        let revisionEditor = revisionEditors[0];
+        expect(revisionEditor.value).to.be('210949');
+        revisionEditor.value = '21095';
+        revisionEditor.dispatchEvent(new Event('change'));
+
+        customizableTestGroupForm.content('name').value = 'a/b test';
+        customizableTestGroupForm.content('name').dispatchEvent(new Event('input'));
+        expect(requests.length).to.be(3);
+        expect(requests[2].url).to.be('/api/commits/1/21095?prefix-match=true');
+        requests[2].resolve({commits: [commitObjectC]});
+
+        await waitForComponentsToRender(context);
+
+        revisionEditors = customizableTestGroupForm.content('custom-table').querySelectorAll('input:not([type="radio"])');
+        revisionEditor = revisionEditors[0];
+        expect(revisionEditor.value).to.be('210950');
+    });
+
     it('should use the commit set map when customize button is clicked as the behavior of radio buttons', async () => {
         const context = new BrowsingContext();
         const customizableTestGroupForm = await createCustomizableTestGroupFormWithContext(context);
@@ -109,8 +173,8 @@ describe('CustomizableTestGroupFormTests', () => {
 
         const requests = context.symbols.MockRemoteAPI.requests;
         expect(requests.length).to.be(2);
-        expect(requests[0].url).to.be('/api/commits/1/210948');
-        expect(requests[1].url).to.be('/api/commits/1/210949');
+        expect(requests[0].url).to.be('/api/commits/1/210948?prefix-match=true');
+        expect(requests[1].url).to.be('/api/commits/1/210949?prefix-match=true');
         requests[0].resolve({commits: [commitObjectA]});
         requests[1].resolve({commits: [commitObjectB]});
 
index ea86fc4..081ca9d 100644 (file)
@@ -145,12 +145,6 @@ class CustomizableTestGroupForm extends TestGroupForm {
 
         const commitSets = Array.from(commitSetMap.values());
         const hasCommitWithTestability = commitSets.some((commitSet) =>  !!commitSet.commitsWithTestability().length);
-        for (const c of commitSets) {
-            if (c.commitsWithTestability().length)
-                console.log(c);
-        }
-        console.log({hasCommitWithTestability});
-        console.log('aaaa');
         if (!hasCommitWithTestability)
             return [];
 
index bb5b7f1..3b37b43 100644 (file)
@@ -394,7 +394,7 @@ class IntermediateCommitSet {
 
     _fetchCommitLogAndOwnedCommits(repository, revision)
     {
-        return CommitLog.fetchForSingleRevision(repository, revision).then((commits) => {
+        return CommitLog.fetchForSingleRevision(repository, revision, true).then((commits) => {
             console.assert(commits.length === 1);
             const commit = commits[0];
             if (!commit.ownsCommits())
index 7d52ea5..ac7be33 100644 (file)
@@ -501,9 +501,9 @@ describe('IntermediateCommitSet', () => {
 
             const requests = MockRemoteAPI.requests;
             assert.equal(requests.length, 2);
-            assert.equal(requests[0].url, '/api/commits/111/owner-commit-0');
+            assert.equal(requests[0].url, '/api/commits/111/owner-commit-0?prefix-match=true');
             assert.equal(requests[0].method, 'GET');
-            assert.equal(requests[1].url, '/api/commits/112/owned-commit-0');
+            assert.equal(requests[1].url, '/api/commits/112/owned-commit-0?prefix-match=true');
             assert.equal(requests[1].method, 'GET');
 
             requests[0].resolve({commits: [{
@@ -556,9 +556,9 @@ describe('IntermediateCommitSet', () => {
             const requests = MockRemoteAPI.requests;
 
             assert(requests.length, 2);
-            assert.equal(requests[0].url, '/api/commits/11/webkit-commit-0');
+            assert.equal(requests[0].url, '/api/commits/11/webkit-commit-0?prefix-match=true');
             assert.equal(requests[0].method, 'GET');
-            assert.equal(requests[1].url, '/api/commits/11/webkit-commit-1');
+            assert.equal(requests[1].url, '/api/commits/11/webkit-commit-1?prefix-match=true');
             assert.equal(requests[1].method, 'GET');
 
             requests[1].resolve({commits: [{
@@ -653,7 +653,7 @@ describe('IntermediateCommitSet', () => {
             commitSet.removeCommitForRepository(MockModels.webkit);
 
             const requests = MockRemoteAPI.requests;
-            assert.equal(requests[0].url, '/api/commits/11/webkit-commit-1');
+            assert.equal(requests[0].url, '/api/commits/11/webkit-commit-1?prefix-match=true');
             assert.equal(requests[0].method, 'GET');
 
             requests[0].resolve({commits: [{