Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for copy changes for no data #583

Merged
merged 2 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ INSERT INTO "TestPlanReport" (id, "status", "testPlanVersionId", "createdAt", "a
INSERT INTO "TestPlanReport" (id, "status", "testPlanVersionId", "createdAt", "atId", "browserId", "candidateStatusReachedAt", "recommendedStatusReachedAt", "vendorReviewStatus") VALUES (4, 'CANDIDATE', get_test_plan_version_id(text 'Modal Dialog Example'), '2021-05-14 14:18:23.602-05', 2, 1, '2022-07-06', '2023-01-02', 'READY');
INSERT INTO "TestPlanReport" (id, "status", "testPlanVersionId", "createdAt", "atId", "browserId", "candidateStatusReachedAt", "recommendedStatusReachedAt", "vendorReviewStatus") VALUES (5, 'CANDIDATE', get_test_plan_version_id(text 'Modal Dialog Example'), '2021-05-14 14:18:23.602-05', 3, 3, '2022-07-06', '2023-01-02', 'READY');
INSERT INTO "TestPlanReport" (id, "status", "testPlanVersionId", "createdAt", "atId", "browserId", "candidateStatusReachedAt", "recommendedStatusReachedAt", "vendorReviewStatus") VALUES (6, 'CANDIDATE', get_test_plan_version_id(text 'Checkbox Example (Mixed-State)'), '2021-05-14 14:18:23.602-05', 3, 3, '2022-07-06', '2023-01-02', 'READY');
INSERT INTO "TestPlanReport" (id, "status", "testPlanVersionId", "createdAt", "atId", "browserId") VALUES (7, 'DRAFT', get_test_plan_version_id(text 'Alert Example'), '2021-05-14 14:18:23.602-05', 3, 1);

--
-- Data for Name: User; Type: TABLE DATA; Schema: public; Owner: atr
Expand Down
7 changes: 7 additions & 0 deletions server/tests/integration/embed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ describe('embed', () => {

const nonWarning = screen.queryByText('Recommended Report');
const warning = screen.queryByText('Warning! Unapproved Report');
const unsupportedAtBrowserCombination =
screen.getAllByText('Not Applicable');
const futureSupportedAtBrowserCombination = screen.getAllByText(
'Data Not Yet Available'
);
const nonWarningContents = screen.queryByText(
'The information in this report is generated from candidate tests',
{ exact: false }
Expand All @@ -67,6 +72,8 @@ describe('embed', () => {
expect(initialLoadTime / 10).toBeGreaterThan(cachedTime);
expect(nonWarning || warning).toBeTruthy();
expect(nonWarningContents || warningContents).toBeTruthy();
expect(unsupportedAtBrowserCombination).toBeTruthy();
expect(futureSupportedAtBrowserCombination).toBeTruthy();
expect(viewReportButton).toBeTruthy();
expect(viewReportButtonOnClick).toMatch(
// Onclick should be like the following:
Expand Down