From c3845f439362261553c148915fea7c059195b76e Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 11 Dec 2023 14:29:33 -0800 Subject: [PATCH] Add tests around loading saved reports --- .../Feature/SavedReports/SavedReportsTest.php | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/Feature/SavedReports/SavedReportsTest.php diff --git a/tests/Feature/SavedReports/SavedReportsTest.php b/tests/Feature/SavedReports/SavedReportsTest.php new file mode 100644 index 000000000..7c465beae --- /dev/null +++ b/tests/Feature/SavedReports/SavedReportsTest.php @@ -0,0 +1,52 @@ +actingAs(User::factory()->canViewReports()->create()) + ->get(route('reports/custom')) + ->assertOk() + ->assertViewHas(['savedReport' => function (SavedReport $report) { + // the view should have an empty report by default + return $report->exists() === false; + }]); + } + + public function testCanLoadASavedCustomReport() + { + $user = User::factory()->canViewReports()->create(); + $savedReport = SavedReport::factory()->make(['name' => 'My Awesome Report']); + $user->savedReports()->save($savedReport); + + $this->actingAs($user) + ->get(route('reports/custom', ['report' => $savedReport->id])) + ->assertOk() + ->assertViewHas(['savedReport' => function (SavedReport $viewReport) use ($savedReport) { + return $viewReport->is($savedReport); + }]); + } + + public function testCanOnlySeeOwnSavedCustomReports() + { + $this->markTestIncomplete('potentially...'); + + // create saved reports for two users + // load the route('reports/custom') + // ensure the view only has the current users reports ($saved_reports) + } + + public function testCanSaveACustomReport() + { + $this->markTestIncomplete(); + } +}