@astryxdesign/cli 0.6.0 → 0.6.1
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/CHANGELOG.md +48 -1
- package/README.md +76 -67
- package/api/build/build.test.mjs +37 -0
- package/api/build/build.type.mjs +1 -1
- package/api/build/kit/kit.mjs +31 -1
- package/api/component/_adapter.mjs +14 -28
- package/api/component/integration-import-agreement.test.mjs +318 -0
- package/api/doctor/doctor.d.mts +32 -3
- package/api/doctor/doctor.doc.mjs +2 -1
- package/api/doctor/doctor.mjs +97 -4
- package/api/doctor/doctor.test.mjs +90 -1
- package/api/gap-report/gap-report-worker.d.mts +4 -0
- package/api/gap-report/gap-report-worker.mjs +73 -0
- package/api/gap-report/gap-report.d.mts +81 -0
- package/api/gap-report/gap-report.doc.d.mts +9 -0
- package/api/gap-report/gap-report.doc.mjs +127 -0
- package/api/gap-report/gap-report.mjs +707 -0
- package/api/gap-report/gap-report.test.mjs +1210 -0
- package/api/gap-report/gap-report.type.d.mts +88 -0
- package/api/gap-report/gap-report.type.mjs +69 -0
- package/api/index.d.mts +8 -1
- package/api/index.mjs +24 -1
- package/api/integration/add-contribution.d.mts +44 -0
- package/api/integration/add-contribution.mjs +1160 -0
- package/api/integration/add-contribution.test.mjs +733 -0
- package/api/integration/add-helpers.d.mts +80 -0
- package/api/integration/add-helpers.mjs +333 -0
- package/api/integration/add-helpers.test.mjs +161 -0
- package/api/integration/add-theme.d.mts +10 -0
- package/api/integration/add-theme.mjs +332 -0
- package/api/integration/add-theme.test.mjs +194 -0
- package/api/integration/integration-authoring.type.d.mts +55 -0
- package/api/integration/integration-authoring.type.mjs +76 -0
- package/api/integration/integration-block-exports.test.mjs +4 -0
- package/api/integration/integrationAdd.doc.d.mts +5 -0
- package/api/integration/integrationAdd.doc.mjs +100 -0
- package/api/integration/integrationAddAgentDoc.doc.d.mts +5 -0
- package/api/integration/integrationAddAgentDoc.doc.mjs +49 -0
- package/api/integration/integrationAddCodemod.doc.d.mts +5 -0
- package/api/integration/integrationAddCodemod.doc.mjs +55 -0
- package/api/integration/integrationAddComponent.doc.d.mts +5 -0
- package/api/integration/integrationAddComponent.doc.mjs +49 -0
- package/api/integration/integrationAddDoc.doc.d.mts +5 -0
- package/api/integration/integrationAddDoc.doc.mjs +59 -0
- package/api/integration/integrationAddTemplate.doc.d.mts +5 -0
- package/api/integration/integrationAddTemplate.doc.mjs +55 -0
- package/api/integration/integrationAddTheme.doc.d.mts +5 -0
- package/api/integration/integrationAddTheme.doc.mjs +85 -0
- package/api/integration/integrationPackCheck.doc.d.mts +5 -0
- package/api/integration/integrationPackCheck.doc.mjs +35 -0
- package/api/integration/pack-check.d.mts +27 -0
- package/api/integration/pack-check.mjs +795 -0
- package/api/integration/pack-check.test.mjs +569 -0
- package/api/integration/pack-check.type.d.mts +45 -0
- package/api/integration/pack-check.type.mjs +56 -0
- package/api/integration/public-api.test.mjs +21 -0
- package/api/integration/validate-integration.mjs +221 -11
- package/api/integration/validate-integration.test.mjs +189 -5
- package/api/integration/validateIntegration.doc.mjs +2 -2
- package/api/json/index.ts +1 -0
- package/api/search/search.mjs +19 -1
- package/api/theme/_adapter.d.mts +26 -28
- package/api/theme/_adapter.mjs +101 -38
- package/api/theme/add/add.d.mts +2 -1
- package/api/theme/add/add.mjs +56 -20
- package/api/theme/add/add.test.mjs +1 -0
- package/api/theme/build/build.d.mts +25 -0
- package/api/theme/build/build.mjs +101 -70
- package/api/theme/build/build.test.mjs +77 -44
- package/api/theme/integration-themes.test.mjs +183 -0
- package/api/theme/list/list.d.mts +10 -2
- package/api/theme/list/list.mjs +31 -10
- package/api/theme/list/list.test.mjs +102 -23
- package/api/theme/listThemes.doc.d.mts +1 -5
- package/api/theme/listThemes.doc.mjs +6 -13
- package/api/theme/targets/targets.test.mjs +22 -8
- package/api/theme/theme.d.mts +1 -1
- package/api/theme/theme.mjs +1 -1
- package/api/theme/theme.type.d.mts +9 -0
- package/api/theme/theme.type.mjs +3 -1
- package/api/theme/themeAdd.doc.d.mts +1 -4
- package/api/theme/themeAdd.doc.mjs +31 -31
- package/api/theme/themeBuild.doc.mjs +1 -1
- package/api/theme/themeList.doc.d.mts +1 -4
- package/api/theme/themeList.doc.mjs +7 -15
- package/api/theme/themeListAvailable.doc.d.mts +8 -0
- package/api/theme/themeListAvailable.doc.mjs +57 -0
- package/api/theme/themeTargets.doc.mjs +21 -7
- package/api/upgrade/_adapter.d.mts +2 -0
- package/api/upgrade/_adapter.mjs +1 -0
- package/api/upgrade/registry/registry.d.mts +40 -0
- package/api/upgrade/registry/registry.mjs +1154 -0
- package/api/upgrade/registry/registry.test.mjs +826 -0
- package/api/upgrade/run/run.mjs +49 -8
- package/api/upgrade/status/status.d.mts +6 -4
- package/api/upgrade/status/status.mjs +26 -8
- package/api/upgrade/upgrade.d.mts +2 -2
- package/api/upgrade/upgrade.doc.mjs +33 -9
- package/api/upgrade/upgrade.mjs +34 -7
- package/api/upgrade/upgrade.test.mjs +198 -8
- package/api/upgrade/upgrade.type.d.mts +90 -1
- package/api/upgrade/upgrade.type.mjs +51 -2
- package/assets/docs/cli-integrations.doc.mjs +152 -28
- package/assets/docs/getting-started.doc.mjs +1 -1
- package/assets/docs/{shadcn-compatibility.doc.mjs → shadcn-compatibility.doc.draft.mjs} +23 -13
- package/assets/docs/styling.doc.mjs +3 -3
- package/assets/docs/theme.doc.dense.mjs +2 -2
- package/assets/docs/theme.doc.mjs +23 -13
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.doc.mjs +2 -1
- package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.tsx +38 -12
- package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadShowcase.tsx +87 -0
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +23 -0
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.tsx +75 -0
- package/assets/templates/blocks/components/BreadcrumbItem/BreadcrumbItemShowcase.tsx +5 -19
- package/assets/templates/blocks/components/Center/CenterHorizontal.doc.mjs +3 -2
- package/assets/templates/blocks/components/Center/CenterHorizontal.tsx +4 -5
- package/assets/templates/blocks/components/Toast/ToastAction.tsx +2 -1
- package/assets/templates/blocks/components/Toast/ToastDeduplication.tsx +2 -1
- package/assets/templates/blocks/components/Toast/ToastDismiss.tsx +2 -1
- package/assets/templates/blocks/components/Toast/ToastShowcase.tsx +2 -1
- package/assets/templates/blocks/components/Toast/ToastStacking.tsx +2 -1
- package/assets/templates/blocks/components/Toast/ToastTypes.tsx +2 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +2 -2
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +3 -2
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +3 -2
- package/assets/templates/pages/dashboard-comparison/template.doc.mjs +3 -3
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -2
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +2 -2
- package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -2
- package/assets/templates/themes/butter/butterTheme.ts +3 -3
- package/assets/templates/themes/neutral/neutralTheme.ts +2 -2
- package/assets/templates/themes/stone/stoneTheme.ts +3 -3
- package/assets/theme.template.ts +4 -7
- package/authoring/config/config.doc.mjs +9 -1
- package/authoring/config/parse.d.mts +2 -0
- package/authoring/config/parse.mjs +28 -3
- package/authoring/config/parse.test.mjs +25 -3
- package/authoring/config/type.ts +3 -0
- package/authoring/doctypes/_schema.d.mts +3 -0
- package/authoring/doctypes/_schema.mjs +6 -1
- package/authoring/doctypes/base/type.ts +6 -6
- package/authoring/doctypes/component/component.doc.mjs +6 -0
- package/authoring/doctypes/component/type.ts +2 -0
- package/authoring/gap-report/parse.d.mts +63 -0
- package/authoring/gap-report/parse.mjs +121 -0
- package/authoring/gap-report/parse.test.mjs +172 -0
- package/authoring/gap-report/type.ts +107 -0
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +12 -0
- package/authoring/index.mjs +4 -0
- package/authoring/integration/integration.doc.mjs +14 -2
- package/authoring/integration/parse.test.mjs +9 -4
- package/authoring/integration/schema.d.mts +2 -0
- package/authoring/integration/schema.mjs +1 -0
- package/authoring/integration/type.ts +23 -6
- package/authoring/shadcn/receipt.d.mts +219 -0
- package/authoring/shadcn/receipt.mjs +248 -0
- package/authoring/shadcn/receipt.test.mjs +187 -0
- package/authoring/shadcn/source-variants.d.mts +28 -0
- package/authoring/shadcn/source-variants.mjs +176 -0
- package/authoring/shadcn/source-variants.test.mjs +120 -0
- package/clients/cli/commands/build-theme.mjs +54 -19
- package/clients/cli/commands/build-theme.variants.test.mjs +15 -12
- package/clients/cli/commands/component/index.mjs +1 -1
- package/clients/cli/commands/docs.test.mjs +1 -0
- package/clients/cli/commands/doctor-integration.doc.mjs +1 -1
- package/clients/cli/commands/gap-report.doc.mjs +73 -0
- package/clients/cli/commands/gap-report.mjs +114 -0
- package/clients/cli/commands/gap-report.test.mjs +198 -0
- package/clients/cli/commands/import-hint-correctness.test.mjs +88 -0
- package/clients/cli/commands/integration-add.doc.mjs +88 -0
- package/clients/cli/commands/integration-authoring.test.mjs +177 -0
- package/clients/cli/commands/integration-pack.doc.mjs +34 -0
- package/clients/cli/commands/integration-real-world.test.mjs +618 -0
- package/clients/cli/commands/integration.doc.mjs +28 -0
- package/clients/cli/commands/integration.mjs +153 -0
- package/clients/cli/commands/theme-add.doc.mjs +11 -6
- package/clients/cli/commands/theme-list.doc.mjs +21 -5
- package/clients/cli/commands/theme-targets.behavior.test.mjs +19 -2
- package/clients/cli/commands/theme.doc.mjs +2 -2
- package/clients/cli/commands/upgrade.doc.mjs +17 -4
- package/clients/cli/commands/upgrade.mjs +12 -1
- package/clients/cli/commands/upgrade.test.mjs +41 -0
- package/clients/cli/index.mjs +5 -0
- package/clients/cli/lib/component-format.mjs +42 -26
- package/clients/cli/lib/component-format.test.mjs +34 -3
- package/clients/cli/lib/manifest.mjs +12 -0
- package/foundation/config/project-themes.test.mjs +127 -0
- package/foundation/config/project.d.mts +23 -4
- package/foundation/config/project.mjs +96 -9
- package/foundation/config/project.test.mjs +132 -6
- package/foundation/discovery/component-discovery.d.mts +36 -0
- package/foundation/discovery/component-discovery.mjs +96 -0
- package/foundation/discovery/theme-discovery.d.mts +39 -0
- package/foundation/discovery/theme-discovery.mjs +650 -0
- package/foundation/discovery/theme-discovery.test.mjs +375 -0
- package/foundation/discovery/theming-targets.d.mts +16 -0
- package/foundation/discovery/theming-targets.mjs +39 -3
- package/foundation/discovery/theming-targets.test.mjs +139 -0
- package/foundation/integrations/autolink.d.mts +96 -0
- package/foundation/integrations/autolink.mjs +265 -0
- package/foundation/integrations/autolink.test.mjs +430 -0
- package/foundation/integrations/contribution-inventory.d.mts +152 -0
- package/foundation/integrations/contribution-inventory.mjs +497 -0
- package/foundation/integrations/contribution-inventory.test.mjs +361 -0
- package/foundation/integrations/integrations.d.mts +73 -9
- package/foundation/integrations/integrations.mjs +158 -8
- package/foundation/integrations/integrations.test.mjs +152 -29
- package/foundation/integrations/manifest-writer.d.mts +56 -0
- package/foundation/integrations/manifest-writer.mjs +328 -0
- package/foundation/integrations/manifest-writer.test.mjs +229 -0
- package/foundation/integrations/validate-contributions.mjs +81 -6
- package/foundation/response/error-codes.d.mts +4 -1
- package/foundation/response/error-codes.doc.mjs +16 -1
- package/foundation/response/error-codes.mjs +10 -1
- package/foundation/response/response-types.doc.mjs +23 -2
- package/package.json +8 -1
|
@@ -0,0 +1,1210 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import {spawnSync} from 'node:child_process';
|
|
4
|
+
import * as fs from 'node:fs';
|
|
5
|
+
import * as os from 'node:os';
|
|
6
|
+
import * as path from 'node:path';
|
|
7
|
+
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
|
8
|
+
import {Project} from '../../foundation/config/project.mjs';
|
|
9
|
+
import {
|
|
10
|
+
GAP_REPORT_CATEGORIES,
|
|
11
|
+
PUBLIC_CONFIRMATION_MESSAGE,
|
|
12
|
+
collectGapReportHandlers,
|
|
13
|
+
deliverGapReportHandlers,
|
|
14
|
+
gapReport,
|
|
15
|
+
} from './gap-report.mjs';
|
|
16
|
+
|
|
17
|
+
let projectDir;
|
|
18
|
+
|
|
19
|
+
function configure(integrations = [], opts = {}) {
|
|
20
|
+
const config = {integrations, ...opts};
|
|
21
|
+
fs.writeFileSync(
|
|
22
|
+
path.join(projectDir, 'astryx.config.mjs'),
|
|
23
|
+
`export default ${JSON.stringify(config)};\n`,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function packageDir(packageName) {
|
|
28
|
+
return path.join(projectDir, 'node_modules', ...packageName.split('/'));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function addCoreComponent(component = 'Button') {
|
|
32
|
+
const coreDir = packageDir('@astryxdesign/core');
|
|
33
|
+
const componentDir = path.join(coreDir, 'src', component);
|
|
34
|
+
fs.mkdirSync(componentDir, {recursive: true});
|
|
35
|
+
fs.writeFileSync(
|
|
36
|
+
path.join(coreDir, 'package.json'),
|
|
37
|
+
JSON.stringify({name: '@astryxdesign/core', version: '0.5.4'}),
|
|
38
|
+
);
|
|
39
|
+
fs.writeFileSync(
|
|
40
|
+
path.join(componentDir, `${component}.doc.mjs`),
|
|
41
|
+
`export default {name: ${JSON.stringify(component)}, usage: {description: 'Core fixture'}, props: []};\n`,
|
|
42
|
+
);
|
|
43
|
+
fs.writeFileSync(
|
|
44
|
+
path.join(componentDir, `${component}.tsx`),
|
|
45
|
+
`export const ${component} = null;\n`,
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Add an integration with a handler (function-based, not executable).
|
|
51
|
+
* @param {object} opts
|
|
52
|
+
* @param {string} opts.name
|
|
53
|
+
* @param {'internal'|'public'} [opts.audience]
|
|
54
|
+
* @param {string} [opts.issuesUrl]
|
|
55
|
+
* @param {string} [opts.component]
|
|
56
|
+
* @param {boolean} [opts.handler] whether to export a gapReport handler
|
|
57
|
+
* @param {string} [opts.handleBody] JS code for the handle function body
|
|
58
|
+
* @param {string} [opts.malformedExport] raw JS to export instead of a proper handler
|
|
59
|
+
*/
|
|
60
|
+
function addIntegration({
|
|
61
|
+
name,
|
|
62
|
+
audience = 'public',
|
|
63
|
+
issuesUrl,
|
|
64
|
+
component,
|
|
65
|
+
handler = true,
|
|
66
|
+
handleBody = "return {status: 'filed', message: 'Handled by ' + " +
|
|
67
|
+
JSON.stringify(name) +
|
|
68
|
+
'};',
|
|
69
|
+
malformedExport,
|
|
70
|
+
}) {
|
|
71
|
+
const dir = packageDir(name);
|
|
72
|
+
fs.mkdirSync(dir, {recursive: true});
|
|
73
|
+
fs.writeFileSync(
|
|
74
|
+
path.join(dir, 'package.json'),
|
|
75
|
+
JSON.stringify({name, version: '1.2.3'}),
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const manifest = {};
|
|
79
|
+
if (issuesUrl) manifest.issuesUrl = issuesUrl;
|
|
80
|
+
if (component) {
|
|
81
|
+
manifest.components = './components';
|
|
82
|
+
const components = path.join(dir, 'components');
|
|
83
|
+
fs.mkdirSync(components, {recursive: true});
|
|
84
|
+
fs.writeFileSync(
|
|
85
|
+
path.join(components, `${component}.doc.mjs`),
|
|
86
|
+
`export default {name: ${JSON.stringify(component)}, usage: {description: 'Fixture'}, props: []};\n`,
|
|
87
|
+
);
|
|
88
|
+
fs.writeFileSync(
|
|
89
|
+
path.join(components, `${component}.tsx`),
|
|
90
|
+
`export const ${component} = null;\n`,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
let namedExport = '';
|
|
95
|
+
if (malformedExport != null) {
|
|
96
|
+
namedExport = malformedExport;
|
|
97
|
+
} else if (handler) {
|
|
98
|
+
namedExport = `export const gapReport = {\n audience: ${JSON.stringify(audience)},\n handle: async (report, {signal}) => { ${handleBody} },\n};\n`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
fs.writeFileSync(
|
|
102
|
+
path.join(dir, 'astryx.integration.mjs'),
|
|
103
|
+
`${namedExport}export default ${JSON.stringify(manifest)};\n`,
|
|
104
|
+
);
|
|
105
|
+
return {dir};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const reportOptions = {
|
|
109
|
+
category: 'missing_variant',
|
|
110
|
+
reason: 'Need a compact size',
|
|
111
|
+
detail: 'The current size does not fit the toolbar.',
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
beforeEach(() => {
|
|
115
|
+
projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-gap-report-'));
|
|
116
|
+
fs.writeFileSync(
|
|
117
|
+
path.join(projectDir, 'package.json'),
|
|
118
|
+
JSON.stringify({name: 'fixture-app'}),
|
|
119
|
+
);
|
|
120
|
+
configure();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
afterEach(() => {
|
|
124
|
+
vi.unstubAllEnvs();
|
|
125
|
+
fs.rmSync(projectDir, {recursive: true, force: true});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
describe('gapReport categories and validation', () => {
|
|
129
|
+
it('preserves the legacy category vocabulary', async () => {
|
|
130
|
+
const result = await gapReport(undefined, {listCategories: true});
|
|
131
|
+
expect(result).toEqual({
|
|
132
|
+
type: 'gap-report.categories',
|
|
133
|
+
data: GAP_REPORT_CATEGORIES,
|
|
134
|
+
});
|
|
135
|
+
expect(result.data.map(item => item.value)).toEqual([
|
|
136
|
+
'missing_component',
|
|
137
|
+
'missing_variant',
|
|
138
|
+
'layout_gap',
|
|
139
|
+
'styling_gap',
|
|
140
|
+
'a11y_gap',
|
|
141
|
+
'api_friction',
|
|
142
|
+
'docs_gap',
|
|
143
|
+
'other',
|
|
144
|
+
]);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('rejects missing, unknown, and oversized report fields', async () => {
|
|
148
|
+
await expect(
|
|
149
|
+
gapReport(undefined, {...reportOptions, cwd: projectDir}),
|
|
150
|
+
).rejects.toMatchObject({code: 'ERR_MISSING_ARGUMENT'});
|
|
151
|
+
await expect(
|
|
152
|
+
gapReport('Button', {
|
|
153
|
+
...reportOptions,
|
|
154
|
+
category: 'not_real',
|
|
155
|
+
cwd: projectDir,
|
|
156
|
+
}),
|
|
157
|
+
).rejects.toMatchObject({code: 'ERR_UNKNOWN_CATEGORY'});
|
|
158
|
+
await expect(
|
|
159
|
+
gapReport('Button', {
|
|
160
|
+
...reportOptions,
|
|
161
|
+
detail: 'x'.repeat(8001),
|
|
162
|
+
cwd: projectDir,
|
|
163
|
+
}),
|
|
164
|
+
).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
describe('gapReport fan-out composition', () => {
|
|
169
|
+
it('project handler and integration handler both run in order', async () => {
|
|
170
|
+
const name = '@test/integration-one';
|
|
171
|
+
addIntegration({
|
|
172
|
+
name,
|
|
173
|
+
audience: 'internal',
|
|
174
|
+
handleBody: "return {status: 'filed', message: 'from integration'};",
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// Write config with project handler + integration
|
|
178
|
+
fs.writeFileSync(
|
|
179
|
+
path.join(projectDir, 'astryx.config.mjs'),
|
|
180
|
+
`
|
|
181
|
+
export default {
|
|
182
|
+
integrations: [${JSON.stringify(name)}],
|
|
183
|
+
gapReport: {
|
|
184
|
+
audience: 'internal',
|
|
185
|
+
handle: (report) => ({status: 'filed', message: 'from project'}),
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
`,
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
const result = await gapReport('General', {
|
|
192
|
+
...reportOptions,
|
|
193
|
+
cwd: projectDir,
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
expect(result.data.status).toBe('filed');
|
|
197
|
+
expect(result.data.deliveries).toHaveLength(2);
|
|
198
|
+
expect(
|
|
199
|
+
result.data.deliveries.map(({handlerType, handler, audience}) => ({
|
|
200
|
+
handlerType,
|
|
201
|
+
handler,
|
|
202
|
+
audience,
|
|
203
|
+
})),
|
|
204
|
+
).toEqual([
|
|
205
|
+
{handlerType: 'project', handler: 'project', audience: 'internal'},
|
|
206
|
+
{
|
|
207
|
+
handlerType: 'integration',
|
|
208
|
+
handler: name,
|
|
209
|
+
audience: 'internal',
|
|
210
|
+
},
|
|
211
|
+
]);
|
|
212
|
+
expect(result.data.deliveries[0].message).toBe('from project');
|
|
213
|
+
expect(result.data.deliveries[1].message).toBe('from integration');
|
|
214
|
+
expect(result.data.filedCount).toBe(2);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('runs the self-resolved local package handler', async () => {
|
|
218
|
+
fs.writeFileSync(
|
|
219
|
+
path.join(projectDir, 'package.json'),
|
|
220
|
+
JSON.stringify({name: '@test/local', version: '1.0.0'}),
|
|
221
|
+
);
|
|
222
|
+
fs.writeFileSync(
|
|
223
|
+
path.join(projectDir, 'astryx.integration.mjs'),
|
|
224
|
+
`export const gapReport = {
|
|
225
|
+
audience: 'internal',
|
|
226
|
+
handle(report) { return {status: 'filed', message: report.component}; },
|
|
227
|
+
};
|
|
228
|
+
export default {};
|
|
229
|
+
`,
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
const result = await gapReport('General', {
|
|
233
|
+
...reportOptions,
|
|
234
|
+
cwd: projectDir,
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
expect(result.data.deliveries).toEqual([
|
|
238
|
+
expect.objectContaining({
|
|
239
|
+
handlerType: 'integration',
|
|
240
|
+
handler: '@test/local',
|
|
241
|
+
audience: 'internal',
|
|
242
|
+
status: 'filed',
|
|
243
|
+
message: 'General',
|
|
244
|
+
}),
|
|
245
|
+
]);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('all integration handlers run in config order', async () => {
|
|
249
|
+
addIntegration({
|
|
250
|
+
name: '@test/first',
|
|
251
|
+
audience: 'internal',
|
|
252
|
+
handleBody: "return {status: 'filed', message: 'first'};",
|
|
253
|
+
});
|
|
254
|
+
addIntegration({
|
|
255
|
+
name: '@test/second',
|
|
256
|
+
audience: 'internal',
|
|
257
|
+
handleBody: "return {status: 'filed', message: 'second'};",
|
|
258
|
+
});
|
|
259
|
+
addIntegration({
|
|
260
|
+
name: '@test/third',
|
|
261
|
+
audience: 'internal',
|
|
262
|
+
handleBody: "return {status: 'filed', message: 'third'};",
|
|
263
|
+
});
|
|
264
|
+
configure(['@test/first', '@test/second', '@test/third']);
|
|
265
|
+
|
|
266
|
+
const result = await gapReport('General', {
|
|
267
|
+
...reportOptions,
|
|
268
|
+
cwd: projectDir,
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
expect(result.data.deliveries).toHaveLength(3);
|
|
272
|
+
expect(result.data.deliveries.map(d => d.handler)).toEqual([
|
|
273
|
+
'@test/first',
|
|
274
|
+
'@test/second',
|
|
275
|
+
'@test/third',
|
|
276
|
+
]);
|
|
277
|
+
expect(result.data.deliveries.map(d => d.message)).toEqual([
|
|
278
|
+
'first',
|
|
279
|
+
'second',
|
|
280
|
+
'third',
|
|
281
|
+
]);
|
|
282
|
+
expect(result.data.filedCount).toBe(3);
|
|
283
|
+
expect(result.data.status).toBe('filed');
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('deduplicates handlers by handle function identity', async () => {
|
|
287
|
+
// Create two integrations that share the same handle function
|
|
288
|
+
const sharedDir = path.join(projectDir, 'shared-handler');
|
|
289
|
+
fs.mkdirSync(sharedDir, {recursive: true});
|
|
290
|
+
fs.writeFileSync(
|
|
291
|
+
path.join(sharedDir, 'handler.mjs'),
|
|
292
|
+
"export const handle = async (report) => ({status: 'filed', message: 'shared'});\n",
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
const dir1 = packageDir('@test/first');
|
|
296
|
+
fs.mkdirSync(dir1, {recursive: true});
|
|
297
|
+
fs.writeFileSync(
|
|
298
|
+
path.join(dir1, 'package.json'),
|
|
299
|
+
JSON.stringify({name: '@test/first', version: '1.0.0'}),
|
|
300
|
+
);
|
|
301
|
+
fs.writeFileSync(
|
|
302
|
+
path.join(dir1, 'astryx.integration.mjs'),
|
|
303
|
+
`import {handle} from ${JSON.stringify(path.join(sharedDir, 'handler.mjs'))};\nexport const gapReport = {audience: 'internal', handle};\nexport default {};\n`,
|
|
304
|
+
);
|
|
305
|
+
|
|
306
|
+
const dir2 = packageDir('@test/second');
|
|
307
|
+
fs.mkdirSync(dir2, {recursive: true});
|
|
308
|
+
fs.writeFileSync(
|
|
309
|
+
path.join(dir2, 'package.json'),
|
|
310
|
+
JSON.stringify({name: '@test/second', version: '1.0.0'}),
|
|
311
|
+
);
|
|
312
|
+
fs.writeFileSync(
|
|
313
|
+
path.join(dir2, 'astryx.integration.mjs'),
|
|
314
|
+
`import {handle} from ${JSON.stringify(path.join(sharedDir, 'handler.mjs'))};\nexport const gapReport = {audience: 'internal', handle};\nexport default {};\n`,
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
configure(['@test/first', '@test/second']);
|
|
318
|
+
|
|
319
|
+
const result = await gapReport('General', {
|
|
320
|
+
...reportOptions,
|
|
321
|
+
cwd: projectDir,
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
expect(result.data.deliveries).toHaveLength(1);
|
|
325
|
+
expect(result.data.deliveries[0].message).toBe('shared');
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it('deduplicates the same handle across project and integration', () => {
|
|
329
|
+
const handle = async () => ({status: 'filed', message: 'shared'});
|
|
330
|
+
const entries = collectGapReportHandlers(
|
|
331
|
+
/** @type {any} */ ({
|
|
332
|
+
config: {gapReport: {audience: 'internal', handle}},
|
|
333
|
+
configPath: '/tmp/astryx.config.mjs',
|
|
334
|
+
loadedIntegrations: [
|
|
335
|
+
{
|
|
336
|
+
name: '@test/shared',
|
|
337
|
+
__manifestFile: '/tmp/astryx.integration.mjs',
|
|
338
|
+
__gapReport: {audience: 'internal', handle},
|
|
339
|
+
},
|
|
340
|
+
],
|
|
341
|
+
}),
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
expect(entries).toHaveLength(1);
|
|
345
|
+
expect(entries[0]).toMatchObject({
|
|
346
|
+
kind: 'handler',
|
|
347
|
+
handlerType: 'project',
|
|
348
|
+
handlerName: 'project',
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
it('each handler receives a fresh structuredClone', async () => {
|
|
353
|
+
addIntegration({
|
|
354
|
+
name: '@test/mutator',
|
|
355
|
+
audience: 'internal',
|
|
356
|
+
handleBody:
|
|
357
|
+
"report.component = 'MUTATED'; return {status: 'filed', message: report.component};",
|
|
358
|
+
});
|
|
359
|
+
addIntegration({
|
|
360
|
+
name: '@test/reader',
|
|
361
|
+
audience: 'internal',
|
|
362
|
+
handleBody: "return {status: 'filed', message: report.component};",
|
|
363
|
+
});
|
|
364
|
+
configure(['@test/mutator', '@test/reader']);
|
|
365
|
+
|
|
366
|
+
const result = await gapReport('General', {
|
|
367
|
+
...reportOptions,
|
|
368
|
+
cwd: projectDir,
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
expect(result.data.deliveries).toHaveLength(2);
|
|
372
|
+
expect(result.data.deliveries[0].message).toBe('MUTATED');
|
|
373
|
+
expect(result.data.deliveries[1].message).toBe('General');
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
it('repeated Project.load does not duplicate handlers', async () => {
|
|
377
|
+
addIntegration({
|
|
378
|
+
name: '@test/only',
|
|
379
|
+
audience: 'internal',
|
|
380
|
+
handleBody: "return {status: 'filed', message: 'once'};",
|
|
381
|
+
});
|
|
382
|
+
configure(['@test/only']);
|
|
383
|
+
|
|
384
|
+
// Call twice — second load should not add duplicates
|
|
385
|
+
const result1 = await gapReport('General', {
|
|
386
|
+
...reportOptions,
|
|
387
|
+
cwd: projectDir,
|
|
388
|
+
});
|
|
389
|
+
const result2 = await gapReport('General', {
|
|
390
|
+
...reportOptions,
|
|
391
|
+
cwd: projectDir,
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
expect(result1.data.deliveries).toHaveLength(1);
|
|
395
|
+
expect(result2.data.deliveries).toHaveLength(1);
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
it('does not treat inheritDebug as a gap-report opt-out', async () => {
|
|
399
|
+
fs.writeFileSync(
|
|
400
|
+
path.join(projectDir, 'package.json'),
|
|
401
|
+
JSON.stringify({name: 'fixture-app', astryx: {inheritDebug: false}}),
|
|
402
|
+
);
|
|
403
|
+
addIntegration({
|
|
404
|
+
name: '@test/always',
|
|
405
|
+
audience: 'internal',
|
|
406
|
+
handleBody: "return {status: 'filed', message: 'still ran'};",
|
|
407
|
+
});
|
|
408
|
+
configure(['@test/always']);
|
|
409
|
+
|
|
410
|
+
const result = await gapReport('General', {
|
|
411
|
+
...reportOptions,
|
|
412
|
+
cwd: projectDir,
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
expect(result.data.deliveries).toHaveLength(1);
|
|
416
|
+
expect(result.data.deliveries[0]).toMatchObject({
|
|
417
|
+
handler: '@test/always',
|
|
418
|
+
status: 'filed',
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
describe('gapReport handler isolation', () => {
|
|
424
|
+
it('terminates one timed-out handler and then runs the next handler', async () => {
|
|
425
|
+
addIntegration({
|
|
426
|
+
name: '@test/slow',
|
|
427
|
+
audience: 'internal',
|
|
428
|
+
handleBody: 'return new Promise(() => {});',
|
|
429
|
+
});
|
|
430
|
+
addIntegration({
|
|
431
|
+
name: '@test/after',
|
|
432
|
+
audience: 'internal',
|
|
433
|
+
handleBody: "return {status: 'filed', message: 'after'};",
|
|
434
|
+
});
|
|
435
|
+
configure(['@test/slow', '@test/after']);
|
|
436
|
+
const project = await Project.load(projectDir);
|
|
437
|
+
|
|
438
|
+
const deliveries = await deliverGapReportHandlers(
|
|
439
|
+
collectGapReportHandlers(project),
|
|
440
|
+
/** @type {any} */ ({component: 'Button'}),
|
|
441
|
+
{timeoutMs: 200},
|
|
442
|
+
);
|
|
443
|
+
|
|
444
|
+
expect(deliveries).toEqual([
|
|
445
|
+
{
|
|
446
|
+
handlerType: 'integration',
|
|
447
|
+
handler: '@test/slow',
|
|
448
|
+
audience: 'internal',
|
|
449
|
+
status: 'failed',
|
|
450
|
+
url: null,
|
|
451
|
+
message: 'Gap report handler timed out.',
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
handlerType: 'integration',
|
|
455
|
+
handler: '@test/after',
|
|
456
|
+
audience: 'internal',
|
|
457
|
+
status: 'filed',
|
|
458
|
+
url: null,
|
|
459
|
+
message: 'after',
|
|
460
|
+
},
|
|
461
|
+
]);
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
it('a timed-out late process.exit cannot terminate the caller', () => {
|
|
465
|
+
addIntegration({
|
|
466
|
+
name: '@test/late-exit',
|
|
467
|
+
audience: 'internal',
|
|
468
|
+
handleBody:
|
|
469
|
+
'await new Promise(resolve => setTimeout(resolve, 210)); process.exit(42);',
|
|
470
|
+
});
|
|
471
|
+
addIntegration({
|
|
472
|
+
name: '@test/after-late-exit',
|
|
473
|
+
audience: 'internal',
|
|
474
|
+
handleBody: "return {status: 'filed', message: 'survived'};",
|
|
475
|
+
});
|
|
476
|
+
configure(['@test/late-exit', '@test/after-late-exit']);
|
|
477
|
+
|
|
478
|
+
const projectModule = path.resolve(
|
|
479
|
+
import.meta.dirname,
|
|
480
|
+
'../../foundation/config/project.mjs',
|
|
481
|
+
);
|
|
482
|
+
const gapModule = path.resolve(import.meta.dirname, 'gap-report.mjs');
|
|
483
|
+
const source = `
|
|
484
|
+
const {Project} = await import(${JSON.stringify(projectModule)});
|
|
485
|
+
const {collectGapReportHandlers, deliverGapReportHandlers} = await import(${JSON.stringify(gapModule)});
|
|
486
|
+
const project = await Project.load(${JSON.stringify(projectDir)});
|
|
487
|
+
const deliveries = await deliverGapReportHandlers(
|
|
488
|
+
collectGapReportHandlers(project),
|
|
489
|
+
{component: 'Button'},
|
|
490
|
+
{timeoutMs: 200},
|
|
491
|
+
);
|
|
492
|
+
await new Promise(resolve => setTimeout(resolve, 300));
|
|
493
|
+
process.stdout.write(JSON.stringify(deliveries));
|
|
494
|
+
`;
|
|
495
|
+
const child = spawnSync(
|
|
496
|
+
process.execPath,
|
|
497
|
+
['--input-type=module', '-e', source],
|
|
498
|
+
{encoding: 'utf8', timeout: 5000},
|
|
499
|
+
);
|
|
500
|
+
|
|
501
|
+
expect(child.status, child.stderr).toBe(0);
|
|
502
|
+
expect(JSON.parse(child.stdout)).toMatchObject([
|
|
503
|
+
{handler: '@test/late-exit', status: 'failed'},
|
|
504
|
+
{handler: '@test/after-late-exit', status: 'filed'},
|
|
505
|
+
]);
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
it('redirects handler stdout and restores the parent stream method', async () => {
|
|
509
|
+
fs.writeFileSync(
|
|
510
|
+
path.join(projectDir, 'astryx.config.mjs'),
|
|
511
|
+
`export default {
|
|
512
|
+
gapReport: {
|
|
513
|
+
audience: 'internal',
|
|
514
|
+
handle() {
|
|
515
|
+
process.stdout.write('handler-noise');
|
|
516
|
+
return {status: 'skipped'};
|
|
517
|
+
},
|
|
518
|
+
},
|
|
519
|
+
};\n`,
|
|
520
|
+
);
|
|
521
|
+
const project = await Project.load(projectDir);
|
|
522
|
+
const stderrWrite = vi
|
|
523
|
+
.spyOn(process.stderr, 'write')
|
|
524
|
+
.mockImplementation(() => true);
|
|
525
|
+
const stdoutBefore = process.stdout.write;
|
|
526
|
+
try {
|
|
527
|
+
const deliveries = await deliverGapReportHandlers(
|
|
528
|
+
collectGapReportHandlers(project),
|
|
529
|
+
/** @type {any} */ ({component: 'Button'}),
|
|
530
|
+
);
|
|
531
|
+
|
|
532
|
+
expect(deliveries[0].status).toBe('skipped');
|
|
533
|
+
expect(
|
|
534
|
+
stderrWrite.mock.calls.map(call => String(call[0])).join(''),
|
|
535
|
+
).toContain('handler-noise');
|
|
536
|
+
expect(process.stdout.write).toBe(stdoutBefore);
|
|
537
|
+
} finally {
|
|
538
|
+
stderrWrite.mockRestore();
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
it('later handlers run after one throws', async () => {
|
|
543
|
+
addIntegration({
|
|
544
|
+
name: '@test/thrower',
|
|
545
|
+
audience: 'internal',
|
|
546
|
+
handleBody: "throw new Error('handler exploded');",
|
|
547
|
+
});
|
|
548
|
+
addIntegration({
|
|
549
|
+
name: '@test/survivor',
|
|
550
|
+
audience: 'internal',
|
|
551
|
+
handleBody: "return {status: 'filed', message: 'survived'};",
|
|
552
|
+
});
|
|
553
|
+
configure(['@test/thrower', '@test/survivor']);
|
|
554
|
+
|
|
555
|
+
const result = await gapReport('General', {
|
|
556
|
+
...reportOptions,
|
|
557
|
+
cwd: projectDir,
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
expect(result.data.deliveries).toHaveLength(2);
|
|
561
|
+
expect(result.data.deliveries[0].status).toBe('failed');
|
|
562
|
+
expect(result.data.deliveries[0].message).toContain('handler exploded');
|
|
563
|
+
expect(result.data.deliveries[1].status).toBe('filed');
|
|
564
|
+
expect(result.data.deliveries[1].message).toBe('survived');
|
|
565
|
+
expect(result.data.status).toBe('partial');
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
it('later handlers run after one tries process.exit', async () => {
|
|
569
|
+
addIntegration({
|
|
570
|
+
name: '@test/exiter',
|
|
571
|
+
audience: 'internal',
|
|
572
|
+
handleBody: 'process.exit(42);',
|
|
573
|
+
});
|
|
574
|
+
addIntegration({
|
|
575
|
+
name: '@test/survivor',
|
|
576
|
+
audience: 'internal',
|
|
577
|
+
handleBody: "return {status: 'filed', message: 'still here'};",
|
|
578
|
+
});
|
|
579
|
+
configure(['@test/exiter', '@test/survivor']);
|
|
580
|
+
|
|
581
|
+
const result = await gapReport('General', {
|
|
582
|
+
...reportOptions,
|
|
583
|
+
cwd: projectDir,
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
expect(result.data.deliveries).toHaveLength(2);
|
|
587
|
+
expect(result.data.deliveries[0].status).toBe('failed');
|
|
588
|
+
expect(result.data.deliveries[0].message).toContain('process.exit');
|
|
589
|
+
expect(result.data.deliveries[1].status).toBe('filed');
|
|
590
|
+
expect(result.data.filedCount).toBe(1);
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
it('later handlers run after one changes process.exitCode', async () => {
|
|
594
|
+
addIntegration({
|
|
595
|
+
name: '@test/exit-code',
|
|
596
|
+
audience: 'internal',
|
|
597
|
+
handleBody:
|
|
598
|
+
"process.exitCode = 42; return {status: 'filed', message: 'wrong'};",
|
|
599
|
+
});
|
|
600
|
+
addIntegration({
|
|
601
|
+
name: '@test/survivor',
|
|
602
|
+
audience: 'internal',
|
|
603
|
+
handleBody: "return {status: 'filed', message: 'still here'};",
|
|
604
|
+
});
|
|
605
|
+
configure(['@test/exit-code', '@test/survivor']);
|
|
606
|
+
const before = process.exitCode;
|
|
607
|
+
|
|
608
|
+
const result = await gapReport('General', {
|
|
609
|
+
...reportOptions,
|
|
610
|
+
cwd: projectDir,
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
expect(process.exitCode).toBe(before);
|
|
614
|
+
expect(result.data.deliveries[0]).toMatchObject({
|
|
615
|
+
handler: '@test/exit-code',
|
|
616
|
+
status: 'failed',
|
|
617
|
+
message: 'Handler changed process.exitCode.',
|
|
618
|
+
});
|
|
619
|
+
expect(result.data.deliveries[1]).toMatchObject({
|
|
620
|
+
handler: '@test/survivor',
|
|
621
|
+
status: 'filed',
|
|
622
|
+
});
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
it('handler that returns non-receipt is a failed delivery', async () => {
|
|
626
|
+
addIntegration({
|
|
627
|
+
name: '@test/non-receipt',
|
|
628
|
+
audience: 'internal',
|
|
629
|
+
handleBody: "return 'not an object';",
|
|
630
|
+
});
|
|
631
|
+
addIntegration({
|
|
632
|
+
name: '@test/after',
|
|
633
|
+
audience: 'internal',
|
|
634
|
+
handleBody: "return {status: 'filed', message: 'still ok'};",
|
|
635
|
+
});
|
|
636
|
+
configure(['@test/non-receipt', '@test/after']);
|
|
637
|
+
|
|
638
|
+
const result = await gapReport('General', {
|
|
639
|
+
...reportOptions,
|
|
640
|
+
cwd: projectDir,
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
expect(result.data.deliveries).toHaveLength(2);
|
|
644
|
+
expect(result.data.deliveries[0].status).toBe('failed');
|
|
645
|
+
expect(result.data.deliveries[1].status).toBe('filed');
|
|
646
|
+
});
|
|
647
|
+
|
|
648
|
+
it('malformed integration handler is isolated as a failed delivery', async () => {
|
|
649
|
+
const dir = packageDir('@test/malformed');
|
|
650
|
+
fs.mkdirSync(dir, {recursive: true});
|
|
651
|
+
fs.writeFileSync(
|
|
652
|
+
path.join(dir, 'package.json'),
|
|
653
|
+
JSON.stringify({name: '@test/malformed', version: '1.0.0'}),
|
|
654
|
+
);
|
|
655
|
+
fs.writeFileSync(
|
|
656
|
+
path.join(dir, 'astryx.integration.mjs'),
|
|
657
|
+
"export const gapReport = {audience: 'internal', command: './writer.mjs'};\nexport default {};\n",
|
|
658
|
+
);
|
|
659
|
+
|
|
660
|
+
addIntegration({
|
|
661
|
+
name: '@test/valid',
|
|
662
|
+
audience: 'internal',
|
|
663
|
+
handleBody: "return {status: 'filed', message: 'ok'};",
|
|
664
|
+
});
|
|
665
|
+
configure(['@test/malformed', '@test/valid']);
|
|
666
|
+
|
|
667
|
+
const result = await gapReport('General', {
|
|
668
|
+
...reportOptions,
|
|
669
|
+
cwd: projectDir,
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
expect(result.data.deliveries).toHaveLength(2);
|
|
673
|
+
expect(result.data.deliveries.map(d => d.handler)).toEqual([
|
|
674
|
+
'@test/malformed',
|
|
675
|
+
'@test/valid',
|
|
676
|
+
]);
|
|
677
|
+
expect(result.data.deliveries[0].status).toBe('failed');
|
|
678
|
+
expect(result.data.deliveries[1]).toMatchObject({
|
|
679
|
+
status: 'filed',
|
|
680
|
+
message: 'ok',
|
|
681
|
+
});
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
it('invalid handler receipt is recorded as failed delivery', async () => {
|
|
685
|
+
addIntegration({
|
|
686
|
+
name: '@test/bad-receipt',
|
|
687
|
+
audience: 'internal',
|
|
688
|
+
handleBody: "return {status: 'invalid_status'};",
|
|
689
|
+
});
|
|
690
|
+
addIntegration({
|
|
691
|
+
name: '@test/good',
|
|
692
|
+
audience: 'internal',
|
|
693
|
+
handleBody: "return {status: 'filed', message: 'good'};",
|
|
694
|
+
});
|
|
695
|
+
configure(['@test/bad-receipt', '@test/good']);
|
|
696
|
+
|
|
697
|
+
const result = await gapReport('General', {
|
|
698
|
+
...reportOptions,
|
|
699
|
+
cwd: projectDir,
|
|
700
|
+
});
|
|
701
|
+
|
|
702
|
+
expect(result.data.deliveries).toHaveLength(2);
|
|
703
|
+
expect(result.data.deliveries[0].status).toBe('failed');
|
|
704
|
+
expect(result.data.deliveries[0].message).toContain('invalid receipt');
|
|
705
|
+
expect(result.data.deliveries[1].status).toBe('filed');
|
|
706
|
+
});
|
|
707
|
+
});
|
|
708
|
+
|
|
709
|
+
describe('gapReport per-handler consent', () => {
|
|
710
|
+
it('gates a public project handler until consent is explicit', async () => {
|
|
711
|
+
const marker = path.join(projectDir, 'project-handler-ran');
|
|
712
|
+
fs.writeFileSync(
|
|
713
|
+
path.join(projectDir, 'astryx.config.mjs'),
|
|
714
|
+
`import * as fs from 'node:fs';
|
|
715
|
+
export default {
|
|
716
|
+
gapReport: {
|
|
717
|
+
audience: 'public',
|
|
718
|
+
handle() {
|
|
719
|
+
fs.writeFileSync(${JSON.stringify(marker)}, 'yes');
|
|
720
|
+
return {status: 'filed', message: 'project filed'};
|
|
721
|
+
},
|
|
722
|
+
},
|
|
723
|
+
};\n`,
|
|
724
|
+
);
|
|
725
|
+
|
|
726
|
+
const pending = await gapReport('General', {
|
|
727
|
+
...reportOptions,
|
|
728
|
+
cwd: projectDir,
|
|
729
|
+
});
|
|
730
|
+
expect(pending.data.deliveries[0]).toMatchObject({
|
|
731
|
+
handlerType: 'project',
|
|
732
|
+
handler: 'project',
|
|
733
|
+
audience: 'public',
|
|
734
|
+
status: 'consent_required',
|
|
735
|
+
});
|
|
736
|
+
expect(fs.existsSync(marker)).toBe(false);
|
|
737
|
+
|
|
738
|
+
const filed = await gapReport('General', {
|
|
739
|
+
...reportOptions,
|
|
740
|
+
confirmPublic: true,
|
|
741
|
+
cwd: projectDir,
|
|
742
|
+
});
|
|
743
|
+
expect(filed.data.deliveries[0]).toMatchObject({
|
|
744
|
+
handlerType: 'project',
|
|
745
|
+
handler: 'project',
|
|
746
|
+
audience: 'public',
|
|
747
|
+
status: 'filed',
|
|
748
|
+
});
|
|
749
|
+
expect(fs.readFileSync(marker, 'utf8')).toBe('yes');
|
|
750
|
+
});
|
|
751
|
+
|
|
752
|
+
it('public handler is skipped while internal handler runs', async () => {
|
|
753
|
+
addIntegration({
|
|
754
|
+
name: '@test/public-one',
|
|
755
|
+
audience: 'public',
|
|
756
|
+
handleBody: "return {status: 'filed', message: 'public filed'};",
|
|
757
|
+
});
|
|
758
|
+
addIntegration({
|
|
759
|
+
name: '@test/internal-one',
|
|
760
|
+
audience: 'internal',
|
|
761
|
+
handleBody: "return {status: 'filed', message: 'internal filed'};",
|
|
762
|
+
});
|
|
763
|
+
configure(['@test/public-one', '@test/internal-one']);
|
|
764
|
+
|
|
765
|
+
const result = await gapReport('General', {
|
|
766
|
+
...reportOptions,
|
|
767
|
+
cwd: projectDir,
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
expect(result.data.deliveries).toHaveLength(2);
|
|
771
|
+
expect(result.data.deliveries[0].status).toBe('consent_required');
|
|
772
|
+
expect(result.data.deliveries[0].message).toBe(PUBLIC_CONFIRMATION_MESSAGE);
|
|
773
|
+
expect(result.data.deliveries[1].status).toBe('filed');
|
|
774
|
+
expect(result.data.deliveries[1].message).toBe('internal filed');
|
|
775
|
+
expect(result.data.filedCount).toBe(1);
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
it('multiple internal handlers all run without consent', async () => {
|
|
779
|
+
addIntegration({
|
|
780
|
+
name: '@test/internal-a',
|
|
781
|
+
audience: 'internal',
|
|
782
|
+
handleBody: "return {status: 'filed', message: 'a'};",
|
|
783
|
+
});
|
|
784
|
+
addIntegration({
|
|
785
|
+
name: '@test/internal-b',
|
|
786
|
+
audience: 'internal',
|
|
787
|
+
handleBody: "return {status: 'filed', message: 'b'};",
|
|
788
|
+
});
|
|
789
|
+
configure(['@test/internal-a', '@test/internal-b']);
|
|
790
|
+
|
|
791
|
+
const result = await gapReport('General', {
|
|
792
|
+
...reportOptions,
|
|
793
|
+
cwd: projectDir,
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
expect(result.data.deliveries).toHaveLength(2);
|
|
797
|
+
expect(result.data.deliveries.every(d => d.status === 'filed')).toBe(true);
|
|
798
|
+
expect(result.data.filedCount).toBe(2);
|
|
799
|
+
expect(result.data.status).toBe('filed');
|
|
800
|
+
});
|
|
801
|
+
|
|
802
|
+
it('public handler runs when confirmPublic is true', async () => {
|
|
803
|
+
addIntegration({
|
|
804
|
+
name: '@test/public-ok',
|
|
805
|
+
audience: 'public',
|
|
806
|
+
handleBody: "return {status: 'filed', message: 'public worked'};",
|
|
807
|
+
});
|
|
808
|
+
configure(['@test/public-ok']);
|
|
809
|
+
|
|
810
|
+
const result = await gapReport('General', {
|
|
811
|
+
...reportOptions,
|
|
812
|
+
confirmPublic: true,
|
|
813
|
+
cwd: projectDir,
|
|
814
|
+
});
|
|
815
|
+
|
|
816
|
+
expect(result.data.deliveries).toHaveLength(1);
|
|
817
|
+
expect(result.data.deliveries[0].status).toBe('filed');
|
|
818
|
+
expect(result.data.deliveries[0].message).toBe('public worked');
|
|
819
|
+
});
|
|
820
|
+
});
|
|
821
|
+
|
|
822
|
+
describe('gapReport fallback behavior', () => {
|
|
823
|
+
it('handlers suppress the built-in fallback', async () => {
|
|
824
|
+
addIntegration({
|
|
825
|
+
name: '@test/has-handler',
|
|
826
|
+
audience: 'internal',
|
|
827
|
+
issuesUrl: 'https://github.com/acme/widgets/issues',
|
|
828
|
+
handleBody: "return {status: 'filed', message: 'handler took it'};",
|
|
829
|
+
});
|
|
830
|
+
configure(['@test/has-handler'], {
|
|
831
|
+
issuesUrl: 'https://github.com/acme/core/issues',
|
|
832
|
+
});
|
|
833
|
+
|
|
834
|
+
const result = await gapReport('General', {
|
|
835
|
+
...reportOptions,
|
|
836
|
+
cwd: projectDir,
|
|
837
|
+
});
|
|
838
|
+
|
|
839
|
+
// Should use handler, not GitHub fallback
|
|
840
|
+
expect(result.data.deliveries).toHaveLength(1);
|
|
841
|
+
expect(result.data.deliveries[0].message).toBe('handler took it');
|
|
842
|
+
});
|
|
843
|
+
|
|
844
|
+
it('no-handler GitHub consent-gated fallback works', async () => {
|
|
845
|
+
configure([], {issuesUrl: 'https://github.com/acme/widgets/issues/new'});
|
|
846
|
+
const binDir = path.join(projectDir, 'bin');
|
|
847
|
+
const argsFile = path.join(projectDir, 'gh-args.json');
|
|
848
|
+
fs.mkdirSync(binDir, {recursive: true});
|
|
849
|
+
fs.writeFileSync(
|
|
850
|
+
path.join(binDir, 'gh'),
|
|
851
|
+
`#!/usr/bin/env node
|
|
852
|
+
import fs from 'node:fs';
|
|
853
|
+
fs.writeFileSync(${JSON.stringify(argsFile)}, JSON.stringify(process.argv.slice(2)));
|
|
854
|
+
console.log('https://github.com/acme/widgets/issues/42');
|
|
855
|
+
`,
|
|
856
|
+
{mode: 0o755},
|
|
857
|
+
);
|
|
858
|
+
fs.chmodSync(path.join(binDir, 'gh'), 0o755);
|
|
859
|
+
vi.stubEnv('PATH', `${binDir}${path.delimiter}${process.env.PATH ?? ''}`);
|
|
860
|
+
|
|
861
|
+
// Without consent
|
|
862
|
+
const pending = await gapReport('Button', {
|
|
863
|
+
...reportOptions,
|
|
864
|
+
cwd: projectDir,
|
|
865
|
+
});
|
|
866
|
+
expect(pending.data.deliveries[0].status).toBe('consent_required');
|
|
867
|
+
expect(fs.existsSync(argsFile)).toBe(false);
|
|
868
|
+
|
|
869
|
+
// With consent
|
|
870
|
+
const filed = await gapReport('Button', {
|
|
871
|
+
...reportOptions,
|
|
872
|
+
confirmPublic: true,
|
|
873
|
+
cwd: projectDir,
|
|
874
|
+
});
|
|
875
|
+
expect(filed.data.deliveries[0].status).toBe('filed');
|
|
876
|
+
expect(filed.data.status).toBe('filed');
|
|
877
|
+
});
|
|
878
|
+
|
|
879
|
+
it('no-handler non-GitHub route returns routed_only', async () => {
|
|
880
|
+
configure([], {issuesUrl: 'https://tracker.example/new'});
|
|
881
|
+
|
|
882
|
+
const result = await gapReport('Button', {
|
|
883
|
+
...reportOptions,
|
|
884
|
+
confirmPublic: true,
|
|
885
|
+
cwd: projectDir,
|
|
886
|
+
});
|
|
887
|
+
|
|
888
|
+
expect(result.data.deliveries[0].status).toBe('routed_only');
|
|
889
|
+
expect(result.data.deliveries[0].url).toBe('https://tracker.example/new');
|
|
890
|
+
expect(result.data.status).toBe('routed_only');
|
|
891
|
+
});
|
|
892
|
+
|
|
893
|
+
it('no handler and no issues URL throws ERR_NOT_FOUND', async () => {
|
|
894
|
+
// Create a project with an integration that has no handler, no issuesUrl,
|
|
895
|
+
// and target an unknown package explicitly
|
|
896
|
+
const name = '@test/bare';
|
|
897
|
+
const dir = packageDir(name);
|
|
898
|
+
fs.mkdirSync(dir, {recursive: true});
|
|
899
|
+
fs.writeFileSync(
|
|
900
|
+
path.join(dir, 'package.json'),
|
|
901
|
+
JSON.stringify({name, version: '1.0.0'}),
|
|
902
|
+
);
|
|
903
|
+
fs.writeFileSync(
|
|
904
|
+
path.join(dir, 'astryx.integration.mjs'),
|
|
905
|
+
'export default {};\n',
|
|
906
|
+
);
|
|
907
|
+
configure([name]);
|
|
908
|
+
|
|
909
|
+
await expect(
|
|
910
|
+
gapReport('Button', {
|
|
911
|
+
...reportOptions,
|
|
912
|
+
package: name,
|
|
913
|
+
cwd: projectDir,
|
|
914
|
+
}),
|
|
915
|
+
).rejects.toMatchObject({code: 'ERR_NOT_FOUND'});
|
|
916
|
+
});
|
|
917
|
+
});
|
|
918
|
+
|
|
919
|
+
describe('gapReport target selection', () => {
|
|
920
|
+
it('routes to the unique component owner', async () => {
|
|
921
|
+
addIntegration({
|
|
922
|
+
name: '@test/owner',
|
|
923
|
+
audience: 'internal',
|
|
924
|
+
component: 'TargetWidget',
|
|
925
|
+
handleBody: "return {status: 'filed', message: report.target.package};",
|
|
926
|
+
});
|
|
927
|
+
configure(['@test/owner']);
|
|
928
|
+
|
|
929
|
+
const result = await gapReport('XDSTargetWidget', {
|
|
930
|
+
...reportOptions,
|
|
931
|
+
cwd: projectDir,
|
|
932
|
+
});
|
|
933
|
+
|
|
934
|
+
expect(result.data.package).toBe('@test/owner');
|
|
935
|
+
expect(result.data.deliveries[0].message).toBe('@test/owner');
|
|
936
|
+
});
|
|
937
|
+
|
|
938
|
+
it('uses explicit package', async () => {
|
|
939
|
+
addIntegration({
|
|
940
|
+
name: '@test/first',
|
|
941
|
+
audience: 'internal',
|
|
942
|
+
handleBody: "return {status: 'filed', message: 'first'};",
|
|
943
|
+
});
|
|
944
|
+
addIntegration({
|
|
945
|
+
name: '@test/second',
|
|
946
|
+
audience: 'internal',
|
|
947
|
+
handleBody: "return {status: 'filed', message: 'second'};",
|
|
948
|
+
});
|
|
949
|
+
configure(['@test/first', '@test/second']);
|
|
950
|
+
|
|
951
|
+
const result = await gapReport('General', {
|
|
952
|
+
...reportOptions,
|
|
953
|
+
package: '@test/second',
|
|
954
|
+
cwd: projectDir,
|
|
955
|
+
});
|
|
956
|
+
|
|
957
|
+
expect(result.data.package).toBe('@test/second');
|
|
958
|
+
// Both handlers still run (fan-out)
|
|
959
|
+
expect(result.data.deliveries).toHaveLength(2);
|
|
960
|
+
});
|
|
961
|
+
|
|
962
|
+
it('falls back to Core when no component owner found', async () => {
|
|
963
|
+
addIntegration({
|
|
964
|
+
name: '@test/no-match',
|
|
965
|
+
audience: 'internal',
|
|
966
|
+
handleBody: "return {status: 'filed', message: report.target.package};",
|
|
967
|
+
});
|
|
968
|
+
configure(['@test/no-match']);
|
|
969
|
+
|
|
970
|
+
const result = await gapReport('General', {
|
|
971
|
+
...reportOptions,
|
|
972
|
+
cwd: projectDir,
|
|
973
|
+
});
|
|
974
|
+
|
|
975
|
+
expect(result.data.package).toBe('@astryxdesign/core');
|
|
976
|
+
});
|
|
977
|
+
|
|
978
|
+
it('requires --package when multiple packages own the component', async () => {
|
|
979
|
+
addIntegration({
|
|
980
|
+
name: '@test/first',
|
|
981
|
+
component: 'SharedWidget',
|
|
982
|
+
audience: 'internal',
|
|
983
|
+
});
|
|
984
|
+
addIntegration({
|
|
985
|
+
name: '@test/second',
|
|
986
|
+
component: 'SharedWidget',
|
|
987
|
+
audience: 'internal',
|
|
988
|
+
});
|
|
989
|
+
configure(['@test/first', '@test/second']);
|
|
990
|
+
|
|
991
|
+
await expect(
|
|
992
|
+
gapReport('SharedWidget', {...reportOptions, cwd: projectDir}),
|
|
993
|
+
).rejects.toMatchObject({code: 'ERR_AMBIGUOUS_COMPONENT'});
|
|
994
|
+
});
|
|
995
|
+
});
|
|
996
|
+
|
|
997
|
+
describe('gapReport aggregate status and CLI exit', () => {
|
|
998
|
+
it('all filed → status filed', async () => {
|
|
999
|
+
addIntegration({
|
|
1000
|
+
name: '@test/a',
|
|
1001
|
+
audience: 'internal',
|
|
1002
|
+
handleBody: "return {status: 'filed', message: 'a'};",
|
|
1003
|
+
});
|
|
1004
|
+
configure(['@test/a']);
|
|
1005
|
+
|
|
1006
|
+
const result = await gapReport('General', {
|
|
1007
|
+
...reportOptions,
|
|
1008
|
+
cwd: projectDir,
|
|
1009
|
+
});
|
|
1010
|
+
expect(result.data.status).toBe('filed');
|
|
1011
|
+
});
|
|
1012
|
+
|
|
1013
|
+
it('mix of filed and failed → status partial', async () => {
|
|
1014
|
+
addIntegration({
|
|
1015
|
+
name: '@test/fail',
|
|
1016
|
+
audience: 'internal',
|
|
1017
|
+
handleBody: "throw new Error('boom');",
|
|
1018
|
+
});
|
|
1019
|
+
addIntegration({
|
|
1020
|
+
name: '@test/ok',
|
|
1021
|
+
audience: 'internal',
|
|
1022
|
+
handleBody: "return {status: 'filed', message: 'ok'};",
|
|
1023
|
+
});
|
|
1024
|
+
configure(['@test/fail', '@test/ok']);
|
|
1025
|
+
|
|
1026
|
+
const result = await gapReport('General', {
|
|
1027
|
+
...reportOptions,
|
|
1028
|
+
cwd: projectDir,
|
|
1029
|
+
});
|
|
1030
|
+
expect(result.data.status).toBe('partial');
|
|
1031
|
+
});
|
|
1032
|
+
|
|
1033
|
+
it('mix of failed and consent-required → status partial', async () => {
|
|
1034
|
+
addIntegration({
|
|
1035
|
+
name: '@test/fail',
|
|
1036
|
+
audience: 'internal',
|
|
1037
|
+
handleBody: "throw new Error('boom');",
|
|
1038
|
+
});
|
|
1039
|
+
addIntegration({
|
|
1040
|
+
name: '@test/public',
|
|
1041
|
+
audience: 'public',
|
|
1042
|
+
handleBody: "return {status: 'filed', message: 'public'};",
|
|
1043
|
+
});
|
|
1044
|
+
configure(['@test/fail', '@test/public']);
|
|
1045
|
+
|
|
1046
|
+
const result = await gapReport('General', {
|
|
1047
|
+
...reportOptions,
|
|
1048
|
+
cwd: projectDir,
|
|
1049
|
+
});
|
|
1050
|
+
|
|
1051
|
+
expect(result.data.status).toBe('partial');
|
|
1052
|
+
expect(result.data.deliveries.map(d => d.status)).toEqual([
|
|
1053
|
+
'failed',
|
|
1054
|
+
'consent_required',
|
|
1055
|
+
]);
|
|
1056
|
+
});
|
|
1057
|
+
|
|
1058
|
+
it('all failed → status failed', async () => {
|
|
1059
|
+
addIntegration({
|
|
1060
|
+
name: '@test/fail1',
|
|
1061
|
+
audience: 'internal',
|
|
1062
|
+
handleBody: "throw new Error('boom');",
|
|
1063
|
+
});
|
|
1064
|
+
configure(['@test/fail1']);
|
|
1065
|
+
|
|
1066
|
+
const result = await gapReport('General', {
|
|
1067
|
+
...reportOptions,
|
|
1068
|
+
cwd: projectDir,
|
|
1069
|
+
});
|
|
1070
|
+
expect(result.data.status).toBe('failed');
|
|
1071
|
+
});
|
|
1072
|
+
|
|
1073
|
+
it('report event shape is plain camelCase with no internal context', async () => {
|
|
1074
|
+
addIntegration({
|
|
1075
|
+
name: '@test/inspector',
|
|
1076
|
+
audience: 'internal',
|
|
1077
|
+
handleBody: `
|
|
1078
|
+
const keys = Object.keys(report).sort();
|
|
1079
|
+
const targetKeys = Object.keys(report.target).sort();
|
|
1080
|
+
return {
|
|
1081
|
+
status: 'filed',
|
|
1082
|
+
message: JSON.stringify({
|
|
1083
|
+
keys,
|
|
1084
|
+
targetKeys,
|
|
1085
|
+
source: report.source,
|
|
1086
|
+
sv: report.schemaVersion,
|
|
1087
|
+
}),
|
|
1088
|
+
};
|
|
1089
|
+
`,
|
|
1090
|
+
});
|
|
1091
|
+
configure(['@test/inspector']);
|
|
1092
|
+
vi.stubEnv('ASTRYX_AGENT_ID', 'secret-agent');
|
|
1093
|
+
|
|
1094
|
+
const result = await gapReport('Button', {
|
|
1095
|
+
...reportOptions,
|
|
1096
|
+
cwd: projectDir,
|
|
1097
|
+
});
|
|
1098
|
+
|
|
1099
|
+
const info = JSON.parse(result.data.deliveries[0].message);
|
|
1100
|
+
expect(info.sv).toBe(1);
|
|
1101
|
+
expect(info.source).toBe('ai');
|
|
1102
|
+
expect(info.keys).toEqual([
|
|
1103
|
+
'category',
|
|
1104
|
+
'categoryLabel',
|
|
1105
|
+
'component',
|
|
1106
|
+
'detail',
|
|
1107
|
+
'intention',
|
|
1108
|
+
'schemaVersion',
|
|
1109
|
+
'source',
|
|
1110
|
+
'target',
|
|
1111
|
+
'timestamp',
|
|
1112
|
+
]);
|
|
1113
|
+
expect(info.targetKeys).toEqual(['issuesUrl', 'package', 'version']);
|
|
1114
|
+
// No handler-private context fields or raw agent identifiers
|
|
1115
|
+
expect(result.data.deliveries[0].message).not.toContain('debug');
|
|
1116
|
+
expect(result.data.deliveries[0].message).not.toContain('context');
|
|
1117
|
+
expect(result.data.deliveries[0].message).not.toContain('secret-agent');
|
|
1118
|
+
});
|
|
1119
|
+
|
|
1120
|
+
it('receipt type is gap-report.file for the aggregate response', async () => {
|
|
1121
|
+
addIntegration({
|
|
1122
|
+
name: '@test/basic',
|
|
1123
|
+
audience: 'internal',
|
|
1124
|
+
handleBody: "return {status: 'filed', message: 'ok'};",
|
|
1125
|
+
});
|
|
1126
|
+
configure(['@test/basic']);
|
|
1127
|
+
|
|
1128
|
+
const result = await gapReport('General', {
|
|
1129
|
+
...reportOptions,
|
|
1130
|
+
cwd: projectDir,
|
|
1131
|
+
});
|
|
1132
|
+
|
|
1133
|
+
expect(result.type).toBe('gap-report.file');
|
|
1134
|
+
expect(result.data).toHaveProperty('deliveries');
|
|
1135
|
+
expect(result.data).toHaveProperty('filedCount');
|
|
1136
|
+
expect(result.data).toHaveProperty('routedOnlyCount');
|
|
1137
|
+
expect(result.data).toHaveProperty('status');
|
|
1138
|
+
expect(result.data).toHaveProperty('package');
|
|
1139
|
+
expect(result.data).toHaveProperty('issuesUrl');
|
|
1140
|
+
});
|
|
1141
|
+
});
|
|
1142
|
+
|
|
1143
|
+
describe('gapReport strict receipt validation', () => {
|
|
1144
|
+
it('rejects receipt with unknown fields', async () => {
|
|
1145
|
+
addIntegration({
|
|
1146
|
+
name: '@test/extra-fields',
|
|
1147
|
+
audience: 'internal',
|
|
1148
|
+
handleBody: "return {status: 'filed', message: 'ok', extra: true};",
|
|
1149
|
+
});
|
|
1150
|
+
configure(['@test/extra-fields']);
|
|
1151
|
+
|
|
1152
|
+
const result = await gapReport('General', {
|
|
1153
|
+
...reportOptions,
|
|
1154
|
+
cwd: projectDir,
|
|
1155
|
+
});
|
|
1156
|
+
|
|
1157
|
+
expect(result.data.deliveries[0].status).toBe('failed');
|
|
1158
|
+
});
|
|
1159
|
+
|
|
1160
|
+
it('rejects routed_only without url', async () => {
|
|
1161
|
+
addIntegration({
|
|
1162
|
+
name: '@test/no-url',
|
|
1163
|
+
audience: 'internal',
|
|
1164
|
+
handleBody: "return {status: 'routed_only', message: 'but no url'};",
|
|
1165
|
+
});
|
|
1166
|
+
configure(['@test/no-url']);
|
|
1167
|
+
|
|
1168
|
+
const result = await gapReport('General', {
|
|
1169
|
+
...reportOptions,
|
|
1170
|
+
cwd: projectDir,
|
|
1171
|
+
});
|
|
1172
|
+
|
|
1173
|
+
expect(result.data.deliveries[0].status).toBe('failed');
|
|
1174
|
+
});
|
|
1175
|
+
|
|
1176
|
+
it('accepts valid routed_only with url', async () => {
|
|
1177
|
+
addIntegration({
|
|
1178
|
+
name: '@test/routed',
|
|
1179
|
+
audience: 'internal',
|
|
1180
|
+
handleBody:
|
|
1181
|
+
"return {status: 'routed_only', url: 'https://example.com/issue/1'};",
|
|
1182
|
+
});
|
|
1183
|
+
configure(['@test/routed']);
|
|
1184
|
+
|
|
1185
|
+
const result = await gapReport('General', {
|
|
1186
|
+
...reportOptions,
|
|
1187
|
+
cwd: projectDir,
|
|
1188
|
+
});
|
|
1189
|
+
|
|
1190
|
+
expect(result.data.deliveries[0].status).toBe('routed_only');
|
|
1191
|
+
expect(result.data.routedOnlyCount).toBe(1);
|
|
1192
|
+
});
|
|
1193
|
+
|
|
1194
|
+
it('accepts skipped without url or message', async () => {
|
|
1195
|
+
addIntegration({
|
|
1196
|
+
name: '@test/skipper',
|
|
1197
|
+
audience: 'internal',
|
|
1198
|
+
handleBody: "return {status: 'skipped'};",
|
|
1199
|
+
});
|
|
1200
|
+
configure(['@test/skipper']);
|
|
1201
|
+
|
|
1202
|
+
const result = await gapReport('General', {
|
|
1203
|
+
...reportOptions,
|
|
1204
|
+
cwd: projectDir,
|
|
1205
|
+
});
|
|
1206
|
+
|
|
1207
|
+
expect(result.data.deliveries[0].status).toBe('skipped');
|
|
1208
|
+
expect(result.data.status).toBe('skipped');
|
|
1209
|
+
});
|
|
1210
|
+
});
|