Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/Models/Note.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace App\Models;

use Database\Factories\NoteFactory;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

Expand All @@ -15,6 +17,9 @@
*/
class Note extends Model
{
/** @use HasFactory<NoteFactory> */
use HasFactory;

protected $table = 'note';

public $timestamps = false;
Expand Down
26 changes: 26 additions & 0 deletions database/factories/NoteFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Database\Factories;

use App\Models\Note;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

/**
* @extends Factory<Note>
*/
class NoteFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => Str::uuid()->toString(),
'text' => Str::uuid()->toString(),
];
}
}
5 changes: 1 addition & 4 deletions tests/Browser/Pages/BuildNotesPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ public function tearDown(): void

private function addNote(): Note
{
$note = Note::create([
'name' => Str::uuid()->toString(),
'text' => Str::uuid()->toString(),
]);
$note = Note::factory()->create();

$this->build->notes()->attach($note);

Expand Down
5 changes: 1 addition & 4 deletions tests/Browser/Pages/BuildSidebarComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,7 @@ public function testNotesItem(): void
$this->assertDisabled($browser, "/builds/{$build->id}", '@sidebar-notes');

$build->notes()->attach(
Note::create([
'name' => Str::uuid()->toString(),
'text' => Str::uuid()->toString(),
])
Note::factory()->create()
);

$this->assertNotDisabled($browser, "/builds/{$build->id}", '@sidebar-notes', "/builds/{$build->id}/notes");
Expand Down
17 changes: 3 additions & 14 deletions tests/Feature/GraphQL/NoteTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,9 @@ protected function setUp(): void
$this->public_project = $this->makePublicProject();
$this->private_project = $this->makePrivateProject();

$this->note1 = Note::create([
'name' => Str::uuid()->toString(),
'text' => Str::uuid()->toString(),
]);

$this->note2 = Note::create([
'name' => Str::uuid()->toString(),
'text' => Str::uuid()->toString(),
]);

$this->note3 = Note::create([
'name' => Str::uuid()->toString(),
'text' => Str::uuid()->toString(),
]);
$this->note1 = Note::factory()->create();
$this->note2 = Note::factory()->create();
$this->note3 = Note::factory()->create();

$this->public_project->builds()->create([
'name' => 'build1',
Expand Down