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

Add missing entities to report summary #4215

Merged
merged 3 commits into from
Jan 23, 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
4 changes: 2 additions & 2 deletions client/src/components/Compact.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ const EmptySpaceTdS = styled.td`
`

export const CompactRow = ({ label, content, ...otherProps }) => {
const { style, className } = otherProps
const { id, style, className } = otherProps
// merge custom style
const CustomStyled = styled(CompactRowS)`
${style};
Expand All @@ -360,7 +360,7 @@ export const CompactRow = ({ label, content, ...otherProps }) => {
const isHeaderRow = className === "reportField"

return (
<CustomStyled className={className || null}>
<CustomStyled id={id} className={className}>
{label && <RowLabelS isHeaderRow={isHeaderRow}>{label}</RowLabelS>}
<CompactRowContentS colSpan={label ? 1 : 2}>{content}</CompactRowContentS>
</CustomStyled>
Expand Down
5 changes: 3 additions & 2 deletions client/src/components/SimpleMultiCheckboxDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useOutsideClick } from "utils"
* @param {object} options {key1: { text: string, active: boolean}, ...}
* @param {function} setOptions
*/
const SimpleMultiCheckboxDropdown = ({ label, options, setOptions }) => {
const SimpleMultiCheckboxDropdown = ({ id, label, options, setOptions }) => {
const [active, setActive] = useState(false)
const dropDownRef = useRef(null)
useOutsideClick(dropDownRef, () => setActive(false))
Expand All @@ -23,7 +23,7 @@ const SimpleMultiCheckboxDropdown = ({ label, options, setOptions }) => {
{label}
</Button>
<div>
<div>
<div id={id}>
{Object.entries(options).map(([optionKey, option]) => (
<label htmlFor={optionKey} key={optionKey}>
{option.text}
Expand Down Expand Up @@ -134,6 +134,7 @@ const DropdownButton = styled.span`
`

SimpleMultiCheckboxDropdown.propTypes = {
id: PropTypes.string,
label: PropTypes.string,
options: PropTypes.objectOf(
PropTypes.shape({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,31 +105,46 @@ const InstantAssessmentsContainerField = ({
formikProps,
canRead,
canWrite,
readonly
readonly,
showEntitiesWithoutAssessments
}) => {
const { values } = formikProps

function hasFilteredAssessments(ac, e) {
const filteredAssessment = Model.filterAssessmentConfig(
ac,
e,
relatedObject
)
return (
!_isEmpty(filteredAssessment.questions) ||
!_isEmpty(filteredAssessment.questionSets)
)
}
// Sort entities to display the ones without any assessment at the beginning,
// then the ones with assessments. Keep the original sort order within each section.
function sortEntries(e1, e2) {
const e1hasAssessments = e1
.getInstantAssessments()
.some(([, ac]) => hasFilteredAssessments(ac, e1))
const e2hasAssessments = e2
.getInstantAssessments()
.some(([, ac]) => hasFilteredAssessments(ac, e2))
return Number(e1hasAssessments) - Number(e2hasAssessments)
}
function getEntitiesWithAssessments(entity) {
return entity
.getInstantAssessments()
.some(([, ac]) => hasFilteredAssessments(ac, entity))
}
const filteredEntities = showEntitiesWithoutAssessments
? entities.sort(sortEntries)
: entities.filter(getEntitiesWithAssessments)
return (
<Table>
<tbody>
{entities.map(entity => {
{filteredEntities.map(entity => {
const entityInstantAssessments = entity.getInstantAssessments()
let hasAssessments = false
entityInstantAssessments.forEach(([ak, ac]) => {
const filteredAssessment = Model.filterAssessmentConfig(
ac,
entity,
relatedObject
)
if (
!_isEmpty(filteredAssessment.questions) ||
!_isEmpty(filteredAssessment.questionSets)
) {
hasAssessments = true
}
})
if (!hasAssessments) {
return null
}

return (
<React.Fragment key={`assessment-${values.uuid}-${entity.uuid}`}>
Expand Down Expand Up @@ -172,7 +187,8 @@ InstantAssessmentsContainerField.propTypes = {
}),
canRead: PropTypes.bool,
canWrite: PropTypes.bool,
readonly: PropTypes.bool
readonly: PropTypes.bool,
showEntitiesWithoutAssessments: PropTypes.bool
}
InstantAssessmentsContainerField.defaultProps = {
entities: [],
Expand Down
4 changes: 4 additions & 0 deletions client/src/pages/reports/Compact.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,15 @@ const CompactReportView = ({ pageDispatchers }) => {
className="reportField"
/>
<CompactRow
id="principals"
label="principals"
content={getAttendeesAndAssessments(
Person.ROLE.PRINCIPAL
)}
className="reportField"
/>
<CompactRow
id="advisors"
label="advisors"
content={getAttendeesAndAssessments(Person.ROLE.ADVISOR)}
className="reportField"
Expand Down Expand Up @@ -484,6 +486,7 @@ const CompactReportView = ({ pageDispatchers }) => {
}}
canRead={canReadAssessments}
readonly
showEntitiesWithoutAssessments
/>
) : (
attendees.map(attendee => (
Expand Down Expand Up @@ -534,6 +537,7 @@ const CompactReportViewHeader = ({
))}
</DropdownButton>
<SimpleMultiCheckboxDropdown
id="optionalFields"
label="Optional Fields ⇓"
options={optionalFields}
setOptions={setOptionalFields}
Expand Down
36 changes: 36 additions & 0 deletions client/tests/webdriver/baseSpecs/printReport.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ import Home from "../pages/home.page"
import MyReports, { REPORT_STATES } from "../pages/myReports.page"
import ShowReport from "../pages/report/showReport.page"

const PRINCIPALS = [
"Maj CHRISVILLE, Chris",
"CIV KYLESON, Kyle",
"CIV SHARTON, Shardul"
]

const ADVISORS = ["CIV DMIN, Arthur", "CIV GUIST, Lin"]

describe("Show print report page", () => {
beforeEach("Open the show report page", () => {
MyReports.open("arthur")
Expand Down Expand Up @@ -52,5 +60,33 @@ describe("Show print report page", () => {
const bannerSecurityText = Home.bannerSecurityText.getText()
expect(compactBannerText).to.equal(bannerSecurityText)
})
it("Should display all attendees", () => {
const displayedPrincipals =
ShowReport.getCompactViewAttendees("principals")
const displayedAdvisors = ShowReport.getCompactViewAttendees("advisors")
PRINCIPALS.forEach(principal => {
expect(displayedPrincipals).to.contain(principal)
})
ADVISORS.forEach(advisor => {
expect(displayedAdvisors).to.contain(advisor)
})
})
it("Should display all attendees when assessments are shown", () => {
ShowReport.selectOptionalField("assessments")
const displayedPrincipals = ShowReport.getCompactViewAttendees(
"principals",
true
)
PRINCIPALS.forEach(principal => {
expect(displayedPrincipals).to.contain(principal)
})
const displayedAdvisors = ShowReport.getCompactViewAttendees(
"advisors",
true
)
ADVISORS.forEach(advisor => {
expect(displayedAdvisors).to.contain(advisor)
})
})
})
})
29 changes: 29 additions & 0 deletions client/tests/webdriver/pages/report/showReport.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,35 @@ class ShowReport extends Page {
this.reportStatus.waitForExist()
this.reportStatus.waitForDisplayed()
}

getCompactViewAttendees(type, withAssessments) {
return withAssessments
? browser
.$$(`#${type} > td > table > tbody > tr > td`)
// Filter out the assessment rows to get the attendees
.filter(row => {
return row.$("span > a").isExisting()
})
.map(row => {
return row.$("span > a").getText()
})
: browser
.$$(`#${type} > td > span > a`)
.map(attendeeLink => attendeeLink.getText())
}

