Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-jeremy committed Oct 14, 2024
1 parent faf9c8e commit 2fe41da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/desktop-client/e2e/accounts.mobile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ test.describe('Mobile Accounts', () => {
await expect(page).toMatchThemeScreenshots();

await accountPage.clearSearch();
await expect(accountPage.transactions).not.toHaveCount(0);

await accountPage.searchByText('Kroger');
await expect(accountPage.transactionList).toBeVisible();
await expect(accountPage.transactions).not.toHaveCount(0);
await expect(page).toMatchThemeScreenshots();
});
Expand Down
12 changes: 7 additions & 5 deletions packages/loot-core/src/client/data-hooks/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
useSchedules,
} from './schedules';

const defaultQuery = q('transactions').select('*');

type UseTransactionsProps = {
queryBuilder: (query: Query) => Query;
options?: {
Expand All @@ -37,9 +39,8 @@ export function useTransactions({
queryBuilder,
options = { pageCount: 50, includePreviewTransactions: false },
}: UseTransactionsProps): UseTransactionsResult {
const initialQuery = q('transactions').select('*');
const [query, setQuery] = useState<Query>(
queryBuilder?.(initialQuery) ?? initialQuery,
queryBuilder?.(defaultQuery) ?? defaultQuery,
);
const [isLoading, setIsLoading] = useState(false);
const [transactions, setTransactions] = useState<
Expand Down Expand Up @@ -86,8 +87,8 @@ export function useTransactions({

const updateQuery = useCallback(
(queryBuilder: (currentQuery: Query) => Query) =>
setQuery(queryBuilder?.(query) ?? query),
[query],
setQuery(currentQuery => queryBuilder?.(currentQuery) ?? currentQuery),
[],
);

return {
Expand Down Expand Up @@ -168,7 +169,8 @@ function usePreviewTransactions({
setPreviewTransactions(ungroupTransactions(withDefaults));
}
});
} else {
} else if (!isUnmounted) {
// Nothing to preview
setIsLoading(false);
}

Expand Down

0 comments on commit 2fe41da

Please sign in to comment.