diff --git a/resources/views/admin/students/index.blade.php b/resources/views/admin/students/index.blade.php
index 9c40ddb..1d946f6 100644
--- a/resources/views/admin/students/index.blade.php
+++ b/resources/views/admin/students/index.blade.php
@@ -6,7 +6,7 @@
Students
Click name to edit
- New Student
+ New Student
@@ -20,7 +20,7 @@
@foreach($students as $student)
- {{ $student->full_name(true) }}
+ {{ $student->full_name(true) }}
{{ $student->school->name }}
{{ $student->grade }}
{{ $student->entries->count() }}
diff --git a/tests/Feature/Pages/Admin/StudentIndexTest.php b/tests/Feature/Pages/Admin/StudentIndexTest.php
new file mode 100644
index 0000000..56cba25
--- /dev/null
+++ b/tests/Feature/Pages/Admin/StudentIndexTest.php
@@ -0,0 +1,69 @@
+adminUser = User::factory()->admin()->create();
+ $this->normalUser = User::factory()->create();
+ $this->students = Student::factory()->count(5)->create();
+});
+
+it('is available to admin users', function () {
+ $user = User::factory()->admin()->create();
+
+ $response = $this->actingAs($user)->get(route('admin.students.index'));
+
+ $response->assertOk();
+});
+
+it('is not available to normal users', function () {
+ $response = $this->actingAs($this->normalUser)->get(route('admin.students.index'));
+
+ $response->assertRedirect(route('dashboard'));
+});
+
+it('has a new student button', function () {
+ $response = $this->actingAs($this->adminUser)->get(route('admin.students.index'));
+
+ $response
+ ->assertSee('New Student')
+ ->assertSeeInOrder([
+ 'a href=',
+ route('admin.students.create'),
+ 'New Student',
+ '/a',
+ ], false);
+});
+it('shows info for each student', function () {
+ // Arrange
+ $response = $this->actingAs($this->adminUser)->get(route('admin.students.index'));
+ // Act & Assert
+ $response->assertOk();
+ foreach ($this->students as $student) {
+ $response->assertSeeInOrder([
+ 'td',
+ $student->full_name(true),
+ '/td',
+ 'td',
+ $student->school->name,
+ '/td',
+ 'td',
+ $student->grade,
+ '/td',
+ 'td',
+ $student->entries->count(),
+ '/td',
+ ]);
+ }
+});
+it('shows a link to edit each student', function () {
+ // Arrange
+ $response = $this->actingAs($this->adminUser)->get(route('admin.students.index'));
+ // Act & Assert
+ foreach ($this->students as $student) {
+ $response->assertSee(route('admin.students.edit', $student));
+ }
+});
diff --git a/tests/Feature/Pages/Admin/UsersIndexTest.php b/tests/Feature/Pages/Admin/UsersIndexTest.php
index bee9992..c9198ff 100644
--- a/tests/Feature/Pages/Admin/UsersIndexTest.php
+++ b/tests/Feature/Pages/Admin/UsersIndexTest.php
@@ -10,13 +10,13 @@ use function Pest\Laravel\get;
uses(RefreshDatabase::class);
beforeEach(function () {
- $this->adminUser = User::factory()->admin()->create();
+ $this->adminUser = User::factory()->admin()->create();
$this->nonAdminUser = User::factory()->create();
- $this->tabUser = User::factory()->tab()->create();
- $this->users = User::factory(3)->create();
- $this->schools = [];
+ $this->tabUser = User::factory()->tab()->create();
+ $this->users = User::factory(3)->create();
+ $this->schools = [];
foreach ($this->users as $user) {
- $school = School::factory()->create();
+ $school = School::factory()->create();
$user->school_id = $school->id;
$user->save();
}