Skip to content

Commit

Permalink
Adjust existing test to include ports rather than seprate test
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Feb 25, 2025
1 parent 0c04f0c commit b5bfc55
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions tests/Feature/Entries/AddsHeadersToLivePreviewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ public function it_sets_header_when_multisite()
config()->set('statamic.system.multisite', true);

$this->setSites([
'en' => ['url' => 'http://localhost/', 'locale' => 'en'],
'fr' => ['url' => 'http://localhost/fr/', 'locale' => 'fr'],
'third' => ['url' => 'http://third/', 'locale' => 'en'],
'one' => ['url' => 'http://withport.com:8080/', 'locale' => 'en'],
'two' => ['url' => 'http://withport.com:8080/fr/', 'locale' => 'fr'],
'three' => ['url' => 'http://withoutport.com/', 'locale' => 'en'],
'four' => ['url' => 'http://withoutport.com/fr/', 'locale' => 'fr'],
'five' => ['url' => 'http://third.com/', 'locale' => 'en'],
'six' => ['url' => 'http://third.com/fr/', 'locale' => 'fr'],
]);

$substitute = EntryFactory::collection('test')->id('2')->slug('charlie')->data(['title' => 'Substituted title', 'foo' => 'Substituted foo'])->make();
Expand All @@ -71,26 +74,6 @@ public function it_sets_header_when_multisite()

$this->get('/test?token=test-token')
->assertHeader('X-Statamic-Live-Preview', true)
->assertHeader('Content-Security-Policy', 'frame-ancestors http://localhost http://third');
}

#[Test]
public function it_includes_ports_in_csp_header()
{
config()->set('statamic.system.multisite', true);

$this->setSites([
'en' => ['url' => 'http://localhost:8080', 'locale' => 'en'],
'fr' => ['url' => 'http://localhost:8080/fr/', 'locale' => 'fr'],
'third' => ['url' => 'http://third/', 'locale' => 'en'],
]);

$substitute = EntryFactory::collection('test')->id('2')->slug('charlie')->data(['title' => 'Substituted title', 'foo' => 'Substituted foo'])->make();

LivePreview::tokenize('test-token', $substitute);

$this->get('/test?token=test-token')
->assertHeader('X-Statamic-Live-Preview', true)
->assertHeader('Content-Security-Policy', 'frame-ancestors http://localhost:8080 http://third');
->assertHeader('Content-Security-Policy', 'frame-ancestors http://withport.com:8080 http://withoutport.com http://third.com');
}
}

0 comments on commit b5bfc55

Please sign in to comment.