Skip to content

Commit

Permalink
AB#1114: Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Chessray committed Jun 17, 2024
1 parent 5028b60 commit f34ecf9
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 9 deletions.
20 changes: 15 additions & 5 deletions client/src/components/Compact.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ export const CompactHeaderContent = ({
<HeaderContentS bgc={appSettings[SETTING_KEY_COLOR]}>
<img src={anetLogo} alt="logo" width="50" height="12" />
<ClassificationBoxS>
<ClassificationBanner classification={classification} />
<ClassificationBanner
classification={classification}
bannerId="header-banner"
/>
{sensitiveInformation && <SensitivityInformation />}
</ClassificationBoxS>
</HeaderContentS>
Expand All @@ -150,7 +153,10 @@ export const CompactFooterContent = ({ object, classification }) => {
{object.uuid}
</Link>
</span>
<ClassificationBanner classification={classification} />
<ClassificationBanner
classification={classification}
bannerId="footer-banner"
/>
<PrintedByBoxS>
<div>
printed by{" "}
Expand Down Expand Up @@ -270,16 +276,20 @@ const FooterContentS = styled.div`
background-color: ${props => props.bgc} !important;
`

const ClassificationBanner = ({ classification }) => {
const ClassificationBanner = ({ classification, bannerId }) => {
return (
<ClassificationBannerS>
<CompactSecurityBanner classification={classification} />
<CompactSecurityBanner
classification={classification}
bannerId={bannerId}
/>
</ClassificationBannerS>
)
}

ClassificationBanner.propTypes = {
classification: PropTypes.string
classification: PropTypes.string,
bannerId: PropTypes.string
}

const ClassificationBannerS = styled.div`
Expand Down
11 changes: 7 additions & 4 deletions client/src/components/SecurityBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,17 @@ ConnectionBanner.propTypes = {
connection: PropTypes.object.isRequired
}

export const CompactSecurityBanner = ({ classification }) => {
export const CompactSecurityBanner = ({ classification, bannerId }) => {
const { appSettings } = useContext(AppContext)
return (
<CompactBannerS className="banner" bgc={appSettings[SETTING_KEY_COLOR]}>
{(classification && (
<span className="classificationText">{classification}</span>
<span className="classificationText" id={bannerId}>
{classification}
</span>
)) || (
<>
<span className="classificationText">
<span className="classificationText" id={bannerId}>
{appSettings[SETTING_KEY_CLASSIFICATION]?.toUpperCase() || ""}
</span>{" "}
<span className="releasabilityText">
Expand All @@ -229,7 +231,8 @@ export const CompactSecurityBanner = ({ classification }) => {
}

CompactSecurityBanner.propTypes = {
classification: PropTypes.string
classification: PropTypes.string,
bannerId: PropTypes.string
}

const CompactBannerS = styled.div`
Expand Down
44 changes: 44 additions & 0 deletions client/tests/webdriver/baseSpecs/printReport.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const ADVISORS = ["CIV DMIN, Arthur", "CIV GUIST, Lin"]

const TASKS = ["EF 1 » EF 1.2 » 1.2.A", "EF 1 » EF 1.2 » 1.2.B"]

const DEFAULT_REPORT_CLASSIFICATION = "DEMO USE ONLY"

describe("Show print report page", () => {
beforeEach("Open the show report page", async() => {
await MyReports.open("arthur")
Expand Down Expand Up @@ -124,4 +126,46 @@ describe("Show print report page", () => {
}
})
})
describe("When on the print page of a report without classification", () => {
it("We should see the default text for classification in the header and footer banners", async() => {
await (await ShowReport.getClassificationHeader()).waitForExist()
await (await ShowReport.getClassificationHeader()).waitForDisplayed()
await (await ShowReport.getClassificationFooter()).waitForExist()
await (await ShowReport.getClassificationFooter()).waitForDisplayed()
expect(
await (await ShowReport.getClassificationHeader()).getText()
).to.equal(DEFAULT_REPORT_CLASSIFICATION)
expect(
await (await ShowReport.getClassificationFooter()).getText()
).to.equal(DEFAULT_REPORT_CLASSIFICATION)
})
})
})

const REPORT_CLASSIFICATION = "NATO UNCLASSIFIED"
describe("Show print report page with classification", () => {
beforeEach("Open the show report page", async() => {
await MyReports.open("arthur")
await MyReports.selectReport(
"A classified report from Arthur",
REPORT_STATES.DRAFT
)
await (await ShowReport.getCompactViewButton()).click()
await (await ShowReport.getCompactView()).waitForExist()
await (await ShowReport.getCompactView()).waitForDisplayed()
})
describe("When on the print page of a report with classification", () => {
it("We should see the classification in the header and footer banners", async() => {
await (await ShowReport.getClassificationHeader()).waitForExist()
await (await ShowReport.getClassificationHeader()).waitForDisplayed()
await (await ShowReport.getClassificationFooter()).waitForExist()
await (await ShowReport.getClassificationFooter()).waitForDisplayed()
expect(
await (await ShowReport.getClassificationHeader()).getText()
).to.equal(REPORT_CLASSIFICATION)
expect(
await (await ShowReport.getClassificationFooter()).getText()
).to.equal(REPORT_CLASSIFICATION)
})
})
})
8 changes: 8 additions & 0 deletions client/tests/webdriver/pages/report/showReport.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ class ShowReport extends Page {
await fieldCheckbox.click()
}
}

async getClassificationHeader() {
return browser.$("#header-banner")
}

async getClassificationFooter() {
return browser.$("#footer-banner")
}
}

export default new ShowReport()

0 comments on commit f34ecf9

Please sign in to comment.