mirror of
https://github.com/feeddeck/feeddeck.git
synced 2026-04-30 11:28:45 -05:00
[core] Add Test Setup for Flutter (#87)
This commit adds a new "Continuous Integration" GitHub Action, which is used to run the tests for the Flutter app (and later also for Deno). This commit also adds a first test, so that the GitHub Action does not fail. This PR also removes the Visual Studio Code and Neovim configurations from the contribution guide, since I'm not using it anymore and for that I do not want to maintain it any longer.
This commit is contained in:
36
.github/workflows/continuous-integration.yaml
vendored
Normal file
36
.github/workflows/continuous-integration.yaml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
name: Continuous Integration
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
flutter:
|
||||
name: Flutter
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: "app"
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Flutter
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
flutter-version: '3.16.0'
|
||||
channel: 'stable'
|
||||
cache: true
|
||||
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
|
||||
cache-path: '${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:'
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
flutter pub get
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
flutter test
|
||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,8 +1,5 @@
|
||||
# Visual Studio Code Launch Configurations
|
||||
.vscode/launch.json
|
||||
|
||||
# Neovim
|
||||
.nvim.lua
|
||||
# Visual Studio Code
|
||||
.vscode
|
||||
|
||||
# Environment Variables
|
||||
/supabase/.env.local
|
||||
|
||||
17
.vscode/settings.json
vendored
17
.vscode/settings.json
vendored
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"deno.enable": true,
|
||||
"deno.unstable": true,
|
||||
"deno.lint": true,
|
||||
"deno.enablePaths": [
|
||||
"./supabase/functions"
|
||||
],
|
||||
"deno.importMap": "./supabase/functions/import_map.json",
|
||||
"editor.formatOnSave": true,
|
||||
"editor.defaultFormatter": "denoland.vscode-deno",
|
||||
"[json]": {
|
||||
"editor.defaultFormatter": "vscode.json-language-features"
|
||||
},
|
||||
"[html]": {
|
||||
"editor.defaultFormatter": "vscode.html-language-features"
|
||||
}
|
||||
}
|
||||
128
CONTRIBUTING.md
128
CONTRIBUTING.md
@@ -79,131 +79,25 @@ required variables to the `flutter run` command:
|
||||
./run.sh --device="chrome" --environment="local"
|
||||
```
|
||||
|
||||
Alternative you can also run the project from Visual Studio Code or Neovim
|
||||
with the following configuration files. Within the different configurations you
|
||||
have to provide the following arguments:
|
||||
`--dart-define SUPABASE_URL=<SUPABASE_URL>`,
|
||||
`--dart-define SUPABASE_ANON_KEY=<SUPABASE_ANON_KEY>`,
|
||||
`--dart-define SUPABASE_SITE_URL=<SUPABASE_SITE_URL>` and
|
||||
`--dart-define GOOGLE_CLIENT_ID=<GOOGLE_CLIENT_ID>`.
|
||||
To run the tests the following command can be used:
|
||||
|
||||
<details>
|
||||
<summary>Visual Studio Code: `.vscode/launch.json`</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Local - Chrome",
|
||||
"type": "dart",
|
||||
"request": "launch",
|
||||
"program": "app/lib/main.dart",
|
||||
"args": [
|
||||
"-d",
|
||||
"chrome",
|
||||
"--web-port",
|
||||
"3000",
|
||||
"--web-browser-flag=--disable-web-security",
|
||||
"--dart-define",
|
||||
"SUPABASE_URL=<SUPABASE_URL>",
|
||||
"--dart-define",
|
||||
"SUPABASE_ANON_KEY=<SUPABASE_ANON_KEY>",
|
||||
"--dart-define",
|
||||
"SUPABASE_SITE_URL=<SUPABASE_SITE_URL>",
|
||||
"--dart-define",
|
||||
"GOOGLE_CLIENT_ID=<GOOGLE_CLIENT_ID>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Local - iOS Simulator",
|
||||
"type": "dart",
|
||||
"request": "launch",
|
||||
"program": "app/lib/main.dart",
|
||||
"args": [
|
||||
"-d",
|
||||
"iPhone 14 Pro Max",
|
||||
"--dart-define",
|
||||
"SUPABASE_URL=<SUPABASE_URL>",
|
||||
"--dart-define",
|
||||
"SUPABASE_ANON_KEY=<SUPABASE_ANON_KEY>",
|
||||
"--dart-define",
|
||||
"SUPABASE_SITE_URL=<SUPABASE_SITE_URL>",
|
||||
"--dart-define",
|
||||
"GOOGLE_CLIENT_ID=<GOOGLE_CLIENT_ID>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Local - macOS",
|
||||
"type": "dart",
|
||||
"request": "launch",
|
||||
"program": "app/lib/main.dart",
|
||||
"args": [
|
||||
"-d",
|
||||
"macOS",
|
||||
"--dart-define",
|
||||
"SUPABASE_URL=<SUPABASE_URL>",
|
||||
"--dart-define",
|
||||
"SUPABASE_ANON_KEY=<SUPABASE_ANON_KEY>",
|
||||
"--dart-define",
|
||||
"SUPABASE_SITE_URL=<SUPABASE_SITE_URL>",
|
||||
"--dart-define",
|
||||
"GOOGLE_CLIENT_ID=<GOOGLE_CLIENT_ID>"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```sh
|
||||
flutter test
|
||||
```
|
||||
|
||||
</details>
|
||||
To check the test coverage the `--coverage` flag can be added to the command and
|
||||
an HTML report can be generated:
|
||||
|
||||
<details>
|
||||
<summary>Neovim: `.nvim.lua`</summary>
|
||||
```sh
|
||||
flutter test --coverage
|
||||
|
||||
# To generate the HTML report lcov is required, which can be installed via Homebrew:
|
||||
brew install lcov
|
||||
|
||||
```lua
|
||||
require('flutter-tools').setup_project({
|
||||
{
|
||||
name = 'Local - Chrome',
|
||||
flavor = 'debug',
|
||||
target = 'lib/main.dart',
|
||||
device = 'chrome',
|
||||
dart_define = {
|
||||
SUPABASE_URL = 'http://localhost:54321',
|
||||
SUPABASE_ANON_KEY = '<SUPABASE_ANON_KEY'
|
||||
SUPABASE_SITE_URL = '<SUPABASE_SITE_URL>',
|
||||
GOOGLE_CLIENT_ID = '<GOOGLE_CLIENT_ID',
|
||||
},
|
||||
},
|
||||
{
|
||||
name = 'Local - iOS Simulator',
|
||||
flavor = 'debug',
|
||||
target = 'lib/main.dart',
|
||||
device = 'iPhone 14 Pro Max',
|
||||
dart_define = {
|
||||
SUPABASE_URL = 'http://localhost:54321',
|
||||
SUPABASE_ANON_KEY = '<SUPABASE_ANON_KEY'
|
||||
SUPABASE_SITE_URL = '<SUPABASE_SITE_URL>',
|
||||
GOOGLE_CLIENT_ID = '<GOOGLE_CLIENT_ID',
|
||||
},
|
||||
},
|
||||
{
|
||||
name = 'Local - Chrome',
|
||||
flavor = 'debug',
|
||||
target = 'lib/main.dart',
|
||||
device = 'macOS',
|
||||
dart_define = {
|
||||
SUPABASE_URL = 'http://localhost:54321',
|
||||
SUPABASE_ANON_KEY = '<SUPABASE_ANON_KEY'
|
||||
SUPABASE_SITE_URL = '<SUPABASE_SITE_URL>',
|
||||
GOOGLE_CLIENT_ID = '<GOOGLE_CLIENT_ID',
|
||||
},
|
||||
},
|
||||
})
|
||||
genhtml coverage/lcov.info -o coverage/html
|
||||
open coverage/html/index.html
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
#### Sort all Imports
|
||||
|
||||
To sort all imports in the Dart code in a uniformly way you have to run the
|
||||
|
||||
1
app/.gitignore
vendored
1
app/.gitignore
vendored
@@ -31,6 +31,7 @@ migrate_working_dir/
|
||||
.pub-cache/
|
||||
.pub/
|
||||
/build/
|
||||
/coverage
|
||||
|
||||
# Symbolication related
|
||||
app.*.symbols
|
||||
|
||||
27
app/test/widgets/item/preview/utils/item_title_test.dart
Normal file
27
app/test/widgets/item/preview/utils/item_title_test.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'package:feeddeck/widgets/item/preview/utils/item_title.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Should render title', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: ItemTitle(itemTitle: 'My Title'),
|
||||
),
|
||||
);
|
||||
expect(find.byType(Container), findsOneWidget);
|
||||
expect(find.byType(Text), findsOneWidget);
|
||||
expect(find.text('My Title'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Should render empty container when empty string is provided',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: ItemTitle(itemTitle: ''),
|
||||
),
|
||||
);
|
||||
expect(find.byType(Container), findsOneWidget);
|
||||
expect(find.byType(Text), findsNothing);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user