Timeline: curator event create/edit forms (#781) #832
@@ -15,14 +15,14 @@ describe('WhoWhenSection — date input behavior', () => {
|
||||
await vi.waitFor(() => {
|
||||
// Invalid → border-red-400 class
|
||||
expect(dateInput.className).toContain('border-red-400');
|
||||
expect(document.querySelector('#date-error')).not.toBeNull();
|
||||
expect(document.querySelector('#documentDate-error')).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('does not show the error before the user has typed', async () => {
|
||||
render(WhoWhenSection, {});
|
||||
|
||||
const error = document.querySelector('#date-error');
|
||||
const error = document.querySelector('#documentDate-error');
|
||||
expect(error).toBeNull();
|
||||
});
|
||||
|
||||
@@ -77,20 +77,20 @@ describe('WhoWhenSection — precision controls', () => {
|
||||
it('renders a labelled precision select', async () => {
|
||||
render(WhoWhenSection, {});
|
||||
|
||||
const label = document.querySelector('label[for="metaDatePrecision"]');
|
||||
const select = document.querySelector('select#metaDatePrecision[name="metaDatePrecision"]');
|
||||
const label = document.querySelector('label[for="documentDatePrecision"]');
|
||||
const select = document.querySelector('select#documentDatePrecision[name="metaDatePrecision"]');
|
||||
expect(label).not.toBeNull();
|
||||
expect(select).not.toBeNull();
|
||||
});
|
||||
|
||||
it('hides the end-date field unless precision is RANGE', async () => {
|
||||
render(WhoWhenSection, { precision: 'DAY' });
|
||||
expect(document.querySelector('input#metaDateEnd')).toBeNull();
|
||||
expect(document.querySelector('input#documentDateEnd')).toBeNull();
|
||||
});
|
||||
|
||||
it('reveals the end-date field when precision is RANGE', async () => {
|
||||
render(WhoWhenSection, { precision: 'RANGE' });
|
||||
expect(document.querySelector('input#metaDateEnd')).not.toBeNull();
|
||||
expect(document.querySelector('input#documentDateEnd')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('never renders the raw cell, and never re-submits it via a hidden input', async () => {
|
||||
@@ -110,9 +110,9 @@ describe('WhoWhenSection — end-before-start inline validation (#678)', () => {
|
||||
endDateIso: '1917-01-10'
|
||||
});
|
||||
|
||||
const end = document.querySelector('input#metaDateEnd') as HTMLInputElement;
|
||||
const end = document.querySelector('input#documentDateEnd') as HTMLInputElement;
|
||||
await vi.waitFor(() => {
|
||||
expect(document.querySelector('#end-date-error')).not.toBeNull();
|
||||
expect(document.querySelector('#documentDate-end-error')).not.toBeNull();
|
||||
expect(end.getAttribute('aria-invalid')).toBe('true');
|
||||
expect(end.className).toContain('border-red-400');
|
||||
});
|
||||
@@ -125,14 +125,16 @@ describe('WhoWhenSection — end-before-start inline validation (#678)', () => {
|
||||
endDateIso: '1917-01-10'
|
||||
});
|
||||
|
||||
await vi.waitFor(() => expect(document.querySelector('#end-date-error')).not.toBeNull());
|
||||
await vi.waitFor(() =>
|
||||
expect(document.querySelector('#documentDate-end-error')).not.toBeNull()
|
||||
);
|
||||
|
||||
const end = document.querySelector('input#metaDateEnd') as HTMLInputElement;
|
||||
const end = document.querySelector('input#documentDateEnd') as HTMLInputElement;
|
||||
end.value = '12.01.1917'; // now after the start
|
||||
end.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
|
||||
await vi.waitFor(() => {
|
||||
expect(document.querySelector('#end-date-error')).toBeNull();
|
||||
expect(document.querySelector('#documentDate-end-error')).toBeNull();
|
||||
expect(end.getAttribute('aria-invalid')).not.toBe('true');
|
||||
});
|
||||
});
|
||||
@@ -144,6 +146,6 @@ describe('WhoWhenSection — end-before-start inline validation (#678)', () => {
|
||||
endDateIso: '1917-01-10'
|
||||
});
|
||||
|
||||
expect(document.querySelector('#end-date-error')).toBeNull();
|
||||
expect(document.querySelector('#documentDate-end-error')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user