@storybook/angular 8.0.0-alpha.3 → 8.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builders/build-storybook/index.spec.js +40 -38
- package/dist/builders/start-storybook/index.spec.js +40 -38
- package/dist/builders/utils/run-compodoc.spec.js +38 -47
- package/dist/client/angular-beta/AbstractRenderer.d.ts +10 -0
- package/dist/client/angular-beta/AbstractRenderer.js +18 -3
- package/dist/client/angular-beta/DocsRenderer.d.ts +1 -0
- package/dist/client/angular-beta/DocsRenderer.js +5 -0
- package/dist/client/angular-beta/RendererFactory.test.js +68 -31
- package/dist/client/angular-beta/utils/PropertyExtractor.test.js +44 -43
- package/dist/client/angular-beta/utils/StoryUID.d.ts +23 -0
- package/dist/client/angular-beta/utils/StoryUID.js +46 -0
- package/dist/client/decorators.test.js +16 -15
- package/dist/client/docs/angular-properties.test.d.ts +1 -1
- package/dist/client/docs/angular-properties.test.js +2 -3
- package/dist/client/docs/compodoc.test.js +8 -7
- package/dist/test-setup.d.ts +1 -0
- package/dist/test-setup.js +7 -0
- package/dist/test-setup.mjs +5 -0
- package/package.json +15 -16
- package/jest.config.js +0 -31
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* @
|
|
3
|
+
* @vitest-environment node
|
|
4
4
|
*/
|
|
5
5
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
6
|
if (k2 === undefined) k2 = k;
|
|
@@ -26,19 +26,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
30
|
+
const vitest_1 = require("vitest");
|
|
29
31
|
const architect_1 = require("@angular-devkit/architect");
|
|
30
32
|
const testing_1 = require("@angular-devkit/architect/testing");
|
|
31
33
|
const core_1 = require("@angular-devkit/core");
|
|
32
34
|
const path = __importStar(require("path"));
|
|
33
|
-
const buildDevStandaloneMock =
|
|
34
|
-
const buildStaticStandaloneMock =
|
|
35
|
+
const buildDevStandaloneMock = vitest_1.vi.fn();
|
|
36
|
+
const buildStaticStandaloneMock = vitest_1.vi.fn();
|
|
35
37
|
const buildMock = {
|
|
36
38
|
buildDevStandalone: buildDevStandaloneMock,
|
|
37
39
|
buildStaticStandalone: buildStaticStandaloneMock,
|
|
38
40
|
withTelemetry: (name, options, fn) => fn(),
|
|
39
41
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
vitest_1.vi.doMock('@storybook/core-server', () => buildMock);
|
|
43
|
+
vitest_1.vi.doMock('@storybook/cli', () => ({
|
|
42
44
|
JsPackageManagerFactory: {
|
|
43
45
|
getPackageManager: () => ({
|
|
44
46
|
runPackageCommand: mockRunScript,
|
|
@@ -49,14 +51,14 @@ jest.doMock('@storybook/cli', () => ({
|
|
|
49
51
|
storybook: 'x.x.x',
|
|
50
52
|
},
|
|
51
53
|
}));
|
|
52
|
-
|
|
53
|
-
const mockRunScript =
|
|
54
|
+
vitest_1.vi.doMock('find-up', () => ({ sync: () => './storybook/tsconfig.ts' }));
|
|
55
|
+
const mockRunScript = vitest_1.vi.fn();
|
|
54
56
|
// Randomly fails on CI. TODO: investigate why
|
|
55
57
|
// eslint-disable-next-line jest/no-disabled-tests
|
|
56
|
-
describe.skip('Build Storybook Builder', () => {
|
|
58
|
+
vitest_1.describe.skip('Build Storybook Builder', () => {
|
|
57
59
|
let architect;
|
|
58
60
|
let architectHost;
|
|
59
|
-
beforeEach(async () => {
|
|
61
|
+
(0, vitest_1.beforeEach)(async () => {
|
|
60
62
|
const registry = new core_1.schema.CoreSchemaRegistry();
|
|
61
63
|
registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
|
|
62
64
|
architectHost = new testing_1.TestingArchitectHost();
|
|
@@ -78,11 +80,11 @@ describe.skip('Build Storybook Builder', () => {
|
|
|
78
80
|
// for the package.json file.
|
|
79
81
|
await architectHost.addBuilderFromPackage(path.join(__dirname, '../../..'));
|
|
80
82
|
});
|
|
81
|
-
beforeEach(() => {
|
|
83
|
+
(0, vitest_1.beforeEach)(() => {
|
|
82
84
|
buildStaticStandaloneMock.mockImplementation((_options) => Promise.resolve(_options));
|
|
83
85
|
});
|
|
84
86
|
afterEach(() => {
|
|
85
|
-
|
|
87
|
+
vitest_1.vi.clearAllMocks();
|
|
86
88
|
});
|
|
87
89
|
it('should start storybook with angularBrowserTarget', async () => {
|
|
88
90
|
const run = await architect.scheduleBuilder('@storybook/angular:build-storybook', {
|
|
@@ -91,17 +93,17 @@ describe.skip('Build Storybook Builder', () => {
|
|
|
91
93
|
});
|
|
92
94
|
const output = await run.result;
|
|
93
95
|
await run.stop();
|
|
94
|
-
expect(output.success).toBeTruthy();
|
|
95
|
-
expect(mockRunScript).not.toHaveBeenCalledWith();
|
|
96
|
-
expect(buildStaticStandaloneMock).toHaveBeenCalledWith(expect.objectContaining({
|
|
96
|
+
(0, vitest_1.expect)(output.success).toBeTruthy();
|
|
97
|
+
(0, vitest_1.expect)(mockRunScript).not.toHaveBeenCalledWith();
|
|
98
|
+
(0, vitest_1.expect)(buildStaticStandaloneMock).toHaveBeenCalledWith(vitest_1.expect.objectContaining({
|
|
97
99
|
angularBrowserTarget: 'angular-cli:build-2',
|
|
98
|
-
angularBuilderContext: expect.any(Object),
|
|
100
|
+
angularBuilderContext: vitest_1.expect.any(Object),
|
|
99
101
|
configDir: '.storybook',
|
|
100
102
|
loglevel: undefined,
|
|
101
103
|
quiet: false,
|
|
102
104
|
disableTelemetry: undefined,
|
|
103
105
|
outputDir: 'storybook-static',
|
|
104
|
-
packageJson: expect.any(Object),
|
|
106
|
+
packageJson: vitest_1.expect.any(Object),
|
|
105
107
|
mode: 'static',
|
|
106
108
|
tsConfig: './storybook/tsconfig.ts',
|
|
107
109
|
webpackStatsJson: false,
|
|
@@ -114,17 +116,17 @@ describe.skip('Build Storybook Builder', () => {
|
|
|
114
116
|
});
|
|
115
117
|
const output = await run.result;
|
|
116
118
|
await run.stop();
|
|
117
|
-
expect(output.success).toBeTruthy();
|
|
118
|
-
expect(mockRunScript).not.toHaveBeenCalledWith();
|
|
119
|
-
expect(buildStaticStandaloneMock).toHaveBeenCalledWith(expect.objectContaining({
|
|
119
|
+
(0, vitest_1.expect)(output.success).toBeTruthy();
|
|
120
|
+
(0, vitest_1.expect)(mockRunScript).not.toHaveBeenCalledWith();
|
|
121
|
+
(0, vitest_1.expect)(buildStaticStandaloneMock).toHaveBeenCalledWith(vitest_1.expect.objectContaining({
|
|
120
122
|
angularBrowserTarget: null,
|
|
121
|
-
angularBuilderContext: expect.any(Object),
|
|
123
|
+
angularBuilderContext: vitest_1.expect.any(Object),
|
|
122
124
|
configDir: '.storybook',
|
|
123
125
|
loglevel: undefined,
|
|
124
126
|
quiet: false,
|
|
125
127
|
disableTelemetry: undefined,
|
|
126
128
|
outputDir: 'storybook-static',
|
|
127
|
-
packageJson: expect.any(Object),
|
|
129
|
+
packageJson: vitest_1.expect.any(Object),
|
|
128
130
|
mode: 'static',
|
|
129
131
|
tsConfig: 'path/to/tsConfig.json',
|
|
130
132
|
webpackStatsJson: false,
|
|
@@ -138,16 +140,16 @@ describe.skip('Build Storybook Builder', () => {
|
|
|
138
140
|
});
|
|
139
141
|
const output = await run.result;
|
|
140
142
|
await run.stop();
|
|
141
|
-
expect(output.success).toBeTruthy();
|
|
142
|
-
expect(mockRunScript).not.toHaveBeenCalledWith();
|
|
143
|
-
expect(buildStaticStandaloneMock).toHaveBeenCalledWith(expect.objectContaining({
|
|
143
|
+
(0, vitest_1.expect)(output.success).toBeTruthy();
|
|
144
|
+
(0, vitest_1.expect)(mockRunScript).not.toHaveBeenCalledWith();
|
|
145
|
+
(0, vitest_1.expect)(buildStaticStandaloneMock).toHaveBeenCalledWith(vitest_1.expect.objectContaining({
|
|
144
146
|
angularBrowserTarget: null,
|
|
145
|
-
angularBuilderContext: expect.any(Object),
|
|
147
|
+
angularBuilderContext: vitest_1.expect.any(Object),
|
|
146
148
|
configDir: '.storybook',
|
|
147
149
|
loglevel: undefined,
|
|
148
150
|
quiet: false,
|
|
149
151
|
outputDir: 'storybook-static',
|
|
150
|
-
packageJson: expect.any(Object),
|
|
152
|
+
packageJson: vitest_1.expect.any(Object),
|
|
151
153
|
mode: 'static',
|
|
152
154
|
tsConfig: 'path/to/tsConfig.json',
|
|
153
155
|
webpackStatsJson: true,
|
|
@@ -161,11 +163,11 @@ describe.skip('Build Storybook Builder', () => {
|
|
|
161
163
|
});
|
|
162
164
|
try {
|
|
163
165
|
await run.result;
|
|
164
|
-
expect(false).toEqual('Throw expected');
|
|
166
|
+
(0, vitest_1.expect)(false).toEqual('Throw expected');
|
|
165
167
|
}
|
|
166
168
|
catch (error) {
|
|
167
169
|
// eslint-disable-next-line jest/no-try-expect, jest/no-conditional-expect
|
|
168
|
-
expect(error).toEqual('Broken build, fix the error above.\nYou may need to refresh the browser.');
|
|
170
|
+
(0, vitest_1.expect)(error).toEqual('Broken build, fix the error above.\nYou may need to refresh the browser.');
|
|
169
171
|
}
|
|
170
172
|
});
|
|
171
173
|
it('should run compodoc', async () => {
|
|
@@ -174,16 +176,16 @@ describe.skip('Build Storybook Builder', () => {
|
|
|
174
176
|
});
|
|
175
177
|
const output = await run.result;
|
|
176
178
|
await run.stop();
|
|
177
|
-
expect(output.success).toBeTruthy();
|
|
178
|
-
expect(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', './storybook/tsconfig.ts', '-d', '.', '-e', 'json'], '');
|
|
179
|
-
expect(buildStaticStandaloneMock).toHaveBeenCalledWith(expect.objectContaining({
|
|
179
|
+
(0, vitest_1.expect)(output.success).toBeTruthy();
|
|
180
|
+
(0, vitest_1.expect)(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', './storybook/tsconfig.ts', '-d', '.', '-e', 'json'], '');
|
|
181
|
+
(0, vitest_1.expect)(buildStaticStandaloneMock).toHaveBeenCalledWith(vitest_1.expect.objectContaining({
|
|
180
182
|
angularBrowserTarget: 'angular-cli:build-2',
|
|
181
|
-
angularBuilderContext: expect.any(Object),
|
|
183
|
+
angularBuilderContext: vitest_1.expect.any(Object),
|
|
182
184
|
configDir: '.storybook',
|
|
183
185
|
loglevel: undefined,
|
|
184
186
|
quiet: false,
|
|
185
187
|
outputDir: 'storybook-static',
|
|
186
|
-
packageJson: expect.any(Object),
|
|
188
|
+
packageJson: vitest_1.expect.any(Object),
|
|
187
189
|
mode: 'static',
|
|
188
190
|
tsConfig: './storybook/tsconfig.ts',
|
|
189
191
|
webpackStatsJson: false,
|
|
@@ -197,17 +199,17 @@ describe.skip('Build Storybook Builder', () => {
|
|
|
197
199
|
});
|
|
198
200
|
const output = await run.result;
|
|
199
201
|
await run.stop();
|
|
200
|
-
expect(output.success).toBeTruthy();
|
|
201
|
-
expect(mockRunScript).not.toHaveBeenCalledWith();
|
|
202
|
-
expect(buildStaticStandaloneMock).toHaveBeenCalledWith(expect.objectContaining({
|
|
202
|
+
(0, vitest_1.expect)(output.success).toBeTruthy();
|
|
203
|
+
(0, vitest_1.expect)(mockRunScript).not.toHaveBeenCalledWith();
|
|
204
|
+
(0, vitest_1.expect)(buildStaticStandaloneMock).toHaveBeenCalledWith(vitest_1.expect.objectContaining({
|
|
203
205
|
angularBrowserTarget: null,
|
|
204
|
-
angularBuilderContext: expect.any(Object),
|
|
206
|
+
angularBuilderContext: vitest_1.expect.any(Object),
|
|
205
207
|
angularBuilderOptions: { assets: [], styles: ['style.scss'] },
|
|
206
208
|
configDir: '.storybook',
|
|
207
209
|
loglevel: undefined,
|
|
208
210
|
quiet: false,
|
|
209
211
|
outputDir: 'storybook-static',
|
|
210
|
-
packageJson: expect.any(Object),
|
|
212
|
+
packageJson: vitest_1.expect.any(Object),
|
|
211
213
|
mode: 'static',
|
|
212
214
|
tsConfig: 'path/to/tsConfig.json',
|
|
213
215
|
webpackStatsJson: false,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* @
|
|
3
|
+
* @vitest-environment node
|
|
4
4
|
*/
|
|
5
5
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
6
|
if (k2 === undefined) k2 = k;
|
|
@@ -26,21 +26,23 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
30
|
+
const vitest_1 = require("vitest");
|
|
29
31
|
const architect_1 = require("@angular-devkit/architect");
|
|
30
32
|
const testing_1 = require("@angular-devkit/architect/testing");
|
|
31
33
|
const core_1 = require("@angular-devkit/core");
|
|
32
34
|
const path = __importStar(require("path"));
|
|
33
|
-
const buildDevStandaloneMock =
|
|
34
|
-
const buildStaticStandaloneMock =
|
|
35
|
+
const buildDevStandaloneMock = vitest_1.vi.fn();
|
|
36
|
+
const buildStaticStandaloneMock = vitest_1.vi.fn();
|
|
35
37
|
const buildMock = {
|
|
36
38
|
buildDevStandalone: buildDevStandaloneMock,
|
|
37
39
|
buildStaticStandalone: buildStaticStandaloneMock,
|
|
38
40
|
withTelemetry: (_, __, fn) => fn(),
|
|
39
41
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const mockRunScript =
|
|
43
|
-
|
|
42
|
+
vitest_1.vi.doMock('@storybook/core-server', () => buildMock);
|
|
43
|
+
vitest_1.vi.doMock('find-up', () => ({ sync: () => './storybook/tsconfig.ts' }));
|
|
44
|
+
const mockRunScript = vitest_1.vi.fn();
|
|
45
|
+
vitest_1.vi.mock('@storybook/cli', () => ({
|
|
44
46
|
getEnvConfig: (options) => options,
|
|
45
47
|
versions: {
|
|
46
48
|
storybook: 'x.x.x',
|
|
@@ -53,10 +55,10 @@ jest.mock('@storybook/cli', () => ({
|
|
|
53
55
|
}));
|
|
54
56
|
// Randomly fails on CI. TODO: investigate why
|
|
55
57
|
// eslint-disable-next-line jest/no-disabled-tests
|
|
56
|
-
describe.skip('Start Storybook Builder', () => {
|
|
58
|
+
vitest_1.describe.skip('Start Storybook Builder', () => {
|
|
57
59
|
let architect;
|
|
58
60
|
let architectHost;
|
|
59
|
-
beforeEach(async () => {
|
|
61
|
+
(0, vitest_1.beforeEach)(async () => {
|
|
60
62
|
const registry = new core_1.schema.CoreSchemaRegistry();
|
|
61
63
|
registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);
|
|
62
64
|
architectHost = new testing_1.TestingArchitectHost();
|
|
@@ -78,13 +80,13 @@ describe.skip('Start Storybook Builder', () => {
|
|
|
78
80
|
// for the package.json file.
|
|
79
81
|
await architectHost.addBuilderFromPackage(path.join(__dirname, '../../..'));
|
|
80
82
|
});
|
|
81
|
-
beforeEach(() => {
|
|
83
|
+
(0, vitest_1.beforeEach)(() => {
|
|
82
84
|
buildDevStandaloneMock.mockImplementation((_options) => Promise.resolve(_options));
|
|
83
85
|
});
|
|
84
86
|
afterEach(() => {
|
|
85
|
-
|
|
87
|
+
vitest_1.vi.clearAllMocks();
|
|
86
88
|
});
|
|
87
|
-
it('should start storybook with angularBrowserTarget', async () => {
|
|
89
|
+
(0, vitest_1.it)('should start storybook with angularBrowserTarget', async () => {
|
|
88
90
|
const run = await architect.scheduleBuilder('@storybook/angular:start-storybook', {
|
|
89
91
|
browserTarget: 'angular-cli:build-2',
|
|
90
92
|
port: 4400,
|
|
@@ -92,17 +94,17 @@ describe.skip('Start Storybook Builder', () => {
|
|
|
92
94
|
});
|
|
93
95
|
const output = await run.result;
|
|
94
96
|
await run.stop();
|
|
95
|
-
expect(output.success).toBeTruthy();
|
|
96
|
-
expect(mockRunScript).not.toHaveBeenCalledWith();
|
|
97
|
-
expect(buildDevStandaloneMock).toHaveBeenCalledWith(expect.objectContaining({
|
|
97
|
+
(0, vitest_1.expect)(output.success).toBeTruthy();
|
|
98
|
+
(0, vitest_1.expect)(mockRunScript).not.toHaveBeenCalledWith();
|
|
99
|
+
(0, vitest_1.expect)(buildDevStandaloneMock).toHaveBeenCalledWith(vitest_1.expect.objectContaining({
|
|
98
100
|
angularBrowserTarget: 'angular-cli:build-2',
|
|
99
|
-
angularBuilderContext: expect.any(Object),
|
|
101
|
+
angularBuilderContext: vitest_1.expect.any(Object),
|
|
100
102
|
ci: false,
|
|
101
103
|
configDir: '.storybook',
|
|
102
104
|
disableTelemetry: undefined,
|
|
103
105
|
host: 'localhost',
|
|
104
106
|
https: false,
|
|
105
|
-
packageJson: expect.any(Object),
|
|
107
|
+
packageJson: vitest_1.expect.any(Object),
|
|
106
108
|
port: 4400,
|
|
107
109
|
quiet: false,
|
|
108
110
|
smokeTest: false,
|
|
@@ -112,7 +114,7 @@ describe.skip('Start Storybook Builder', () => {
|
|
|
112
114
|
tsConfig: './storybook/tsconfig.ts',
|
|
113
115
|
}));
|
|
114
116
|
});
|
|
115
|
-
it('should start storybook with tsConfig', async () => {
|
|
117
|
+
(0, vitest_1.it)('should start storybook with tsConfig', async () => {
|
|
116
118
|
const run = await architect.scheduleBuilder('@storybook/angular:start-storybook', {
|
|
117
119
|
tsConfig: 'path/to/tsConfig.json',
|
|
118
120
|
port: 4400,
|
|
@@ -120,17 +122,17 @@ describe.skip('Start Storybook Builder', () => {
|
|
|
120
122
|
});
|
|
121
123
|
const output = await run.result;
|
|
122
124
|
await run.stop();
|
|
123
|
-
expect(output.success).toBeTruthy();
|
|
124
|
-
expect(mockRunScript).not.toHaveBeenCalledWith();
|
|
125
|
-
expect(buildDevStandaloneMock).toHaveBeenCalledWith(expect.objectContaining({
|
|
125
|
+
(0, vitest_1.expect)(output.success).toBeTruthy();
|
|
126
|
+
(0, vitest_1.expect)(mockRunScript).not.toHaveBeenCalledWith();
|
|
127
|
+
(0, vitest_1.expect)(buildDevStandaloneMock).toHaveBeenCalledWith(vitest_1.expect.objectContaining({
|
|
126
128
|
angularBrowserTarget: null,
|
|
127
|
-
angularBuilderContext: expect.any(Object),
|
|
129
|
+
angularBuilderContext: vitest_1.expect.any(Object),
|
|
128
130
|
ci: false,
|
|
129
131
|
configDir: '.storybook',
|
|
130
132
|
disableTelemetry: undefined,
|
|
131
133
|
host: 'localhost',
|
|
132
134
|
https: false,
|
|
133
|
-
packageJson: expect.any(Object),
|
|
135
|
+
packageJson: vitest_1.expect.any(Object),
|
|
134
136
|
port: 4400,
|
|
135
137
|
quiet: false,
|
|
136
138
|
smokeTest: false,
|
|
@@ -140,7 +142,7 @@ describe.skip('Start Storybook Builder', () => {
|
|
|
140
142
|
tsConfig: 'path/to/tsConfig.json',
|
|
141
143
|
}));
|
|
142
144
|
});
|
|
143
|
-
it('should throw error', async () => {
|
|
145
|
+
(0, vitest_1.it)('should throw error', async () => {
|
|
144
146
|
buildDevStandaloneMock.mockRejectedValue(true);
|
|
145
147
|
const run = await architect.scheduleBuilder('@storybook/angular:start-storybook', {
|
|
146
148
|
browserTarget: 'angular-cli:build-2',
|
|
@@ -149,30 +151,30 @@ describe.skip('Start Storybook Builder', () => {
|
|
|
149
151
|
});
|
|
150
152
|
try {
|
|
151
153
|
await run.result;
|
|
152
|
-
expect(false).toEqual('Throw expected');
|
|
154
|
+
(0, vitest_1.expect)(false).toEqual('Throw expected');
|
|
153
155
|
}
|
|
154
156
|
catch (error) {
|
|
155
157
|
// eslint-disable-next-line jest/no-try-expect, jest/no-conditional-expect
|
|
156
|
-
expect(error).toEqual('Broken build, fix the error above.\nYou may need to refresh the browser.');
|
|
158
|
+
(0, vitest_1.expect)(error).toEqual('Broken build, fix the error above.\nYou may need to refresh the browser.');
|
|
157
159
|
}
|
|
158
160
|
});
|
|
159
|
-
it('should run compodoc', async () => {
|
|
161
|
+
(0, vitest_1.it)('should run compodoc', async () => {
|
|
160
162
|
const run = await architect.scheduleBuilder('@storybook/angular:start-storybook', {
|
|
161
163
|
browserTarget: 'angular-cli:build-2',
|
|
162
164
|
});
|
|
163
165
|
const output = await run.result;
|
|
164
166
|
await run.stop();
|
|
165
|
-
expect(output.success).toBeTruthy();
|
|
166
|
-
expect(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', './storybook/tsconfig.ts', '-d', '.', '-e', 'json'], '');
|
|
167
|
-
expect(buildDevStandaloneMock).toHaveBeenCalledWith(expect.objectContaining({
|
|
167
|
+
(0, vitest_1.expect)(output.success).toBeTruthy();
|
|
168
|
+
(0, vitest_1.expect)(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', './storybook/tsconfig.ts', '-d', '.', '-e', 'json'], '');
|
|
169
|
+
(0, vitest_1.expect)(buildDevStandaloneMock).toHaveBeenCalledWith(vitest_1.expect.objectContaining({
|
|
168
170
|
angularBrowserTarget: 'angular-cli:build-2',
|
|
169
|
-
angularBuilderContext: expect.any(Object),
|
|
171
|
+
angularBuilderContext: vitest_1.expect.any(Object),
|
|
170
172
|
ci: false,
|
|
171
173
|
disableTelemetry: undefined,
|
|
172
174
|
configDir: '.storybook',
|
|
173
175
|
host: 'localhost',
|
|
174
176
|
https: false,
|
|
175
|
-
packageJson: expect.any(Object),
|
|
177
|
+
packageJson: vitest_1.expect.any(Object),
|
|
176
178
|
port: 9009,
|
|
177
179
|
quiet: false,
|
|
178
180
|
smokeTest: false,
|
|
@@ -182,7 +184,7 @@ describe.skip('Start Storybook Builder', () => {
|
|
|
182
184
|
tsConfig: './storybook/tsconfig.ts',
|
|
183
185
|
}));
|
|
184
186
|
});
|
|
185
|
-
it('should start storybook with styles options', async () => {
|
|
187
|
+
(0, vitest_1.it)('should start storybook with styles options', async () => {
|
|
186
188
|
const run = await architect.scheduleBuilder('@storybook/angular:start-storybook', {
|
|
187
189
|
tsConfig: 'path/to/tsConfig.json',
|
|
188
190
|
port: 4400,
|
|
@@ -191,11 +193,11 @@ describe.skip('Start Storybook Builder', () => {
|
|
|
191
193
|
});
|
|
192
194
|
const output = await run.result;
|
|
193
195
|
await run.stop();
|
|
194
|
-
expect(output.success).toBeTruthy();
|
|
195
|
-
expect(mockRunScript).not.toHaveBeenCalledWith();
|
|
196
|
-
expect(buildDevStandaloneMock).toHaveBeenCalledWith({
|
|
196
|
+
(0, vitest_1.expect)(output.success).toBeTruthy();
|
|
197
|
+
(0, vitest_1.expect)(mockRunScript).not.toHaveBeenCalledWith();
|
|
198
|
+
(0, vitest_1.expect)(buildDevStandaloneMock).toHaveBeenCalledWith({
|
|
197
199
|
angularBrowserTarget: null,
|
|
198
|
-
angularBuilderContext: expect.any(Object),
|
|
200
|
+
angularBuilderContext: vitest_1.expect.any(Object),
|
|
199
201
|
angularBuilderOptions: { assets: [], styles: ['src/styles.css'] },
|
|
200
202
|
disableTelemetry: undefined,
|
|
201
203
|
ci: false,
|
|
@@ -203,7 +205,7 @@ describe.skip('Start Storybook Builder', () => {
|
|
|
203
205
|
host: 'localhost',
|
|
204
206
|
https: false,
|
|
205
207
|
port: 4400,
|
|
206
|
-
packageJson: expect.any(Object),
|
|
208
|
+
packageJson: vitest_1.expect.any(Object),
|
|
207
209
|
quiet: false,
|
|
208
210
|
smokeTest: false,
|
|
209
211
|
sslCa: undefined,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
3
5
|
const operators_1 = require("rxjs/operators");
|
|
4
|
-
const
|
|
5
|
-
const mockRunScript =
|
|
6
|
-
|
|
6
|
+
const run_compodoc_1 = require("./run-compodoc");
|
|
7
|
+
const mockRunScript = vitest_1.vi.fn();
|
|
8
|
+
vitest_1.vi.mock('@storybook/cli', () => ({
|
|
7
9
|
JsPackageManagerFactory: {
|
|
8
10
|
getPackageManager: () => ({
|
|
9
11
|
runPackageCommandSync: mockRunScript,
|
|
@@ -11,76 +13,65 @@ jest.mock('@storybook/cli', () => ({
|
|
|
11
13
|
},
|
|
12
14
|
}));
|
|
13
15
|
const builderContextLoggerMock = {
|
|
14
|
-
createChild:
|
|
15
|
-
log:
|
|
16
|
-
debug:
|
|
17
|
-
info:
|
|
18
|
-
warn:
|
|
19
|
-
error:
|
|
20
|
-
fatal:
|
|
16
|
+
createChild: vitest_1.vi.fn(),
|
|
17
|
+
log: vitest_1.vi.fn(),
|
|
18
|
+
debug: vitest_1.vi.fn(),
|
|
19
|
+
info: vitest_1.vi.fn(),
|
|
20
|
+
warn: vitest_1.vi.fn(),
|
|
21
|
+
error: vitest_1.vi.fn(),
|
|
22
|
+
fatal: vitest_1.vi.fn(),
|
|
21
23
|
};
|
|
22
|
-
describe('runCompodoc', () => {
|
|
23
|
-
afterEach(() => {
|
|
24
|
+
(0, vitest_1.describe)('runCompodoc', () => {
|
|
25
|
+
(0, vitest_1.afterEach)(() => {
|
|
24
26
|
mockRunScript.mockClear();
|
|
25
27
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
const builderContextMock = {
|
|
29
|
+
workspaceRoot: 'path/to/project',
|
|
30
|
+
logger: builderContextLoggerMock,
|
|
31
|
+
};
|
|
32
|
+
(0, vitest_1.it)('should run compodoc with tsconfig from context', async () => {
|
|
33
|
+
(0, run_compodoc_1.runCompodoc)({
|
|
28
34
|
compodocArgs: [],
|
|
29
35
|
tsconfig: 'path/to/tsconfig.json',
|
|
30
|
-
},
|
|
31
|
-
workspaceRoot: 'path/to/project',
|
|
32
|
-
logger: builderContextLoggerMock,
|
|
33
|
-
})
|
|
36
|
+
}, builderContextMock)
|
|
34
37
|
.pipe((0, operators_1.take)(1))
|
|
35
38
|
.subscribe();
|
|
36
|
-
expect(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '-d', 'path/to/project'], 'path/to/project', 'inherit');
|
|
39
|
+
(0, vitest_1.expect)(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '-d', 'path/to/project'], 'path/to/project', 'inherit');
|
|
37
40
|
});
|
|
38
|
-
it('should run compodoc with tsconfig from compodocArgs', async () => {
|
|
39
|
-
runCompodoc({
|
|
41
|
+
(0, vitest_1.it)('should run compodoc with tsconfig from compodocArgs', async () => {
|
|
42
|
+
(0, run_compodoc_1.runCompodoc)({
|
|
40
43
|
compodocArgs: ['-p', 'path/to/tsconfig.stories.json'],
|
|
41
44
|
tsconfig: 'path/to/tsconfig.json',
|
|
42
|
-
},
|
|
43
|
-
workspaceRoot: 'path/to/project',
|
|
44
|
-
logger: builderContextLoggerMock,
|
|
45
|
-
})
|
|
45
|
+
}, builderContextMock)
|
|
46
46
|
.pipe((0, operators_1.take)(1))
|
|
47
47
|
.subscribe();
|
|
48
|
-
expect(mockRunScript).toHaveBeenCalledWith('compodoc', ['-d', 'path/to/project', '-p', 'path/to/tsconfig.stories.json'], 'path/to/project', 'inherit');
|
|
48
|
+
(0, vitest_1.expect)(mockRunScript).toHaveBeenCalledWith('compodoc', ['-d', 'path/to/project', '-p', 'path/to/tsconfig.stories.json'], 'path/to/project', 'inherit');
|
|
49
49
|
});
|
|
50
|
-
it('should run compodoc with default output folder.', async () => {
|
|
51
|
-
runCompodoc({
|
|
50
|
+
(0, vitest_1.it)('should run compodoc with default output folder.', async () => {
|
|
51
|
+
(0, run_compodoc_1.runCompodoc)({
|
|
52
52
|
compodocArgs: [],
|
|
53
53
|
tsconfig: 'path/to/tsconfig.json',
|
|
54
|
-
},
|
|
55
|
-
workspaceRoot: 'path/to/project',
|
|
56
|
-
logger: builderContextLoggerMock,
|
|
57
|
-
})
|
|
54
|
+
}, builderContextMock)
|
|
58
55
|
.pipe((0, operators_1.take)(1))
|
|
59
56
|
.subscribe();
|
|
60
|
-
expect(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '-d', 'path/to/project'], 'path/to/project', 'inherit');
|
|
57
|
+
(0, vitest_1.expect)(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '-d', 'path/to/project'], 'path/to/project', 'inherit');
|
|
61
58
|
});
|
|
62
|
-
it('should run with custom output folder specified with --output compodocArgs', async () => {
|
|
63
|
-
runCompodoc({
|
|
59
|
+
(0, vitest_1.it)('should run with custom output folder specified with --output compodocArgs', async () => {
|
|
60
|
+
(0, run_compodoc_1.runCompodoc)({
|
|
64
61
|
compodocArgs: ['--output', 'path/to/customFolder'],
|
|
65
62
|
tsconfig: 'path/to/tsconfig.json',
|
|
66
|
-
},
|
|
67
|
-
workspaceRoot: 'path/to/project',
|
|
68
|
-
logger: builderContextLoggerMock,
|
|
69
|
-
})
|
|
63
|
+
}, builderContextMock)
|
|
70
64
|
.pipe((0, operators_1.take)(1))
|
|
71
65
|
.subscribe();
|
|
72
|
-
expect(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '--output', 'path/to/customFolder'], 'path/to/project', 'inherit');
|
|
66
|
+
(0, vitest_1.expect)(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '--output', 'path/to/customFolder'], 'path/to/project', 'inherit');
|
|
73
67
|
});
|
|
74
|
-
it('should run with custom output folder specified with -d compodocArgs', async () => {
|
|
75
|
-
runCompodoc({
|
|
68
|
+
(0, vitest_1.it)('should run with custom output folder specified with -d compodocArgs', async () => {
|
|
69
|
+
(0, run_compodoc_1.runCompodoc)({
|
|
76
70
|
compodocArgs: ['-d', 'path/to/customFolder'],
|
|
77
71
|
tsconfig: 'path/to/tsconfig.json',
|
|
78
|
-
},
|
|
79
|
-
workspaceRoot: 'path/to/project',
|
|
80
|
-
logger: builderContextLoggerMock,
|
|
81
|
-
})
|
|
72
|
+
}, builderContextMock)
|
|
82
73
|
.pipe((0, operators_1.take)(1))
|
|
83
74
|
.subscribe();
|
|
84
|
-
expect(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '-d', 'path/to/customFolder'], 'path/to/project', 'inherit');
|
|
75
|
+
(0, vitest_1.expect)(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '-d', 'path/to/customFolder'], 'path/to/project', 'inherit');
|
|
85
76
|
});
|
|
86
77
|
});
|
|
@@ -4,6 +4,13 @@ type StoryRenderInfo = {
|
|
|
4
4
|
storyFnAngular: StoryFnAngularReturnType;
|
|
5
5
|
moduleMetadataSnapshot: string;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Attribute name for the story UID that may be written to the targetDOMNode.
|
|
9
|
+
*
|
|
10
|
+
* If a target DOM node has a story UID attribute, it will be used as part of
|
|
11
|
+
* the selector for the Angular component.
|
|
12
|
+
*/
|
|
13
|
+
export declare const STORY_UID_ATTRIBUTE = "data-sb-story-uid";
|
|
7
14
|
export declare abstract class AbstractRenderer {
|
|
8
15
|
/**
|
|
9
16
|
* Wait and destroy the platform
|
|
@@ -47,6 +54,9 @@ export declare abstract class AbstractRenderer {
|
|
|
47
54
|
* @memberof AbstractRenderer
|
|
48
55
|
*/
|
|
49
56
|
protected generateTargetSelectorFromStoryId(id: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Adds DOM element that angular will use as bootstrap component.
|
|
59
|
+
*/
|
|
50
60
|
protected initAngularRootElement(targetDOMNode: HTMLElement, targetSelector: string): void;
|
|
51
61
|
private fullRendererRequired;
|
|
52
62
|
}
|
|
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
var _a;
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.AbstractRenderer = void 0;
|
|
27
|
+
exports.AbstractRenderer = exports.STORY_UID_ATTRIBUTE = void 0;
|
|
28
28
|
const core_1 = require("@angular/core");
|
|
29
29
|
const platform_browser_1 = require("@angular/platform-browser");
|
|
30
30
|
const rxjs_1 = require("rxjs");
|
|
@@ -34,6 +34,13 @@ const StorybookProvider_1 = require("./StorybookProvider");
|
|
|
34
34
|
const StorybookWrapperComponent_1 = require("./StorybookWrapperComponent");
|
|
35
35
|
const PropertyExtractor_1 = require("./utils/PropertyExtractor");
|
|
36
36
|
const applicationRefs = new Map();
|
|
37
|
+
/**
|
|
38
|
+
* Attribute name for the story UID that may be written to the targetDOMNode.
|
|
39
|
+
*
|
|
40
|
+
* If a target DOM node has a story UID attribute, it will be used as part of
|
|
41
|
+
* the selector for the Angular component.
|
|
42
|
+
*/
|
|
43
|
+
exports.STORY_UID_ATTRIBUTE = 'data-sb-story-uid';
|
|
37
44
|
class AbstractRenderer {
|
|
38
45
|
/**
|
|
39
46
|
* Wait and destroy the platform
|
|
@@ -90,10 +97,16 @@ class AbstractRenderer {
|
|
|
90
97
|
this.storyProps$ = newStoryProps$;
|
|
91
98
|
this.initAngularRootElement(targetDOMNode, targetSelector);
|
|
92
99
|
const analyzedMetadata = new PropertyExtractor_1.PropertyExtractor(storyFnAngular.moduleMetadata, component);
|
|
100
|
+
const storyUid = targetDOMNode.getAttribute(exports.STORY_UID_ATTRIBUTE);
|
|
101
|
+
const componentSelector = storyUid !== null ? `${targetSelector}[${storyUid}]` : targetSelector;
|
|
102
|
+
if (storyUid !== null) {
|
|
103
|
+
const element = targetDOMNode.querySelector(targetSelector);
|
|
104
|
+
element.toggleAttribute(storyUid, true);
|
|
105
|
+
}
|
|
93
106
|
const application = (0, StorybookModule_1.getApplication)({
|
|
94
107
|
storyFnAngular,
|
|
95
108
|
component,
|
|
96
|
-
targetSelector,
|
|
109
|
+
targetSelector: componentSelector,
|
|
97
110
|
analyzedMetadata,
|
|
98
111
|
});
|
|
99
112
|
const applicationRef = await (0, platform_browser_1.bootstrapApplication)(application, {
|
|
@@ -124,8 +137,10 @@ class AbstractRenderer {
|
|
|
124
137
|
const storyIdIsInvalidHtmlTagName = invalidHtmlTag.test(id);
|
|
125
138
|
return storyIdIsInvalidHtmlTagName ? `sb-${id.replace(invalidHtmlTag, '')}-component` : id;
|
|
126
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Adds DOM element that angular will use as bootstrap component.
|
|
142
|
+
*/
|
|
127
143
|
initAngularRootElement(targetDOMNode, targetSelector) {
|
|
128
|
-
// Adds DOM element that angular will use as bootstrap component
|
|
129
144
|
// eslint-disable-next-line no-param-reassign
|
|
130
145
|
targetDOMNode.innerHTML = '';
|
|
131
146
|
targetDOMNode.appendChild(document.createElement(targetSelector));
|
|
@@ -10,4 +10,5 @@ export declare class DocsRenderer extends AbstractRenderer {
|
|
|
10
10
|
}): Promise<void>;
|
|
11
11
|
beforeFullRender(domNode?: HTMLElement): Promise<void>;
|
|
12
12
|
afterFullRender(): Promise<void>;
|
|
13
|
+
protected initAngularRootElement(targetDOMNode: HTMLElement, targetSelector: string): void;
|
|
13
14
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DocsRenderer = void 0;
|
|
4
4
|
const preview_api_1 = require("@storybook/preview-api");
|
|
5
5
|
const core_events_1 = require("@storybook/core-events");
|
|
6
|
+
const StoryUID_1 = require("./utils/StoryUID");
|
|
6
7
|
const AbstractRenderer_1 = require("./AbstractRenderer");
|
|
7
8
|
class DocsRenderer extends AbstractRenderer_1.AbstractRenderer {
|
|
8
9
|
async render(options) {
|
|
@@ -36,5 +37,9 @@ class DocsRenderer extends AbstractRenderer_1.AbstractRenderer {
|
|
|
36
37
|
async afterFullRender() {
|
|
37
38
|
await AbstractRenderer_1.AbstractRenderer.resetCompiledComponents();
|
|
38
39
|
}
|
|
40
|
+
initAngularRootElement(targetDOMNode, targetSelector) {
|
|
41
|
+
super.initAngularRootElement(targetDOMNode, targetSelector);
|
|
42
|
+
targetDOMNode.setAttribute(AbstractRenderer_1.STORY_UID_ATTRIBUTE, (0, StoryUID_1.getNextStoryUID)(targetDOMNode.id));
|
|
43
|
+
}
|
|
39
44
|
}
|
|
40
45
|
exports.DocsRenderer = DocsRenderer;
|