From 132921816a9b43e04b7c396c3b46d9b1f14f2d87 Mon Sep 17 00:00:00 2001 From: Erika Miguel Date: Tue, 28 Mar 2023 15:45:49 -0400 Subject: [PATCH] initial support for copy changes for no data --- client/.storybook/main.js | 4 ++-- client/webpack.config.js | 2 +- config/dev.env | 4 ++-- server/apps/embed.js | 23 +++++++++++++++++++++-- server/handlebars/helpers/index.js | 6 ++++++ server/handlebars/views/main.hbs | 18 +++++++++++++++--- 6 files changed, 47 insertions(+), 10 deletions(-) diff --git a/client/.storybook/main.js b/client/.storybook/main.js index 3922dfbb4..47b716e96 100644 --- a/client/.storybook/main.js +++ b/client/.storybook/main.js @@ -1,7 +1,7 @@ module.exports = { core: { - builder: 'webpack5', - }, + builder: 'webpack5' + }, stories: ['../stories/*.stories.jsx'], addons: ['@storybook/addon-a11y', '@storybook/addon-controls'] }; diff --git a/client/webpack.config.js b/client/webpack.config.js index b3b8fc590..a550e3174 100644 --- a/client/webpack.config.js +++ b/client/webpack.config.js @@ -71,7 +71,7 @@ module.exports = { proxy: [ { context: ['/aria-at', '/api', '/embed'], - target: 'http://localhost:8000' + target: 'http://localhost:5000' } ] }, diff --git a/config/dev.env b/config/dev.env index 3e0c01b77..73d9420ad 100644 --- a/config/dev.env +++ b/config/dev.env @@ -1,6 +1,6 @@ -API_SERVER=http://localhost:8000 +API_SERVER=http://localhost:5000 APP_SERVER=http://localhost:3000 -PORT=8000 +PORT=5000 PGDATABASE=aria_at_report PGUSER=atr PGPASSWORD=atr diff --git a/server/apps/embed.js b/server/apps/embed.js index 7275a30ab..caa548182 100644 --- a/server/apps/embed.js +++ b/server/apps/embed.js @@ -36,7 +36,7 @@ const queryReports = async () => { const { data, errors } = await apolloServer.executeOperation({ query: gql` query { - testPlanReports(statuses: [CANDIDATE, RECOMMENDED]) { + testPlanReports(statuses: [DRAFT, CANDIDATE, RECOMMENDED]) { id metrics status @@ -86,7 +86,10 @@ const getLatestReportsForPattern = ({ allTestPlanReports, pattern }) => { let title; const testPlanReports = allTestPlanReports.filter(report => { - if (report.testPlanVersion.testPlan.id === pattern) { + if ( + report.testPlanVersion.testPlan.id === pattern && + report.status !== 'DRAFT' + ) { title = report.testPlanVersion.title; return true; } @@ -181,6 +184,19 @@ const getLatestReportsForPattern = ({ allTestPlanReports, pattern }) => { }; }; +const getAllAtBrowserCombinations = reports => { + const combinations = {}; + + reports.forEach(report => { + if (!(report.at.name in combinations)) { + combinations[report.at.name] = new Set(); + } + combinations[report.at.name].add(report.browser.name); + }); + + return combinations; +}; + const renderEmbed = ({ allTestPlanReports, queryTitle, @@ -196,9 +212,12 @@ const renderEmbed = ({ status, reportsByAt } = getLatestReportsForPattern({ pattern, allTestPlanReports }); + const allAtBrowserCombinations = + getAllAtBrowserCombinations(allTestPlanReports); return hbs.renderView(resolve(handlebarsPath, 'views/main.hbs'), { layout: 'index', dataEmpty: Object.keys(reportsByAt).length === 0, + allAtBrowserCombinations, title: queryTitle || title || 'Pattern Not Found', pattern, status, diff --git a/server/handlebars/helpers/index.js b/server/handlebars/helpers/index.js index c48dbc2b1..e4c230826 100644 --- a/server/handlebars/helpers/index.js +++ b/server/handlebars/helpers/index.js @@ -13,6 +13,12 @@ module.exports = { getAtVersion: function (object, key) { return object.allAtVersionsByAt[key].name; }, + combinationExists: function (object, atName, browserName) { + if (object.allAtBrowserCombinations[atName].has(browserName)) { + return true; + } + return false; + }, elementExists: function (parentObject, childObject, at, key, last) { const atBrowsers = childObject.map(o => o.browser.name); diff --git a/server/handlebars/views/main.hbs b/server/handlebars/views/main.hbs index 50794f025..98e127d80 100644 --- a/server/handlebars/views/main.hbs +++ b/server/handlebars/views/main.hbs @@ -59,7 +59,11 @@ {{else}} {{#if (isInAllBrowsers "Chrome" @../../this) }} {{#unless (elementExists @../../this @../this this.at.name "Chrome" @last)}} - No Data + {{#if (combinationExists @../../this this.at.name "Chrome")}} + Data Not Yet Available + {{else}} + Not Applicable + {{/if}} {{/unless}} {{/if}} {{/if}} @@ -75,7 +79,11 @@ {{else}} {{#if (isInAllBrowsers "Firefox" @../../this) }} {{#unless (elementExists @../../this @../this this.at.name "Firefox" @last)}} - No Data + {{#if (combinationExists @../../this this.at.name "Firefox")}} + Data Not Yet Available + {{else}} + Not Applicable + {{/if}} {{/unless}} {{/if}} {{/if}} @@ -91,7 +99,11 @@ {{else}} {{#if (isInAllBrowsers "Safari" @../../this) }} {{#unless (elementExists @../../this @../this this.at.name "Safari" @last)}} - No Data + {{#if (combinationExists @../../this this.at.name "Safari")}} + Data Not Yet Available + {{else}} + Not Applicable + {{/if}} {{/unless}} {{/if}} {{/if}}