Skip to content

Add validators, widget updates, tests, fixtures, test doubles and CI workflow - #9

Merged
Faifor merged 1 commit into
mainfrom
codex/update-unit-and-widget-components
Mar 9, 2026
Merged

Add validators, widget updates, tests, fixtures, test doubles and CI workflow#9
Faifor merged 1 commit into
mainfrom
codex/update-unit-and-widget-components

Conversation

@Faifor

@Faifor Faifor commented Mar 9, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Implement comprehensive unit/widget/integration coverage for auth refresh logic, error mapping, input validators, and key UI flows as requested (login, cart, admin reports).
  • Provide deterministic test data and doubles so tests are repeatable and do not depend on external services.
  • Surface validation and submit/loading states in screens to improve UX and make core flows testable.
  • Add CI automation to run the suite on push/PR using the standard flutter test command.

Description

  • Added centralized validators in lib/core/validation/input_validators.dart for profile name, quantity, promo codes, and filters (date range and min-total checks).
  • Converted a few presentation screens to stateful components and added small behaviors: AuthScreen supports onSubmit and submit state, CartScreen supports qty changes and total calculation, and AdminScreen supports report filters with onApplyFilters.
  • Added a broad set of tests under test/ including unit tests for validators, RefreshSessionUseCase, refresh-token interceptor behavior, and error mapper, widget tests for login/cart/admin UIs, and integration-style widget tests for auth flow, cart+checkout, and admin reports.
  • Introduced test doubles and JSON fixtures in test/doubles/mock_repositories.dart and test/fixtures/*.json, and added a GitHub Actions workflow .github/workflows/ci.yml plus a Testing section in README.md documenting flutter test --reporter expanded.

Testing

  • Added unit tests (test/core/*, test/features/*), widget tests (test/widget/*), and integration-style widget tests (test/integration/*) but these are created and committed rather than executed here.
  • Attempted to run flutter test locally in this environment, but it could not be executed because the Flutter SDK is not available (flutter: command not found).
  • CI is configured to run flutter pub get and flutter test --reporter expanded in GitHub Actions via .github/workflows/ci.yml so tests will run on push/PR in the repository environment.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4409aa6b9e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +31 to +34
await widget.onSubmit?.call(
_emailController.text.trim(),
_passwordController.text,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reset submit state when login request fails

If onSubmit throws (for example, on a network/auth failure), the await exits _submit before _isSubmitting is set back to false, leaving the button disabled with a spinner and no way to retry in the same screen state. This makes transient backend errors effectively block the login UI until a rebuild, so the call should be wrapped in try/finally (and optionally surfaced as an error message).

Useful? React with 👍 / 👎.

_error = null;
});

final rows = await widget.onApplyFilters?.call(filters) ?? const <String>[];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Clear admin loading state when filter fetch throws

A thrown exception from onApplyFilters skips the _isLoading = false update, so the Apply button stays disabled and the loading indicator persists indefinitely after a failing fetch. In production this can happen on API errors/timeouts and prevents users from retrying filters without leaving the page; use try/finally to always restore loading state.

Useful? React with 👍 / 👎.

@Faifor
Faifor merged commit cf52407 into main Mar 9, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant