You've already forked Atomcms-edit
217 lines
5.1 KiB
PHP
Executable File
217 lines
5.1 KiB
PHP
Executable File
<?php
|
|
|
|
use App\Models\User;
|
|
|
|
test('staff applications page loads', function () {
|
|
installHotel();
|
|
|
|
$user = User::factory()->create();
|
|
|
|
$response = $this->actingAs($user)->get('/community/staff-applications');
|
|
|
|
// Status check
|
|
$response->assertStatus(200);
|
|
|
|
// Auth checks
|
|
expect(auth()->check())->toBeTrue();
|
|
expect(auth()->user()->id)->toBe($user->id);
|
|
|
|
// Content checks
|
|
$response->assertSee('staff');
|
|
});
|
|
|
|
test('guest cannot access staff applications', function () {
|
|
installHotel();
|
|
|
|
$response = $this->get('/community/staff-applications');
|
|
|
|
// Redirect check
|
|
$response->assertRedirect('/login');
|
|
|
|
// Guest check
|
|
expect(auth()->guest())->toBeTrue();
|
|
});
|
|
|
|
test('staff page loads', function () {
|
|
installHotel();
|
|
|
|
$response = $this->get('/community/staff');
|
|
|
|
// Status check
|
|
$response->assertStatus(200);
|
|
|
|
// Guest check
|
|
expect(auth()->guest())->toBeTrue();
|
|
|
|
// Content checks
|
|
$response->assertSee('Staff');
|
|
});
|
|
|
|
test('photos page loads', function () {
|
|
installHotel();
|
|
|
|
$response = $this->get('/community/photos');
|
|
|
|
// Status check
|
|
$response->assertStatus(200);
|
|
|
|
// Guest check
|
|
expect(auth()->guest())->toBeTrue();
|
|
|
|
// Content checks
|
|
$response->assertSee('Photo');
|
|
});
|
|
|
|
test('leaderboard page loads', function () {
|
|
installHotel();
|
|
|
|
$response = $this->get('/leaderboard');
|
|
|
|
// Status check
|
|
$response->assertStatus(200);
|
|
|
|
// Guest check
|
|
expect(auth()->guest())->toBeTrue();
|
|
|
|
// Content checks
|
|
$response->assertSee('Leaderboard');
|
|
});
|
|
|
|
test('community pages have proper structure', function () {
|
|
installHotel();
|
|
|
|
$pages = [
|
|
'/community/staff' => 'Staff',
|
|
'/community/photos' => 'Photos',
|
|
'/leaderboard' => 'Leaderboard',
|
|
];
|
|
|
|
foreach ($pages as $url => $content) {
|
|
$response = $this->get($url);
|
|
$response->assertStatus(200);
|
|
$response->assertSee($content);
|
|
expect(auth()->guest())->toBeTrue();
|
|
}
|
|
});
|
|
|
|
test('authenticated user can access community pages', function () {
|
|
installHotel();
|
|
|
|
$user = User::factory()->create();
|
|
|
|
$pages = [
|
|
'/community/staff',
|
|
'/community/photos',
|
|
'/leaderboard',
|
|
];
|
|
|
|
foreach ($pages as $url) {
|
|
$response = $this->actingAs($user)->get($url);
|
|
expect($response->status())->toBe(200);
|
|
expect(auth()->check())->toBeTrue();
|
|
expect(auth()->user()->id)->toBe($user->id);
|
|
}
|
|
});
|
|
|
|
test('staff applications requires authentication', function () {
|
|
installHotel();
|
|
|
|
// Multiple guest access attempts
|
|
for ($i = 0; $i < 3; $i++) {
|
|
$response = $this->get('/community/staff-applications');
|
|
$response->assertRedirect('/login');
|
|
expect(auth()->guest())->toBeTrue();
|
|
}
|
|
});
|
|
|
|
test('staff page shows team members', function () {
|
|
installHotel();
|
|
|
|
$response = $this->get('/community/staff');
|
|
|
|
$response->assertStatus(200);
|
|
|
|
// Should contain staff-related content
|
|
$response->assertSee('Staff');
|
|
$response->assertSee('Team');
|
|
});
|
|
|
|
test('photos page has proper layout', function () {
|
|
installHotel();
|
|
|
|
$response = $this->get('/community/photos');
|
|
|
|
$response->assertStatus(200);
|
|
|
|
// HTML structure checks
|
|
$response->assertSee('<!DOCTYPE html>');
|
|
$response->assertSee('<html');
|
|
});
|
|
|
|
test('leaderboard shows rankings', function () {
|
|
installHotel();
|
|
|
|
$response = $this->get('/leaderboard');
|
|
|
|
$response->assertStatus(200);
|
|
|
|
// Should contain leaderboard elements
|
|
$response->assertSee('Leaderboard');
|
|
$response->assertSee('Rank');
|
|
});
|
|
|
|
test('community routes return correct status codes', function () {
|
|
installHotel();
|
|
|
|
$user = User::factory()->create();
|
|
|
|
// Public pages - 200 for guests
|
|
$this->get('/community/staff')->assertStatus(200);
|
|
$this->get('/community/photos')->assertStatus(200);
|
|
$this->get('/leaderboard')->assertStatus(200);
|
|
|
|
// Protected page - 302 for guests
|
|
$this->get('/community/staff-applications')->assertStatus(302);
|
|
|
|
// All pages - 200 for authenticated
|
|
$this->actingAs($user)->get('/community/staff')->assertStatus(200);
|
|
$this->actingAs($user)->get('/community/photos')->assertStatus(200);
|
|
$this->actingAs($user)->get('/leaderboard')->assertStatus(200);
|
|
$this->actingAs($user)->get('/community/staff-applications')->assertStatus(200);
|
|
});
|
|
|
|
test('community pages load within reasonable time', function () {
|
|
installHotel();
|
|
|
|
$urls = [
|
|
'/community/staff',
|
|
'/community/photos',
|
|
'/leaderboard',
|
|
];
|
|
|
|
foreach ($urls as $url) {
|
|
$start = microtime(true);
|
|
$response = $this->get($url);
|
|
$end = microtime(true);
|
|
|
|
$duration = ($end - $start) * 1000;
|
|
|
|
$response->assertStatus(200);
|
|
expect($duration)->toBeLessThan(5000);
|
|
}
|
|
});
|
|
|
|
test('staff applications page shows form elements', function () {
|
|
installHotel();
|
|
|
|
$user = User::factory()->create();
|
|
|
|
$response = $this->actingAs($user)->get('/community/staff-applications');
|
|
|
|
$response->assertStatus(200);
|
|
|
|
// Should contain form elements
|
|
$response->assertSee('form');
|
|
$response->assertSee('apply');
|
|
});
|