Skip to content
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 components/conference/ConferenceDetails.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ describe("ConferenceDetails", () => {
mockUser = { uid: "reader", emailVerified: true }
render(<ConferenceDetails {...props} />)
expect(
screen.getByRole("dialog", { name: "input.panel_title" })
screen.getByRole("dialog", { name: "input.cosign_title" })
).toBeInTheDocument()
letGo()
})
Expand All @@ -613,7 +613,7 @@ describe("ConferenceDetails", () => {
mockUser = { uid: "reader", emailVerified: true }
rerender(<ConferenceDetails {...props} />)
expect(
screen.getByRole("dialog", { name: "input.panel_title" })
screen.getByRole("dialog", { name: "input.cosign_title" })
).toBeInTheDocument()
expect(mockDispatch).toHaveBeenCalledTimes(1)
})
Expand Down
9 changes: 6 additions & 3 deletions components/conference/ConferenceDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -664,12 +664,15 @@ function InputPanel({
return () => onDraft(undefined)
}, [edit.draft, edit.loading, onDraft])

const mode = cosigning ? "cosign_" : ""
const title =
step === "review"
? "input.review_title"
: cosigning && edit.publication
? `input.${mode}review_title`
: !cosigning
? "input.panel_title"
: edit.publication
? "input.cosign_edit_title"
: "input.panel_title"
: "input.cosign_title"
return (
<Panel
open={open}
Expand Down
6 changes: 3 additions & 3 deletions components/conference/input/CosignForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ describe("CosignForm", () => {
const onPosted = jest.fn()
const onStep = jest.fn()
mount(edit, "write", { onPosted, onStep })
press("input.review")
press("input.cosign_review")
expect(onStep).not.toHaveBeenCalled()

fireEvent.click(
screen.getByRole("checkbox", { name: "input.cosign_no_words_label" })
)
expect(screen.getByRole("textbox")).toBeDisabled()
press("input.review")
press("input.cosign_review")
expect(onStep).toHaveBeenCalledWith("review")
expect(edit.publishTestimony.execute).not.toHaveBeenCalled()
})
Expand Down Expand Up @@ -254,7 +254,7 @@ describe("CosignForm", () => {
fireEvent.change(screen.getByRole("textbox"), {
target: { value: "After." }
})
press("input.review")
press("input.cosign_review")
expect(onStep).toHaveBeenCalledWith("review")
})

Expand Down
12 changes: 11 additions & 1 deletion components/conference/input/CosignForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
Body,
ConductRule,
Field,
Hint,
Label,
Muted,
Primary,
Expand Down Expand Up @@ -233,6 +234,12 @@ const Optional = styled(Cosigned)`
color: ${ink.faint};
`

/** Where the reader's line lands in the letter. */
const LineHint = styled(Hint)`
margin: -4px 0 8px;
text-align: left;
`

const NoteField = styled(Field)`
&:disabled {
background: ${wash.default};
Expand Down Expand Up @@ -447,6 +454,9 @@ export function CosignForm({
{t("input.cosign_body_label")}{" "}
<Optional>{t("input.cosign_optional")}</Optional>
</Label>
<LineHint>
{t("input.cosign_line_hint", { name: nameOf(parent) })}
</LineHint>
<NoteField
ref={field}
value={content}
Expand Down Expand Up @@ -495,7 +505,7 @@ export function CosignForm({
aria-disabled={!ready}
onClick={() => (ready ? onStep("review") : ask.ask())}
>
{t("input.review")}
{t("input.cosign_review")}
</Press>
</Actions>
</Body>
Expand Down
26 changes: 26 additions & 0 deletions components/conference/input/InputForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,33 @@ const review = (edit: UseEditConferenceTestimony) =>
/>
)

const write = (edit: UseEditConferenceTestimony) =>
render(
<InputForm
court={194}
conferenceId="H1-S1"
conferees={["CC", "BF"]}
edit={edit}
subject="Phone-Free Schools"
step="write"
onStep={jest.fn()}
onCancel={jest.fn()}
onPosted={jest.fn()}
/>
)

describe("InputForm", () => {
it("promises the email to legislators only when the profile has some", () => {
const { unmount } = write(editing())
expect(screen.getByText("input.delivery_note")).toBeInTheDocument()
unmount()

mockProfile.current = { fullName: "Gina K." }
write(editing())
expect(screen.getByText("input.delivery_note_weekly")).toBeInTheDocument()
expect(screen.queryByText("input.delivery_note")).not.toBeInTheDocument()
})

it("leaves a cosign's draft alone while it sits behind a closed panel", () => {
jest.useFakeTimers()
const edit = {
Expand Down
79 changes: 47 additions & 32 deletions components/conference/input/InputForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ const Option = styled.button<{ $on: boolean; $position: ConferencePosition }>`
}}
`

/** What a position means, under its label where it needs saying. */
const OptionHelp = styled.span`
display: block;
margin-top: 2px;
font-size: 0.75rem;
font-weight: 300;
`

const ask = keyframes`
0%, 100% { transform: translateX(0); }
20% { transform: translateX(-4px); }
Expand Down Expand Up @@ -175,28 +183,26 @@ export const Rules = styled.ul`
}
`

