Title: [250355] trunk/Tools
Revision
250355
Author
[email protected]
Date
2019-09-25 13:27:35 -0700 (Wed, 25 Sep 2019)

Log Message

results.webkit.org: Add investigation drawer
https://bugs.webkit.org/show_bug.cgi?id=202106

Reviewed by Dewei Zhu.

* resultsdbpy/resultsdbpy/view/static/js/drawer.js: Support multiple 'main' classes.
* resultsdbpy/resultsdbpy/view/static/js/expectations.js: Added.
(Expectations.colorMap): Return a dictionary mapping type strings to colors.
(Expectations.stringToStateId): Map a string to a state ID for sorting.
(Expectations.typeForId): Return a type string given an ID.
(Expectations.symbolForId): Return a symbol for a type given an ID.
(Expectations.colorForId): Return a color given an ID.
(Expectations.unexpectedResults): Given a list of actual results and expected results,
return a state.
(Expectations):
* resultsdbpy/resultsdbpy/view/static/js/investigate.js: Added.
(commitsForUuid):
(testRunLink):
(elapsed):
(percentage):
(contentForAgregateData):
(contentForData):
(_InvestigateDrawer):
(_InvestigateDrawer.prototype.isRendered):
(_InvestigateDrawer.prototype.expand): Expand the investigation drawer.
(_InvestigateDrawer.prototype.collapse): Collapse the investigation drawer.
(_InvestigateDrawer.prototype.select): Select an element to investigate.
* resultsdbpy/resultsdbpy/view/static/js/timeline.js:
(statsForSingleResult): Move Expectation constants.
(TimelineFromEndpoint.prototype.render): Investigate specific data points instead
of jumping to the build.
(Expectations.stringToStateId): Deleted.
(Expectations.unexpectedResults): Deleted.
(Expectations): Deleted.
* resultsdbpy/resultsdbpy/view/static/library/css/webkit.css:
(.drawer.display): Make minimum height.
(@media screen and (min-width: 600px)): Move main and sidebar so they override drawer.
(@media screen and (min-width: 768px)): Ditto.
* resultsdbpy/resultsdbpy/view/templates/commits.html:
* resultsdbpy/resultsdbpy/view/templates/search.html:
* resultsdbpy/resultsdbpy/view/templates/suite_results.html:

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (250354 => 250355)


--- trunk/Tools/ChangeLog	2019-09-25 19:43:02 UTC (rev 250354)
+++ trunk/Tools/ChangeLog	2019-09-25 20:27:35 UTC (rev 250355)
@@ -1,3 +1,47 @@
+2019-09-25  Jonathan Bedard  <[email protected]>
+
+        results.webkit.org: Add investigation drawer
+        https://bugs.webkit.org/show_bug.cgi?id=202106
+
+        Reviewed by Dewei Zhu.
+
+        * resultsdbpy/resultsdbpy/view/static/js/drawer.js: Support multiple 'main' classes.
+        * resultsdbpy/resultsdbpy/view/static/js/expectations.js: Added.
+        (Expectations.colorMap): Return a dictionary mapping type strings to colors.
+        (Expectations.stringToStateId): Map a string to a state ID for sorting.
+        (Expectations.typeForId): Return a type string given an ID.
+        (Expectations.symbolForId): Return a symbol for a type given an ID.
+        (Expectations.colorForId): Return a color given an ID.
+        (Expectations.unexpectedResults): Given a list of actual results and expected results,
+        return a state.
+        (Expectations):
+        * resultsdbpy/resultsdbpy/view/static/js/investigate.js: Added.
+        (commitsForUuid):
+        (testRunLink):
+        (elapsed):
+        (percentage):
+        (contentForAgregateData):
+        (contentForData):
+        (_InvestigateDrawer):
+        (_InvestigateDrawer.prototype.isRendered):
+        (_InvestigateDrawer.prototype.expand): Expand the investigation drawer.
+        (_InvestigateDrawer.prototype.collapse): Collapse the investigation drawer.
+        (_InvestigateDrawer.prototype.select): Select an element to investigate.
+        * resultsdbpy/resultsdbpy/view/static/js/timeline.js:
+        (statsForSingleResult): Move Expectation constants.
+        (TimelineFromEndpoint.prototype.render): Investigate specific data points instead
+        of jumping to the build.
+        (Expectations.stringToStateId): Deleted.
+        (Expectations.unexpectedResults): Deleted.
+        (Expectations): Deleted.
+        * resultsdbpy/resultsdbpy/view/static/library/css/webkit.css:
+        (.drawer.display): Make minimum height.
+        (@media screen and (min-width: 600px)): Move main and sidebar so they override drawer.
+        (@media screen and (min-width: 768px)): Ditto.
+        * resultsdbpy/resultsdbpy/view/templates/commits.html:
+        * resultsdbpy/resultsdbpy/view/templates/search.html:
+        * resultsdbpy/resultsdbpy/view/templates/suite_results.html:
+
 2019-09-25  Alex Christensen  <[email protected]>
 
         Remove duplicate WebsiteDataStoreConfiguration copying code

