-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dadc10d
commit 9fa513b
Showing
4 changed files
with
243 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
use App\Models\User; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Support\Facades\Hash; | ||
use Laravel\Pennant\Feature; | ||
use Livewire\Volt\Volt; | ||
|
||
beforeEach(function (): void { | ||
|
@@ -29,3 +30,98 @@ | |
->assertRedirect('login'); | ||
$this->assertGuest(); | ||
}); | ||
|
||
test('experiments are displayed correctly', function (): void { | ||
Feature::define('test-experiment', true); | ||
|
||
Volt::test('profile.experiments-manager') | ||
->assertSee('Feature Experiments') | ||
->assertSee('Test experiment'); | ||
}); | ||
|
||
test('experiment details can be viewed', function (): void { | ||
Feature::define('test-experiment', true); | ||
|
||
Volt::test('profile.experiments-manager') | ||
->call('viewExperimentDetails', 'test-experiment') | ||
->assertDispatched('open-modal', 'experiment-details') | ||
->assertSee('Test experiment'); | ||
}); | ||
|
||
test('experiments can be toggled', function (): void { | ||
Feature::define('test-experiment', true); | ||
|
||
Volt::test('profile.experiments-manager') | ||
->call('toggleExperiment', 'test-experiment') | ||
->assertDispatched('experiment-toggled'); | ||
|
||
$this->assertFalse(Feature::active('test-experiment')); | ||
|
||
Volt::test('profile.experiments-manager') | ||
->call('toggleExperiment', 'test-experiment') | ||
->assertDispatched('experiment-toggled'); | ||
|
||
$this->assertTrue(Feature::active('test-experiment')); | ||
}); | ||
|
||
test('feedback modal can be opened', function (): void { | ||
Feature::define('test-experiment', true); | ||
|
||
Volt::test('profile.experiments-manager') | ||
->call('viewExperimentDetails', 'test-experiment') | ||
->call('openFeedbackModal') | ||
->assertSet('showFeedbackModal', true) | ||
->assertDispatched('close-modal', 'experiment-details') | ||
->assertDispatched('open-modal', 'experiment-feedback'); | ||
}); | ||
|
||
test('feedback can be submitted', function (): void { | ||
Feature::define('test-experiment', true); | ||
|
||
Http::fake([ | ||
'https://feedback.vanguardbackup.com/api/feedback' => Http::response(['status' => 'success', 'message' => 'Feedback submitted successfully'], 200), | ||
]); | ||
|
||
Volt::test('profile.experiments-manager') | ||
->set('selectedExperiment', 'test-experiment') | ||
->set('feedbackText', 'This is a test feedback') | ||
->set('feedbackEmail', '[email protected]') | ||
->call('submitFeedback') | ||
->assertSet('showFeedbackModal', false) | ||
->assertDispatched('close-modal', 'experiment-feedback') | ||
->assertDispatched('open-modal', 'experiment-details'); | ||
}); | ||
|
||
test('feedback submission handles validation errors', function (): void { | ||
Feature::define('test-experiment', true); | ||
|
||
Http::fake([ | ||
'https://feedback.vanguardbackup.com/api/feedback' => Http::response(['errors' => ['feedbackText' => ['The feedback text field is required.']]], 422), | ||
]); | ||
|
||
Volt::test('profile.experiments-manager') | ||
->set('selectedExperiment', 'test-experiment') | ||
->set('feedbackText', '') | ||
->call('submitFeedback') | ||
->assertHasErrors(['feedbackText' => 'required']); | ||
}); | ||
|
||
test('feedback modal can be closed', function (): void { | ||
Volt::test('profile.experiments-manager') | ||
->set('showFeedbackModal', true) | ||
->call('closeFeedbackModal') | ||
->assertSet('showFeedbackModal', false) | ||
->assertDispatched('close-modal', 'experiment-feedback') | ||
->assertDispatched('open-modal', 'experiment-details'); | ||
}); | ||
|
||
test('experiment details are correctly populated', function (): void { | ||
Feature::define('test-experiment', true); | ||
|
||
$testable = Volt::test('profile.experiments-manager'); | ||
|
||
$testable->call('viewExperimentDetails', 'test-experiment'); | ||
|
||
$selectedExperiment = $testable->get('selectedExperiment'); | ||
$this->assertEquals('test-experiment', $selectedExperiment); | ||
}); |