const RuleLabel = styled.p`
margin: 0 0 8px;
font-size: 0.6875rem;
font-weight: 600;
letter-spacing: 0.08em;
text-transform: uppercase;
color: ${ink.mid};
`

export const Problem = styled.p`
margin: 12px 0 0;
font-size: 0.75rem;
color: ${red.refused};
`

const Hint = styled.p`
export const Hint = styled.p`
margin: 0;
text-align: right;
font-size: 0.75rem;
color: ${ink.mid};
`

/** Where posted input goes, under the field it is written in. */
const Delivery = styled(Hint)`
margin-top: 8px;
text-align: left;
line-height: 1.5;
`

/** A field that asks for what is missing: pressed on without it, the field
* goes red, shakes and takes the focus; words in it settle it. */
export function useAsk(field: RefObject<HTMLElement | null>) {
Expand Down Expand Up @@ -309,15 +315,6 @@ export function ReviewStep({
<Scroll>
{cosign && !letter.content.trim() && <NoLine onAdd={onBack} />}
<LetterReview {...letter} testimonyId={edit.publication?.id} />
{!cosign && (
<div style={{ marginTop: 20 }}>
<RuleLabel>{t("input.rules_label")}</RuleLabel>
<Rules>
<li>{t("input.rule_revise")}</li>
<ConductRule />
</Rules>
</div>
)}
{needsReason && <ReasonField value={reason} onChange={onReason} />}
{problem}
</Scroll>
Expand Down Expand Up @@ -456,24 +453,28 @@ export function InputForm({
<Scroll>
<Label>{t("input.position_label")}</Label>
<Options>
{conferencePositions.map(p => (
<Option
key={p}
type="button"
$on={p === position}
$position={p}
aria-pressed={p === position}
onClick={() => setPosition(p)}
>
{t(`input.position.${p}.long`)}
</Option>
))}
{conferencePositions.map(p => {
const help = t(`input.position.${p}.help`, { defaultValue: "" })
return (
<Option
key={p}
type="button"
$on={p === position}
$position={p}
aria-pressed={p === position}
onClick={() => setPosition(p)}
>
{t(`input.position.${p}.long`)}
{help && <OptionHelp>{help}</OptionHelp>}
</Option>
)
})}
</Options>
<Label>{t("input.body_label")}</Label>
<Field
ref={field}
value={content}
placeholder={t("input.prompt")}
placeholder={t(`input.position.${position}.prompt`)}
$refused={ask.refused}
$asking={ask.asking}
onAnimationEnd={ask.asked}
Expand All @@ -482,6 +483,20 @@ export function InputForm({
setContent(e.target.value)
}}
/>
<Delivery>
{hasLegislators(profile ?? {}) ? (
t("input.delivery_note")
) : (
<Trans t={t} i18nKey="input.delivery_note_weekly">
When you post, MAPLE will include your input in the weekly
update to the conferees.
<Internal href="/edit-profile/about-you">
Add your representative and senator to your profile
</Internal>
and MAPLE will email them your input too.
</Trans>
)}
</Delivery>
{failed && <Problem role="alert">{t("input.error")}</Problem>}
</Scroll>
<Actions>
Expand Down
4 changes: 1 addition & 3 deletions functions/src/conferenceLetters/letters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ describe("buildLetterEmail", () => {
expect(email.from).toBe(
'"Ada via MAPLE" <notifications@mapletestimony.org>'
)
expect(email.message.subject).toBe(
"Phone-Free Schools: Please pass something"
)
expect(email.message.subject).toBe("Phone-Free Schools: Pass a final bill")
})

it("turns tracking off per message", () => {
Expand Down
2 changes: 1 addition & 1 deletion functions/src/conferenceUpdates/weeklyUpdate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ describe("the update email", () => {
])
expect(data.changes).toContain("2 inputs added.")
expect(data.changes).toContain("Counted input went from 1 to 3.")
expect(data.changes).toContain("Don't pass anything: 0 → 1.")
expect(data.changes).toContain("Don’t pass a final bill: 0 → 1.")
})

it("renders the conferees, figures and a link to the page", () => {
Expand Down
8 changes: 4 additions & 4 deletions functions/src/email/digestEmail.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ describe("digest email, conferences", () => {
court: "194",
newTestimonyCount: 3,
stances: [
{ stance: "Please pass something", count: 2 },
{ stance: "Don't pass anything", count: 1 }
{ stance: "Pass a final bill", count: 2 },
{ stance: "Don’t pass a final bill", count: 1 }
]
}
],
Expand All @@ -53,8 +53,8 @@ describe("digest email, conferences", () => {
)
expect(html).toContain("Phone-Free Schools")
expect(html).toContain("New Inputs")
expect(html).toMatch(/2<\/td>\s*<td[^>]*>Please pass something/)
expect(html).toContain("Don&#x27;t pass anything")
expect(html).toMatch(/2<\/td>\s*<td[^>]*>Pass a final bill/)
expect(html).toContain("Don’t pass a final bill")
})

it("leaves the section out for a reader following no conference", () => {
Expand Down
6 changes: 3 additions & 3 deletions functions/src/notifications/deliverNotifications.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,10 @@ describe("buildDigestData — conferences", () => {
court: "194",
newTestimonyCount: 3,
stances: [
{ stance: "Please pass something", count: 2 },
{ stance: "Pass a final bill", count: 2 },
{ stance: "Pass the Senate version", count: 0 },
{ stance: "Pass the House version", count: 0 },
{ stance: "Don't pass anything", count: 1 }
{ stance: "Don’t pass a final bill", count: 1 }
]
}
])
Expand Down Expand Up @@ -443,7 +443,7 @@ describe("buildDigestData — conferences", () => {
billId: "S2581",
court: "194",
conferenceId: "phones",
stance: "Please pass something"
stance: "Pass a final bill"
}
])
})
Expand Down
4 changes: 2 additions & 2 deletions functions/src/shared/conferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export const conferenceName = (c: Named) =>
c.name?.trim() || c.title?.trim() || ""
// The site's wording, conferences input.position.*.long; a test holds them equal.
export const CONFERENCE_STANCES: Record<ConferencePosition, string> = {
passSomething: "Please pass something",
passSomething: "Pass a final bill",
passSenateVersion: "Pass the Senate version",
passHouseVersion: "Pass the House version",
passNothing: "Don't pass anything"
passNothing: "Don’t pass a final bill"
}
Loading
Loading