Modified: trunk/Tools/resultsdbpy/resultsdbpy/view/static/js/drawer.js (250354 => 250355)


--- trunk/Tools/resultsdbpy/resultsdbpy/view/static/js/drawer.js	2019-09-25 19:43:02 UTC (rev 250354)
+++ trunk/Tools/resultsdbpy/resultsdbpy/view/static/js/drawer.js	2019-09-25 20:27:35 UTC (rev 250355)
@@ -40,7 +40,7 @@
     const HIDDEN = false;
     const VISIBLE = true;
     let drawerState = VISIBLE;
-    let main = null;
+    let mains = [];
 
     const sidebarControl = document.getElementsByClassName('mobile-sidebar-control')[0];
     sidebarControl.classList.add('display');
@@ -50,12 +50,10 @@
         onStateUpdate: (element, state) => {
             if (state) {
                 element.classList.remove("hidden");
-                if (main)
-                    main.classList.remove("hidden");
+                mains.forEach(main => main.classList.remove("hidden"));
             } else {
                 element.classList.add("hidden");
-                if (main)
-                    main.classList.add("hidden");
+                mains.forEach(main => main.classList.add("hidden"));
             }
 
             for (let node of element.children) {
@@ -68,8 +66,9 @@
         },
         onElementMount: (element) => {
             let candidates = document.getElementsByClassName("main");
-            if (candidates.length)
-                main = candidates[0];
+            mains = [];
+            for (let count = 0; count < candidates.length; ++count)
+                mains.push(candidates[count]);
 
             sidebarControl._onclick_ = () => {
                 if (element.style.display)

Added: trunk/Tools/resultsdbpy/resultsdbpy/view/static/js/expectations.js (0 => 250355)


--- trunk/Tools/resultsdbpy/resultsdbpy/view/static/js/expectations.js	                        (rev 0)
+++ trunk/Tools/resultsdbpy/resultsdbpy/view/static/js/expectations.js	2019-09-25 20:27:35 UTC (rev 250355)
@@ -0,0 +1,103 @@
+// Copyright (C) 2019 Apple Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+
+class Expectations
+{
+    static colorMap() {
+        const computedStyle = getComputedStyle(document.body);
+        return {
+            success: computedStyle.getPropertyValue('--greenLight').trim(),
+            failed: computedStyle.getPropertyValue('--redLight').trim(),
+            timedout: computedStyle.getPropertyValue('--orangeLight').trim(),
+            crashed: computedStyle.getPropertyValue('--purpleLight').trim(),
+        };
+    }
+
+    static stringToStateId(string) {
+        return Expectations.stateToIdMap[string];
+    }
+    static typeForId(string) {
+        const id = Expectations.stringToStateId(string);
+        let result = 'success';
+        Expectations.failureTypes.forEach(type => {
+            const idForType = Expectations.stringToStateId(Expectations.failureTypeMap[type]);
+            if (id <= idForType)
+                result = type;
+        });
+        return result;
+    }
+    static symbolForId(string) {
+        return Expectations.symbolMap[Expectations.typeForId(string)];
+    }
+    static colorForId(string) {
+        return Expectations.colorMap()[Expectations.typeForId(string)];
+    }
+
+    static unexpectedResults(results, expectations)
+    {
+        let r = results.split('.');
+        expectations.split(' ').forEach(expectation => {
+            const i = r.indexOf(expectation);
+            if (i > -1)
+                r.splice(i, 1);
+            if (expectation === 'FAIL')
+                ['TEXT', 'AUDIO', 'IMAGE'].forEach(expectation => {
+                    const i = r.indexOf(expectation);
+                    if (i > -1)
+                        r.splice(i, 1);
+                });
+        });
+        let result = 'PASS';
+        r.forEach(candidate => {
+            if (Expectations.stringToStateId(candidate) < Expectations.stringToStateId(result))
+                result = candidate;
+        });
+        return result;
+    }
+}
+
+Expectations.stateToIdMap = {
+    CRASH: 0x00,
+    TIMEOUT: 0x08,
+    IMAGE: 0x10,
+    AUDIO: 0x18,
+    TEXT: 0x20,
+    FAIL: 0x28,
+    ERROR: 0x30,
+    WARNING: 0x38,
+    PASS: 0x40,
+};
+Expectations.failureTypes = ['failed', 'timedout', 'crashed'];
+Expectations.failureTypeMap = {
+    failed: 'ERROR',
+    timedout: 'TIMEOUT',
+    crashed: 'CRASH',
+}
+Expectations.symbolMap = {
+    success: '✓',
+    failed: '𝖷',
+    timedout: '⎋',
+    crashed: '!',
+}
+
+export {Expectations};

Added: trunk/Tools/resultsdbpy/resultsdbpy/view/static/js/investigate.js (0 => 250355)


--- trunk/Tools/resultsdbpy/resultsdbpy/view/static/js/investigate.js	                        (rev 0)
+++ trunk/Tools/resultsdbpy/resultsdbpy/view/static/js/investigate.js	2019-09-25 20:27:35 UTC (rev 250355)
@@ -0,0 +1,342 @@
+// Copyright (C) 2019 Apple Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+//    notice, this list of conditions and the following disclaimer in the
+//    documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+
+import {DOM, REF} from '/library/js/Ref.js';
+import {CommitBank} from '/assets/js/commit.js';
+import {queryToParams, paramsToQuery, QueryModifier, } from '/assets/js/common.js';
+import {Configuration} from '/assets/js/configuration.js'
+import {Expectations} from '/assets/js/expectations.js';
+
+function commitsForUuid(uuid) {
+    return `Commits: ${CommitBank.commitsDuringUuid(uuid).map((commit) => {
+            const params = {
+                branch: commit.branch ? [commit.branch] : branch,
+                uuid: [commit.uuid],
+            }
+            if (!params.branch)
+                delete params.branch;
+            const query = paramsToQuery(params);
+            return `<a href="" target="_blank">${commit.id.substring(0,12)}</a>`;
+        }).join(', ')}`
+}
+
+function testRunLink(suite, data)
+{
+    if (!data.start_time)
+        return '';
+    const branch = queryToParams(document.URL.split('?')[1]).branch;
+    return `<a href="" () {
+        const buildParams = data.configuration.toParams();
+        buildParams['suite'] = [suite];
+        buildParams['uuid'] = [data.uuid];
+        buildParams['after_time'] = [data.start_time];
+        buildParams['before_time'] = [data.start_time];
+        if (branch)
+            buildParams['branch'] = branch;
+        return buildParams;
+    } ())}" target="_blank">Test run</a> @ ${new Date(data.start_time * 1000).toLocaleString()}`;
+}
+
+function elapsed(data)
+{
+    if (data.time)
+        return `Took ${data.time / 1000} seconds`;
+    if (data.stats && data.stats.start_time && data.stats.end_time) {
+        const time = new Date((data.stats.end_time - data.stats.start_time) * 1000);
+        console.log(data.stats.end_time - data.stats.start_time);
+        let result = 'Suite took ';
+        if (time.getMinutes())
+            result += `${time.getMinutes()}:`;
+        result += `${time.getSeconds() <= 9 && time.getMinutes() ? '0' : ''}${time.getSeconds()}.${time.getMilliseconds() <= 99 ? '0' : ''}${time.getMilliseconds() <= 9 ? '0' : ''}${time.getMilliseconds()} `;
+        if (time.getMinutes())
+            result += 'minutes to run';
+        else
+            result += 'seconds to run';
+        return result;
+    }
+    return '';
+}
+
+function percentage(value, max)
+{
+    if (value === max)
+        return '100 %';
+    if (!value)
+        return '0 %';
+    const result = Math.round(value / max * 100);
+    if (!result)
+        return '<1 %';
+    if (result === 100)
+        return '99 %';
+    return `${result} %`
+}
+
+function resultsForData(data, willFilterExpected = false)
+{
+    const result = [];
+    let testsRan = 1;
+    let totalTests = 1;
+    if (data.stats && data.stats.tests_run) {
+        testsRan = data.stats.tests_run;
+        totalTests = data.stats.tests_run + (data.stats.tests_skipped ? data.stats.tests_skipped : 0);
+    }
+    result.push(`Ran ${testsRan.toLocaleString()} of ${totalTests.toLocaleString()} tests`);
+    if (data.actual) {
+        const type = Expectations.typeForId(data.actual);
+        result.push(`<div>
+                Actual: ${data.actual}
+                <div class="dot ${type} small">
+                    <div class="tiny text" style="font-weight: normal;margin-top: 0px">${Expectations.symbolMap[type]}</div>
+                </div>
+            </div>`);
+    }
+    if (data.expected) {
+        const type = Expectations.typeForId(data.expected);
+        result.push(`<div>
+                Expected: ${data.expected}
+                <div class="dot ${type} small">
+                    <div class="tiny text" style="font-weight: normal;margin-top: 0px">${Expectations.symbolMap[type]}</div>
+                </div>
+            </div>`);
+    }
+    if (data.stats && data.stats.tests_run) {
+        const succeeded = data.stats.tests_run - data.stats[`tests${willFilterExpected ? '_unexpected_' : '_'}failed`];
+        if (succeeded)
+            result.push(`<div>
+                    <div class="dot success small">
+                        <div class="tiny text" style="font-weight: normal;margin-top: 0px">${Expectations.symbolMap.success}</div>
+                    </div>
+                    ${data.start_time ? succeeded.toLocaleString() : percentage(succeeded, data.stats.tests_run)} passed
+                </div>`);
+    }
+    for (let i = 0; i < Expectations.failureTypes.length; i++) {
+        if (!data.stats)
+            continue;
+        const type = Expectations.failureTypes[i];
+        let value = data.stats[`tests${willFilterExpected ? '_unexpected_' : '_'}${type}`];
+        if (i < Expectations.failureTypes.length - 1)
+            value -= data.stats[`tests${willFilterExpected ? '_unexpected_' : '_'}${Expectations.failureTypes[i + 1]}`];
+        if (!value)
+            continue;
+        result.push(`<div>
+                <div class="dot ${type} small">
+                    <div class="tiny text" style="font-weight: normal;margin-top: 0px">${Expectations.symbolMap[type]}</div>
+                </div>
+                ${data.start_time ? value.toLocaleString() : percentage(value, data.stats.tests_run)} ${type}
+            </div>`);
+    }
+    return result;
+}
+
+function renderInvestigateDrawer(arrays)
+{
+    return `<div class="row">
+            ${arrays.map(array => {
+                return `<div class="col-s-6 list">
+                        ${array.map(element => {
+                            return `<div class="item">${element}</div>`;
+                        }).join('')}
+                    </div>`;
+            }).join('<div class="divider mobile-control"></div>')}
+        </div>`
+}
+
+function contentForAgregateData(suite, agregateData, data, willFilterExpected = false)
+{
+    const metaData = [
+        `${data.length} reports for ${agregateData.configuration}`,
+        commitsForUuid(agregateData.uuid),
+    ];
+    let count = 0;
+    data.forEach(node => {
+        const myCount = count;
+        let dotType = 'success';
+        if (node.stats) {
+            Expectations.failureTypes.forEach(type => {
+                if (node.stats[`tests${willFilterExpected ? '_unexpected_' : '_'}${type}`] > 0)
+                    dotType = type;
+            });
+        } else {
+            let resultId = Expectations.stringToStateId(node.actual);
+            if (willFilterExpected)
+                resultId = Expectations.stringToStateId(Expectations.unexpectedResults(node.actual, node.expected));
+            Expectations.failureTypes.forEach(type => {
+                if (Expectations.stringToStateId(Expectations.failureTypeMap[type]) >= resultId)
+                    dotType = type;
+            });
+        }
+        metaData.push(`<div>
+                <div class="dot ${dotType} small">
+                    <div class="tiny text" style="font-weight: normal;margin-top: 0px">${Expectations.symbolMap[dotType]}</div>
+                </div>
+                <a class="link-button" ref="${REF.createRef({
+                    onElementMount: (element) => {
+                        element._onclick_ = () => InvestigateDrawer.select(myCount + 1);
+                    },
+                })}">
+                    ${node.configuration}
+                </a>
+            </div>`);
+        ++count;
+    });
+    return renderInvestigateDrawer([metaData, resultsForData(agregateData, willFilterExpected)]);
+}
+
+function contentForData(suite, data, willFilterExpected = false)
+{
+    const metaData = [
+        data.configuration,
+        commitsForUuid(data.uuid),
+        testRunLink(suite, data),
+        elapsed(data),
+    ];
+
+    return renderInvestigateDrawer([metaData, resultsForData(data, willFilterExpected)]);
+}
+
+class _InvestigateDrawer {
+    constructor() {
+        this.ref = null;
+        this.content = null;
+        this.close = null;
+        this.previous = null;
+        this.next = null;
+
+        this.selected = 0;
+        this.suite = null;
+        this.agregate = null;
+        this.data = ""
+
+        this.willFilterExpected = false;
+    }
+    isRendered() {
+        let result = true;
+        ['ref', 'content', 'close', 'previous', 'next'].forEach(element => {
+            if (!result)
+                return;
+            result = this[element] && this[element].element;
+        });
+        if (!result)
+            console.error('Investigation drawer not rendered');
+        return result;
+    }
+    toString() {
+        const self = this;
+        this.ref = REF.createRef();
+        this.content = REF.createRef({
+            state: '',
+            onStateUpdate: (element, state) => {
+                DOM.inject(element, state);
+            },
+        });
+        this.close = REF.createRef({
+            onElementMount: (element) => {
+                element._onclick_ = () => self.collapse();
+            },
+        });
+
+        this.previous = REF.createRef({
+            onElementMount: (element) => {
+                element._onclick_ = () => self.select(self.selected - 1);
+            },
+        });
+        this.next = REF.createRef({
+            onElementMount: (element) => {
+                element._onclick_ = () => self.select(self.selected + 1);
+            },
+        });
+
+        return `<div class="drawer main right-sidebar" ref="${this.ref}" style="z-index: 20">
+                <div class="content unselectable" style="display: flex; justify-content: space-between; flex-direction: row; padding: 10px;">
+                    <div style="width: 150px; text-align: left">
+                        <a class="button" style="cursor: pointer" ref="${this.previous}">◀ Previous</a>
+                    </div>
+                    <div>
+                        <a class="button" style="cursor: pointer" ref="${this.close}">Close</a>
+                    </div>
+                    <div style="width: 150px; text-align: right">
+                        <a class="button" style="cursor: pointer" ref="${this.next}">Next ▶</a>
+                    </div>
+                </div>
+                <div class="content" ref="${this.content}">
+                </div>
+            </div>`;
+    }
+    expand(suite, agregateData, allData) {
+        if (!this.isRendered())
+            return;
+        this.ref.element.classList.add('display');
+        this.suite = suite;
+        this.agregate = agregateData;
+        this.data = ""
+        this.select(0);
+    }
+    collapse() {
+        if (!this.isRendered())
+            return;
+        this.ref.element.classList.remove('display');
+
+        this.agregate = null;
+        this.data = ""
+        this.select(0);
+    }
+    select(index) {
+        let candidates = this.data.length;
+        if (this.agregate && this.data.length > 1)
+            candidates += 1;
+        if (!candidates) {
+            this.ref.element.classList.remove('display');
+            return;
+        }
+
+        // Force selection in bounds
+        if (index < 0)
+            index = 0;
+        if (index >= candidates)
+            index = candidates - 1;
+        this.selected = index;
+
+        // Display next/previous buttons
+        if (index)
+            this.previous.element.style.display = null;
+        else
+            this.previous.element.style.display = 'none';
+        if (index === candidates - 1)
+            this.next.element.style.display = 'none';
+        else
+            this.next.element.style.display = null;
+
+        if (this.agregate && this.data.length > 1 && !this.selected)
+            this.content.setState(contentForAgregateData(this.suite, this.agregate, this.data, this.willFilterExpected));
+        else
+            this.content.setState(contentForData(
+                this.suite,
+                this.data[this.agregate && this.data.length > 1 ? this.selected - 1 : this.selected],
+                this.willFilterExpected,
+            ));
+    }
+}
+
+const InvestigateDrawer = new _InvestigateDrawer();
+
+export {InvestigateDrawer};

Modified: trunk/Tools/resultsdbpy/resultsdbpy/view/static/js/timeline.js (250354 => 250355)


--- trunk/Tools/resultsdbpy/resultsdbpy/view/static/js/timeline.js	2019-09-25 19:43:02 UTC (rev 250354)
+++ trunk/Tools/resultsdbpy/resultsdbpy/view/static/js/timeline.js	2019-09-25 20:27:35 UTC (rev 250355)
@@ -24,6 +24,8 @@
 import {CommitBank} from '/assets/js/commit.js';
 import {Configuration} from '/assets/js/configuration.js';
 import {deepCompare, ErrorDisplay, escapeHTML, paramsToQuery, queryToParams} from '/assets/js/common.js';
+import {Expectations} from '/assets/js/expectations.js';
+import {InvestigateDrawer} from '/assets/js/investigate.js';
 import {ToolTip} from '/assets/js/tooltip.js';
 import {Timeline} from '/library/js/components/TimelineComponents.js';
 import {DOM, EventStream, REF, FP} from '/library/js/Ref.js';
@@ -31,53 +33,6 @@
 
 const DEFAULT_LIMIT = 100;
 
-const stateToIDMapping = {
-    CRASH: 0x00,
-    TIMEOUT: 0x08,
-    IMAGE: 0x10,
-    AUDIO: 0x18,
-    TEXT: 0x20,
-    FAIL: 0x28,
-    ERROR: 0x30,
-    WARNING: 0x38,
-    PASS: 0x40,
-};
-
-const TestResultsSymbolMap = {
-    success: '✓',
-    failed: '𝖷',
-    timedout: '⎋',
-    crashed: '!',
-}
-
-class Expectations
-{
-    static stringToStateId(string) {
-        return stateToIDMapping[string];
-    }
-
-    static unexpectedResults(results, expectations)
-    {
-        let r = results.split('.');
-        expectations.split(' ').forEach(expectation => {
-            const i = r.indexOf(expectation);
-            if (i > -1)
-                r.splice(i, 1);
-            if (expectation === 'FAIL')
-                ['TEXT', 'AUDIO', 'IMAGE'].forEach(expectation => {
-                    const i = r.indexOf(expectation);
-                    if (i > -1)
-                        r.splice(i, 1);
-                });
-        });
-        let result = 'PASS';
-        r.forEach(candidate => {
-            if (Expectations.stringToStateId(candidate) < Expectations.stringToStateId(result))
-                result = candidate;
-        });
-        return result;
-    }
-}
 let willFilterExpected = false;
 
 function minimumUuidForResults(results, limit) {
@@ -258,12 +213,6 @@
 }
 
 const testsRegex = /tests_([a-z])+/;
-const failureTypeOrder = ['failed', 'timedout', 'crashed'];
-const failureTypeMapping = {
-    failed: 'ERROR',
-    timedout: 'TIMEOUT',
-    crashed: 'CRASH',
-}
 
 function inPlaceCombine(out, obj)
 {
@@ -317,8 +266,8 @@
         tests_run: 1,
         tests_skipped: 0,
     }
-    failureTypeOrder.forEach(type => {
-        const idForType = Expectations.stringToStateId(failureTypeMapping[type]);
+    Expectations.failureTypes.forEach(type => {
+        const idForType = Expectations.stringToStateId(Expectations.failureTypeMap[type]);
         stats[`tests_${type}`] = actualId > idForType  ? 0 : 1;
         stats[`tests_unexpected_${type}`] = unexpectedId > idForType  ? 0 : 1;
     });
@@ -530,14 +479,7 @@
         const commits = commitsForResults(this.results, limit, this.allCommits);
         const scale = scaleForCommits(commits);
 
-        const computedStyle = getComputedStyle(document.body);
-        const colorMap = {
-            success: computedStyle.getPropertyValue('--greenLight').trim(),
-            failed: computedStyle.getPropertyValue('--redLight').trim(),
-            timedout: computedStyle.getPropertyValue('--orangeLight').trim(),
-            crashed: computedStyle.getPropertyValue('--purpleLight').trim(),
-        }
-
+        const colorMap = Expectations.colorMap();
         this.updates = [];
         const options = {
             getScaleFunc: (value) => {
@@ -552,7 +494,7 @@
 
                 let tag = null;
                 let color = colorMap.success;
-                let symbol = TestResultsSymbolMap.success;
+                let symbol = Expectations.symbolMap.success;
                 if (data.stats) {
                     tag = data.stats[`tests${willFilterExpected ? '_unexpected_' : '_'}failed`];
 
@@ -564,10 +506,10 @@
                         tag = `${tag} %`
                     }
 
-                    failureTypeOrder.forEach(type => {
+                    Expectations.failureTypes.forEach(type => {
                         if (data.stats[`tests${willFilterExpected ? '_unexpected_' : '_'}${type}`] > 0) {
                             color = colorMap[type];
-                            symbol = TestResultsSymbolMap[type];
+                            symbol = Expectations.symbolMap[type];
                         }
                     });
                 } else {
@@ -574,10 +516,10 @@
                     let resultId = Expectations.stringToStateId(data.actual);
                     if (willFilterExpected)
                         resultId = Expectations.stringToStateId(Expectations.unexpectedResults(data.actual, data.expected));
-                    failureTypeOrder.forEach(type => {
-                        if (Expectations.stringToStateId(failureTypeMapping[type]) >= resultId) {
+                    Expectations.failureTypes.forEach(type => {
+                        if (Expectations.stringToStateId(Expectations.failureTypeMap[type]) >= resultId) {
                             color = colorMap[type];
-                            symbol = TestResultsSymbolMap[type];
+                            symbol = Expectations.symbolMap[type];
                         }
                     });
                 }
@@ -588,20 +530,44 @@
 
         function onDotClickFactory(configuration) {
             return (data) => {
-                // FIXME: We should do something sane here, but we probably need another endpoint
-                if (!data.start_time) {
-                    alert('Node is a combination of multiple runs');
-                    return;
-                }
-
-                let buildParams = configuration.toParams();
-                buildParams['suite'] = [self.suite];
-                buildParams['uuid'] = [data.uuid];
-                buildParams['after_time'] = [data.start_time];
-                buildParams['before_time'] = [data.start_time];
-                if (branch)
-                    buildParams['branch'] = branch;
-                window.open(`/urls/build?${paramsToQuery(buildParams)}`, '_blank');
+                let allData = [];
+                let partialConfiguration = {};
+                self.configurations.forEach(configurationKey => {
+                    if (configurationKey.compare(configuration) || configurationKey.compareSDKs(configuration))
+                        return;
+                    self.results[configurationKey.toKey()].forEach(pair => {
+                        const computedConfiguration = new Configuration(pair.configuration);
+                        if (computedConfiguration.compare(configuration) || computedConfiguration.compareSDKs(configuration))
+                            return;
+                        let doesMatch = false;
+                        pair.results.forEach(node => {
+                            if (node.uuid !== data.uuid)
+                                return;
+                            doesMatch = true;
+                            let dataNode = {};
+                            Object.keys(node).forEach(key => {
+                                dataNode[key] = node[key];
+                            });
+                            dataNode['configuration'] = computedConfiguration;
+                            allData.push(dataNode);
+                        });
+                        if (doesMatch) {
+                            Configuration.members().forEach(member => {
+                                if (member in partialConfiguration) {
+                                    if (partialConfiguration[member] !== null && partialConfiguration[member] !== computedConfiguration[member])
+                                        partialConfiguration[member] = null;
+                                } else if (computedConfiguration[member] !== null)
+                                    partialConfiguration[member] = computedConfiguration[member];
+                            });
+                        }
+                    });
+                });
+                let agregateData = {};
+                Object.keys(data).forEach(key => {
+                    agregateData[key] = data[key];
+                });
+                agregateData['configuration'] = new Configuration(partialConfiguration);
+                InvestigateDrawer.expand(self.suite, agregateData, allData);
             }
         }
 
@@ -832,6 +798,7 @@
 } 
 
 function Legend(callback=null, plural=false) {
+    InvestigateDrawer.willFilterExpected = willFilterExpected;
     let updateLabelEvents = new EventStream();
     const legendDetails = {
         success: {
@@ -873,7 +840,7 @@
                     }
                 });
                 return `<div class="item">
-                        <div class="dot ${key}" ref="${dot}"><div class="text">${TestResultsSymbolMap[key]}</div></div>
+                        <div class="dot ${key}" ref="${dot}"><div class="text">${Expectations.symbolMap[key]}</div></div>
                         ${LegendLabel(updateLabelEvents, legendDetails[key].expected, legendDetails[key].unexpected)}
                     </div>`
             }).join('')}
@@ -888,6 +855,8 @@
                     else
                         willFilterExpected = false;
                     updateLabelEvents.add(willFilterExpected);
+                    InvestigateDrawer.willFilterExpected = willFilterExpected;
+                    InvestigateDrawer.select(InvestigateDrawer.selected);
                     callback();
                 };
             },

Modified: trunk/Tools/resultsdbpy/resultsdbpy/view/static/library/css/webkit.css (250354 => 250355)


--- trunk/Tools/resultsdbpy/resultsdbpy/view/static/library/css/webkit.css	2019-09-25 19:43:02 UTC (rev 250354)
+++ trunk/Tools/resultsdbpy/resultsdbpy/view/static/library/css/webkit.css	2019-09-25 20:27:35 UTC (rev 250355)
@@ -890,7 +890,7 @@
   background-color: var(--blurBackgroundColor);
   -webkit-backdrop-filter: blur(5px) brightness(88%);
   backdrop-filter: blur(5px) brightness(88%);
-  z-index: 50;
+  z-index: var(--middleZIndex);
   right: 0;
 }
 .sidebar.hidden {
@@ -937,87 +937,6 @@
   margin-top: calc(12px * 2  + var(--largeSize) * 1.3 + var(--smallSize) * 1.3 + 12px * 2);
 }
 
-@media screen and (min-width: 600px) {
-  .sidebar {
-    display: block;
-    width: 299px;
-    z-index: 0;
-    left: 0;
-    right: unset;
-  }
-  .sidebar.left.hidden {
-    display: block;
-    left: -249px;
-  }
-  .sidebar.right.hidden {
-    display: block;
-    right: -249px;
-  }
-  .sidebar.under-topbar-with-actions {
-    height: calc(100% - 12px * 2  - var(--largeSize) * 1.3);
-    bottom: 0;
-  }
-
-  .main {
-    margin-left: 299px;
-    width: calc(100% - 299px);
-  }
-
-  .main.left {
-    margin-left: 0px;
-    margin-right: 299px;
-  }
-  .main.right.hidden {
-    margin-left: 50px;
-    width: calc(100% - 50px);
-  }
-  .main.left.hidden {
-    margin-left: 0;
-    margin-right: 50px;
-    width: calc(100% - 50px);
-  }
-
-  .main.under-topbar-with-actions {
-    margin-top: calc(12px * 2  + var(--largeSize) * 1.3);
-  }
-}
-
-@media screen and (min-width: 768px) {
-  .sidebar {
-    display: block;
-    width: 310px;
-    z-index: 0;
-    left: 0;
-    right: unset;
-  }
-  .sidebar.left.hidden {
-    display: block;
-    left: -260px;
-  }
-  .sidebar.right.hidden {
-    display: block;
-    right: -260px;
-  }
-  .sidebar.under-topbar-with-actions {
-    height: calc(100% - 12px * 2  - var(--largeSize) * 1.3);
-    bottom: 0;
-  }
-
-  .mobile-sidebar-control.display {
-    display: none;
-  }
-
-  .main {
-    margin-left: 310px;
-    width: calc(100% - 310px);
-  }
-
-  .main.left {
-    margin-left: 0px;
-    margin-right: 310px;
-  }
-}
-
 .sidebar.right {
   left: unset;
   right: 0;
@@ -1548,6 +1467,7 @@
 }
 
 .drawer.display {
+  min-height: 250px;
   height: 30%;
   box-shadow: 0px 0px 5px 1px var(--grey);
 }
@@ -1762,6 +1682,85 @@
   pointer-events: none; 
 }
 
+@media screen and (min-width: 600px) {
+  .sidebar {
+    display: block;
+    width: 299px;
+    left: 0;
+    right: unset;
+  }
+  .sidebar.left.hidden {
+    display: block;
+    left: -249px;
+  }
+  .sidebar.right.hidden {
+    display: block;
+    right: -249px;
+  }
+  .sidebar.under-topbar-with-actions {
+    height: calc(100% - 12px * 2  - var(--largeSize) * 1.3);
+    bottom: 0;
+  }
+
+  .main {
+    margin-left: 299px;
+    width: calc(100% - 299px);
+  }
+
+  .main.right-sidebar {
+    margin-left: 0px;
+    margin-right: 299px;
+  }
+  .main.left-sidebar.hidden {
+    margin-left: 50px;
+    width: calc(100% - 50px);
+  }
+  .main.right-sidebar.hidden {
+    margin-left: 0;
+    margin-right: 50px;
+    width: calc(100% - 50px);
+  }
+
+  .main.under-topbar-with-actions {
+    margin-top: calc(12px * 2  + var(--largeSize) * 1.3);
+  }
+}
+
+@media screen and (min-width: 768px) {
+  .sidebar {
+    display: block;
+    width: 310px;
+    left: 0;
+    right: unset;
+  }
+  .sidebar.left.hidden {
+    display: block;
+    left: -260px;
+  }
+  .sidebar.right.hidden {
+    display: block;
+    right: -260px;
+  }
+  .sidebar.under-topbar-with-actions {
+    height: calc(100% - 12px * 2  - var(--largeSize) * 1.3);
+    bottom: 0;
+  }
+
+  .mobile-sidebar-control.display {
+    display: none;
+  }
+
+  .main {
+    margin-left: 310px;
+    width: calc(100% - 310px);
+  }
+
+  .main.right-sidebar {
+    margin-left: 0px;
+    margin-right: 310px;
+  }
+}
+
 /* timeline */
 .timeline {
   display: flex;
@@ -2607,6 +2606,9 @@
 .desktop-control {
   display: none;
 }
+.mobile-control {
+  display: block;
+}
 
 .mobile-sidebar-control {
   display: none;
@@ -2620,6 +2622,9 @@
   .desktop-control {
     display: block;
   }
+  .mobile-control {
+    display: none;
+  }
   .mobile-sidebar-control.display {
     display: none;
   }

Modified: trunk/Tools/resultsdbpy/resultsdbpy/view/templates/commits.html (250354 => 250355)


--- trunk/Tools/resultsdbpy/resultsdbpy/view/templates/commits.html	2019-09-25 19:43:02 UTC (rev 250354)
+++ trunk/Tools/resultsdbpy/resultsdbpy/view/templates/commits.html	2019-09-25 20:27:35 UTC (rev 250355)
@@ -104,7 +104,7 @@
     OneLineSwitch(),
     BranchSelector(() => {table.reload()}),
 ])}
-<div class="main left under-topbar-with-actions">
+<div class="main right-sidebar under-topbar-with-actions">
     <div class="content">${table}</div>
 </div>`);
 

Modified: trunk/Tools/resultsdbpy/resultsdbpy/view/templates/search.html (250354 => 250355)


--- trunk/Tools/resultsdbpy/resultsdbpy/view/templates/search.html	2019-09-25 19:43:02 UTC (rev 250354)
+++ trunk/Tools/resultsdbpy/resultsdbpy/view/templates/search.html	2019-09-25 20:27:35 UTC (rev 250355)
@@ -34,6 +34,7 @@
 import {deepCompare, ErrorDisplay, queryToParams, paramsToQuery} from '/assets/js/common.js';
 import {Configuration} from '/assets/js/configuration.js';
 import {Drawer, BranchSelector, ConfigurationSelectors, LimitSlider} from '/assets/js/drawer.js';
+import {InvestigateDrawer} from '/assets/js/investigate.js';
 import {SearchBar} from '/assets/js/search.js';
 import {Legend, TimelineFromEndpoint} from '/assets/js/timeline.js';
 import {ToolTip} from '/assets/js/tooltip.js';
@@ -225,6 +226,7 @@
 DOM.inject(
     document.getElementById('app'),
     `${ToolTip}
+    ${InvestigateDrawer}
     ${Drawer([
         Legend(() => {
             view.children.forEach((child) => {
@@ -239,7 +241,7 @@
         ConfigurationSelectors(() => {view.reload()}),
     ], () => onLayoutChange.add())}
 
-    <div class="main left under-topbar-with-actions">
+    <div class="main right-sidebar under-topbar-with-actions">
         <div class="content">
             ${SearchBar(function () {
                 const splitURL = document.URL.split('?');

Modified: trunk/Tools/resultsdbpy/resultsdbpy/view/templates/suite_results.html (250354 => 250355)


--- trunk/Tools/resultsdbpy/resultsdbpy/view/templates/suite_results.html	2019-09-25 19:43:02 UTC (rev 250354)
+++ trunk/Tools/resultsdbpy/resultsdbpy/view/templates/suite_results.html	2019-09-25 20:27:35 UTC (rev 250355)
@@ -34,6 +34,7 @@
 import {deepCompare, ErrorDisplay, queryToParams, paramsToQuery} from '/assets/js/common.js';
 import {Configuration} from '/assets/js/configuration.js';
 import {Drawer, BranchSelector, ConfigurationSelectors, LimitSlider} from '/assets/js/drawer.js';
+import {InvestigateDrawer} from '/assets/js/investigate.js';
 import {Legend, TimelineFromEndpoint} from '/assets/js/timeline.js';
 import {ToolTip} from '/assets/js/tooltip.js';
 import {DOM, REF, EventStream} from '/library/js/Ref.js';
@@ -168,6 +169,7 @@
 });
 
 DOM.inject(document.getElementById('app'), `${ToolTip}
+${InvestigateDrawer}
 ${Drawer([
     Legend(() => {
         for (let suite in view.children) {
@@ -181,7 +183,7 @@
     }),
     ConfigurationSelectors(() => {view.reload()}),
 ], () => onLayoutChange.add())}
-<div class="main left under-topbar-with-actions">
+<div class="main right-sidebar under-topbar-with-actions">
     <div class="content">
         ${view}
     </div>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to