diff --git a/apps/csm-portal/webapp/src/components/MultiSelectField.tsx b/apps/csm-portal/webapp/src/components/MultiSelectField.tsx new file mode 100644 index 0000000000..fb5fd01153 --- /dev/null +++ b/apps/csm-portal/webapp/src/components/MultiSelectField.tsx @@ -0,0 +1,89 @@ +// Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import { Autocomplete, Checkbox, Chip, ListItemText, TextField } from "@wso2/oxygen-ui"; +import type * as React from "react"; +import type { JSX } from "react"; + +export interface MultiSelectFieldProps { + id: string; + label: string; + values: T[]; + options: { value: T; label: string }[]; + onChange: (next: T[]) => void; + disabled?: boolean; +} + +/** + * Autocomplete-based multi-select for a fixed, small set of options (e.g. an + * enum) — selected values render as chips, options are type-to-search + + * checkboxes. Pairs with {@link SearchableMultiSelect} for larger/dynamic + * option lists. Extracted from `CasesFilterBar.tsx` so other feature filter + * bars (e.g. time cards) can reuse the same look and behavior. + */ +export default function MultiSelectField({ + id, + label, + values, + options, + onChange, + disabled, +}: MultiSelectFieldProps): JSX.Element { + const selected = options.filter((o) => values.includes(o.value)); + return ( + + multiple + size="small" + id={id} + disabled={disabled} + options={options} + value={selected} + disableCloseOnSelect + getOptionLabel={(o) => o.label} + isOptionEqualToValue={(o, v) => o.value === v.value} + onChange={(_event, next) => onChange(next.map((o) => o.value))} + renderTags={(value, getTagProps) => + value.map((option, index) => { + const { key, ...tagProps } = getTagProps({ index }); + return ( + + ); + }) + } + renderOption={(props, option, { selected: isSelected }) => { + const { key, ...liProps } = props as React.HTMLAttributes & { + key: string; + }; + return ( +
  • + + +
  • + ); + }} + renderInput={(params) => ( + + )} + /> + ); +} diff --git a/apps/csm-portal/webapp/src/components/SearchableMultiSelect.tsx b/apps/csm-portal/webapp/src/components/SearchableMultiSelect.tsx new file mode 100644 index 0000000000..c51ad34578 --- /dev/null +++ b/apps/csm-portal/webapp/src/components/SearchableMultiSelect.tsx @@ -0,0 +1,131 @@ +// Copyright (c) 2026 WSO2 LLC. (https://www.wso2.com). +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import { Autocomplete, Checkbox, Chip, ListItemText, TextField } from "@wso2/oxygen-ui"; +import type * as React from "react"; +import type { JSX } from "react"; + +export interface SearchableMultiSelectProps { + id: string; + label: string; + placeholder?: string; + values: string[]; + options: string[]; + /** Optional renderer for option labels (e.g. an `@me` sentinel → "Me"). */ + formatOption?: (value: string) => string; + /** Optional secondary line shown beneath each option (e.g. email). */ + getOptionSecondary?: (value: string) => string | undefined; + /** Optional filter against synthetic text (e.g. include email in the query). */ + getOptionSearchText?: (value: string) => string; + onChange: (next: string[]) => void; + disabled?: boolean; +} + +/** + * Multi-select autocomplete. Users type to filter the option list and + * select multiple. Picked values render as removable chips inside the field. + * Internally a thin wrapper over MUI Autocomplete so we keep oxygen-ui + * theming via the re-exported components. Extracted from `CasesFilterBar.tsx` + * so other feature filter bars (e.g. time cards) can reuse the same look and + * behavior instead of a plain free-text field. + */ +export default function SearchableMultiSelect({ + id, + label, + placeholder, + values, + options, + formatOption, + getOptionSecondary, + getOptionSearchText, + onChange, + disabled, +}: SearchableMultiSelectProps): JSX.Element { + const format = formatOption ?? ((v: string) => v); + const searchText = getOptionSearchText ?? format; + return ( + onChange(next as string[])} + disableCloseOnSelect + // MUI's own available-space heuristic sometimes flips the list above + // the field even when there's clearly room below (e.g. sitting above a + // data table) — pin it open downward instead of guessing. + slotProps={{ + popper: { + placement: "bottom-start", + modifiers: [{ name: "flip", enabled: false }], + }, + }} + getOptionLabel={(opt) => format(opt as string)} + isOptionEqualToValue={(opt, val) => opt === val} + filterOptions={(opts, state) => { + const q = state.inputValue.trim().toLowerCase(); + if (!q) return opts; + return opts.filter((o) => searchText(o as string).toLowerCase().includes(q)); + }} + renderTags={(value, getTagProps) => + value.map((option, index) => { + const { key, ...tagProps } = getTagProps({ index }); + return ( + + ); + }) + } + renderOption={(props, option, { selected }) => { + const { key, ...liProps } = props as React.HTMLAttributes & { + key: string; + }; + const primary = format(option as string); + const secondary = getOptionSecondary?.(option as string); + return ( +
  • + + +
  • + ); + }} + renderInput={(params) => ( + + )} + /> + ); +} diff --git a/apps/csm-portal/webapp/src/features/csm-cases/components/CasesFilterBar.tsx b/apps/csm-portal/webapp/src/features/csm-cases/components/CasesFilterBar.tsx index 0187f48546..904631fb52 100644 --- a/apps/csm-portal/webapp/src/features/csm-cases/components/CasesFilterBar.tsx +++ b/apps/csm-portal/webapp/src/features/csm-cases/components/CasesFilterBar.tsx @@ -15,11 +15,8 @@ // under the License. import { - Autocomplete, Box, Button, - Checkbox, - Chip, Dialog, DialogActions, DialogContent, @@ -49,7 +46,6 @@ import { X, } from "@wso2/oxygen-ui-icons-react"; import { useMemo, useState, type JSX } from "react"; -import type * as React from "react"; import type { CaseState, Severity, @@ -76,6 +72,7 @@ import { CASE_TYPE_LABEL, } from "@features/csm-cases/utils/caseType"; import AsyncProjectMultiSelect from "@features/csm-cases/components/AsyncProjectMultiSelect"; +import MultiSelectField from "@components/MultiSelectField"; import AsyncAssigneeMultiSelect from "@features/csm-cases/components/AsyncAssigneeMultiSelect"; import ProductNameMultiSelect from "@features/csm-cases/components/ProductNameMultiSelect"; @@ -164,71 +161,6 @@ const PRIMARY_STATES: CaseState[] = [ "closed", ]; -interface MultiSelectFieldProps { - id: string; - label: string; - values: T[]; - options: { value: T; label: string }[]; - onChange: (next: T[]) => void; - disabled?: boolean; -} - -function MultiSelectField({ - id, - label, - values, - options, - onChange, - disabled, -}: MultiSelectFieldProps): JSX.Element { - // Autocomplete-based multi-select: selected values render as chips and the - // options are type-to-search + checkboxes — matching the product filter. - const selected = options.filter((o) => values.includes(o.value)); - return ( - - multiple - size="small" - id={id} - disabled={disabled} - options={options} - value={selected} - disableCloseOnSelect - getOptionLabel={(o) => o.label} - isOptionEqualToValue={(o, v) => o.value === v.value} - onChange={(_event, next) => onChange(next.map((o) => o.value))} - renderTags={(value, getTagProps) => - value.map((option, index) => { - const { key, ...tagProps } = getTagProps({ index }); - return ( - - ); - }) - } - renderOption={(props, option, { selected: isSelected }) => { - const { key, ...liProps } = props as React.HTMLAttributes & { - key: string; - }; - return ( -
  • - - -
  • - ); - }} - renderInput={(params) => ( - - )} - /> - ); -} - export default function CasesFilterBar({ filters, onChange, diff --git a/apps/csm-portal/webapp/src/features/csm-timecards/api/useTimeCards.ts b/apps/csm-portal/webapp/src/features/csm-timecards/api/useTimeCards.ts index 3205e4703e..1766cdbf9d 100644 --- a/apps/csm-portal/webapp/src/features/csm-timecards/api/useTimeCards.ts +++ b/apps/csm-portal/webapp/src/features/csm-timecards/api/useTimeCards.ts @@ -115,10 +115,12 @@ export function usePostTimeCard(): UseMutationResult< isBillable: input.billable, issueComplexity: input.issueComplexity, workLogComment: input.workLogComment, - // The backend's hour fields are integers (confirmed live: a 0.5 - // value is rejected with 400) even though the form logs quarter-hour - // increments — round each bucket to the nearest whole hour here, at - // the API boundary, so the FE keeps its finer-grained display. + // The backend's time fields are whole minutes (confirmed: + // entity-service's own validation helper is named + // `nonNegativeMinutes`, and a real pre-existing card's `totalTime` of + // 150 only makes sense as ~2.5h of work in one entry, not 150 hours) + // — the form collects minutes directly now, so this is a defensive + // round only, not a unit conversion. timeAnalyzing: Math.round(input.breakdown.analysisDebugging), timeSettingUp: Math.round(input.breakdown.settingUp), timeReproducingDebugging: Math.round(input.breakdown.reproduce), diff --git a/apps/csm-portal/webapp/src/features/csm-timecards/api/useTimeSheets.ts b/apps/csm-portal/webapp/src/features/csm-timecards/api/useTimeSheets.ts index f2384030f4..0ab46d2af0 100644 --- a/apps/csm-portal/webapp/src/features/csm-timecards/api/useTimeSheets.ts +++ b/apps/csm-portal/webapp/src/features/csm-timecards/api/useTimeSheets.ts @@ -90,7 +90,12 @@ export function invalidateTimecards(queryClient: QueryClient): void { } } -/** Map the backend's `TimeCardView` to the portal's `CsmTimeCard`. */ +/** + * Map the backend's `TimeCardView` to the portal's `CsmTimeCard`. `totalTime` + * is already whole minutes on the wire (see `usePostTimeCard`'s note on why), + * which is also the unit the portal displays throughout — a direct + * passthrough, no conversion needed. + */ export function mapTimeCard(v: BeTimeCardView): CsmTimeCard { return { id: v.id, @@ -103,7 +108,7 @@ export function mapTimeCard(v: BeTimeCardView): CsmTimeCard { userName: v.user?.name ?? "—", state: v.state, billable: v.hasBillable, - totalHours: v.totalTime, + totalMinutes: v.totalTime, approvedById: v.approvedBy?.id, approvedByName: v.approvedBy?.name, }; diff --git a/apps/csm-portal/webapp/src/features/csm-timecards/components/CaseTimeCardsPanel.tsx b/apps/csm-portal/webapp/src/features/csm-timecards/components/CaseTimeCardsPanel.tsx index c7dda844e7..31585a12cd 100644 --- a/apps/csm-portal/webapp/src/features/csm-timecards/components/CaseTimeCardsPanel.tsx +++ b/apps/csm-portal/webapp/src/features/csm-timecards/components/CaseTimeCardsPanel.tsx @@ -26,6 +26,7 @@ import { import { Clock, Plus } from "@wso2/oxygen-ui-icons-react"; import RelativeTime from "@components/RelativeTime"; import { useCaseTimeCards, useDecideTimeCard } from "@features/csm-timecards/api/useTimeCards"; +import { useCurrentEngineer } from "@features/csm-timecards/api/useTimeSheets"; import { useIsTeamLead } from "@features/csm-timecards/hooks/useIsTeamLead"; import { billableLabel } from "@features/csm-timecards/constants/timeCardConstants"; import { BackendApiError } from "@api/backend/client"; @@ -62,13 +63,14 @@ export default function CaseTimeCardsPanel({ }: CaseTimeCardsPanelProps): JSX.Element { const { data, isLoading, isError } = useCaseTimeCards(caseId, projectId); const isTeamLead = useIsTeamLead(); + const me = useCurrentEngineer(); const decide = useDecideTimeCard(); const { showError } = useErrorBanner(); const [reviewCard, setReviewCard] = useState(null); const cards = useMemo(() => data?.cards ?? [], [data]); const total = useMemo( - () => Math.round(cards.reduce((s, c) => s + c.totalHours, 0) * 100) / 100, + () => cards.reduce((s, c) => s + c.totalMinutes, 0), [cards], ); @@ -114,7 +116,7 @@ export default function CaseTimeCardsPanel({ }} > - {total.toFixed(2)}h + {total} min Across {cards.length} {cards.length === 1 ? "entry" : "entries"} @@ -164,17 +166,24 @@ export default function CaseTimeCardsPanel({ > {c.userName} - {c.totalHours.toFixed(2)}h + {c.totalMinutes} min - {isTeamLead && !readOnly && c.state === "submitted" && ( - - )} + {/* Never shown on your own card: the backend 403s a + self-decide regardless of approver status, so a card you + submitted yourself can never actually be reviewed by you. */} + {isTeamLead && + !readOnly && + c.state === "submitted" && + !!me.id && + c.userId !== me.id && ( + + )} diff --git a/apps/csm-portal/webapp/src/features/csm-timecards/components/LogTimeCardDialog.tsx b/apps/csm-portal/webapp/src/features/csm-timecards/components/LogTimeCardDialog.tsx index f9767c8b78..7ea94e26ea 100644 --- a/apps/csm-portal/webapp/src/features/csm-timecards/components/LogTimeCardDialog.tsx +++ b/apps/csm-portal/webapp/src/features/csm-timecards/components/LogTimeCardDialog.tsx @@ -47,9 +47,7 @@ import { ACTIVITY_BUCKETS, DEFAULT_BILLABLE, DEFAULT_ISSUE_COMPLEXITY, - DEFAULT_TIME_CARD_CATEGORY, ISSUE_COMPLEXITY_OPTIONS, - TIME_CARD_CATEGORIES, WORK_LOG_MAX, } from "@features/csm-timecards/constants/timeCardConstants"; import type { @@ -58,12 +56,11 @@ import type { CreateTimeCardInput, IssueComplexity, TimeCardApprover, - TimeCardCategory, } from "@features/csm-timecards/types/timeCards"; import { emptyBreakdown, timeCardDraftErrors, - totalHours, + totalMinutes, } from "@features/csm-timecards/utils/timeCardTotals"; import { localTodayIso } from "@features/csm-timecards/utils/timeSheetWeek"; @@ -91,8 +88,9 @@ function fullName(u: NormalizedUser): string { return u.name.trim() || u.userName; } -/** One activity row: a labelled hours input plus a proportion bar (relative to - * the current logged total so each bar shows share-of-work, not share-of-day). */ +/** One activity row: a labelled whole-minutes input plus a proportion bar + * (relative to the current logged total so each bar shows share-of-work, not + * share-of-day). */ function ActivityRow({ label, value, @@ -123,8 +121,8 @@ function ActivityRow({ type="number" size="small" value={Number.isFinite(value) ? value : 0} - onChange={(e) => onChange(Math.max(0, Number(e.target.value) || 0))} - slotProps={{ htmlInput: { min: 0, step: 0.25, "aria-label": label } }} + onChange={(e) => onChange(Math.max(0, Math.round(Number(e.target.value) || 0)))} + slotProps={{ htmlInput: { min: 0, step: 1, "aria-label": label } }} onBlur={onBlur} sx={{ width: 96 }} /> @@ -140,9 +138,12 @@ function ActivityRow({ } /** - * "Log time" form. Mirrors the ServiceNow fields (date, category, the five - * activity buckets, work-log comment, issue complexity, approver) with a live - * running total, per-activity proportion bars, and inline validation. + * "Log time" form. Mirrors the ServiceNow fields (date, the five activity + * buckets, work-log comment, issue complexity, approver) with a live + * running total, per-activity proportion bars, and inline validation. There + * was a "Category" field here too, but it was never actually sent anywhere + * (`usePostTimeCard`'s payload has no such field) — removed rather than kept + * as a choice that silently did nothing. * Creating a card submits it immediately — the backend has no draft step, so * there is no "Pending" status and no edit-after-create (see the module-level * note in `types/timeCards.ts` on why edit isn't supported). @@ -159,7 +160,6 @@ export default function LogTimeCardDialog({ const me = resolveUserInfo(useIdTokenClaims()); const [date, setDate] = useState(localTodayIso()); - const [category, setCategory] = useState(DEFAULT_TIME_CARD_CATEGORY); const [issueComplexity, setIssueComplexity] = useState( DEFAULT_ISSUE_COMPLEXITY, ); @@ -173,7 +173,7 @@ export default function LogTimeCardDialog({ setTouched((prev) => new Set(prev).add(field)); const isTouched = (field: string): boolean => touched.has(field); - const total = totalHours(breakdown); + const total = totalMinutes(breakdown); const errors = timeCardDraftErrors({ date, breakdown, @@ -218,7 +218,7 @@ export default function LogTimeCardDialog({ const setActivity = (key: ActivityKey, next: number): void => setBreakdown((prev) => ({ ...prev, [key]: next })); - const ALL_FIELDS = ["date", "hours", "workLogComment", "approver"]; + const ALL_FIELDS = ["date", "minutes", "workLogComment", "approver"]; const handleSubmit = (): void => { if (!isValid || !approver) { setTouched(new Set(ALL_FIELDS)); @@ -230,7 +230,6 @@ export default function LogTimeCardDialog({ projectId, projectName, date, - category, breakdown, billable, workLogComment: workLogComment.trim(), @@ -285,40 +284,19 @@ export default function LogTimeCardDialog({ {projectName ? ` · ${projectName}` : ""} - {/* Date + category */} - - setDate(e.target.value)} - onBlur={() => touch("date")} - error={isTouched("date") && !!errors.date} - helperText={isTouched("date") ? errors.date : undefined} - slotProps={{ inputLabel: { shrink: true } }} - /> - setCategory(e.target.value as TimeCardCategory)} - > - {TIME_CARD_CATEGORIES.map((c) => ( - - {c} - - ))} - - + setDate(e.target.value)} + onBlur={() => touch("date")} + error={isTouched("date") && !!errors.date} + helperText={isTouched("date") ? errors.date : undefined} + slotProps={{ inputLabel: { shrink: true } }} + sx={{ maxWidth: { sm: 220 }, minWidth: 160 }} + /> @@ -330,25 +308,19 @@ export default function LogTimeCardDialog({ justifyContent: "space-between", }} > - Time breakdown (hours) + Time breakdown (minutes) - {total.toFixed(2)}h total + {total} min total - {isTouched("hours") && errors.hours && ( + {isTouched("minutes") && errors.minutes && ( - {errors.hours} + {errors.minutes} )} - - Each activity is logged in whole-hour increments — quarter-hours - help you balance the total below, but round to the nearest hour - on submit (a small amount split across several activities may - round down to 0h for those activities). - {ACTIVITY_BUCKETS.map((b) => ( setActivity(b.key, next)} - onBlur={() => touch("hours")} + onBlur={() => touch("minutes")} /> ))} diff --git a/apps/csm-portal/webapp/src/features/csm-timecards/components/TimeCardReviewDialog.tsx b/apps/csm-portal/webapp/src/features/csm-timecards/components/TimeCardReviewDialog.tsx index 1fee853af6..7ee30cdc27 100644 --- a/apps/csm-portal/webapp/src/features/csm-timecards/components/TimeCardReviewDialog.tsx +++ b/apps/csm-portal/webapp/src/features/csm-timecards/components/TimeCardReviewDialog.tsx @@ -58,8 +58,8 @@ function Field({ label, value }: { label: string; value: string }): JSX.Element /** * Team-lead review of a submitted time card, then accept or reject with an * optional comment. Only shows what the backend actually returns on read — - * category, issue complexity, work-log comment and the hour breakdown are - * accepted on create but never echoed back, so they aren't shown here. + * issue complexity, work-log comment and the per-activity minute breakdown + * are accepted on create but never echoed back, so they aren't shown here. */ export default function TimeCardReviewDialog({ card, @@ -75,7 +75,7 @@ export default function TimeCardReviewDialog({ return ( - Review time card · {card.caseNumber} · {card.totalHours.toFixed(2)}h + Review time card · {card.caseNumber} · {card.totalMinutes} min diff --git a/apps/csm-portal/webapp/src/features/csm-timecards/components/TimeSheetCard.tsx b/apps/csm-portal/webapp/src/features/csm-timecards/components/TimeSheetCard.tsx index 9ddf18794a..7f0ef940ca 100644 --- a/apps/csm-portal/webapp/src/features/csm-timecards/components/TimeSheetCard.tsx +++ b/apps/csm-portal/webapp/src/features/csm-timecards/components/TimeSheetCard.tsx @@ -99,7 +99,7 @@ export default function TimeSheetCard({ - {sheet.totalHours.toFixed(2)}h + {sheet.totalMinutes} min @@ -125,7 +125,7 @@ export default function TimeSheetCard({ - {c.caseNumber} · {c.totalHours.toFixed(2)}h + {c.caseNumber} · {c.totalMinutes} min r.toLowerCase()); const isAdmin = roles.includes(TIMECARD_ADMIN_GROUP.toLowerCase()); - const isApprover = isAdmin || roles.includes(TIMECARD_APPROVER_GROUP.toLowerCase()); + const isApprover = roles.includes(TIMECARD_APPROVER_GROUP.toLowerCase()); return { isApprover, isAdmin }; } diff --git a/apps/csm-portal/webapp/src/features/csm-timecards/pages/CsmTimeCardsPage.tsx b/apps/csm-portal/webapp/src/features/csm-timecards/pages/CsmTimeCardsPage.tsx index dc88e1240b..cfddb76711 100644 --- a/apps/csm-portal/webapp/src/features/csm-timecards/pages/CsmTimeCardsPage.tsx +++ b/apps/csm-portal/webapp/src/features/csm-timecards/pages/CsmTimeCardsPage.tsx @@ -14,12 +14,11 @@ // specific language governing permissions and limitations // under the License. -import { useState, type ChangeEvent, type JSX } from "react"; +import { useMemo, useState, type ChangeEvent, type JSX } from "react"; import { Box, Chip, CircularProgress, - InputAdornment, MenuItem, Tab, Tabs, @@ -28,7 +27,7 @@ import { Typography, Button, } from "@wso2/oxygen-ui"; -import { ListFilter, Search, X } from "@wso2/oxygen-ui-icons-react"; +import { ListFilter, X } from "@wso2/oxygen-ui-icons-react"; import { useAllTimeCards, useApprovalQueue, @@ -46,6 +45,7 @@ import { TIME_CARD_STATE_META } from "@features/csm-timecards/constants/timeCard import { useTimecardRole } from "@features/csm-timecards/hooks/useTimecardRole"; import TimeSheetCard from "@features/csm-timecards/components/TimeSheetCard"; import TimeCardReviewDialog from "@features/csm-timecards/components/TimeCardReviewDialog"; +import SearchableMultiSelect from "@components/SearchableMultiSelect"; import type { TimecardAction } from "@features/csm-timecards/utils/timeSheetState"; import type { CsmTimeCard, @@ -54,6 +54,29 @@ import type { TimeCardState, } from "@features/csm-timecards/types/timeCards"; +/** Builds a `userId -> userName` lookup plus the option list a + * `SearchableMultiSelect` engineer filter needs, scoped to whatever sheets + * are currently loaded for one tab (there's no engineer-search endpoint for + * time cards, so — like the work-item filter — this only ever offers + * engineers actually present on the current page, not the full directory). */ +function engineerOptionsFrom(sheets: CsmTimeSheet[] | undefined): { + ids: string[]; + nameById: Map; +} { + const nameById = new Map(); + (sheets ?? []).forEach((s) => nameById.set(s.userId, s.userName)); + return { ids: [...nameById.keys()], nameById }; +} + +/** Distinct case numbers present in whatever sheets are currently loaded for + * one tab — the option list for the work-item filter. Same "current page + * only" caveat as {@link engineerOptionsFrom}. */ +function workItemOptionsFrom(sheets: CsmTimeSheet[] | undefined): string[] { + return Array.from( + new Set((sheets ?? []).flatMap((s) => s.cards.map((c) => c.caseNumber))), + ); +} + const DEFAULT_ROWS_PER_PAGE = 20; // Top option is the backend's max page limit; larger requests are rejected. const ROWS_PER_PAGE_OPTIONS = [10, 20, BE_MAX_PAGE_LIMIT]; @@ -102,10 +125,10 @@ export default function CsmTimeCardsPage(): JSX.Element { // Search filters (sent as a POST body, never query params). Project and // state are server-side; work item and engineer are client-side over the // returned page — the backend has no filter for either. - const [filterProject, setFilterProject] = useState(""); - const [filterWorkItem, setFilterWorkItem] = useState(""); + const [filterProject, setFilterProject] = useState([]); + const [filterWorkItem, setFilterWorkItem] = useState([]); const [filterState, setFilterState] = useState(""); - const [filterEngineer, setFilterEngineer] = useState(""); + const [filterEngineer, setFilterEngineer] = useState([]); const projects = useProjectOptions(); // The backend requires a non-empty `projectIds` to return anything at all @@ -113,9 +136,9 @@ export default function CsmTimeCardsPage(): JSX.Element { // the OpenAPI spec documenting it as optional). Default to every project // the user can see (already fetched for the filter dropdown below) so // "My time sheets" / "Approvals" work with no filter picked; the explicit - // project filter narrows that down when set. - const scopeProjectIds = filterProject - ? [filterProject] + // project filter narrows that down when set (to one or several). + const scopeProjectIds = filterProject.length + ? filterProject : (projects.data ?? []).map((p) => p.id); const baseFilters: TimeCardSearchFilters = { @@ -144,7 +167,10 @@ export default function CsmTimeCardsPage(): JSX.Element { const decideCard = useDecideCard(); const anyFilterActive = - !!filterProject || !!filterWorkItem.trim() || !!filterState || !!filterEngineer.trim(); + filterProject.length > 0 || + filterWorkItem.length > 0 || + !!filterState || + filterEngineer.length > 0; // A filter change re-scopes the search for every tab, so every tab's page // position needs to reset too — otherwise "page 3" of a narrower result @@ -154,7 +180,7 @@ export default function CsmTimeCardsPage(): JSX.Element { allPagination.setPage(0); approvalsPagination.setPage(0); }; - const handleFilterProjectChange = (v: string): void => { + const handleFilterProjectChange = (v: string[]): void => { setFilterProject(v); resetAllPages(); }; @@ -163,10 +189,10 @@ export default function CsmTimeCardsPage(): JSX.Element { resetAllPages(); }; const clearFilters = (): void => { - setFilterProject(""); - setFilterWorkItem(""); + setFilterProject([]); + setFilterWorkItem([]); setFilterState(""); - setFilterEngineer(""); + setFilterEngineer([]); resetAllPages(); }; @@ -174,18 +200,42 @@ export default function CsmTimeCardsPage(): JSX.Element { if (action === "approve" || action === "reject") setReviewCard(card); }; - /** Client-side work-item substring filter, applied over already-fetched sheets. */ + /** Client-side work-item filter (case number is in the selected set), + * applied over already-fetched sheets. */ const byWorkItem = (sheets: CsmTimeSheet[] | undefined): CsmTimeSheet[] | undefined => { - const q = filterWorkItem.trim().toLowerCase(); - if (!q || !sheets) return sheets; + if (filterWorkItem.length === 0 || !sheets) return sheets; return sheets .map((s) => ({ ...s, - cards: s.cards.filter((c) => c.caseNumber.toLowerCase().includes(q)), + cards: s.cards.filter((c) => filterWorkItem.includes(c.caseNumber)), })) .filter((s) => s.cards.length > 0); }; + // Work-item / engineer option lists are scoped per tab — each tab has its + // own loaded page of sheets, and there's no search endpoint for either, so + // the picker can only ever offer what's actually on the current page. + const mineWorkItemOptions = useMemo( + () => workItemOptionsFrom(mySheets.data?.sheets), + [mySheets.data], + ); + const allWorkItemOptions = useMemo( + () => workItemOptionsFrom(allCards.data?.sheets), + [allCards.data], + ); + const approvalsWorkItemOptions = useMemo( + () => workItemOptionsFrom(queue.data?.sheets), + [queue.data], + ); + const allEngineerOptions = useMemo( + () => engineerOptionsFrom(allCards.data?.sheets), + [allCards.data], + ); + const approvalsEngineerOptions = useMemo( + () => engineerOptionsFrom(queue.data?.sheets), + [queue.data], + ); + return ( setFilterEngineer(e.target.value)} - sx={{ width: 180 }} - /> + + allEngineerOptions.nameById.get(id) ?? id} + onChange={setFilterEngineer} + /> + } engineerChip={ - filterEngineer.trim() + filterEngineer.length > 0 ? { - label: `Engineer: ${filterEngineer.trim()}`, - onDelete: () => setFilterEngineer(""), + label: `Engineer: ${filterEngineer + .map((id) => allEngineerOptions.nameById.get(id) ?? id) + .join(", ")}`, + onDelete: () => setFilterEngineer([]), } : undefined } @@ -323,17 +380,16 @@ export default function CsmTimeCardsPage(): JSX.Element { ) : ( <> {(() => { - const q = filterEngineer.trim().toLowerCase(); const byEngineer = (allCards.data?.sheets ?? []).filter( - (s) => !q || s.userName.toLowerCase().includes(q), + (s) => filterEngineer.length === 0 || filterEngineer.includes(s.userId), ); const filtered = byWorkItem(byEngineer) ?? []; if (filtered.length === 0) { return ( 0 && byEngineer.length === 0 + ? "No time cards match the selected engineers." : anyFilterActive ? "No time cards match the current filters." : "No time logged yet." @@ -378,25 +434,31 @@ export default function CsmTimeCardsPage(): JSX.Element { setFilterProject={handleFilterProjectChange} filterWorkItem={filterWorkItem} setFilterWorkItem={setFilterWorkItem} + workItemOptions={approvalsWorkItemOptions} filterState={filterState} setFilterState={handleFilterStateChange} onClear={clearFilters} hideStateFilter engineerSlot={ - setFilterEngineer(e.target.value)} - sx={{ width: 180 }} - /> + + approvalsEngineerOptions.nameById.get(id) ?? id} + onChange={setFilterEngineer} + /> + } engineerChip={ - filterEngineer.trim() + filterEngineer.length > 0 ? { - label: `Engineer: ${filterEngineer.trim()}`, - onDelete: () => setFilterEngineer(""), + label: `Engineer: ${filterEngineer + .map((id) => approvalsEngineerOptions.nameById.get(id) ?? id) + .join(", ")}`, + onDelete: () => setFilterEngineer([]), } : undefined } @@ -414,9 +476,8 @@ export default function CsmTimeCardsPage(): JSX.Element { ) : ( (() => { - const q = filterEngineer.trim().toLowerCase(); const byEngineer = (queue.data?.sheets ?? []).filter( - (s) => !q || s.userName.toLowerCase().includes(q), + (s) => filterEngineer.length === 0 || filterEngineer.includes(s.userId), ); const filtered = byWorkItem(byEngineer) ?? []; if (filtered.length === 0) { @@ -426,8 +487,8 @@ export default function CsmTimeCardsPage(): JSX.Element { // Only blame the engineer filter when it's the one that // excluded everything — if it matched fine and the // work-item filter emptied the result, say that instead. - q && byEngineer.length === 0 - ? `No engineers match "${filterEngineer}".` + filterEngineer.length > 0 && byEngineer.length === 0 + ? "No time cards match the selected engineers." : "No time cards match the current filters." } /> @@ -499,6 +560,7 @@ function FilterBar({ setFilterProject, filterWorkItem, setFilterWorkItem, + workItemOptions, filterState, setFilterState, onClear, @@ -507,15 +569,18 @@ function FilterBar({ hideStateFilter, }: { projects: BeProject[]; - filterProject: string; - setFilterProject: (v: string) => void; - filterWorkItem: string; - setFilterWorkItem: (v: string) => void; + filterProject: string[]; + setFilterProject: (v: string[]) => void; + filterWorkItem: string[]; + setFilterWorkItem: (v: string[]) => void; + /** Case numbers to offer in the work-item picker — scoped to whatever the + * calling tab currently has loaded (see `workItemOptionsFrom`). */ + workItemOptions: string[]; filterState: TimeCardState | ""; setFilterState: (v: TimeCardState | "") => void; onClear: () => void; engineerSlot?: JSX.Element; - /** Active-chip for the Engineer filter — only the Approvals tab has one. */ + /** Active-chip for the Engineer filter — only the All/Approvals tabs have one. */ engineerChip?: { label: string; onDelete: () => void }; /** Approvals always forces `states: ["submitted"]` server-side (see * `useApprovalQueue`), so the State control can't actually narrow anything @@ -524,19 +589,19 @@ function FilterBar({ }): JSX.Element { const activeChips: { key: string; label: string; onDelete: () => void }[] = []; if (engineerChip) activeChips.push({ key: "engineer", ...engineerChip }); - if (filterProject) { - const name = projects.find((p) => p.id === filterProject)?.name ?? filterProject; + if (filterProject.length > 0) { + const names = filterProject.map((id) => projects.find((p) => p.id === id)?.name ?? id); activeChips.push({ key: "project", - label: `Project: ${name}`, - onDelete: () => setFilterProject(""), + label: `Project: ${names.join(", ")}`, + onDelete: () => setFilterProject([]), }); } - if (filterWorkItem.trim()) { + if (filterWorkItem.length > 0) { activeChips.push({ key: "workItem", - label: `Work item: ${filterWorkItem.trim()}`, - onDelete: () => setFilterWorkItem(""), + label: `Work item: ${filterWorkItem.join(", ")}`, + onDelete: () => setFilterWorkItem([]), }); } if (!hideStateFilter && filterState) { @@ -575,39 +640,28 @@ function FilterBar({ - setFilterProject(e.target.value)} - sx={{ width: 200 }} - > - All projects - {projects.map((p) => ( - - {p.name ?? p.id} - - ))} - - - setFilterWorkItem(e.target.value)} - sx={{ width: 190 }} - slotProps={{ - input: { - startAdornment: ( - - - - ), - }, - }} - /> + + p.id)} + formatOption={(id) => projects.find((p) => p.id === id)?.name ?? id} + onChange={setFilterProject} + /> + + + + + {engineerSlot} diff --git a/apps/csm-portal/webapp/src/features/csm-timecards/types/timeCards.ts b/apps/csm-portal/webapp/src/features/csm-timecards/types/timeCards.ts index 5e4a6ca0b1..c1a1fd518c 100644 --- a/apps/csm-portal/webapp/src/features/csm-timecards/types/timeCards.ts +++ b/apps/csm-portal/webapp/src/features/csm-timecards/types/timeCards.ts @@ -30,7 +30,7 @@ export type TimeCardState = | "processed"; /** - * The fixed activity buckets a time card splits its hours across — the + * The fixed activity buckets a time card splits its time across — the * activity categories from the Time Management requirement (ISSU-009). * Write-only: the backend accepts these on create (`timeAnalyzing`, * `timeSettingUp`, …) but never returns them on read, so they shape the @@ -46,7 +46,8 @@ export const ACTIVITY_KEYS = [ export type ActivityKey = (typeof ACTIVITY_KEYS)[number]; -/** Hours logged against each activity bucket (log-time form state only). */ +/** Whole minutes logged against each activity bucket (log-time form state + * only) — matches the backend's own unit for these fields directly. */ export type ActivityBreakdown = Record; /** A team lead eligible to approve a time card (ServiceNow "approver_list"). */ @@ -55,26 +56,16 @@ export interface TimeCardApprover { name: string; } -/** - * Work category options (the ServiceNow "Category" field). Write-only — see - * {@link ActivityBreakdown}. - */ -export type TimeCardCategory = - | "Task work" - | "Investigation" - | "Customer call" - | "Documentation"; - /** Issue-complexity options (the ServiceNow "Issue Complexity" field). Write-only. */ export type IssueComplexity = "N/A" | "Low" | "Medium" | "High"; /** * A time card as returned by `POST /time-cards/search` and the mutation * endpoints (the backend's `TimeCardView`). This is the complete set of - * fields the backend ever returns for a card — `category`, `issueComplexity`, - * `workLogComment`, the hour breakdown, and any lead comment are accepted on - * write but never read back, so editing an existing card isn't supported - * (it would silently blank those fields). + * fields the backend ever returns for a card — `issueComplexity`, + * `workLogComment`, the per-activity minute breakdown, and any lead comment + * are accepted on write but never read back, so editing an existing card + * isn't supported (it would silently blank those fields). */ export interface CsmTimeCard { id: string; @@ -98,7 +89,9 @@ export interface CsmTimeCard { state: TimeCardState; /** Whether the logged time is billable to the customer (ISSU-009). */ billable: boolean; - totalHours: number; + /** Whole minutes — the backend's own unit for this field (see + * `mapTimeCard` in `useTimeSheets.ts`). */ + totalMinutes: number; /** The deciding approver, once a decision has been made. */ approvedById?: string; approvedByName?: string; @@ -116,7 +109,6 @@ export interface CreateTimeCardInput { projectId: string; projectName: string; date: string; - category: TimeCardCategory; breakdown: ActivityBreakdown; /** Billable classification (ISSU-009). */ billable: boolean; @@ -151,7 +143,8 @@ export interface CsmTimeSheet { weekEnd: string; state: TimeSheetState; cards: CsmTimeCard[]; - totalHours: number; + /** Whole minutes, summed from `cards`. */ + totalMinutes: number; } /** diff --git a/apps/csm-portal/webapp/src/features/csm-timecards/utils/__tests__/timeCardTotals.test.ts b/apps/csm-portal/webapp/src/features/csm-timecards/utils/__tests__/timeCardTotals.test.ts index 33d6c0420c..f681164aa3 100644 --- a/apps/csm-portal/webapp/src/features/csm-timecards/utils/__tests__/timeCardTotals.test.ts +++ b/apps/csm-portal/webapp/src/features/csm-timecards/utils/__tests__/timeCardTotals.test.ts @@ -17,57 +17,38 @@ import { describe, expect, it } from "vitest"; import { emptyBreakdown, - hasLoggedHours, - roundedTotalHours, + hasLoggedTime, timeCardDraftErrors, - totalHours, + totalMinutes, } from "@features/csm-timecards/utils/timeCardTotals"; import { WORK_LOG_MAX } from "@features/csm-timecards/constants/timeCardConstants"; describe("timeCardTotals", () => { it("emptyBreakdown is all zeros and sums to 0", () => { - expect(totalHours(emptyBreakdown())).toBe(0); - expect(hasLoggedHours(emptyBreakdown())).toBe(false); + expect(totalMinutes(emptyBreakdown())).toBe(0); + expect(hasLoggedTime(emptyBreakdown())).toBe(false); }); - it("sums activity buckets without float drift", () => { + it("sums activity buckets", () => { expect( - totalHours({ - analysisDebugging: 0.1, - reproduce: 1.5, - settingUp: 0.2, - providingSolution: 0.5, + totalMinutes({ + analysisDebugging: 15, + reproduce: 90, + settingUp: 20, + providingSolution: 30, answering: 0, }), - ).toBe(2.3); + ).toBe(155); }); - it("detects logged hours", () => { - expect(hasLoggedHours({ ...emptyBreakdown(), answering: 0.25 })).toBe(true); - }); - - describe("roundedTotalHours", () => { - it("matches totalHours when every bucket already rounds cleanly", () => { - expect( - roundedTotalHours({ ...emptyBreakdown(), analysisDebugging: 1, reproduce: 2 }), - ).toBe(3); - }); - - it("rounds down to 0 when every bucket is under 0.5h, even with a nonzero raw total", () => { - expect( - roundedTotalHours({ - ...emptyBreakdown(), - analysisDebugging: 0.25, - reproduce: 0.25, - }), - ).toBe(0); - }); + it("detects logged time", () => { + expect(hasLoggedTime({ ...emptyBreakdown(), answering: 15 })).toBe(true); }); describe("timeCardDraftErrors", () => { const valid = { date: "2026-06-27", - breakdown: { ...emptyBreakdown(), analysisDebugging: 1 }, + breakdown: { ...emptyBreakdown(), analysisDebugging: 60 }, workLogComment: "Investigated root cause.", approverId: "lead-1", }; @@ -84,7 +65,7 @@ describe("timeCardTotals", () => { approverId: undefined, }); expect(errors.date).toBeDefined(); - expect(errors.hours).toBeDefined(); + expect(errors.minutes).toBeDefined(); expect(errors.workLogComment).toBeDefined(); expect(errors.approver).toBeDefined(); }); @@ -96,13 +77,5 @@ describe("timeCardTotals", () => { }); expect(errors.workLogComment).toBeDefined(); }); - - it("flags an hours total that rounds down to 0h even though the raw total is nonzero", () => { - const errors = timeCardDraftErrors({ - ...valid, - breakdown: { ...emptyBreakdown(), analysisDebugging: 0.25, reproduce: 0.25 }, - }); - expect(errors.hours).toBeDefined(); - }); }); }); diff --git a/apps/csm-portal/webapp/src/features/csm-timecards/utils/__tests__/timeSheetGrouping.test.ts b/apps/csm-portal/webapp/src/features/csm-timecards/utils/__tests__/timeSheetGrouping.test.ts index 6b7cc9b1b9..69fe051822 100644 --- a/apps/csm-portal/webapp/src/features/csm-timecards/utils/__tests__/timeSheetGrouping.test.ts +++ b/apps/csm-portal/webapp/src/features/csm-timecards/utils/__tests__/timeSheetGrouping.test.ts @@ -30,7 +30,7 @@ function card(overrides: Partial): CsmTimeCard { userName: "Test User", state: "submitted", billable: false, - totalHours: 1, + totalMinutes: 60, ...overrides, }; } diff --git a/apps/csm-portal/webapp/src/features/csm-timecards/utils/timeCardTotals.ts b/apps/csm-portal/webapp/src/features/csm-timecards/utils/timeCardTotals.ts index 3f851642f3..0df190d598 100644 --- a/apps/csm-portal/webapp/src/features/csm-timecards/utils/timeCardTotals.ts +++ b/apps/csm-portal/webapp/src/features/csm-timecards/utils/timeCardTotals.ts @@ -20,7 +20,7 @@ import { } from "@features/csm-timecards/types/timeCards"; import { WORK_LOG_MAX } from "@features/csm-timecards/constants/timeCardConstants"; -/** A fresh breakdown with every activity at zero hours. */ +/** A fresh breakdown with every activity at zero minutes. */ export function emptyBreakdown(): ActivityBreakdown { return { analysisDebugging: 0, @@ -31,40 +31,20 @@ export function emptyBreakdown(): ActivityBreakdown { }; } -/** Round to 2 decimals to avoid float drift in summed hours (e.g. 0.1 + 0.2). */ -export function roundHours(value: number): number { - return Math.round(value * 100) / 100; +/** Total whole minutes across all activity buckets. */ +export function totalMinutes(breakdown: ActivityBreakdown): number { + return ACTIVITY_KEYS.reduce((sum, key) => sum + (breakdown[key] || 0), 0); } -/** Total hours across all activity buckets. */ -export function totalHours(breakdown: ActivityBreakdown): number { - return roundHours( - ACTIVITY_KEYS.reduce((sum, key) => sum + (breakdown[key] || 0), 0), - ); -} - -/** True when at least one activity bucket has positive hours. */ -export function hasLoggedHours(breakdown: ActivityBreakdown): boolean { +/** True when at least one activity bucket has logged time. */ +export function hasLoggedTime(breakdown: ActivityBreakdown): boolean { return ACTIVITY_KEYS.some((key) => (breakdown[key] || 0) > 0); } -/** - * What the submitted card's total will actually be: each bucket rounded to - * a whole hour independently, then summed — mirrors `usePostTimeCard`'s - * per-field `Math.round()` exactly, since the backend's hour fields are - * integers. A form can show a valid nonzero total (e.g. two 0.25h buckets, - * summing to a "logged" 0.5h) where every individual bucket still rounds to - * 0 — this catches that case so the form can block submit instead of - * silently sending an all-zero card. - */ -export function roundedTotalHours(breakdown: ActivityBreakdown): number { - return ACTIVITY_KEYS.reduce((sum, key) => sum + Math.round(breakdown[key] || 0), 0); -} - /** Field-level validation errors for the log dialog, keyed by field name. */ export interface TimeCardDraftErrors { date?: string; - hours?: string; + minutes?: string; workLogComment?: string; approver?: string; } @@ -84,14 +64,8 @@ export interface TimeCardDraft { export function timeCardDraftErrors(draft: TimeCardDraft): TimeCardDraftErrors { const errors: TimeCardDraftErrors = {}; if (!draft.date) errors.date = "Pick a date."; - if (!hasLoggedHours(draft.breakdown)) { - errors.hours = "Log time against at least one activity."; - } else if (roundedTotalHours(draft.breakdown) === 0) { - // Each bucket is sent to the backend rounded to a whole hour — a form - // that looks valid (some bucket > 0) can still round down to an - // all-zero card if every bucket is under 0.5h. - errors.hours = - "Logged time rounds down to 0h — the backend only accepts whole hours per activity. Increase an activity's hours to at least 0.5."; + if (!hasLoggedTime(draft.breakdown)) { + errors.minutes = "Log time against at least one activity."; } if (!draft.workLogComment.trim()) { errors.workLogComment = "Add a work log comment."; diff --git a/apps/csm-portal/webapp/src/features/csm-timecards/utils/timeSheetGrouping.ts b/apps/csm-portal/webapp/src/features/csm-timecards/utils/timeSheetGrouping.ts index 622c4fb2fa..baa9330226 100644 --- a/apps/csm-portal/webapp/src/features/csm-timecards/utils/timeSheetGrouping.ts +++ b/apps/csm-portal/webapp/src/features/csm-timecards/utils/timeSheetGrouping.ts @@ -20,7 +20,6 @@ import type { TimeSheetState, } from "@features/csm-timecards/types/timeCards"; import { weekEndOf, weekStartOf } from "@features/csm-timecards/utils/timeSheetWeek"; -import { roundHours } from "@features/csm-timecards/utils/timeCardTotals"; /** Roll a week's cards up into a single display status. */ export function sheetStatus(cards: CsmTimeCard[]): TimeSheetState { @@ -69,7 +68,7 @@ export function groupIntoSheets( weekEnd: weekEndOf(weekStart), state: sheetStatus(weekCards), cards: weekCards, - totalHours: roundHours(weekCards.reduce((sum, c) => sum + c.totalHours, 0)), + totalMinutes: weekCards.reduce((sum, c) => sum + c.totalMinutes, 0), }); } return sheets.sort((a, b) => b.weekStart.localeCompare(a.weekStart)); diff --git a/apps/csm-portal/webapp/tests/e2e/pages/TimeCardsPage.ts b/apps/csm-portal/webapp/tests/e2e/pages/TimeCardsPage.ts index 75f3d027a4..c10bcd4473 100644 --- a/apps/csm-portal/webapp/tests/e2e/pages/TimeCardsPage.ts +++ b/apps/csm-portal/webapp/tests/e2e/pages/TimeCardsPage.ts @@ -88,6 +88,20 @@ export class TimeCardsPage { await this.page.getByRole("option", { name: optionLabel, exact: true }).click(); } + /** Type into the Work item filter and pick the matching option — it's a + * multi-select autocomplete sourced from case numbers on the current page + * (`SearchableMultiSelect`), not a plain free-text field, so typing alone + * doesn't apply anything until an option is actually selected. */ + async filterWorkItem(caseNumber: string): Promise { + await this.page.getByLabel("Work item").fill(caseNumber); + await this.page.getByRole("option", { name: caseNumber, exact: true }).click(); + } + + /** Clears every active filter via the filter bar's "Clear all" button. */ + async clearFilters(): Promise { + await this.page.getByRole("button", { name: "Clear all" }).click(); + } + reviewDialog(): Locator { return this.page.getByRole("dialog"); } diff --git a/apps/csm-portal/webapp/tests/e2e/specs/timecards/approvals.spec.ts b/apps/csm-portal/webapp/tests/e2e/specs/timecards/approvals.spec.ts index f308fdf622..4d44583b3e 100644 --- a/apps/csm-portal/webapp/tests/e2e/specs/timecards/approvals.spec.ts +++ b/apps/csm-portal/webapp/tests/e2e/specs/timecards/approvals.spec.ts @@ -110,7 +110,7 @@ test.describe("time cards — approvals queue", () => { const tc = new TimeCardsPage(page); await tc.goto(); await tc.openApprovals(); - await page.getByLabel("Work item").fill(caseNumber!); + await tc.filterWorkItem(caseNumber!); await expect(tc.cardRow(caseNumber!)).toBeVisible({ timeout: 15_000 }); await tc.cardButton(caseNumber!, "Approve").click(); diff --git a/apps/csm-portal/webapp/tests/e2e/specs/timecards/my-sheets.spec.ts b/apps/csm-portal/webapp/tests/e2e/specs/timecards/my-sheets.spec.ts index c1b4a2279d..23ed57fd67 100644 --- a/apps/csm-portal/webapp/tests/e2e/specs/timecards/my-sheets.spec.ts +++ b/apps/csm-portal/webapp/tests/e2e/specs/timecards/my-sheets.spec.ts @@ -97,14 +97,17 @@ test.describe("time cards — my time sheets", () => { await tc.goto(); await expect(tc.cardRow(caseNumber!)).toBeVisible({ timeout: 15_000 }); - // Work item filter narrows to the matching card. - await page.getByLabel("Work item").fill(caseNumber!); + // Work item filter narrows to the matching card. It's a multi-select + // sourced from case numbers on the current page, not free text, so + // there's no equivalent "type something that can't match" case anymore + // (nothing to select if it doesn't exist) — clearing instead confirms + // the filter was actually applied and removable. + await tc.filterWorkItem(caseNumber!); await expect(tc.cardRow(caseNumber!)).toBeVisible(); - - // A work item that can't match anything hides it. - await page.getByLabel("Work item").fill("no-such-case-number-zzz"); - await expect(tc.cardText(caseNumber!)).toHaveCount(0); - await page.getByLabel("Work item").fill(""); + await tc.clearFilters(); + // "Clear all" only shows up while a filter is active, so it going away + // means the work item filter actually got removed. + await expect(page.getByRole("button", { name: "Clear all" })).toHaveCount(0); // State filter: the card was just created, so it's "submitted". await tc.filterState("Submitted");