Skip to content

Commit

Permalink
initial support for copy changes for no data
Browse files Browse the repository at this point in the history
  • Loading branch information
evmiguel committed Mar 28, 2023
1 parent d3898db commit ab13bcd
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
23 changes: 21 additions & 2 deletions server/apps/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions server/handlebars/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
18 changes: 15 additions & 3 deletions server/handlebars/views/main.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@
{{else}}
{{#if (isInAllBrowsers "Chrome" @../../this) }}
{{#unless (elementExists @../../this @../this this.at.name "Chrome" @last)}}
<td><span class="no-data-cell">No Data</span></td>
{{#if (combinationExists @../../this this.at.name "Chrome")}}
<td><span class="no-data-cell">Data Not Yet Available</span></td>
{{else}}
<td><span class="no-data-cell">Not Applicable</span></td>
{{/if}}
{{/unless}}
{{/if}}
{{/if}}
Expand All @@ -75,7 +79,11 @@
{{else}}
{{#if (isInAllBrowsers "Firefox" @../../this) }}
{{#unless (elementExists @../../this @../this this.at.name "Firefox" @last)}}
<td><span class="no-data-cell">No Data</span></td>
{{#if (combinationExists @../../this this.at.name "Firefox")}}
<td><span class="no-data-cell">Data Not Yet Available</span></td>
{{else}}
<td><span class="no-data-cell">Not Applicable</span></td>
{{/if}}
{{/unless}}
{{/if}}
{{/if}}
Expand All @@ -91,7 +99,11 @@
{{else}}
{{#if (isInAllBrowsers "Safari" @../../this) }}
{{#unless (elementExists @../../this @../this this.at.name "Safari" @last)}}
<td><span class="no-data-cell">No Data</span></td>
{{#if (combinationExists @../../this this.at.name "Safari")}}
<td><span class="no-data-cell">Data Not Yet Available</span></td>
{{else}}
<td><span class="no-data-cell">Not Applicable</span></td>
{{/if}}
{{/unless}}
{{/if}}
{{/if}}
Expand Down

0 comments on commit ab13bcd

Please sign in to comment.