Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/pull_request_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ jobs:
PHP_VERSION: 8.3
OTEL_SDK_DISABLED: true
OTEL_SERVICE_ENABLED: false
MAIL_FROM_EMAIL: noreply@tipit.net
MAIL_FROM_NAME: noreply@tipit.net
services:
mysql:
image: mysql:8.0
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
PHP_VERSION: 8.3
OTEL_SDK_DISABLED: true
OTEL_SERVICE_ENABLED: false
MAIL_FROM_EMAIL: noreply@tipit.net
MAIL_FROM_NAME: noreply@tipit.net
services:
mysql:
image: mysql:8.0
Expand Down
94 changes: 64 additions & 30 deletions resources/views/emails/welcome_new_user_email_fn.blade.php
Original file line number Diff line number Diff line change
@@ -1,37 +1,71 @@
@extends('emails.email_layout')

@section('content')
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:middle;" width="100%">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
<tbody>
<tr>
<td align="center" style="font-size:0px;padding:10px 25px;padding-right:25px;padding-left:25px;word-break:break-word;">
<div style="font-family:open Sans Helvetica, Arial, sans-serif;font-size:16px;line-height:1;text-align:center;color:#000000;">Your {!! Config::get('app.app_name') !!} is: <a href="#" style="text-decoration:none !important;color:black !important; cursor:default !important">{!!$user_email!!}</a></div>
</td>
</tr>
@if(!empty($reset_password_link))
<tr>
<td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;">
<div style="font-family:open Sans Helvetica, Arial, sans-serif;font-size:16px;line-height:1;text-align:center;color:#000000;">If you did not set a password you can <a href="{!! $reset_password_link !!}" target="_blank">do so now</a> (this link expires in {!! $reset_password_link_lifetime !!} min).</div>
</td>
</tr>
@endif
@if(!$user_is_complete)
<tr>
<td align="center" style="font-size:0px;padding:10px 25px;padding-right:16px;padding-left:25px;word-break:break-word;">
<div style="font-family:open Sans Helvetica, Arial, sans-serif;font-size:16px;line-height:1;text-align:center;color:#000000;">If you have not entered your first name, last name, company, and country please <a href="{!! URL::action("UserController@getLogin") !!}" target="_blank">do so in your profile now</a>. You may also update your photo, add a bio, and provide other information you wish to share.</div>
</td>
</tr>
@endif
<tr>
<td align="center" style="font-size:0px;padding:10px 25px;padding-right:16px;padding-left:25px;word-break:break-word;">
<div style="font-family:open Sans Helvetica, Arial, sans-serif;font-size:16px;line-height:1;text-align:center;color:#000000;">Your {!! Config::get('app.app_name') !!} can be used to access all {!! Config::get('app.tenant_name') !!} apps necessary to interact with the event. In order for the apps to operate, each one will ask for permission to access your information and/or request the authority to use your {!! Config::get('app.app_name') !!}.</div>
</td>
</tr>
<tr>
<td align="center" style="font-size:0px;padding:10px 25px;padding-right:25px;padding-left:25px;word-break:break-word;">
<div style="font-family:open Sans Helvetica, Arial, sans-serif;font-size:16px;line-height:1;text-align:center;color:#000000;">Should you have any questions, please email <a href="mailto:{!! Config::get('app.help_email') !!}">{!! Config::get('app.help_email') !!}</a> for assistance.</div>
</td>
</tr>
<tr>
<td style="padding: 24px 40px 8px;">
<h1 style="font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 22px; font-weight: 500; margin: 0 0 8px; color: #0A0A0A; letter-spacing: -0.01em;">Your FNid is ready.</h1>
<p style="font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 15px; color: #5F5E5A; margin: 0 0 24px; line-height: 1.6;">One identity, every FNTECH app &mdash; for this event and the next.</p>
</td>
</tr>
<tr>
<td style="padding: 0 40px 32px;">
<div style="background: #F5F4EF; border-radius: 6px; padding: 14px 16px;">
<span style="font-family: 'Courier New', monospace; font-size: 14px; color: #0A0A0A; word-break: break-all;">{{ $user_email }}</span>
</div>
</td>
</tr>
@if(!empty($reset_password_link))
<tr>
<td style="padding: 0 40px 32px;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
<tbody>
<tr>
<td style="vertical-align: top; width: 32px; padding-right: 10px;">
<div style="width: 22px; height: 22px; border-radius: 50%; background: #E6F1FB; color: #0C64C8; font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 12px; font-weight: 500; text-align: center; line-height: 22px;">1</div>
</td>
<td>
<div style="font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 15px; font-weight: 500; color: #0A0A0A; margin-bottom: 4px;">Set your password</div>
<p style="font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 14px; color: #5F5E5A; margin: 0 0 12px; line-height: 1.6;">Link expires in {!! $reset_password_link_lifetime !!} minutes.</p>
<a href="{!! $reset_password_link !!}" target="_blank" style="display: inline-block; background: #0A0A0A; color: #FFFFFF; text-decoration: none; font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 14px; font-weight: 500; padding: 9px 18px; border-radius: 6px;">Set password &rarr;</a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
@endif
@if(!$user_is_complete)
<tr>
<td style="padding: 0 40px 32px;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
<tbody>
<tr>
<td style="vertical-align: top; width: 32px; padding-right: 10px;">
<div style="width: 22px; height: 22px; border-radius: 50%; background: #E6F1FB; color: #0C64C8; font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 12px; font-weight: 500; text-align: center; line-height: 22px;">{{ !empty($reset_password_link) ? '2' : '1' }}</div>
</td>
<td>
<div style="font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 15px; font-weight: 500; color: #0A0A0A; margin-bottom: 4px;">Complete your profile</div>
<p style="font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 14px; color: #5F5E5A; margin: 0 0 12px; line-height: 1.6;">Add your name, company, and country. Photo and bio optional.</p>
<a href="{!! $bio_link !!}" target="_blank" style="display: inline-block; background: transparent; color: #0A0A0A; text-decoration: none; font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 14px; font-weight: 500; padding: 8px 17px; border-radius: 6px; border: 1px solid #B4B2A9;">Open profile &rarr;</a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
@endif
<tr>
<td style="padding: 0 40px 24px; border-top: 1px solid #E5E4DE;">
<p style="font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 13px; color: #5F5E5A; margin: 20px 0 0; line-height: 1.6;">You stay in control. Each {!! Config::get('app.tenant_name') !!} app will ask before accessing your information or acting on your behalf.</p>
</td>
</tr>
<tr>
<td style="background: #F5F4EF; padding: 20px 40px; font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 13px; color: #5F5E5A; text-align: center;">
Questions? <a href="mailto:{!! Config::get('app.help_email') !!}" style="color: #0C64C8; text-decoration: none;">{!! Config::get('app.help_email') !!}</a>
</td>
</tr>
</tbody>
</table>
@stop
106 changes: 106 additions & 0 deletions tests/unit/WelcomeNewUserEmailFnViewTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php namespace Tests\unit;

