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}} diff --git a/server/scripts/populate-test-data/pg_dump_2021_05_test_data.sql b/server/scripts/populate-test-data/pg_dump_2021_05_test_data.sql index 0b93d9128..512e0c849 100644 --- a/server/scripts/populate-test-data/pg_dump_2021_05_test_data.sql +++ b/server/scripts/populate-test-data/pg_dump_2021_05_test_data.sql @@ -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 diff --git a/server/tests/integration/embed.test.js b/server/tests/integration/embed.test.js index 2ef687f54..60dc40af9 100644 --- a/server/tests/integration/embed.test.js +++ b/server/tests/integration/embed.test.js @@ -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 } @@ -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: