fix: restore default faction + remove dead data-testid attributes
- Restore default faction to 'adepta-sororitas' on first load (matches pre-refactor behavior; was a silent behavior change) - Add regression test asserting default-load shows only Adepta Sororitas units and hides the Faction column - Remove unused data-testid="app-root" from App.jsx and data-testid="mover-row" from MoversPanel.jsx (no test queried either)
This commit is contained in:
@@ -12,7 +12,7 @@ export default function App() {
|
||||
const [data, setData] = useState(null)
|
||||
const initial = useMemo(() => readFiltersFromUrl(), [])
|
||||
const [query, setQuery] = useState(initial.q)
|
||||
const [faction, setFaction] = useState(initial.faction)
|
||||
const [faction, setFaction] = useState(initial.faction || 'adepta-sororitas')
|
||||
const [dir, setDir] = useState(initial.dir)
|
||||
const [sizeChoice, setSizeChoice] = useState({})
|
||||
const [modalRow, setModalRow] = useState(null)
|
||||
@@ -82,7 +82,7 @@ export default function App() {
|
||||
if (!data) return <Box sx={{ p: 4, color: 'text.secondary' }}>Loading…</Box>
|
||||
|
||||
return (
|
||||
<Box data-testid="app-root" sx={{ minHeight: '100vh', bgcolor: 'background.default' }}>
|
||||
<Box sx={{ minHeight: '100vh', bgcolor: 'background.default' }}>
|
||||
<FilterBar
|
||||
query={query} setQuery={setQuery}
|
||||
faction={faction} setFaction={setFaction}
|
||||
|
||||
@@ -10,7 +10,6 @@ export function MoversPanel({ title, units, accent, onSelectUnit, showFaction })
|
||||
{units.map((u, i) => (
|
||||
<Box
|
||||
key={i}
|
||||
data-testid="mover-row"
|
||||
sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', cursor: 'pointer', py: 0.15, px: 0.25, borderRadius: 0.5, '&:hover': { bgcolor: accent === 'success' ? 'rgba(63,185,80,0.08)' : 'rgba(248,81,73,0.08)' } }}
|
||||
onClick={() => onSelectUnit(u)}
|
||||
>
|
||||
|
||||
@@ -91,6 +91,16 @@ describe('App (end-to-end UI)', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('defaults to Adepta Sororitas and hides the Faction column on bare-URL load', async () => {
|
||||
renderWithTheme(<App />)
|
||||
// Wait for data load — Palatine is Adepta Sororitas, so it must be present
|
||||
await waitFor(() => screen.getAllByText('Palatine')[0])
|
||||
// Intercessor Squad is Space Marines — must NOT be visible because default faction is 'adepta-sororitas'
|
||||
expect(screen.queryByText('Intercessor Squad')).not.toBeInTheDocument()
|
||||
// Faction column header must be hidden because a faction is active
|
||||
expect(screen.queryByRole('columnheader', { name: 'Faction' })).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('updates the active size of a multi-size unit when the # cell is changed', async () => {
|
||||
const user = userEvent.setup()
|
||||
renderWithTheme(<App />)
|
||||
@@ -138,9 +148,13 @@ describe('App (end-to-end UI)', () => {
|
||||
it('shows "No historical data" for units with empty history', async () => {
|
||||
const user = userEvent.setup()
|
||||
renderWithTheme(<App />)
|
||||
await waitFor(() => screen.getByText('New Unit X'))
|
||||
await waitFor(() => screen.getAllByText('Palatine')[0])
|
||||
// Default faction is Adepta Sororitas; switch to "All" so Necron's New Unit X is visible
|
||||
await user.click(screen.getByLabelText('Faction'))
|
||||
await user.click(screen.getByRole('option', { name: 'All' }))
|
||||
await waitFor(() => screen.getAllByText('New Unit X')[0])
|
||||
// Click on the "New Unit X" row (no history)
|
||||
await user.click(screen.getByText('New Unit X'))
|
||||
await user.click(screen.getAllByText('New Unit X')[0])
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/no historical data/i)).toBeInTheDocument()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user