edk12564 commented on code in PR #32:
URL: 
https://github.com/apache/fineract-consumer-facing/pull/32#discussion_r3502348101


##########
frontend/src/app/layout/shell.component.ts:
##########
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { ChangeDetectionStrategy, Component, DestroyRef, inject, signal } from 
'@angular/core';
+import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
+import {
+  NavigationCancel,
+  NavigationEnd,
+  NavigationError,
+  NavigationStart,
+  Router,
+  RouterLink,
+  RouterLinkActive,
+  RouterOutlet,
+} from '@angular/router';
+import { MatButtonModule } from '@angular/material/button';
+import { MatIconModule } from '@angular/material/icon';
+import { MatListModule } from '@angular/material/list';
+import { MatProgressBarModule } from '@angular/material/progress-bar';
+import { MatSidenavModule } from '@angular/material/sidenav';
+import { MatToolbarModule } from '@angular/material/toolbar';
+import { AuthService } from '../core/auth/auth.service';
+
+@Component({
+  selector: 'app-shell',
+  changeDetection: ChangeDetectionStrategy.OnPush,
+  imports: [
+    RouterLink,
+    RouterLinkActive,
+    RouterOutlet,
+    MatButtonModule,
+    MatIconModule,
+    MatListModule,
+    MatProgressBarModule,
+    MatSidenavModule,
+    MatToolbarModule,
+  ],
+  template: `
+    @if (loading()) {
+      <mat-progress-bar mode="indeterminate" />
+    }
+
+    <mat-toolbar>
+      <mat-icon class="brand-icon">account_balance</mat-icon>
+      <span>Fineract Consumer</span>
+      <span class="spacer"></span>
+      <button mat-icon-button aria-label="Logout" (click)="logout()">
+        <mat-icon>logout</mat-icon>
+      </button>
+    </mat-toolbar>
+
+    <mat-sidenav-container>
+      <mat-sidenav mode="side" opened>
+        <mat-nav-list>
+          <a mat-list-item routerLink="/summary" 
routerLinkActive="active-link">
+            <mat-icon matListItemIcon>dashboard</mat-icon>Summary
+          </a>
+          <a mat-list-item routerLink="/savings" 
routerLinkActive="active-link">
+            <mat-icon matListItemIcon>savings</mat-icon>Savings
+          </a>
+          <a mat-list-item routerLink="/loans" routerLinkActive="active-link">
+            <mat-icon matListItemIcon>request_quote</mat-icon>Loans
+          </a>
+          <a mat-list-item routerLink="/transfers" 
routerLinkActive="active-link">
+            <mat-icon matListItemIcon>swap_horiz</mat-icon>Transfers
+          </a>
+        </mat-nav-list>
+      </mat-sidenav>
+      <mat-sidenav-content>
+        <main>
+          <router-outlet />
+        </main>
+      </mat-sidenav-content>
+    </mat-sidenav-container>
+  `,
+  styles: `
+    .brand-icon {
+      margin-right: 0.5rem;
+    }
+    .spacer {
+      flex: 1 1 auto;
+    }
+    mat-sidenav-container {
+      height: calc(100vh - 64px);
+    }
+    mat-sidenav {
+      width: 15rem;
+    }
+    main {
+      padding: 2rem;
+    }

Review Comment:
   Thanks for the comments Aman. I learned a lot here. But I think I account 
for this one in the Angular 16+ way with 
"this.router.events.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((event)",
 which should unsubscribe from the observable when the component is destroyed. 
I think this is the modern equivalent of the ngOnDestroy + unsubscribe() 
pattern. 
   
   Other than that, I just pushed a change to use APPLICATION_JSON constant and 
a new translation layer and UI element for the frontend. Please take a look!



##########
frontend/playwright/tests/transfers.spec.ts:
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { type Page, expect, test } from '@playwright/test';
+
+async function mockResumedSession(page: Page): Promise<void> {
+  await page.route('**/api/v1/authentication/refresh', route =>
+    route.fulfill({
+      status: 200,
+      contentType: 'application/json',
+      body: JSON.stringify({ accessToken: 'fake-jwt' }),
+    }),
+  );
+}
+
+async function fillTransferForm(page: Page): Promise<void> {
+  await page.locator('input[formControlName="fromAccountId"]').fill('1');
+  await page.locator('input[formControlName="toAccountId"]').fill('2');
+  await page.locator('mat-select[formControlName="toAccountType"]').click();
+  await page.getByRole('option', { name: 'Savings' }).click();
+  await page.locator('input[formControlName="amount"]').fill('50');
+  await page.getByRole('button', { name: 'Send transfer' }).click();
+}
+
+test('transfers route is guarded: redirects to /login when unauthenticated', 
async ({ page }) => {
+  // No session resume: the refresh fails, so the app stays logged out and the 
guard redirects.
+  await page.route('**/api/v1/authentication/refresh', route => 
route.fulfill({ status: 401 }));
+
+  await page.goto('/transfers');
+  await expect(page).toHaveURL(/\/login$/);
+});
+
+test('logged-in: form -> OTP step-up -> confirm -> success', async ({ page }) 
=> {
+  await mockResumedSession(page);
+  await page.route('**/api/v1/transfers/initiate', route =>
+    route.fulfill({
+      status: 200,
+      contentType: 'application/json',
+      body: JSON.stringify({ stepUpToken: 'tok', sentTo: 'a***@example.com' }),
+    }),
+  );
+  await page.route('**/api/v1/transfers/confirm', route =>
+    route.fulfill({
+      status: 200,
+      contentType: 'application/json',
+      body: JSON.stringify({ transferId: 100, fromAccountId: 1, toAccountId: 
2, amount: 50 }),
+    }),
+  );
+
+  await page.goto('/transfers');
+  await expect(page).toHaveURL(/\/transfers$/);
+
+  await fillTransferForm(page);
+
+  const otpField = page.locator('input[formControlName="otp"]');
+  await expect(otpField).toBeVisible();
+  await otpField.fill('ABC123');
+  await page.getByRole('button', { name: 'Verify' }).click();
+
+  await expect(page.getByText(/transfer complete/i)).toBeVisible();
+});
+
+test('wrong OTP: surfaces the ConsumerApiError snackbar and stays on the OTP 
step', async ({
+  page,
+}) => {
+  await mockResumedSession(page);
+  await page.route('**/api/v1/transfers/initiate', route =>
+    route.fulfill({
+      status: 200,
+      contentType: 'application/json',

Review Comment:
   Fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to