Skip to content

Commit dc17a81

Browse files
committed
fix: remove storybook:generate-preview command
1 parent 4613dda commit dc17a81

File tree

10 files changed

+67
-105
lines changed

10 files changed

+67
-105
lines changed

src/Command/GeneratePreviewCommand.php

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/DependencyInjection/StorybookExtension.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Storybook\Attributes\AsArgsProcessor;
77
use Storybook\Attributes\AsComponentMock;
88
use Storybook\CacheWarmer\StorybookCacheWarmer;
9-
use Storybook\Command\GeneratePreviewCommand;
109
use Storybook\Command\StorybookInitCommand;
1110
use Storybook\Controller\StorybookController;
1211
use Storybook\Controller\StorybookPreviewController;
@@ -152,13 +151,6 @@ static function (ChildDefinition $definition, AsComponentMock $attributeInstance
152151
$container->register('storybook.component_proxy_factory', ComponentProxyFactory::class)
153152
->setArgument(0, new AbstractArgument(\sprintf('Provided in "%s".', ComponentMockPass::class)));
154153

155-
// Internal commands
156-
$container->register('storybook.generate_preview_command', GeneratePreviewCommand::class)
157-
->setArgument(0, new Reference('twig'))
158-
->setArgument(1, new Reference('event_dispatcher'))
159-
->addTag('console.command', ['name' => 'storybook:generate-preview'])
160-
;
161-
162154
// Init command
163155
$container->register('storybook.init_command', StorybookInitCommand::class)
164156
->setArgument(0, $container->getParameter('kernel.project_dir'))

storybook/dist/index.d.mts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ type SymfonyOptions = {
5656
additionalWatchPaths?: string[];
5757
/**
5858
* When Storybook and Symfony are not on the same host (e.g. Symfony is Dockerized), mounted paths may differ.
59-
* This option allows to map paths from Symfony host to Storybook host.
59+
* This option allows to map paths from Storybook host to Symfony host.
60+
*
61+
* Example: { __dirname: '/var/www' }
6062
*/
6163
templatePathAliases?: {
6264
[p: string]: string;

storybook/dist/index.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ type SymfonyOptions = {
5656
additionalWatchPaths?: string[];
5757
/**
5858
* When Storybook and Symfony are not on the same host (e.g. Symfony is Dockerized), mounted paths may differ.
59-
* This option allows to map paths from Symfony host to Storybook host.
59+
* This option allows to map paths from Storybook host to Symfony host.
60+
*
61+
* Example: { __dirname: '/var/www' }
6062
*/
6163
templatePathAliases?: {
6264
[p: string]: string;

storybook/dist/server/framework-preset.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

storybook/dist/server/framework-preset.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/Functional/Command/GeneratePreviewCommandTest.php

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Storybook\Tests\Functional\Controller;
4+
5+
use Storybook\Tests\StoryTestTrait;
6+
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
7+
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
8+
use Symfony\Component\DomCrawler\Crawler;
9+
10+
class StorybookPreviewControllerTest extends WebTestCase
11+
{
12+
use StoryTestTrait;
13+
14+
public function testPreview()
15+
{
16+
$client = static::createClient();
17+
$client->request('GET', '_storybook/preview');
18+
19+
$this->assertResponseIsSuccessful();
20+
21+
// Check that the preview contains the basic HTML structure
22+
$this->assertSelectorExists('html');
23+
$this->assertSelectorExists('head');
24+
$this->assertSelectorExists('body');
25+
}
26+
}

tests/Unit/Command/GeneratePreviewCommandTest.php

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Storybook\Tests\Unit\Controller;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use Storybook\Controller\StorybookPreviewController;
7+
use Storybook\Event\GeneratePreviewEvent;
8+
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
9+
use Symfony\Component\HttpFoundation\Response;
10+
use Twig\Environment;
11+
12+
class StorybookPreviewControllerTest extends TestCase
13+
{
14+
public function testControllerReturnsResponse()
15+
{
16+
$twig = $this->createMock(Environment::class);
17+
$eventDispatcher = $this->createMock(EventDispatcherInterface::class);
18+
19+
$controller = new StorybookPreviewController($twig, $eventDispatcher);
20+
21+
$twig->expects($this->once())
22+
->method('render')
23+
->with('@Storybook/preview.html.twig')
24+
->willReturn('');
25+
26+
$eventDispatcher
27+
->expects($this->once())
28+
->method('dispatch')
29+
->with($this->isInstanceOf(GeneratePreviewEvent::class));
30+
31+
$this->assertInstanceOf(Response::class, $controller());
32+
}
33+
}

0 commit comments

Comments
 (0)