diff --git a/.gitignore b/.gitignore index 7fe978f..1891c29 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ yarn-error.log /.fleet /.idea /.vscode +.DS_Store diff --git a/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php b/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php new file mode 100644 index 0000000..81a7229 --- /dev/null +++ b/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php @@ -0,0 +1,28 @@ +string('email')->primary(); + $table->string('token'); + $table->timestamp('created_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('password_reset_tokens'); + } +}; diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 0000000..2e7af2b --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/resources/css/app.css b/resources/css/app.css new file mode 100644 index 0000000..b5c61c9 --- /dev/null +++ b/resources/css/app.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; diff --git a/resources/js/app.js b/resources/js/app.js new file mode 100644 index 0000000..e59d6a0 --- /dev/null +++ b/resources/js/app.js @@ -0,0 +1 @@ +import './bootstrap'; diff --git a/resources/js/views/dashboard/ArticleEdit.vue b/resources/js/views/dashboard/ArticleEdit.vue deleted file mode 100644 index 9b0b935..0000000 --- a/resources/js/views/dashboard/ArticleEdit.vue +++ /dev/null @@ -1,345 +0,0 @@ - - - diff --git a/resources/js/views/dashboard/ArticleList.vue b/resources/js/views/dashboard/ArticleList.vue deleted file mode 100644 index 6dfb633..0000000 --- a/resources/js/views/dashboard/ArticleList.vue +++ /dev/null @@ -1,290 +0,0 @@ - - - diff --git a/resources/js/views/dashboard/Dashboard.vue b/resources/js/views/dashboard/Dashboard.vue deleted file mode 100644 index b14a1df..0000000 --- a/resources/js/views/dashboard/Dashboard.vue +++ /dev/null @@ -1,164 +0,0 @@ - - - - - diff --git a/resources/js/views/dashboard/DiscordBotLogs.vue b/resources/js/views/dashboard/DiscordBotLogs.vue deleted file mode 100644 index f29c80d..0000000 --- a/resources/js/views/dashboard/DiscordBotLogs.vue +++ /dev/null @@ -1,71 +0,0 @@ - - - diff --git a/resources/js/views/dashboard/EventEdit.vue b/resources/js/views/dashboard/EventEdit.vue deleted file mode 100644 index f77df1a..0000000 --- a/resources/js/views/dashboard/EventEdit.vue +++ /dev/null @@ -1,397 +0,0 @@ - - - - - diff --git a/resources/js/views/dashboard/EventList.vue b/resources/js/views/dashboard/EventList.vue deleted file mode 100644 index ae805e8..0000000 --- a/resources/js/views/dashboard/EventList.vue +++ /dev/null @@ -1,405 +0,0 @@ - - - - - diff --git a/resources/js/views/dashboard/MediaEdit.vue b/resources/js/views/dashboard/MediaEdit.vue deleted file mode 100644 index d1c0ab6..0000000 --- a/resources/js/views/dashboard/MediaEdit.vue +++ /dev/null @@ -1,576 +0,0 @@ - - - - - diff --git a/resources/js/views/dashboard/MediaList.vue b/resources/js/views/dashboard/MediaList.vue deleted file mode 100644 index 5301418..0000000 --- a/resources/js/views/dashboard/MediaList.vue +++ /dev/null @@ -1,484 +0,0 @@ - - - - - diff --git a/resources/js/views/dashboard/ShortlinkEdit.vue b/resources/js/views/dashboard/ShortlinkEdit.vue deleted file mode 100644 index 65bbb6f..0000000 --- a/resources/js/views/dashboard/ShortlinkEdit.vue +++ /dev/null @@ -1,203 +0,0 @@ - - - - - diff --git a/resources/js/views/dashboard/ShortlinkList.vue b/resources/js/views/dashboard/ShortlinkList.vue deleted file mode 100644 index 3d1b49d..0000000 --- a/resources/js/views/dashboard/ShortlinkList.vue +++ /dev/null @@ -1,295 +0,0 @@ - - - - - diff --git a/resources/js/views/dashboard/UserEdit.vue b/resources/js/views/dashboard/UserEdit.vue deleted file mode 100644 index 3013d9e..0000000 --- a/resources/js/views/dashboard/UserEdit.vue +++ /dev/null @@ -1,263 +0,0 @@ - - - diff --git a/resources/js/views/dashboard/UserList.vue b/resources/js/views/dashboard/UserList.vue deleted file mode 100644 index 103d715..0000000 --- a/resources/js/views/dashboard/UserList.vue +++ /dev/null @@ -1,247 +0,0 @@ - - - diff --git a/resources/js/views/form.ts b/resources/js/views/form.ts deleted file mode 100644 index a3985f2..0000000 --- a/resources/js/views/form.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { reactive } from "vue"; -import { Form, FormControl, FormObject } from "../helpers/form"; - -export const form: FormObject = reactive( - Form({ - password: FormControl("", Required()), - }), -); diff --git a/resources/views/app.blade.php b/resources/views/app.blade.php deleted file mode 100644 index 040b862..0000000 --- a/resources/views/app.blade.php +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - STEMMechanics - - - - - - - -
- @vite('resources/js/main.js') - - diff --git a/resources/views/emails/exception.blade.php b/resources/views/emails/exception.blade.php deleted file mode 100644 index 70957b5..0000000 --- a/resources/views/emails/exception.blade.php +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - {!! $content ?? '' !!} - - \ No newline at end of file diff --git a/resources/views/emails/user/change_email_verify.blade.php b/resources/views/emails/user/change_email_verify.blade.php deleted file mode 100644 index e7d491b..0000000 --- a/resources/views/emails/user/change_email_verify.blade.php +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - - STEMMechanics - Forgot Password - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - STEMMechanics Logo - -

Hey {{ $user?->display_name }},

- We just need to confirm that this is your new email address. Click this link stemmechanics.com.au/verify-email and if you are asked, use the confirm code: -
- {{ $code }} -
- But if you didn't ask to reset your password, you can delete - this email and your password will remain the same. -
- Need help or got feedback? - Contact us - or touch base at - @stemmechanics. -
- Sent by STEMMechanics · - Visit our Website - · - @stemmechanics
PO Box 36, Edmonton, QLD 4869, Australia -
- - diff --git a/resources/views/emails/user/change_email_verify_plain.blade.php b/resources/views/emails/user/change_email_verify_plain.blade.php deleted file mode 100644 index 04d8feb..0000000 --- a/resources/views/emails/user/change_email_verify_plain.blade.php +++ /dev/null @@ -1,16 +0,0 @@ -Hey {{ $user?->display_name }}, - -We just need to confirm that this is your new email address. - -Enter the following URL in your browser: - -https://www.stemmechanics.com.au/verify-email - -and when asked, use the confirm code: {{ $code }} - -Need help or got feedback? Contact us at https://www.stemmechanics.com.au/contact or touch base on twitter at @stemmechanics - --- -Sent by STEMMechanics -https://www.stemmechanics.com.au/ -PO Box 36, Edmonton, QLD 4869, Australia diff --git a/resources/views/emails/user/changed_email.blade.php b/resources/views/emails/user/changed_email.blade.php deleted file mode 100644 index 45a6af3..0000000 --- a/resources/views/emails/user/changed_email.blade.php +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - STEMMechanics - Forgot Password - - - - - - - - - - - - - - - - - - - - - - - - -
- - STEMMechanics Logo - -

Yo {{ $user?->display_name }}

- Just a quick word that your email has been changed to {{ $new_email }}. -
- If this was not you, please contact us by replying to this email so we can disable your account. -
- Need help or got feedback? - Contact us - or touch base at - @stemmechanics. -
- Sent by STEMMechanics · - Visit our Website - · - @stemmechanics
PO Box 36, Edmonton, QLD 4869, Australia -
- - diff --git a/resources/views/emails/user/changed_email_plain.blade.php b/resources/views/emails/user/changed_email_plain.blade.php deleted file mode 100644 index 611155f..0000000 --- a/resources/views/emails/user/changed_email_plain.blade.php +++ /dev/null @@ -1,12 +0,0 @@ -Yo {{ $user?->display_name }} - -Just a quick word that your email has been changed to {{ $new_email }}. - -If this was not you, please contact us by replying to this email so we can disable your account. - -Need help or got feedback? Contact us at https://www.stemmechanics.com.au/contact or touch base on twitter at @stemmechanics - --- -Sent by STEMMechanics -https://www.stemmechanics.com.au/ -PO Box 36, Edmonton, QLD 4869, Australia \ No newline at end of file diff --git a/resources/views/emails/user/changed_password.blade.php b/resources/views/emails/user/changed_password.blade.php deleted file mode 100644 index cf4b548..0000000 --- a/resources/views/emails/user/changed_password.blade.php +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - STEMMechanics - Forgot Password - - - - - - - - - - - - - - - - - - - - - - - - -
- - STEMMechanics Logo - -

Yo {{ $user?->display_name }}

- Just a quick word that your password has been changed. -
- If this was not you, please contact us by replying to this email so we can disable your account. -
- Need help or got feedback? - Contact us - or touch base at - @stemmechanics. -
- Sent by STEMMechanics · - Visit our Website - · - @stemmechanics
PO Box 36, Edmonton, QLD 4869, Australia -
- - diff --git a/resources/views/emails/user/changed_password_plain.blade.php b/resources/views/emails/user/changed_password_plain.blade.php deleted file mode 100644 index 723515f..0000000 --- a/resources/views/emails/user/changed_password_plain.blade.php +++ /dev/null @@ -1,12 +0,0 @@ -Yo {{ $user?->display_name }} - -Just a quick word that your password has been changed. - -If this was not you, please contact us by replying to this email so we can disable your account. - -Need help or got feedback? Contact us at https://www.stemmechanics.com.au/contact or touch base on twitter at @stemmechanics - --- -Sent by STEMMechanics -https://www.stemmechanics.com.au/ -PO Box 36, Edmonton, QLD 4869, Australia \ No newline at end of file diff --git a/resources/views/emails/user/contact.blade.php b/resources/views/emails/user/contact.blade.php deleted file mode 100644 index b87a8d2..0000000 --- a/resources/views/emails/user/contact.blade.php +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - STEMMechanics - Forgot Password - - - - - - - - - - - - - - - - - - - - - - - - -
- - STEMMechanics Logo - -

Hi STEMMechanics,

- {{ $content }} -
- From: {{ $name }} - {{ $email }} -
- Need help or got feedback? - Contact us - or touch base at - @stemmechanics. -
- Sent by STEMMechanics · - Visit our Website - · - @stemmechanics
PO Box 36, Edmonton, QLD 4869, Australia -
- - diff --git a/resources/views/emails/user/contact_plain.blade.php b/resources/views/emails/user/contact_plain.blade.php deleted file mode 100644 index f1236c9..0000000 --- a/resources/views/emails/user/contact_plain.blade.php +++ /dev/null @@ -1,8 +0,0 @@ -{{ $content }} - -From: {{ $name }} - {{ $email }} - --- -Sent by STEMMechanics -https://www.stemmechanics.com.au/ -PO Box 36, Edmonton, QLD 4869, Australia diff --git a/resources/views/emails/user/email_verify.blade.php b/resources/views/emails/user/email_verify.blade.php deleted file mode 100644 index 933f3fb..0000000 --- a/resources/views/emails/user/email_verify.blade.php +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - STEMMechanics - Forgot Password - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - STEMMechanics Logo - -

Welcome {{ $user?->display_name }},

- We've heard you would like to try out our workshops and courses! -
- Before we can let you loose on our website, we need to make sure you are a real person and not a pesky robot or cat. Click this link stemmechanics.com.au/verify-email and if you are asked, use the confirm code: -
- {{ $code }} -
- But if you didn't ask to reset your password, you can delete - this email and your password will remain the same. -
- Need help or got feedback? - Contact us - or touch base at - @stemmechanics. -
- Sent by STEMMechanics · - Visit our Website - · - @stemmechanics
PO Box 36, Edmonton, QLD 4869, Australia -
- - diff --git a/resources/views/emails/user/email_verify_plain.blade.php b/resources/views/emails/user/email_verify_plain.blade.php deleted file mode 100644 index 6f279d3..0000000 --- a/resources/views/emails/user/email_verify_plain.blade.php +++ /dev/null @@ -1,17 +0,0 @@ -Welcome {{ $user?->display_name }}, - -We've heard you would like to try out our workshops and courses! -Before we can let you loose on our website, we need to make sure you are a real person and not a pesky robot or cat. - -Enter the following URL in your browser: - -https://www.stemmechanics.com.au/verify-email - -and when asked, use the confirm code: {{ $code }} - -Need help or got feedback? Contact us at https://www.stemmechanics.com.au/contact or touch base on twitter at @stemmechanics - --- -Sent by STEMMechanics -https://www.stemmechanics.com.au/ -PO Box 36, Edmonton, QLD 4869, Australia diff --git a/resources/views/emails/user/forgot_password.blade.php b/resources/views/emails/user/forgot_password.blade.php deleted file mode 100644 index c98950f..0000000 --- a/resources/views/emails/user/forgot_password.blade.php +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - STEMMechanics - Forgot Password - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - STEMMechanics Logo - -

Yo {{ $user?->display_name }}

- We all forget things sometimes! But you can reset your - password by clicking the link - Reset Password - and entering the following code: -
- {{ $code }} -
- But if you didn't ask to reset your password, you can delete - this email and your password will remain the same. -
- Need help or got feedback? - Contact us - or touch base at - @stemmechanics. -
- Sent by STEMMechanics · - Visit our Website - · - @stemmechanics
PO Box 36, Edmonton, QLD 4869, Australia -
- - diff --git a/resources/views/emails/user/forgot_password_plain.blade.php b/resources/views/emails/user/forgot_password_plain.blade.php deleted file mode 100644 index bd95a01..0000000 --- a/resources/views/emails/user/forgot_password_plain.blade.php +++ /dev/null @@ -1,14 +0,0 @@ -Yo {{ $user?->display_name }} - -We all forget things sometimes! But you can reset your password typing the following into your browser https://www.stemmechanics.com.au/reset-password and entering the following code: - -{{ $code }} - -But if you didn't ask to reset your password, you can delete this email and we will keep your current password. - -Need help or got feedback? Contact us at https://www.stemmechanics.com.au/contact or touch base on twitter at @stemmechanics - --- -Sent by STEMMechanics -https://www.stemmechanics.com.au/ -PO Box 36, Edmonton, QLD 4869, Australia \ No newline at end of file diff --git a/resources/views/errors/503.blade.php b/resources/views/errors/503.blade.php deleted file mode 100644 index eb0eaa1..0000000 --- a/resources/views/errors/503.blade.php +++ /dev/null @@ -1,31 +0,0 @@ - -Site Maintenance - - -
- - -

We’ll be back soon!

-
-

Sorry for the inconvenience but we’re performing some maintenance at the moment. If you need to you can always contact us by email or over on Discord, otherwise we’ll be back online shortly!

-

— The STEMMechanics Team

-
-
\ No newline at end of file diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php new file mode 100644 index 0000000..1aa35c0 --- /dev/null +++ b/resources/views/welcome.blade.php @@ -0,0 +1,15 @@ + + + + + + @vite('resources/css/app.css') + + Laravel + + +

+ Hello world! +

+ + diff --git a/routes/api.php b/routes/api.php index 0446adb..889937e 100644 --- a/routes/api.php +++ b/routes/api.php @@ -1,18 +1,7 @@ name('login'); -Route::post('/register', [UserController::class, 'register']); - -Route::get('/analytics', [AnalyticsController::class, 'index']); -Route::get('/analytics/{session}', [AnalyticsController::class, 'show']); -Route::post('/analytics', [AnalyticsController::class, 'store']); - -Route::apiResource('users', UserController::class); -Route::post('/users/forgotPassword', [UserController::class, 'forgotPassword']); -Route::post('/users/resetPassword', [UserController::class, 'resetPassword']); -Route::post('/users/resendVerifyEmailCode', [UserController::class, 'resendVerifyEmailCode']); -Route::post('/users/verifyEmail', [UserController::class, 'verifyEmail']); -Route::get('/users/{user}/events', [UserController::class, 'eventList']); - -Route::get('media/jobs', [MediaJobController::class, 'index']); -Route::get('media/jobs/{mediaJob}', [MediaJobController::class, 'show']); -Route::apiResource('media', MediaController::class); -Route::get('media/{media}/download', [MediaController::class, 'download']); - -Route::apiResource('articles', ArticleController::class); -// Route::apiAddendumResource('attachments', 'articles', ArticleController::class); - -Route::apiResource('events', EventController::class); -Route::apiAddendumResource('attachments', 'events', EventController::class); - -Route::get('/events/{event}/users', [EventController::class, 'userList']); -Route::post('/events/{event}/users', [EventController::class, 'userAdd']); -Route::match(['put', 'patch'], '/events/{event}/users', [EventController::class, 'userUpdate']); -Route::delete('/events/{event}/users/{user}', [EventController::class, 'userDelete']); - -Route::post('/contact', [ContactController::class, 'send']); - -Route::apiResource('/shortlinks', ShortlinkController::class); - -Route::get('/logs/{name}', [LogController::class, 'show']); -Route::get('/ocr', [OCRController::class, 'show']); - -Route::middleware('auth:sanctum')->group(function () { - Route::post('/logout', [AuthController::class, 'logout']); - Route::get('/me', [AuthController::class, 'me']); +Route::middleware('auth:sanctum')->get('/user', function (Request $request) { + return $request->user(); }); - -Route::any('{any}', function () { - return response()->json(['message' => 'Resource not found'], 404); -})->where('any', '.*'); diff --git a/routes/web.php b/routes/web.php index b9aedb5..d259f33 100644 --- a/routes/web.php +++ b/routes/web.php @@ -8,11 +8,11 @@ use Illuminate\Support\Facades\Route; |-------------------------------------------------------------------------- | | Here is where you can register web routes for your application. These -| routes are loaded by the RouteServiceProvider within a group which -| contains the "web" middleware group. Now create something great! +| routes are loaded by the RouteServiceProvider and all of them will +| be assigned to the "web" middleware group. Make something great! | */ -Route::get('/{any}', function () { - return view('app'); -})->where('any', '.*'); +Route::get('/', function () { + return view('welcome'); +}); diff --git a/scripts/keras.py b/scripts/keras.py deleted file mode 100644 index bebd26c..0000000 --- a/scripts/keras.py +++ /dev/null @@ -1,13 +0,0 @@ -import sys -import urllib.parse -import numpy as np -import keras_ocr - -if len(sys.argv) > 1: - url = urllib.parse.unquote(sys.argv[1]) - image = keras_ocr.tools.read(url) - pipeline = keras_ocr.pipeline.Pipeline() - prediction = pipeline.recognize([image]) - print("----------START----------") - for text, box in prediction [0]: - print(text) diff --git a/storage/logs/.gitignore b/storage/logs/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/storage/logs/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 0000000..f40759a --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,12 @@ +/** @type {import('tailwindcss').Config} */ +export default { + content: [ + "./resources/**/*.blade.php", + "./resources/**/*.js", + "./resources/**/*.vue", + ], + theme: { + extend: {}, + }, + plugins: [], +} diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php index c6b6d48..cc68301 100644 --- a/tests/CreatesApplication.php +++ b/tests/CreatesApplication.php @@ -9,12 +9,10 @@ trait CreatesApplication { /** * Creates the application. - * - * @return \Illuminate\Foundation\Application */ public function createApplication(): Application { - $app = require __DIR__ . '/../bootstrap/app.php'; + $app = require __DIR__.'/../bootstrap/app.php'; $app->make(Kernel::class)->bootstrap(); diff --git a/tests/Feature/ArticlesApiTest.php b/tests/Feature/ArticlesApiTest.php deleted file mode 100644 index 37d1332..0000000 --- a/tests/Feature/ArticlesApiTest.php +++ /dev/null @@ -1,162 +0,0 @@ -faker = FakerFactory::create(); - } - - /** - * Tests that any user can view an article if it's published and not in the future. - * - * @return void - */ - public function testAnyUserCanViewArticle(): void - { - // Create an event - $article = Article::factory()->create([ - 'publish_at' => $this->faker->dateTimeBetween('-2 months', '-1 month'), - ]); - - // Create a future event - $futureArticle = Article::factory()->create([ - 'publish_at' => $this->faker->dateTimeBetween('+1 month', '+2 months'), - ]); - - // Send GET request to the /api/articles endpoint - $response = $this->getJson('/api/articles'); - $response->assertStatus(200); - - // Assert that the event is in the response data - $response->assertJsonCount(1, 'articles'); - $response->assertJsonFragment([ - 'id' => $article->id, - 'title' => $article->title, - 'content' => $article->content, - ]); - - $response->assertJsonMissing([ - 'id' => $futureArticle->id, - 'title' => $futureArticle->title, - 'content' => $futureArticle->content, - ]); - } - - /** - * Tests that an admin can create, update, and delete articles. - * - * @return void - */ - public function testAdminCanCreateUpdateDeleteArticle(): void - { - // Create a user with the admin/events permission - $adminUser = User::factory()->create(); - $adminUser->givePermission('admin/articles'); - - // Create media data - $media = Media::factory()->create(['user_id' => $adminUser->id]); - - // Create event data - $articleData = Article::factory()->make([ - 'user_id' => $adminUser->id, - 'hero' => $media->id, - ])->toArray(); - - // Test creating event - $response = $this->actingAs($adminUser)->postJson('/api/articles', $articleData); - $response->assertStatus(201); - $this->assertDatabaseHas('articles', [ - 'title' => $articleData['title'], - 'content' => $articleData['content'], - ]); - - // Test viewing event - $article = Article::where('title', $articleData['title'])->first(); - $response = $this->get("/api/articles/$article->id"); - $response->assertStatus(200); - $response->assertJsonStructure([ - 'article' => [ - 'id', - 'title', - 'content', - ] - ]); - - // Test updating event - $articleData['title'] = 'Updated Article'; - $response = $this->actingAs($adminUser)->putJson("/api/articles/$article->id", $articleData); - $response->assertStatus(200); - $this->assertDatabaseHas('articles', [ - 'title' => 'Updated Article', - ]); - - // Test deleting event - $response = $this->actingAs($adminUser)->delete("/api/articles/$article->id"); - $response->assertStatus(204); - $this->assertDatabaseMissing('articles', [ - 'title' => 'Updated Article', - ]); - } - - /** - * Tests that a non-admin user cannot create, update, or delete articles. - * - * @return void - */ - public function testNonAdminCannotCreateUpdateDeleteArticle(): void - { - // Create a user without admin/events permission - $user = User::factory()->create(); - - // Authenticate as the user - $this->actingAs($user); - - // Try to create a new article - $media = Media::factory()->create(['user_id' => $user->id]); - - $newArticleData = Article::factory()->make(['user_id' => $user->id, 'hero' => $media->id])->toArray(); - - $response = $this->postJson('/api/articles', $newArticleData); - $response->assertStatus(403); - - // Try to update an event - $article = Article::factory()->create(); - $updatedArticleData = [ - 'title' => 'Updated Event', - 'content' => 'This is an updated event.', - // Add more fields as needed - ]; - $response = $this->putJson('/api/articles/' . $article->id, $updatedArticleData); - $response->assertStatus(403); - - // Try to delete an event - $article = Article::factory()->create(); - $response = $this->deleteJson('/api/articles/' . $article->id); - $response->assertStatus(403); - } -} diff --git a/tests/Feature/AuthApiTest.php b/tests/Feature/AuthApiTest.php deleted file mode 100644 index 012b95f..0000000 --- a/tests/Feature/AuthApiTest.php +++ /dev/null @@ -1,70 +0,0 @@ -create([ - 'password' => bcrypt('password'), - ]); - - // Test successful login - $response = $this->postJson('/api/login', [ - 'email' => $user->email, - 'password' => 'password', - ]); - $response->assertStatus(200); - $response->assertJsonStructure([ - 'token', - ]); - $token = $response->json('token'); - - // Test getting authenticated user - $response = $this->withHeaders([ - 'Authorization' => "Bearer $token", - ])->get('/api/me'); - $response->assertStatus(200); - $response->assertJson([ - 'user' => [ - 'id' => $user->id, - 'email' => $user->email, - ] - ]); - - // Test logout - $response = $this->withHeaders([ - 'Authorization' => "Bearer $token", - ])->postJson('/api/logout'); - $response->assertStatus(204); - - // Test failed login - $response = $this->postJson('/api/login', [ - 'email' => $user->email, - 'password' => 'wrongpassword', - ]); - $response->assertStatus(422); - } -} diff --git a/tests/Feature/ContactFormTest.php b/tests/Feature/ContactFormTest.php deleted file mode 100644 index fc212e7..0000000 --- a/tests/Feature/ContactFormTest.php +++ /dev/null @@ -1,43 +0,0 @@ - 'John Doe', - 'email' => 'johndoe@example.com', - 'content' => 'Hello, this is a test message.', - ]; - - $response = $this->postJson('/api/contact', $formData); - $response->assertStatus(201); - - $formData = [ - 'name' => 'John Doe', - 'content' => 'Hello, this is a test message.', - ]; - - $response = $this->postJson('/api/contact', $formData); - $response->assertStatus(422); - } -} diff --git a/tests/Feature/EventsApiTest.php b/tests/Feature/EventsApiTest.php deleted file mode 100644 index 36d7b2f..0000000 --- a/tests/Feature/EventsApiTest.php +++ /dev/null @@ -1,204 +0,0 @@ -faker = FakerFactory::create(); - } - - /** - * Tests that any user can view an event if it's published and not in the future. - * - * @return void - */ - public function testAnyUserCanViewEvent(): void - { - // Create an event - $event = Event::factory()->create([ - 'publish_at' => Carbon::parse($this->faker->dateTimeBetween('-2 months', '-1 month')), - 'status' => 'open', - ]); - - // Create a future event - $futureEvent = Event::factory()->create([ - 'publish_at' => Carbon::parse($this->faker->dateTimeBetween('+1 day', '+1 month')), - 'status' => 'open', - ]); - - // Send GET request to the /api/events endpoint - $response = $this->getJson('/api/events'); - $response->assertStatus(200); - - // Assert that the event is in the response data - $response->assertJsonCount(1, 'events'); - $response->assertJsonFragment([ - 'id' => $event->id, - 'title' => $event->title, - ]); - - $response->assertJsonMissing([ - 'id' => $futureEvent->id, - 'title' => $futureEvent->title, - ]); - } - - /** - * Tests that any user cannot see draft events. - * - * @return void - */ - public function testAnyUserCannotSeeDraftEvent(): void - { - // Create a draft event - $draftEvent = Event::factory()->create([ - 'publish_at' => Carbon::parse($this->faker->dateTimeBetween('-2 months', '-1 month')), - 'status' => 'draft', - ]); - - // Create a open event - $openEvent = Event::factory()->create([ - 'publish_at' => Carbon::parse($this->faker->dateTimeBetween('-2 months', '-1 month')), - 'status' => 'open', - ]); - - // Create a closed event - $closedEvent = Event::factory()->create([ - 'publish_at' => Carbon::parse($this->faker->dateTimeBetween('-2 months', '-1 month')), - 'status' => 'closed', - ]); - - // Send GET request to the /api/events endpoint - $response = $this->getJson('/api/events'); - $response->assertStatus(200); - - // Assert that the event is in the response data - $response->assertJsonCount(2, 'events'); - - $response->assertJsonMissing([ - 'id' => $draftEvent->id, - 'title' => $draftEvent->title, - ]); - } - - /** - * Tests that an admin can create, update, and delete events. - * - * @return void - */ - public function testAdminCanCreateUpdateDeleteEvent(): void - { - // Create a user with the admin/events permission - $adminUser = User::factory()->create(); - $adminUser->givePermission('admin/events'); - - // Create media data - $media = Media::factory()->create(['user_id' => $adminUser->id]); - - // Create event data - $eventData = Event::factory()->make([ - 'start_at' => now()->addDays(7), - 'end_at' => now()->addDays(7)->addHours(2), - 'hero' => $media->id, - ])->toArray(); - - // Test creating event - $response = $this->actingAs($adminUser)->postJson('/api/events', $eventData); - $response->assertStatus(201); - $this->assertDatabaseHas('events', [ - 'title' => $eventData['title'], - 'content' => $eventData['content'], - ]); - - // Test viewing event - $event = Event::where('title', $eventData['title'])->first(); - $response = $this->get("/api/events/$event->id"); - $response->assertStatus(200); - $response->assertJsonStructure([ - 'event' => [ - 'id', - 'title', - 'content', - 'start_at', - 'end_at', - ] - ]); - - // Test updating event - $eventData['title'] = 'Updated Event'; - $response = $this->actingAs($adminUser)->putJson("/api/events/$event->id", $eventData); - $response->assertStatus(200); - $this->assertDatabaseHas('events', [ - 'title' => 'Updated Event', - ]); - - // Test deleting event - $response = $this->actingAs($adminUser)->delete("/api/events/$event->id"); - $response->assertStatus(204); - $this->assertDatabaseMissing('events', [ - 'title' => 'Updated Event', - ]); - } - - /** - * Tests that a non-admin user cannot create, update, or delete events. - * - * @return void - */ - public function testNonAdminCannotCreateUpdateDeleteEvent(): void - { - // Create a user without admin/events permission - $user = User::factory()->create(); - - // Authenticate as the user - $this->actingAs($user); - - // Try to create a new event - $media = Media::factory()->create(['user_id' => $user->id]); - - $newEventData = Event::factory()->make(['hero' => $media->id])->toArray(); - - $response = $this->postJson('/api/events', $newEventData); - $response->assertStatus(403); - - // Try to update an event - $event = Event::factory()->create(); - $updatedEventData = [ - 'title' => 'Updated Event', - 'content' => 'This is an updated event.', - // Add more fields as needed - ]; - $response = $this->putJson('/api/events/' . $event->id, $updatedEventData); - $response->assertStatus(403); - - // Try to delete an event - $event = Event::factory()->create(); - $response = $this->deleteJson('/api/events/' . $event->id); - $response->assertStatus(403); - } -} diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php new file mode 100644 index 0000000..8364a84 --- /dev/null +++ b/tests/Feature/ExampleTest.php @@ -0,0 +1,19 @@ +get('/'); + + $response->assertStatus(200); + } +} diff --git a/tests/Feature/UsersApiTest.php b/tests/Feature/UsersApiTest.php deleted file mode 100644 index 2974143..0000000 --- a/tests/Feature/UsersApiTest.php +++ /dev/null @@ -1,263 +0,0 @@ -create(); - $nonAdminUser->revokePermission('admin/users'); - - // create an admin user - $adminUser = User::factory()->create(); - $adminUser->givePermission('admin/users'); - - // ensure the non-admin user can access the endpoint and see basic user info only - $response = $this->actingAs($nonAdminUser)->get('/api/users'); - $response->assertStatus(200); - $response->assertJsonStructure([ - 'users' => [ - '*' => [ - 'id', - 'display_name' - ] - ], - 'total' - ]); - - $response->assertJsonMissing([ - 'users' => [ - '*' => [ - 'email', - 'password' - ] - ], - ]); - - // ensure the admin user can access the endpoint and see additional user info - $response = $this->actingAs($adminUser)->get('/api/users'); - $response->assertStatus(200); - $response->assertJsonStructure([ - 'users' => [ - '*' => [ - 'id', - 'email' - ] - ], - 'total' - ]); - $response->assertJsonMissing([ - 'users' => [ - '*' => [ - 'password' - ] - ] - ]); - $response->assertJsonFragment([ - 'id' => $nonAdminUser->id, - 'email' => $nonAdminUser->email - ]); - } - - /** - * Tests that guests cannot create a user via the API. - * - * @return void - */ - public function testGuestCannotCreateUser(): void - { - $userData = [ - 'email' => 'johndoe@example.com', - 'password' => 'password', - ]; - - $response = $this->postJson('/api/users', $userData); - $response->assertStatus(401); - $this->assertDatabaseMissing('users', [ - 'email' => $userData['email'], - ]); - } - - /** - * Tests that guests can register a user via the API. - * - * @return void - */ - public function testGuestCanRegisterUser(): void - { - $userData = [ - 'first_name' => 'John', - 'last_name' => 'Doe', - 'display_name' => 'jackdoe', - 'email' => 'johndoe@example.com', - 'password' => 'password', - ]; - - $response = $this->postJson('/api/register', $userData); - $response->assertStatus(200); - $this->assertDatabaseHas('users', [ - 'email' => $userData['email'], - ]); - } - - /** - * Tests that duplicate email or display name entries cannot be created. - * - * @return void - */ - public function testCannotCreateDuplicateEmailOrDisplayName(): void - { - $userData = [ - 'display_name' => 'JackDoe', - 'first_name' => 'Jack', - 'last_name' => 'Doe', - 'email' => 'jackdoe@example.com', - 'password' => 'password', - ]; - - // Test creating user - $response = $this->postJson('/api/register', $userData); - $response->assertStatus(200); - $this->assertDatabaseHas('users', [ - 'email' => 'jackdoe@example.com', - ]); - - // Test creating duplicate user - $response = $this->postJson('/api/register', $userData); - $response->assertStatus(422); - $response->assertJsonValidationErrors(['display_name', 'email']); - } - - /** - * Tests that a user can only update their own user info. - * - * @return void - */ - public function testUserCanOnlyUpdateOwnUser(): void - { - $user = User::factory()->create(); - - $userData = [ - 'email' => 'raffi@example.com', - 'password' => 'password', - ]; - - // Test updating own user - $response = $this->actingAs($user)->putJson('/api/users/' . $user->id, $userData); - $response->assertStatus(200); - $this->assertDatabaseHas('users', [ - 'id' => $user->id, - 'email' => 'raffi@example.com', - ]); - - // Test updating another user - $otherUser = User::factory()->create(); - $otherUserData = [ - 'email' => 'otherraffi@example.com', - 'password' => 'password', - ]; - - $response = $this->actingAs($user)->putJson('/api/users/' . $otherUser->id, $otherUserData); - $response->assertStatus(403); - } - - /** - * Tests that a user cannot delete users via the API. - * - * @return void - */ - public function testUserCannotDeleteUsers(): void - { - $user = User::factory()->create(); - - // Test deleting own user - $response = $this->actingAs($user)->deleteJson('/api/users/' . $user->id); - $response->assertStatus(403); - $this->assertDatabaseHas('users', ['id' => $user->id]); - - // Test deleting another user - $otherUser = User::factory()->create(); - $response = $this->actingAs($user)->deleteJson('/api/users/' . $otherUser->id); - $response->assertStatus(403); - $this->assertDatabaseHas('users', ['id' => $otherUser->id]); - } - - /** - * Tests that an admin can update any user's info. - * - * @return void - */ - public function testAdminCanUpdateAnyUser(): void - { - $admin = User::factory()->create(); - $admin->givePermission('admin/users'); - - $user = User::factory()->create(); - - $userData = [ - 'email' => 'todddoe@example.com', - 'password' => 'password', - ]; - - // Test updating own user - $response = $this->actingAs($admin)->putJson('/api/users/' . $user->id, $userData); - $response->assertStatus(200); - $this->assertDatabaseHas('users', [ - 'id' => $user->id, - 'email' => 'todddoe@example.com' - ]); - - // Test updating another user - $otherUser = User::factory()->create(); - $otherUserData = [ - 'email' => 'kimdoe@example.com', - 'password' => 'password', - ]; - - $response = $this->actingAs($admin)->putJson('/api/users/' . $otherUser->id, $otherUserData); - $response->assertStatus(200); - $this->assertDatabaseHas('users', [ - 'id' => $otherUser->id, - 'email' => 'kimdoe@example.com', - ]); - } - - /** - * Tests that an admin can delete any user via the API. - * - * @return void - */ - public function testAdminCanDeleteAnyUser(): void - { - $admin = User::factory()->create(); - $admin->givePermission('admin/users'); - - $user = User::factory()->create(); - - // Test deleting own user - $response = $this->actingAs($admin)->deleteJson('/api/users/' . $user->id); - $response->assertStatus(204); - $this->assertDatabaseMissing('users', ['id' => $user->id]); - - // Test deleting another user - $otherUser = User::factory()->create(); - $response = $this->actingAs($admin)->deleteJson('/api/users/' . $otherUser->id); - $response->assertStatus(204); - $this->assertDatabaseMissing('users', ['id' => $otherUser->id]); - } -} diff --git a/tests/TestCase.php b/tests/TestCase.php index c6f92c9..2932d4a 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -7,17 +7,4 @@ use Illuminate\Foundation\Testing\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase { use CreatesApplication; - - - /** - * {@inheritDoc} - * - * @return void - */ - protected function setUp(): void - { - parent::setUp(); - - $this->withoutVite(); - } } diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php index 500fbfe..5773b0c 100644 --- a/tests/Unit/ExampleTest.php +++ b/tests/Unit/ExampleTest.php @@ -4,12 +4,10 @@ namespace Tests\Unit; use PHPUnit\Framework\TestCase; -final class ExampleTest extends TestCase +class ExampleTest extends TestCase { /** * A basic test example. - * - * @return void */ public function test_that_true_is_true(): void { diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index b48fd4e..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "target": "esnext", - "module": "esnext", - // "strict": true, - "moduleResolution": "node", - "esModuleInterop": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true - }, - "include": ["resources/**/*"], - "exclude": ["node_modules", "dist"] -} diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..421b569 --- /dev/null +++ b/vite.config.js @@ -0,0 +1,11 @@ +import { defineConfig } from 'vite'; +import laravel from 'laravel-vite-plugin'; + +export default defineConfig({ + plugins: [ + laravel({ + input: ['resources/css/app.css', 'resources/js/app.js'], + refresh: true, + }), + ], +}); diff --git a/vite.config.ts b/vite.config.ts deleted file mode 100644 index 6de0114..0000000 --- a/vite.config.ts +++ /dev/null @@ -1,52 +0,0 @@ -import vue from "@vitejs/plugin-vue"; -import laravel from "laravel-vite-plugin"; -import analyzer from "rollup-plugin-analyzer"; -import { compression } from "vite-plugin-compression2"; -import { defineConfig } from "vite"; -import Unocss from "unocss/vite"; - -export default defineConfig({ - plugins: [ - vue({ - template: { - compilerOptions: { - isCustomElement: (tag) => ["ion-icon"].includes(tag), - }, - transformAssetUrls: { - base: null, - includeAbsolute: false, - }, - }, - }), - Unocss({}), - laravel({ - input: ["resources/css/app.scss", "resources/js/main.js"], - refresh: true, - }), - analyzer({ summaryOnly: true }), - compression({ - include: [/\.(js)$/, /\.(css)$/], - // deleteOriginalAssets: true, - }), - ], - css: { - preprocessorOptions: { - scss: { - // additionalData: `@import "./resources/css/variables.scss";`, - }, - }, - }, - envPrefix: ["VITE_", "APP_URL"], - resolve: { - alias: { - vue: "vue/dist/vue.esm-bundler.js", - }, - }, - build: { - chunkSizeWarningLimit: 500, - rollupOptions: { - output: {}, - }, - }, - base: "", -});