.
This commit is contained in:
parent
36ec4003a3
commit
fdd7a5c763
2 changed files with 23 additions and 5 deletions
|
|
@ -397,7 +397,7 @@ describe('LocationSearch', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('keeps only the three most recent local searches', async () => {
|
it('keeps only the ten most recent local searches', async () => {
|
||||||
vi.stubGlobal(
|
vi.stubGlobal(
|
||||||
'fetch',
|
'fetch',
|
||||||
vi.fn((input: string | URL | Request) => {
|
vi.fn((input: string | URL | Request) => {
|
||||||
|
|
@ -416,8 +416,22 @@ describe('LocationSearch', () => {
|
||||||
|
|
||||||
render(<LocationSearch onFlyTo={vi.fn()} onLocationSearched={vi.fn()} />);
|
render(<LocationSearch onFlyTo={vi.fn()} onLocationSearched={vi.fn()} />);
|
||||||
|
|
||||||
|
// Search eleven distinct postcodes; only the ten most recent should be kept.
|
||||||
|
const postcodes = [
|
||||||
|
'SW1A 1AA',
|
||||||
|
'E14 2DG',
|
||||||
|
'W1A 1AA',
|
||||||
|
'EC1A 1BB',
|
||||||
|
'N1 1AA',
|
||||||
|
'M1 1AE',
|
||||||
|
'B33 8TH',
|
||||||
|
'CR2 6XH',
|
||||||
|
'DN55 1PT',
|
||||||
|
'L1 8JQ',
|
||||||
|
'G1 1AA',
|
||||||
|
];
|
||||||
const input = screen.getByRole('textbox');
|
const input = screen.getByRole('textbox');
|
||||||
for (const postcode of ['SW1A 1AA', 'E14 2DG', 'W1A 1AA', 'EC1A 1BB']) {
|
for (const postcode of postcodes) {
|
||||||
fireEvent.change(input, { target: { value: postcode } });
|
fireEvent.change(input, { target: { value: postcode } });
|
||||||
fireEvent.keyDown(input, { key: 'Enter' });
|
fireEvent.keyDown(input, { key: 'Enter' });
|
||||||
|
|
||||||
|
|
@ -432,13 +446,13 @@ describe('LocationSearch', () => {
|
||||||
const stored = JSON.parse(window.localStorage.getItem(RECENT_SEARCHES_STORAGE_KEY) ?? '[]') as {
|
const stored = JSON.parse(window.localStorage.getItem(RECENT_SEARCHES_STORAGE_KEY) ?? '[]') as {
|
||||||
label?: string;
|
label?: string;
|
||||||
}[];
|
}[];
|
||||||
expect(stored.map((search) => search.label)).toEqual(['EC1A 1BB', 'W1A 1AA', 'E14 2DG']);
|
// Most recent first, oldest ('SW1A 1AA') dropped past the limit of ten.
|
||||||
|
expect(stored.map((search) => search.label)).toEqual([...postcodes].reverse().slice(0, 10));
|
||||||
|
|
||||||
fireEvent.focus(input);
|
fireEvent.focus(input);
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(screen.getByRole('button', { name: 'EC1A 1BB' })).toBeTruthy();
|
expect(screen.getByRole('button', { name: 'G1 1AA' })).toBeTruthy();
|
||||||
expect(screen.getByRole('button', { name: 'W1A 1AA' })).toBeTruthy();
|
|
||||||
expect(screen.getByRole('button', { name: 'E14 2DG' })).toBeTruthy();
|
expect(screen.getByRole('button', { name: 'E14 2DG' })).toBeTruthy();
|
||||||
});
|
});
|
||||||
expect(screen.queryByText('SW1A 1AA')).toBeNull();
|
expect(screen.queryByText('SW1A 1AA')).toBeNull();
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,10 @@ const KEEP_UNKNOWN_LISTING_FILTER_FEATURES: &[&str] = &[
|
||||||
"Leasehold/Freehold",
|
"Leasehold/Freehold",
|
||||||
"Number of bedrooms & living rooms",
|
"Number of bedrooms & living rooms",
|
||||||
"Property type",
|
"Property type",
|
||||||
|
"Construction year",
|
||||||
|
"Interior height (m)",
|
||||||
|
"Current energy rating",
|
||||||
|
"Potential energy rating"
|
||||||
];
|
];
|
||||||
const LISTING_BOUNDS_EPSILON_DEGREES: f64 = 0.00001;
|
const LISTING_BOUNDS_EPSILON_DEGREES: f64 = 0.00001;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue