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 1329218
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 10 deletions.
4 changes: 2 additions & 2 deletions client/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
core: {
builder: 'webpack5',
},
builder: 'webpack5'
},
stories: ['../stories/*.stories.jsx'],
addons: ['@storybook/addon-a11y', '@storybook/addon-controls']
};
2 changes: 1 addition & 1 deletion client/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module.exports = {
proxy: [
{
context: ['/aria-at', '/api', '/embed'],
target: 'http://localhost:8000'
target: 'http://localhost:5000'
}
]
},
Expand Down
4 changes: 2 additions & 2 deletions config/dev.env
Original file line number Diff line number Diff line change
@@ -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
Expand Down
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 1329218

Please sign in to comment.