Skip to content

Commit

Permalink
🧪 improve onboarding e2e test stability
Browse files Browse the repository at this point in the history
  • Loading branch information
MatissJanis committed Sep 25, 2024
1 parent 373dfb0 commit 39a3e0e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
36 changes: 22 additions & 14 deletions packages/desktop-client/src/components/FinancesApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { NarrowAlternate, WideComponent } from './responsive';
import { Settings } from './settings';
import { FloatableSidebar } from './sidebar';
import { Titlebar } from './Titlebar';
import { LoadingIndicator } from './reports/LoadingIndicator';

Check warning on line 38 in packages/desktop-client/src/components/FinancesApp.tsx

View workflow job for this annotation

GitHub Actions / lint

`./reports/LoadingIndicator` import should occur before import of `./responsive`

function NarrowNotSupported({
redirectTo = '/budget',
Expand Down Expand Up @@ -65,19 +66,6 @@ function WideNotSupported({ children, redirectTo = '/budget' }) {
}

function RouterBehaviors() {
const navigate = useNavigate();
const accounts = useAccounts();
const accountsLoaded = useSelector(
(state: State) => state.queries.accountsLoaded,
);
useEffect(() => {
// If there are no accounts, we want to redirect the user to
// the All Accounts screen which will prompt them to add an account
if (accountsLoaded && accounts.length === 0) {
navigate('/accounts');
}
}, [accountsLoaded, accounts]);

const location = useLocation();
const href = useHref(location);
useEffect(() => {
Expand All @@ -91,6 +79,11 @@ export function FinancesApp() {
const dispatch = useDispatch();
const { t } = useTranslation();

const accounts = useAccounts();
const accountsLoaded = useSelector(
(state: State) => state.queries.accountsLoaded,
);

const [lastUsedVersion, setLastUsedVersion] = useLocalPref(
'flags.updateNotificationShownForVersion',
);
Expand Down Expand Up @@ -180,7 +173,22 @@ export function FinancesApp() {
<BankSyncStatus />

<Routes>
<Route path="/" element={<Navigate to="/budget" replace />} />
<Route
path="/"
element={
accountsLoaded ? (
accounts.length > 0 ? (
<Navigate to="/budget" replace />
) : (
// If there are no accounts, we want to redirect the user to
// the All Accounts screen which will prompt them to add an account
<Navigate to="/accounts" replace />
)
) : (
<LoadingIndicator />
)
}
/>

<Route path="/reports/*" element={<Reports />} />

Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/3503.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [MatissJanis]
---

e2e: improve onboarding test stability.

0 comments on commit 39a3e0e

Please sign in to comment.