fix(export): label synthetic ordinal '# Days Reach (ordinal)' to avoid collision with same-named daily field
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -51,7 +51,7 @@ export default function ExportDataModal({
|
||||
const activeDaily = useMemo(() => (dailyTemplate ?? []).filter((f) => f.active), [dailyTemplate]);
|
||||
const xOptions = useMemo(() => [
|
||||
{ id: '__date__', label: 'Date' },
|
||||
{ id: '__days__', label: '# Days Reach' },
|
||||
{ id: '__days__', label: '# Days Reach (ordinal)' },
|
||||
...activeDaily.map((f) => ({ id: f.fieldId, label: f.label })),
|
||||
], [activeDaily]);
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ export function buildSampleIndex(statuses, xField, dailyTemplate) {
|
||||
|
||||
function xFieldLabel(xField, dailyTemplate) {
|
||||
if (xField === '__date__') return 'Date';
|
||||
if (xField === '__days__') return '# Days Reach';
|
||||
if (xField === '__days__') return '# Days Reach (ordinal)';
|
||||
return (dailyTemplate ?? []).find((f) => f.fieldId === xField)?.label ?? '';
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ describe('ExportDataModal', () => {
|
||||
await waitFor(() => expect(screen.getByText(/2 rows/i)).toBeInTheDocument());
|
||||
fireEvent.click(screen.getByText('Export CSV'));
|
||||
const text = await readBlobText(dl.getBlob());
|
||||
expect(text).toBe('Data,Total attempts\n\n# Days Reach,Alpha,Beta\n1,5,9\n2,7,');
|
||||
expect(text).toBe('Data,Total attempts\n\n# Days Reach (ordinal),Alpha,Beta\n1,5,9\n2,7,');
|
||||
await dl.restore();
|
||||
});
|
||||
|
||||
|
||||
@@ -281,7 +281,7 @@ describe('buildSubjectSeriesMatrix', () => {
|
||||
{ xField: '__days__', dataParam: totalParam, groupField: '__none__' },
|
||||
{ statuses: ssStatuses, animals: ssAnimals, dailyTemplate: [] },
|
||||
);
|
||||
expect(m.corner).toBe('# Days Reach');
|
||||
expect(m.corner).toBe('# Days Reach (ordinal)');
|
||||
expect(m.rows.map((r) => r.member.label)).toEqual(['1', '2']);
|
||||
expect(m.rows[0].values).toEqual([5, 9]);
|
||||
expect(m.rows[1].values).toEqual([7, '']);
|
||||
|
||||
Reference in New Issue
Block a user