Skip to content

Commit

Permalink
198 add ecmps beta apis to api docs cards (#201)
Browse files Browse the repository at this point in the history
* Added ECMPS beta cards
* Added context about ECMPS and CAMPD and links to Power Sector Emission Data Guide
* Added Tags for CAMPD and ECMPS as well as the beta
* Split the API Doc card from the API Docs component
  • Loading branch information
ibarra-michelle authored May 14, 2023
1 parent 550819a commit 52bfbf8
Show file tree
Hide file tree
Showing 5 changed files with 273 additions and 39 deletions.
49 changes: 49 additions & 0 deletions src/components/APIDocCard/APIDocCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import {
Card,
CardHeader,
CardBody,
CardFooter,
Button,
Tag,
} from "@trussworks/react-uswds";
import React, { useRef, useEffect } from "react";
import { Link as RouterLink } from "react-router-dom";

export const APIDocCard = ({ page, index }) => {
const apiCardDocsRef = useRef(null);
useEffect(() => {
apiCardDocsRef.current.focus();
});

return (
<Card gridLayout={{ desktop: { col: 4 } }} key={index} align="left">
<CardHeader>
<h2
card-testid="card-title"
tabIndex={-1}
ref={apiCardDocsRef}
style={{ outline: "none" }}
>
{page.title}
</h2>
</CardHeader>
<CardBody>
{page.tags.map((tag) => {
return <Tag>{tag}</Tag>;
})}
<p>{page.description}</p>
</CardBody>
<CardFooter>
<RouterLink
to={`/swagger/${page.name}`}
rel="noopener noreferrer"
aria-label={`Link to ${page.title} API documentation`}
>
<Button className="usa-button" type="button">
View {page.title} docs
</Button>
</RouterLink>
</CardFooter>
</Card>
);
};
57 changes: 57 additions & 0 deletions src/components/APIDocCard/APIDocCard.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from "react";
import { getByText, render, waitFor, screen } from "@testing-library/react";
import { APIDocCard } from "./APIDocCard";
import { axe, toHaveNoViolations } from "jest-axe";
import { MemoryRouter } from "react-router-dom";
import { CardGroup } from "@trussworks/react-uswds";

window.open = jest.fn(); // mock window.open for testing the card
jest.setTimeout(30000);

describe("test the APIDocs page", () => {
it("renders the main content", async () => {
window.open.mockClear();
render(
<MemoryRouter>
<CardGroup>
<APIDocCard
page={{
title: "Beta",
name: "test",
description: "read",
tags: ["ECMPS"],
}}
index={1}
/>
</CardGroup>
</MemoryRouter>
);

await waitFor(() => {
expect(screen.getByText("Beta")).toBeInTheDocument();
});
});

expect.extend(toHaveNoViolations);

test("should pass axe accessibility tests", async () => {
const { container } = render(
<MemoryRouter>
<CardGroup>
<APIDocCard
page={{
title: "Beta",
name: "test",
description: "read",
tags: ["ECMPS"],
}}
index={1}
/>
</CardGroup>
</MemoryRouter>
);
const results = await axe(container);

expect(results).toHaveNoViolations();
});
});
110 changes: 72 additions & 38 deletions src/components/APIDocs/APIDocs.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import {
CardGroup,
Grid,
GridContainer,
CardGroup,
Card,
CardHeader,
CardBody,
CardFooter,
Button,
Tag,
Alert,
} from "@trussworks/react-uswds";
import React, { useRef, useEffect } from "react";
import { Link as RouterLink } from "react-router-dom";
import { constants } from "../../helpers/constants";
import { APIDocCard } from "../APIDocCard/APIDocCard";

export const APIDocs = () => {
const apiDocsRef = useRef(null);
Expand All @@ -28,41 +25,78 @@ export const APIDocs = () => {
</h1>
<p>
Explore the following CAM API Swagger docs for endpoints that
serve emissions, account, and compliance information.
serve emissions, account, and compliance information. The APIs
currently in production support the Clean Air Markets Program Data
( <Tag>CAMPD</Tag>) application, which provides allowance,
compliance, emissions and facility/unit attributes data collected
under EPA’s federal market-based trading programs. The beta APIs
listed below are for the Emissions Collection and Monitoring Plan
System ( <Tag>ECMPS</Tag>) 2.0, which is the tool used by
emissions sources to report monitoring plans and QA tests,
emissions, and operating data to EPA.
</p>
<p>
<b>Note:</b> The data obtained through CAMPD and the supporting
APIs come from the raw data submitted to ECMPS and have emissions
data that are apportioned for units with complex configurations,
whereas the emissions data found in ECMPS are raw reported data
without apportionment. For more detailed information about the
data CAMD collects and the specific difference between ECMPS and
CAMPD visit the "
<a
href="https://www.epa.gov/airmarkets/power-sector-emissions-data"
target="_blank"
rel="noopener noreferrer"
>
Power Sector Emissions Data resource page
</a>
" and read more in the following document: {""}
<a
href="https://www.epa.gov/system/files/documents/2022-07/CAMD%27s%20Power%20Sector%20Emissions%20Data%20Guide%20-%2007182022.pdf"
target="_blank"
rel="noopener noreferrer"
>
Power Sector Emissions Data Guide (pdf)
</a>
.
</p>

<Alert>
The ECMPS 2.0 {<Tag>beta</Tag>} tag in the beta section below
indicate that these APIs are in beta, which means they do not
contain up-to-date data and are not guaranteed to be stable.{" "}
<b>
These Beta APIs are only available for testing and should not be
used in production applications.
</b>{" "}
Visit the "
<a href="https://www.epa.gov/power-sector/ecmps-re-engineering-effort">
ECMPS 2.0 re-engineering page
</a>
" for more information about the ECMPS re-engineering effort.
</Alert>
</Grid>
</Grid>
<Grid row gap>
<br />
<Grid row>
<h2>Production API Documentation</h2>
<CardGroup>
{constants.swaggerPages
.filter((page) => page.env === "prod")
.map((page, index) => {
return <APIDocCard page={page} index={index}></APIDocCard>;
})}
</CardGroup>
</Grid>

<Grid row>
<h2>Beta API Documentation</h2>
<CardGroup>
{constants.swaggerPages.map((page, index) => {
return (
<Card
gridLayout={{ desktop: { col: 6 } }}
key={index}
align="left"
>
<CardHeader>
<h2 aria-label={`${page.title} API documents card`}>
{page.title}
</h2>
</CardHeader>
<CardBody>
<p>{page.description}</p>
</CardBody>
<CardFooter>
<RouterLink
to={`/swagger/${page.name}`}
rel="noopener noreferrer"
aria-label={`Link to ${page.title} API documentation`}
>
<Button className="usa-button" type="button">
View {page.title} docs
</Button>
</RouterLink>
</CardFooter>
</Card>
);
})}
{constants.swaggerPages
.filter((page) => page.env === "beta")
.map((page, index) => {
return <APIDocCard page={page} index={index}></APIDocCard>;
})}
</CardGroup>
</Grid>
</GridContainer>
Expand Down
2 changes: 1 addition & 1 deletion src/components/APIDocs/APIDocs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("test the APIDocs page", () => {
<APIDocs />
</MemoryRouter>
);
const textElement = screen.getByText(/API Documentation/i);
const textElement = screen.getByText(/Explore/i);
expect(textElement).toBeInTheDocument();
});

Expand Down
94 changes: 94 additions & 0 deletions src/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,138 @@ export const constants = {
name: "account-mgmt",
url: "https://api.epa.gov/easey/account-mgmt/swagger-json",
title: "Account",
env: "prod",
tags: ["CAMPD"],
description:
"Account management API endpoints for account information, allowance holdings, transactions, and compliance",
},
{
name: "facilities-mgmt",
url: "https://api.epa.gov/easey/facilities-mgmt/swagger-json",
title: "Facilities",
env: "prod",
tags: ["CAMPD"],
description:
"Facility management API endpoints for power sector facilities and their attributes (e.g. units, stacks, and owners)",
},
{
name: "emissions-mgmt",
url: "https://api.epa.gov/easey/emissions-mgmt/swagger-json",
title: "Emissions",
env: "prod",
tags: ["CAMPD"],
description:
"Emissions management API endpoints for apportioned emissions data (e.g. hourly, daily, monthly, annual, and ozone season)",
},
{
name: "master-data-mgmt",
url: "https://api.epa.gov/easey/master-data-mgmt/swagger-json",
title: "Master Data Management",
env: "prod",
tags: ["CAMPD"],
description:
"Master data management API endpoints for lookup codes and data relationships",
},
{
name: "streaming-services",
url: "https://api.epa.gov/easey/streaming-services/swagger-json",
title: "Streaming Services",
env: "prod",
tags: ["CAMPD"],
description:
"Streaming services API contains endpoints to stream account, allowance, facilities, and emissions data",
},
{
name: "camd-services",
url: "https://api.epa.gov/easey/camd-services/swagger-json",
title: "CAMD Services",
env: "prod",
tags: ["CAMPD"],
description:
"CAMD services API contains an endpoint for large, prepackaged datasets of facility submission files (I.e., emissions, monitoring plans, QA), apportioned emissions (including MATS), allowance, compliance, and facility data",
},
// {
// name: "account-mgmt",
// url: "https://api.epa.gov/easey/beta/account-mgmt/swagger-json",
// title: "Account",
// env: "beta",
// tags: ["ECMPS 2.0", "beta"],
// description:
// "Account management Beta API endpoints for account information, allowance holdings, transactions, and compliance",
// },

// {
// name: "beta-auth-mgmt",
// url: "https://api.epa.gov/easey/beta/auth-mgmt/swagger-json",
// title: "Authentication & Authorization",
// env: "beta",
// tags: ["ECMPS 2.0", "beta"],
// description:
// "Authentication and authorization Beta API endpoints for ECMPS user authentication and token generation"
// },
{
name: "beta-monitor-plan-mgmt",
url: "https://api.epa.gov/easey/beta/monitor-plan-mgmt/swagger-json",
title: "Monitoring Plans",
env: "beta",
tags: ["ECMPS 2.0", "beta"],
description:
"Monitoring plan management Beta API endpoints are for viewing and updating monitoring plan data.",
},
{
name: "beta-qa-certification-mgmt",
url: "https://api.epa.gov/easey/beta/qa-certification-mgmt/swagger-json",
title: "QA & Certifications",
env: "beta",
tags: ["ECMPS 2.0", "beta"],
description:
"QA and certification management Beta API endpoints are for viewing and updating QA and certification data.",
},
{
name: "beta-emissions-mgmt",
url: "https://api.epa.gov/easey/beta/emissions-mgmt/swagger-json",
title: "Emissions",
env: "beta",
tags: ["ECMPS 2.0", "beta"],
description:
"Emissions management Beta API endpoints for viewing and importing monitored emissions data and viewing apportioned emissions data (e.g. hourly, daily, monthly, annual, and ozone season)",
},
{
name: "beta-facilities-mgmt",
url: "https://api.epa.gov/easey/beta/facilities-mgmt/swagger-json",
title: "Facilities",
env: "beta",
tags: ["ECMPS 2.0", "beta"],
description:
"Facility management Beta API endpoints for power sector facilities and their attributes (e.g. units, stacks, and owners)",
},
{
name: "beta-master-data-mgmt",
url: "https://api.epa.gov/easey/beta/master-data-mgmt/swagger-json",
title: "Master Data Management",
env: "beta",
tags: ["ECMPS 2.0", "beta"],
description:
"Master data management Beta API endpoints for lookup codes and data relationships",
},
// {
// name: "streaming-services",
// url: "https://api.epa.gov/easey/streaming-services/swagger-json",
// title: "Beta Streaming Services",
// env: "beta",
// tags: ["ECMPS 2.0", "beta"],
// description:
// "Streaming services Beta API contains endpoints to stream account, allowance, facilities, and emissions data",
// },
// {
// name: "camd-services",
// url: "https://api.epa.gov/easey/camd-services/swagger-json",
// title: "Beta CAMD Services",
// env: "beta",
// tags: ["ECMPS 2.0", "beta"],
// description:
// "CAMD services Beta API contains an endpoint for large, prepackaged datasets of facility submission files (I.e., emissions, monitoring plans, QA), apportioned emissions (including MATS), allowance, compliance, and facility data",
// },
],
releasePages: [
{
Expand Down

0 comments on commit 52bfbf8

Please sign in to comment.