From 0815f75de92aca04766cec1853e9fea3d07fb8a8 Mon Sep 17 00:00:00 2001 From: thomas briand Date: Sun, 19 Jan 2025 17:55:39 +0100 Subject: [PATCH 1/2] feat: added two unit test for the mobile app --- .../mobile/test/navigation_page_test.dart | 18 ++++++++++++++++++ .../mobile/test/setting_page_test.dart | 17 +++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 apps/frontend/mobile/test/navigation_page_test.dart create mode 100644 apps/frontend/mobile/test/setting_page_test.dart diff --git a/apps/frontend/mobile/test/navigation_page_test.dart b/apps/frontend/mobile/test/navigation_page_test.dart new file mode 100644 index 00000000..008e9b48 --- /dev/null +++ b/apps/frontend/mobile/test/navigation_page_test.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:aether/views/applet/pages/applet_creation.dart'; +import 'package:aether/views/mainPage/pages/main_navigation.dart'; + +void main() { + group('MainNavigationPage Tests', () { + testWidgets('Floating action button opens AppletCreation page', + (WidgetTester tester) async { + await tester.pumpWidget(const MaterialApp(home: MainNavigationPage())); + + await tester.tap(find.byType(FloatingActionButton)); + await tester.pumpAndSettle(); + + expect(find.byType(AppletCreation), findsOneWidget); + }); + }); +} diff --git a/apps/frontend/mobile/test/setting_page_test.dart b/apps/frontend/mobile/test/setting_page_test.dart new file mode 100644 index 00000000..d97872dc --- /dev/null +++ b/apps/frontend/mobile/test/setting_page_test.dart @@ -0,0 +1,17 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:aether/views/settings/pages/settings_page.dart'; + +void main() { + testWidgets('SettingsPage has Go to Profile and Change API buttons', + (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: SettingsPage(), + ), + ); + + expect(find.text('Go to Profile'), findsOneWidget); + expect(find.text('Change API'), findsOneWidget); + }); +} From 1d0bb28ec5bca66263058384f3b8d4426a3a8f43 Mon Sep 17 00:00:00 2001 From: thomas briand Date: Sun, 19 Jan 2025 22:09:20 +0100 Subject: [PATCH 2/2] feat: login not working --- apps/frontend/web/e2e/demo.test.ts | 47 ++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/apps/frontend/web/e2e/demo.test.ts b/apps/frontend/web/e2e/demo.test.ts index 45f95661..47295ca9 100644 --- a/apps/frontend/web/e2e/demo.test.ts +++ b/apps/frontend/web/e2e/demo.test.ts @@ -1,16 +1,31 @@ -import { test } from '@playwright/test'; - -test('Applets explorer', async ({ page }) => { - await page.goto('http://localhost:5173/'); - await page.locator('.grid > div').first().click(); -}); - -test('Providers explorer', async ({ page }) => { - await page.goto('http://localhost:5173/providers'); - await page.locator('.grid > div').first().click(); -}); - -test('Applets to providers explorer', async ({ page }) => { - await page.goto('http://localhost:5173/'); - await page.getByRole('link', { name: 'Providers' }).click(); -}); +import { test, expect } from '@playwright/test'; + +const baseURL = 'http://localhost:8081'; + +test.describe('App walkthrough', () => { + test('should walk through the app', async ({ page }) => { + await page.goto(`${baseURL}/auth/login`); + + await page.locator('input[placeholder="Enter your email"]').fill('test@test.com'); + await page.locator('input[placeholder="Enter your password"]').fill('123456789aA$$'); + await page.locator('button:text("Sign in")').click(); + + + const currentURL = page.url(); + console.log(`Current URL after login: ${currentURL}`); + + const pageTitle = await page.title(); + console.log(`Page title after login: ${pageTitle}`); + + const bodyText = await page.locator('body').innerText(); + console.log(`Body text after login: ${bodyText}`); + + const loggedInElements = await page.locator('text=Logout, text=Profile, text=Settings').allTextContents(); + console.log(`Visible elements indicating login status: ${loggedInElements}`); + + await page.goto(`${baseURL}/explore/applets`); + const appletsURL = page.url(); + console.log(`Current URL after navigating to applets: ${appletsURL}`); + await expect(page.locator('text=Applets')).toBeVisible(); + }); +}); \ No newline at end of file