@teambit/defender.ui.test-page 0.0.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/dist/index.d.ts +5 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/tests-page.d.ts +7 -0
- package/dist/tests-page.js +130 -0
- package/dist/tests-page.js.map +1 -0
- package/dist/tests-page.module.scss +20 -0
- package/dist/tsconfig.json +32 -0
- package/index.ts +6 -0
- package/package-tar/teambit-defender.ui.test-page-0.0.1.tgz +0 -0
- package/package.json +58 -0
- package/preview-1660620618310.js +5 -0
- package/tests-page.module.scss +20 -0
- package/tests-page.tsx +142 -0
- package/tsconfig.json +32 -0
- package/types/asset.d.ts +29 -0
- package/types/style.d.ts +42 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TestsPage = exports.styles = void 0;
|
|
7
|
+
const tests_page_module_scss_1 = __importDefault(require("./tests-page.module.scss"));
|
|
8
|
+
const { testsPage, testBlock } = tests_page_module_scss_1.default;
|
|
9
|
+
exports.styles = { testsPage, testBlock };
|
|
10
|
+
var tests_page_1 = require("./tests-page");
|
|
11
|
+
Object.defineProperty(exports, "TestsPage", { enumerable: true, get: function () { return tests_page_1.TestsPage; } });
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;AAAA,sFAAkD;AAElD,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,gCAAU,CAAC;AAC/B,QAAA,MAAM,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAE/C,2CAAyC;AAAhC,uGAAA,SAAS,OAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EmptyStateSlot } from '@teambit/tester';
|
|
2
|
+
import { HTMLAttributes } from 'react';
|
|
3
|
+
declare type TestsPageProps = {
|
|
4
|
+
emptyState: EmptyStateSlot;
|
|
5
|
+
} & HTMLAttributes<HTMLDivElement>;
|
|
6
|
+
export declare function TestsPage({ className, emptyState }: TestsPageProps): JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.TestsPage = void 0;
|
|
26
|
+
const client_1 = require("@apollo/client");
|
|
27
|
+
const component_1 = require("@teambit/component");
|
|
28
|
+
const ui_foundation_ui_react_router_use_query_1 = require("@teambit/ui-foundation.ui.react-router.use-query");
|
|
29
|
+
const documenter_ui_heading_1 = require("@teambit/documenter.ui.heading");
|
|
30
|
+
const design_ui_separator_1 = require("@teambit/design.ui.separator");
|
|
31
|
+
const design_ui_empty_box_1 = require("@teambit/design.ui.empty-box");
|
|
32
|
+
const mdx_ui_mdx_layout_1 = require("@teambit/mdx.ui.mdx-layout");
|
|
33
|
+
const design_ui_alert_card_1 = require("@teambit/design.ui.alert-card");
|
|
34
|
+
const defender_ui_test_loader_1 = require("@teambit/defender.ui.test-loader");
|
|
35
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
36
|
+
const react_1 = __importStar(require("react"));
|
|
37
|
+
const defender_ui_test_table_1 = require("@teambit/defender.ui.test-table");
|
|
38
|
+
const tests_page_module_scss_1 = __importDefault(require("./tests-page.module.scss"));
|
|
39
|
+
const TESTS_SUBSCRIPTION_CHANGED = (0, client_1.gql) `
|
|
40
|
+
subscription OnTestsChanged($id: String!) {
|
|
41
|
+
testsChanged(id: $id) {
|
|
42
|
+
testsResults {
|
|
43
|
+
testFiles {
|
|
44
|
+
file
|
|
45
|
+
duration
|
|
46
|
+
pass
|
|
47
|
+
failed
|
|
48
|
+
pending
|
|
49
|
+
errorStr
|
|
50
|
+
tests {
|
|
51
|
+
ancestor
|
|
52
|
+
duration
|
|
53
|
+
status
|
|
54
|
+
name
|
|
55
|
+
error
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
const GET_COMPONENT = (0, client_1.gql) `
|
|
63
|
+
query ($id: String!) {
|
|
64
|
+
getHost {
|
|
65
|
+
id # for GQL caching
|
|
66
|
+
getTests(id: $id) {
|
|
67
|
+
loading
|
|
68
|
+
testsResults {
|
|
69
|
+
testFiles {
|
|
70
|
+
file
|
|
71
|
+
duration
|
|
72
|
+
pass
|
|
73
|
+
failed
|
|
74
|
+
pending
|
|
75
|
+
errorStr
|
|
76
|
+
tests {
|
|
77
|
+
ancestor
|
|
78
|
+
duration
|
|
79
|
+
status
|
|
80
|
+
name
|
|
81
|
+
error
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
function TestsPage({ className, emptyState }) {
|
|
90
|
+
var _a, _b, _c, _d;
|
|
91
|
+
const query = (0, ui_foundation_ui_react_router_use_query_1.useQuery)();
|
|
92
|
+
const component = (0, react_1.useContext)(component_1.ComponentContext);
|
|
93
|
+
const queryHasVersion = query.get('version');
|
|
94
|
+
const id = queryHasVersion ? component.id.toString() : component.id.toStringWithoutVersion();
|
|
95
|
+
const onTestsChanged = (0, client_1.useSubscription)(TESTS_SUBSCRIPTION_CHANGED, {
|
|
96
|
+
variables: { id },
|
|
97
|
+
});
|
|
98
|
+
const { data } = (0, client_1.useQuery)(GET_COMPONENT, {
|
|
99
|
+
variables: { id },
|
|
100
|
+
});
|
|
101
|
+
const testData = ((_a = onTestsChanged.data) === null || _a === void 0 ? void 0 : _a.testsChanged) || ((_b = data === null || data === void 0 ? void 0 : data.getHost) === null || _b === void 0 ? void 0 : _b.getTests);
|
|
102
|
+
const testResults = (_c = testData === null || testData === void 0 ? void 0 : testData.testsResults) === null || _c === void 0 ? void 0 : _c.testFiles;
|
|
103
|
+
// TODO: change loading EmptyBox
|
|
104
|
+
if (testData === null || testData === void 0 ? void 0 : testData.loading)
|
|
105
|
+
return react_1.default.createElement(defender_ui_test_loader_1.TestLoader, null);
|
|
106
|
+
const env = (_d = component.environment) === null || _d === void 0 ? void 0 : _d.id;
|
|
107
|
+
const EmptyStateTemplate = emptyState.get(env || '');
|
|
108
|
+
if ((testResults === null || (testData === null || testData === void 0 ? void 0 : testData.testsResults) === null) &&
|
|
109
|
+
component.host === 'teambit.workspace/workspace' &&
|
|
110
|
+
EmptyStateTemplate) {
|
|
111
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(tests_page_module_scss_1.default.testsPage, className) },
|
|
112
|
+
react_1.default.createElement("div", null,
|
|
113
|
+
react_1.default.createElement(documenter_ui_heading_1.H1, { className: tests_page_module_scss_1.default.title }, "Tests"),
|
|
114
|
+
react_1.default.createElement(design_ui_separator_1.Separator, { isPresentational: true, className: tests_page_module_scss_1.default.separator }),
|
|
115
|
+
react_1.default.createElement(design_ui_alert_card_1.AlertCard, { level: "info", title: "There are no\n tests for this Component. Learn how to add tests:" },
|
|
116
|
+
react_1.default.createElement(mdx_ui_mdx_layout_1.MDXLayout, null,
|
|
117
|
+
react_1.default.createElement(EmptyStateTemplate, null))))));
|
|
118
|
+
}
|
|
119
|
+
// TODO: get the docs domain from the community aspect and pass it here as a prop
|
|
120
|
+
if (testResults === null || (testData === null || testData === void 0 ? void 0 : testData.testsResults) === null) {
|
|
121
|
+
return (react_1.default.createElement(design_ui_empty_box_1.EmptyBox, { title: "This component doesn\u2019t have any tests.", linkText: "Learn how to add tests to your components", link: `https://bit.dev/docs/dev-services-overview/tester/tester-overview` }));
|
|
122
|
+
}
|
|
123
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(tests_page_module_scss_1.default.testsPage, className) },
|
|
124
|
+
react_1.default.createElement("div", null,
|
|
125
|
+
react_1.default.createElement(documenter_ui_heading_1.H1, { className: tests_page_module_scss_1.default.title }, "Tests"),
|
|
126
|
+
react_1.default.createElement(design_ui_separator_1.Separator, { isPresentational: true, className: tests_page_module_scss_1.default.separator }),
|
|
127
|
+
react_1.default.createElement(defender_ui_test_table_1.TestTable, { testResults: testResults, className: tests_page_module_scss_1.default.testBlock }))));
|
|
128
|
+
}
|
|
129
|
+
exports.TestsPage = TestsPage;
|
|
130
|
+
//# sourceMappingURL=tests-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tests-page.js","s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,SAAS,EAAE,SAAS,CAAC;QACrD;YACE,8BAAC,0BAAE,IAAC,SAAS,EAAE,gCAAM,CAAC,KAAK,YAAY;YACvC,8BAAC,+BAAS,IAAC,gBAAgB,QAAC,SAAS,EAAE,gCAAM,CAAC,SAAS,GAAI;YAC3D,8BAAC,kCAAS,IAAC,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,gCAAM,CAAC,SAAS,GAAI,CAChE,CACF,CACP,CAAC;AACJ,CAAC;AAtED,8BAsEC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.testsPage {
|
|
2
|
+
padding: 50px 40px 100px 40px;
|
|
3
|
+
width: 100%;
|
|
4
|
+
overflow-y: auto;
|
|
5
|
+
max-width: 1440px;
|
|
6
|
+
margin: 0 auto;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
|
|
9
|
+
.title {
|
|
10
|
+
margin-bottom: 24px;
|
|
11
|
+
font-size: var(--bit-h-xs, 26px);
|
|
12
|
+
}
|
|
13
|
+
.separator {
|
|
14
|
+
margin-bottom: 41px;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.testBlock {
|
|
19
|
+
margin-bottom: 50px;
|
|
20
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": [
|
|
4
|
+
"es2019",
|
|
5
|
+
"DOM",
|
|
6
|
+
"ES6",
|
|
7
|
+
"DOM.Iterable"
|
|
8
|
+
],
|
|
9
|
+
"target": "es2015",
|
|
10
|
+
"module": "CommonJS",
|
|
11
|
+
"jsx": "react",
|
|
12
|
+
"allowJs": true,
|
|
13
|
+
"composite": true,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"sourceMap": true,
|
|
16
|
+
"skipLibCheck": true,
|
|
17
|
+
"experimentalDecorators": true,
|
|
18
|
+
"outDir": "dist",
|
|
19
|
+
"moduleResolution": "node",
|
|
20
|
+
"esModuleInterop": true,
|
|
21
|
+
"rootDir": ".",
|
|
22
|
+
"resolveJsonModule": true
|
|
23
|
+
},
|
|
24
|
+
"exclude": [
|
|
25
|
+
"dist",
|
|
26
|
+
"package.json"
|
|
27
|
+
],
|
|
28
|
+
"include": [
|
|
29
|
+
"**/*",
|
|
30
|
+
"**/*.json"
|
|
31
|
+
]
|
|
32
|
+
}
|
package/index.ts
ADDED
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@teambit/defender.ui.test-page",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"componentId": {
|
|
6
|
+
"scope": "teambit.defender",
|
|
7
|
+
"name": "ui/test-page",
|
|
8
|
+
"version": "0.0.1"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"classnames": "2.2.6",
|
|
12
|
+
"core-js": "^3.0.0",
|
|
13
|
+
"@teambit/design.ui.separator": "0.0.354",
|
|
14
|
+
"@teambit/documenter.ui.heading": "4.1.1",
|
|
15
|
+
"@teambit/defender.ui.test-loader": "0.0.490",
|
|
16
|
+
"@teambit/defender.ui.test-table": "0.0.495",
|
|
17
|
+
"@teambit/design.ui.alert-card": "0.0.17",
|
|
18
|
+
"@teambit/design.ui.empty-box": "0.0.354",
|
|
19
|
+
"@teambit/mdx.ui.mdx-layout": "0.0.501",
|
|
20
|
+
"@teambit/ui-foundation.ui.react-router.use-query": "0.0.487"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/classnames": "2.2.11",
|
|
24
|
+
"@types/react": "^17.0.8",
|
|
25
|
+
"@types/mocha": "9.1.0",
|
|
26
|
+
"@types/testing-library__jest-dom": "5.9.5",
|
|
27
|
+
"@babel/runtime": "7.12.18",
|
|
28
|
+
"@types/jest": "^26.0.0",
|
|
29
|
+
"@types/react-dom": "^17.0.5",
|
|
30
|
+
"@types/node": "12.20.4"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@apollo/client": "^3.0.0",
|
|
34
|
+
"react-dom": "^16.8.0 || ^17.0.0",
|
|
35
|
+
"react": "^16.8.0 || ^17.0.0"
|
|
36
|
+
},
|
|
37
|
+
"license": "Apache-2.0",
|
|
38
|
+
"private": false,
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=12.22.0"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/teambit/bit"
|
|
45
|
+
},
|
|
46
|
+
"keywords": [
|
|
47
|
+
"bit",
|
|
48
|
+
"components",
|
|
49
|
+
"collaboration",
|
|
50
|
+
"web",
|
|
51
|
+
"react",
|
|
52
|
+
"react-components",
|
|
53
|
+
"angular",
|
|
54
|
+
"angular-components",
|
|
55
|
+
"vue",
|
|
56
|
+
"vue-components"
|
|
57
|
+
]
|
|
58
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.testsPage {
|
|
2
|
+
padding: 50px 40px 100px 40px;
|
|
3
|
+
width: 100%;
|
|
4
|
+
overflow-y: auto;
|
|
5
|
+
max-width: 1440px;
|
|
6
|
+
margin: 0 auto;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
|
|
9
|
+
.title {
|
|
10
|
+
margin-bottom: 24px;
|
|
11
|
+
font-size: var(--bit-h-xs, 26px);
|
|
12
|
+
}
|
|
13
|
+
.separator {
|
|
14
|
+
margin-bottom: 41px;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.testBlock {
|
|
19
|
+
margin-bottom: 50px;
|
|
20
|
+
}
|
package/tests-page.tsx
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { useQuery, useSubscription, gql } from '@apollo/client';
|
|
2
|
+
import { ComponentContext } from '@teambit/component';
|
|
3
|
+
import { useQuery as useRouterQuery } from '@teambit/ui-foundation.ui.react-router.use-query';
|
|
4
|
+
import { H1 } from '@teambit/documenter.ui.heading';
|
|
5
|
+
import { Separator } from '@teambit/design.ui.separator';
|
|
6
|
+
import { EmptyBox } from '@teambit/design.ui.empty-box';
|
|
7
|
+
import { MDXLayout } from '@teambit/mdx.ui.mdx-layout';
|
|
8
|
+
import { AlertCard } from '@teambit/design.ui.alert-card';
|
|
9
|
+
import { TestLoader } from '@teambit/defender.ui.test-loader';
|
|
10
|
+
import { EmptyStateSlot } from '@teambit/tester';
|
|
11
|
+
import classNames from 'classnames';
|
|
12
|
+
import React, { HTMLAttributes, useContext } from 'react';
|
|
13
|
+
import { TestTable } from '@teambit/defender.ui.test-table';
|
|
14
|
+
import styles from './tests-page.module.scss';
|
|
15
|
+
|
|
16
|
+
const TESTS_SUBSCRIPTION_CHANGED = gql`
|
|
17
|
+
subscription OnTestsChanged($id: String!) {
|
|
18
|
+
testsChanged(id: $id) {
|
|
19
|
+
testsResults {
|
|
20
|
+
testFiles {
|
|
21
|
+
file
|
|
22
|
+
duration
|
|
23
|
+
pass
|
|
24
|
+
failed
|
|
25
|
+
pending
|
|
26
|
+
errorStr
|
|
27
|
+
tests {
|
|
28
|
+
ancestor
|
|
29
|
+
duration
|
|
30
|
+
status
|
|
31
|
+
name
|
|
32
|
+
error
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
const GET_COMPONENT = gql`
|
|
41
|
+
query ($id: String!) {
|
|
42
|
+
getHost {
|
|
43
|
+
id # for GQL caching
|
|
44
|
+
getTests(id: $id) {
|
|
45
|
+
loading
|
|
46
|
+
testsResults {
|
|
47
|
+
testFiles {
|
|
48
|
+
file
|
|
49
|
+
duration
|
|
50
|
+
pass
|
|
51
|
+
failed
|
|
52
|
+
pending
|
|
53
|
+
errorStr
|
|
54
|
+
tests {
|
|
55
|
+
ancestor
|
|
56
|
+
duration
|
|
57
|
+
status
|
|
58
|
+
name
|
|
59
|
+
error
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
|
|
68
|
+
type TestsPageProps = {
|
|
69
|
+
emptyState: EmptyStateSlot;
|
|
70
|
+
} & HTMLAttributes<HTMLDivElement>;
|
|
71
|
+
|
|
72
|
+
export function TestsPage({ className, emptyState }: TestsPageProps) {
|
|
73
|
+
const query = useRouterQuery();
|
|
74
|
+
|
|
75
|
+
const component = useContext(ComponentContext);
|
|
76
|
+
|
|
77
|
+
const queryHasVersion = query.get('version');
|
|
78
|
+
|
|
79
|
+
const id = queryHasVersion ? component.id.toString() : component.id.toStringWithoutVersion();
|
|
80
|
+
|
|
81
|
+
const onTestsChanged = useSubscription(TESTS_SUBSCRIPTION_CHANGED, {
|
|
82
|
+
variables: { id },
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const { data } = useQuery(GET_COMPONENT, {
|
|
86
|
+
variables: { id },
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const testData = onTestsChanged.data?.testsChanged || data?.getHost?.getTests;
|
|
90
|
+
const testResults = testData?.testsResults?.testFiles;
|
|
91
|
+
|
|
92
|
+
// TODO: change loading EmptyBox
|
|
93
|
+
if (testData?.loading) return <TestLoader />;
|
|
94
|
+
|
|
95
|
+
const env = component.environment?.id;
|
|
96
|
+
const EmptyStateTemplate = emptyState.get(env || '');
|
|
97
|
+
|
|
98
|
+
if (
|
|
99
|
+
(testResults === null || testData?.testsResults === null) &&
|
|
100
|
+
component.host === 'teambit.workspace/workspace' &&
|
|
101
|
+
EmptyStateTemplate
|
|
102
|
+
) {
|
|
103
|
+
return (
|
|
104
|
+
<div className={classNames(styles.testsPage, className)}>
|
|
105
|
+
<div>
|
|
106
|
+
<H1 className={styles.title}>Tests</H1>
|
|
107
|
+
<Separator isPresentational className={styles.separator} />
|
|
108
|
+
<AlertCard
|
|
109
|
+
level="info"
|
|
110
|
+
title="There are no
|
|
111
|
+
tests for this Component. Learn how to add tests:"
|
|
112
|
+
>
|
|
113
|
+
<MDXLayout>
|
|
114
|
+
<EmptyStateTemplate />
|
|
115
|
+
</MDXLayout>
|
|
116
|
+
</AlertCard>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// TODO: get the docs domain from the community aspect and pass it here as a prop
|
|
123
|
+
if (testResults === null || testData?.testsResults === null) {
|
|
124
|
+
return (
|
|
125
|
+
<EmptyBox
|
|
126
|
+
title="This component doesn’t have any tests."
|
|
127
|
+
linkText="Learn how to add tests to your components"
|
|
128
|
+
link={`https://bit.dev/docs/dev-services-overview/tester/tester-overview`}
|
|
129
|
+
/>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<div className={classNames(styles.testsPage, className)}>
|
|
135
|
+
<div>
|
|
136
|
+
<H1 className={styles.title}>Tests</H1>
|
|
137
|
+
<Separator isPresentational className={styles.separator} />
|
|
138
|
+
<TestTable testResults={testResults} className={styles.testBlock} />
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
);
|
|
142
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": [
|
|
4
|
+
"es2019",
|
|
5
|
+
"DOM",
|
|
6
|
+
"ES6",
|
|
7
|
+
"DOM.Iterable"
|
|
8
|
+
],
|
|
9
|
+
"target": "es2015",
|
|
10
|
+
"module": "CommonJS",
|
|
11
|
+
"jsx": "react",
|
|
12
|
+
"allowJs": true,
|
|
13
|
+
"composite": true,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"sourceMap": true,
|
|
16
|
+
"skipLibCheck": true,
|
|
17
|
+
"experimentalDecorators": true,
|
|
18
|
+
"outDir": "dist",
|
|
19
|
+
"moduleResolution": "node",
|
|
20
|
+
"esModuleInterop": true,
|
|
21
|
+
"rootDir": ".",
|
|
22
|
+
"resolveJsonModule": true
|
|
23
|
+
},
|
|
24
|
+
"exclude": [
|
|
25
|
+
"dist",
|
|
26
|
+
"package.json"
|
|
27
|
+
],
|
|
28
|
+
"include": [
|
|
29
|
+
"**/*",
|
|
30
|
+
"**/*.json"
|
|
31
|
+
]
|
|
32
|
+
}
|
package/types/asset.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare module '*.png' {
|
|
2
|
+
const value: any;
|
|
3
|
+
export = value;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.svg' {
|
|
6
|
+
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
+
|
|
8
|
+
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
|
9
|
+
const src: string;
|
|
10
|
+
export default src;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// @TODO Gilad
|
|
14
|
+
declare module '*.jpg' {
|
|
15
|
+
const value: any;
|
|
16
|
+
export = value;
|
|
17
|
+
}
|
|
18
|
+
declare module '*.jpeg' {
|
|
19
|
+
const value: any;
|
|
20
|
+
export = value;
|
|
21
|
+
}
|
|
22
|
+
declare module '*.gif' {
|
|
23
|
+
const value: any;
|
|
24
|
+
export = value;
|
|
25
|
+
}
|
|
26
|
+
declare module '*.bmp' {
|
|
27
|
+
const value: any;
|
|
28
|
+
export = value;
|
|
29
|
+
}
|
package/types/style.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare module '*.module.css' {
|
|
2
|
+
const classes: { readonly [key: string]: string };
|
|
3
|
+
export default classes;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.module.scss' {
|
|
6
|
+
const classes: { readonly [key: string]: string };
|
|
7
|
+
export default classes;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.module.sass' {
|
|
10
|
+
const classes: { readonly [key: string]: string };
|
|
11
|
+
export default classes;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.module.less' {
|
|
15
|
+
const classes: { readonly [key: string]: string };
|
|
16
|
+
export default classes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*.less' {
|
|
20
|
+
const classes: { readonly [key: string]: string };
|
|
21
|
+
export default classes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.css' {
|
|
25
|
+
const classes: { readonly [key: string]: string };
|
|
26
|
+
export default classes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module '*.sass' {
|
|
30
|
+
const classes: { readonly [key: string]: string };
|
|
31
|
+
export default classes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*.scss' {
|
|
35
|
+
const classes: { readonly [key: string]: string };
|
|
36
|
+
export default classes;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module '*.mdx' {
|
|
40
|
+
const component: any;
|
|
41
|
+
export default component;
|
|
42
|
+
}
|