selectOptionalField(field) {
const optionalFieldsButton = browser.$(
'//button[text()="Optional Fields ⇓"]'
)
const optionalFields = browser.$("#optionalFields")
const fieldCheckbox = browser.$(`input[id="${field}"]`)
optionalFieldsButton.click()
optionalFields.waitForDisplayed()
if (!fieldCheckbox.isSelected()) {
fieldCheckbox.click()
}
}
}

export default new ShowReport()
6 changes: 6 additions & 0 deletions insertBaseData-psql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,12 @@ INSERT INTO "reportPeople" ("personUuid", "reportUuid", "isPrimary", "isAuthor")
VALUES ((SELECT uuid FROM people where "emailAddress"='hunter+arthur@example.com'), :reportuuid, TRUE, TRUE);
INSERT INTO "reportPeople" ("personUuid", "reportUuid", "isPrimary")
VALUES ((SELECT uuid FROM people where "emailAddress"='hunter+shardul@example.com'), :reportuuid, TRUE);
INSERT INTO "reportPeople" ("personUuid", "reportUuid", "isPrimary")
VALUES ((SELECT uuid FROM people where "emailAddress"='lin+guist@example.com'), :reportuuid, FALSE);
INSERT INTO "reportPeople" ("personUuid", "reportUuid", "isPrimary")
VALUES ((SELECT uuid FROM people where "emailAddress"='kyleson+kyle@example.com'), :reportuuid, FALSE);
INSERT INTO "reportPeople" ("personUuid", "reportUuid", "isPrimary")
VALUES ((SELECT uuid FROM people where "emailAddress"='chrisville+chris@example.com'), :reportuuid, FALSE);
INSERT INTO "reportTasks" ("taskUuid", "reportUuid")
VALUES ((SELECT uuid from tasks where "shortName" = '1.2.A'), :reportuuid);
INSERT INTO "reportTasks" ("taskUuid", "reportUuid")
Expand Down