Skip to content

Commit e4f95b6

Browse files
authored
Add tests for profile data in wiki details route (#932)
1 parent 86a4315 commit e4f95b6

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/Routes/Wiki/DetailsTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use App\WikiSetting;
1111
use App\User;
1212
use App\WikiManager;
13+
use App\WikiProfile;
1314

1415
class DetailsTest extends TestCase
1516
{
@@ -59,4 +60,41 @@ public function testSkipsNonPublicSettings()
5960
$this->assertEquals('wwUseQuestyCaptcha', $publicSettings[0]['name']);
6061
$this->assertEquals(1, $publicSettings[0]['value']);
6162
}
63+
64+
public function testWikiProfile()
65+
{
66+
$wiki = Wiki::factory()->create();
67+
$user = User::factory()->create(['verified' => true]);
68+
WikiManager::factory()->create(['wiki_id' => $wiki->id, 'user_id' => $user->id]);
69+
70+
$versionA = WikiProfile::create([
71+
'wiki_id' => $wiki->id,
72+
'audience' => 'wide',
73+
'temporality' => 'temporary',
74+
'purpose' => 'data_hub'
75+
])->refresh()->toArray();
76+
77+
$response = $this->actingAs($user, 'api')
78+
->postJson($this->route, ['wiki' => $wiki->id])
79+
->assertStatus(200);
80+
81+
$profile = data_get($response->json(), 'data.wiki_latest_profile', []);
82+
$this->assertNotEmpty($profile);
83+
$this->assertEquals($versionA, $profile);
84+
85+
$versionB = WikiProfile::create([
86+
'wiki_id' => $wiki->id,
87+
'audience' => 'wide',
88+
'temporality' => 'permanent',
89+
'purpose' => 'data_hub'
90+
])->refresh()->toArray();
91+
92+
$response = $this->actingAs($user, 'api')
93+
->postJson($this->route, ['wiki' => $wiki->id])
94+
->assertStatus(200);
95+
96+
$profile = data_get($response->json(), 'data.wiki_latest_profile', []);
97+
$this->assertNotEmpty($profile);
98+
$this->assertEquals($versionB, $profile);
99+
}
62100
}

0 commit comments

Comments
 (0)