/**
* Copyright 2026 OpenStack Foundation
* Licensed 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.
**/

use App\Mail\WelcomeNewUserEmail;
use Auth\User;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Queue;
use Tests\BrowserKitTestCase;

/**
* Class WelcomeNewUserEmailFnViewTest
*
* Renders and delivers the FNTECH welcome email view to the configured mailer
* (Mailtrap) for visual preview, covering both the full case (password link +
* incomplete profile) and the minimal case (no password link, complete profile).
*
* @package Tests\unit
*/
class WelcomeNewUserEmailFnViewTest extends BrowserKitTestCase
{
protected function prepareForTests(): void
{
$_SERVER['HTTP_CLIENT_IP'] = '127.0.0.1';
Queue::fake();
Mail::fake();
Config::set('app.tenant_name', 'FNTECH');
}

private function makeUser(string $email, bool $complete): User
{
$user = $this->createMock(User::class);
$user->method('getEmail')->willReturn($email);
$user->method('getFullName')->willReturn('Preview User');
$user->method('getFirstName')->willReturn($complete ? 'Preview' : null);
$user->method('getLastName')->willReturn($complete ? 'User' : null);
$user->method('getCompany')->willReturn($complete ? 'ACME Inc.' : null);
$user->method('getCountry')->willReturn($complete ? 'US' : null);
$user->method('createdByOTP')->willReturn(false);
return $user;
}

public function testWelcomeEmailWithPasswordLinkAndIncompleteProfile(): void
{
$email = 'preview+welcome@example.com';
$resetLink = 'https://id.fntech.com/reset/abc123deadbeef';

$mailable = new WelcomeNewUserEmail($this->makeUser($email, false), $resetLink);

$mailable->assertHasSubject(
sprintf('[%1$s] You now have an %1$s', Config::get('app.app_name'))
);
$mailable->assertTo($email);

$html = $mailable->render();

$this->assertStringContainsString('Your FNid is ready.', $html);
$this->assertStringContainsString($email, $html);
// Step 1 — password
$this->assertStringContainsString('Set your password', $html);
$this->assertStringContainsString($resetLink, $html);
// Step 2 — profile
$this->assertStringContainsString('Complete your profile', $html);
$this->assertStringContainsString('Open profile', $html);
// Disclaimer and footer
$this->assertStringContainsString('You stay in control', $html);
$this->assertStringContainsString(Config::get('app.help_email'), $html);

}

public function testWelcomeEmailWithoutPasswordLinkAndCompleteProfile(): void
{
$email = 'preview+welcome-complete@example.com';

$mailable = new WelcomeNewUserEmail($this->makeUser($email, true), null);

$mailable->assertHasSubject(
sprintf('[%1$s] You now have an %1$s', Config::get('app.app_name'))
);
$mailable->assertTo($email);

$html = $mailable->render();

$this->assertStringContainsString('Your FNid is ready.', $html);
$this->assertStringContainsString($email, $html);
// Neither step should appear
$this->assertStringNotContainsString('Set your password', $html);
$this->assertStringNotContainsString('Complete your profile', $html);
// Disclaimer and footer always present
$this->assertStringContainsString('You stay in control', $html);
$this->assertStringContainsString(Config::get('app.help_email'), $html);

}
}
Loading