test: generate gherkin test relevant to configure

This commit is contained in:
insleker 2025-08-29 17:05:09 +08:00
parent 828eee49e2
commit bc0444f873
26 changed files with 211 additions and 1 deletions

1
.gitignore vendored
View File

@ -122,3 +122,4 @@ docs/.*
.vscode/tasks.json
.vscode/launch.json
devtools_options.yaml
test/features/*_test.dart

View File

@ -6,6 +6,6 @@ targets:
- lib/**
- $package$
builders:
pdf_signature|prune_unused_steps:
pdf_signature:
generate_for:
- test/features/**

View File

@ -0,0 +1,61 @@
Feature: App preferences
As a user
I want to configure app preferences such as theme and language
So that the app matches my personal and regional needs, and remembers them next time
Scenario Outline: Choose a theme and apply it immediately
Given the settings screen is open
When the user selects the "<theme>" theme
Then the app UI updates to use the "<theme>" theme
And the preference {theme} is saved as {"<theme>"}
Examples:
| theme |
| light |
| dark |
| system |
Scenario Outline: Choose a language and apply it immediately
Given the settings screen is open
When the user selects a supported language "<language>"
Then all visible texts are displayed in "<language>"
And the preference {language} is saved as {"<language>"}
Examples:
| language |
| en |
| zh-TW |
| es |
Scenario Outline: Remember preferences across app restarts
Given the user previously set theme {"<theme>"} and language {"<language>"}
When the app launches
Then the app UI theme is {"<theme>"}
And the app language is {"<language>"}
Examples:
| theme | language |
| dark | en |
| light | zh-TW |
| system | es |
Scenario: Follow system appearance when theme is set to system
Given the user selects the "system" theme
And the OS appearance switches to dark mode
When the app is resumed or returns to foreground
Then the app UI updates to use the "dark" theme
Scenario: Reset preferences to defaults
Given the user has theme {"dark"} and language {"es"} saved
When the user taps "Reset to defaults"
Then the theme is set to {"system"}
And the language is set to the device locale
And both preferences are saved
Scenario: Ignore invalid stored values and fall back safely
Given stored preferences contain theme {"sepia"} and language {"xx"}
When the app launches
Then the theme falls back to {"system"}
And the language falls back to the device locale
And invalid values are replaced with valid defaults in storage

View File

@ -0,0 +1,7 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: all visible texts are displayed in "<language>"
Future<void> allVisibleTextsAreDisplayedIn(
WidgetTester tester, dynamic language) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,6 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: both preferences are saved
Future<void> bothPreferencesAreSaved(WidgetTester tester) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,7 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: invalid values are replaced with valid defaults in storage
Future<void> invalidValuesAreReplacedWithValidDefaultsInStorage(
WidgetTester tester) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,7 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: stored preferences contain theme {"sepia"} and language {"xx"}
Future<void> storedPreferencesContainThemeAndLanguage(
WidgetTester tester, String param1, String param2) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,6 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: the app is resumed or returns to foreground
Future<void> theAppIsResumedOrReturnsToForeground(WidgetTester tester) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,7 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: the app language is {"<language>"}
Future<void> theAppLanguageIs(
WidgetTester tester, String param1, dynamic language) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,6 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: the app launches
Future<void> theAppLaunches(WidgetTester tester) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,7 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: the app UI theme is {"<theme>"}
Future<void> theAppUiThemeIs(
WidgetTester tester, String param1, dynamic theme) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,6 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: the app UI updates to use the "dark" theme
Future<void> theAppUiUpdatesToUseTheDarkTheme(WidgetTester tester) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,7 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: the app UI updates to use the "<theme>" theme
Future<void> theAppUiUpdatesToUseTheTheme(
WidgetTester tester, dynamic theme) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,6 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: the language falls back to the device locale
Future<void> theLanguageFallsBackToTheDeviceLocale(WidgetTester tester) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,6 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: the language is set to the device locale
Future<void> theLanguageIsSetToTheDeviceLocale(WidgetTester tester) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,6 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: the OS appearance switches to dark mode
Future<void> theOsAppearanceSwitchesToDarkMode(WidgetTester tester) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,7 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: the preference {language} is saved as {"<language>"}
Future<void> thePreferenceIsSavedAs(WidgetTester tester, dynamic param1,
String param2, dynamic language) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,6 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: the settings screen is open
Future<void> theSettingsScreenIsOpen(WidgetTester tester) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,6 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: the theme falls back to {"system"}
Future<void> theThemeFallsBackTo(WidgetTester tester, String param1) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,6 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: the theme is set to {"system"}
Future<void> theThemeIsSetTo(WidgetTester tester, String param1) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,7 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: the user has theme {"dark"} and language {"es"} saved
Future<void> theUserHasThemeAndLanguageSaved(
WidgetTester tester, String param1, String param2) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,7 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: the user previously set theme {"<theme>"} and language {"<language>"}
Future<void> theUserPreviouslySetThemeAndLanguage(WidgetTester tester,
String param1, String param2, dynamic theme, dynamic language) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,7 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: the user selects a supported language "<language>"
Future<void> theUserSelectsASupportedLanguage(
WidgetTester tester, dynamic language) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,6 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: the user selects the "system" theme
Future<void> theUserSelectsTheSystemTheme(WidgetTester tester) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,6 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: the user selects the "<theme>" theme
Future<void> theUserSelectsTheTheme(WidgetTester tester, dynamic theme) async {
throw UnimplementedError();
}

View File

@ -0,0 +1,6 @@
import 'package:flutter_test/flutter_test.dart';
/// Usage: the user taps "Reset to defaults"
Future<void> theUserTapsResetToDefaults(WidgetTester tester) async {
throw UnimplementedError();
}