1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

refactor: adapt to Vite (#940)

* chore: adapt to vite

* remove react-scripts

* add jsdom dep, update snaps

* fix tests

* fix: formatting

* fix: vercel rewrite

* fix: regeneratorRuntime is not defined

Co-authored-by: Tymoteusz Czech <tymek+gpg@getunleash.ai>
Co-authored-by: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com>
This commit is contained in:
Nuno Góis 2022-05-05 16:15:22 +01:00 committed by GitHub
parent b40a2f2bf1
commit 5872a1c82c
27 changed files with 2598 additions and 1248 deletions

View File

@ -18,5 +18,6 @@
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>

View File

@ -24,12 +24,12 @@
},
"license": "Apache-2.0",
"scripts": {
"build": "INLINE_RUNTIME_CHUNK=false react-scripts build",
"build": "tsc && vite build",
"lint": "eslint src",
"start": "react-scripts start",
"start": "vite",
"start:heroku": "UNLEASH_API=https://unleash.herokuapp.com yarn run start",
"start:enterprise": "UNLEASH_API=https://unleash4.herokuapp.com yarn run start",
"test": "react-scripts test",
"test": "vitest",
"prepare": "yarn run build",
"fmt": "prettier src --write --loglevel warn",
"fmt:check": "prettier src --check",
@ -60,6 +60,7 @@
"@types/react-test-renderer": "17.0.2",
"@types/react-timeago": "4.1.3",
"@types/semver": "^7.3.9",
"@vitejs/plugin-react": "^1.3.1",
"chart.js": "3.7.1",
"chartjs-adapter-date-fns": "2.0.0",
"classnames": "2.3.1",
@ -71,6 +72,7 @@
"fast-json-patch": "3.1.1",
"http-proxy-middleware": "2.0.6",
"immer": "^9.0.12",
"jsdom": "^19.0.0",
"lodash.clonedeep": "4.5.0",
"msw": "^0.39.2",
"pkginfo": "^0.4.1",
@ -91,7 +93,13 @@
"semver": "7.3.7",
"swr": "1.3.0",
"tss-react": "^3.6.2",
"typescript": "4.6.4"
"typescript": "4.6.4",
"vite": "^2.9.6",
"vite-plugin-env-compatible": "^1.1.1",
"vite-plugin-svgr": "^2.0.0",
"vite-tsconfig-paths": "^3.4.1",
"vitest": "^0.10.0",
"whatwg-fetch": "^3.6.2"
},
"jest": {
"moduleNameMapper": {

View File

@ -1,3 +1,4 @@
import { vi } from 'vitest';
import React from 'react';
import { screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
@ -7,8 +8,8 @@ import {
SelectProjectInput,
} from './SelectProjectInput';
const onChange = jest.fn();
const onFocus = jest.fn();
const onChange = vi.fn();
const onFocus = vi.fn();
const mockProps: ISelectProjectInputProps = {
options: [

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1
exports[`Date component - snapshot matching 1`] = `
Object {
{
"midday": "2022-03-15T12:00",
"midnight": "2022-03-15T00:00",
}

View File

@ -0,0 +1,291 @@
// Vitest Snapshot v1
exports[`renders correctly with one feature 1`] = `
[
<li
className="MuiListItem-root makeStyles-listItem-1 MuiListItem-gutters"
disabled={false}
>
<span
className="makeStyles-listItemMetric-2"
>
<div
aria-describedby={null}
className="makeStyles-container-8"
onBlur={[Function]}
onFocus={[Function]}
onMouseLeave={[Function]}
onMouseOver={[Function]}
onTouchEnd={[Function]}
onTouchStart={[Function]}
style={
{
"background": "#EDF0F1",
"fontSize": "0.8rem",
}
}
title="No usage reported from connected applications"
>
<span
style={
{
"fontSize": "1.4rem",
}
}
>
</span>
</div>
</span>
<span
className="makeStyles-listItemType-3 _hideLt600_1yorl_42"
>
<svg
aria-describedby={null}
aria-hidden={true}
className="MuiSvgIcon-root makeStyles-icon-9"
data-loading={true}
focusable="false"
onBlur={[Function]}
onFocus={[Function]}
onMouseLeave={[Function]}
onMouseOver={[Function]}
onTouchEnd={[Function]}
onTouchStart={[Function]}
title="This is a \\"\\" toggle"
viewBox="0 0 24 24"
>
<path
d="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0-4.42-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6 0-1.01.25-1.97.7-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4-4-4-4v3z"
/>
</svg>
</span>
<span
className="makeStyles-listItemLink-5"
>
<a
className="_listLink_1yorl_25 _truncate_1yorl_2"
href="/projects/default/features/Another"
onClick={[Function]}
>
<span
aria-describedby={null}
className="_toggleName_1yorl_84"
onBlur={[Function]}
onFocus={[Function]}
onMouseLeave={[Function]}
onMouseOver={[Function]}
onTouchEnd={[Function]}
onTouchStart={[Function]}
title="another's description"
>
Another
 
</span>
<span />
<small>
<time
dateTime="2018-02-04T20:27:52.127Z"
title="2018-02-04T20:27:52.127Z"
>
4 years ago
</time>
</small>
<div>
<span
className="_truncate_1yorl_2"
>
<small>
another's description
</small>
</span>
</div>
</a>
</span>
<span
className="makeStyles-listItemStrategies-6 _hideLt920_1yorl_37"
>
<a
className="makeStyles-disabledLink-7"
href="/projects/default"
onClick={[Function]}
style={
{
"textDecoration": "none",
}
}
>
<div
className="MuiChip-root MuiChip-colorPrimary MuiChip-outlined MuiChip-outlinedPrimary"
onKeyDown={[Function]}
onKeyUp={[Function]}
style={
{
"cursor": "pointer",
"marginLeft": "8px",
}
}
title="Project: default"
>
<span
className="MuiChip-label"
>
default
</span>
</div>
</a>
</span>
</li>,
<div
aria-atomic={true}
aria-live="polite"
className="makeStyles-container-11"
data-testid="ANNOUNCER_ELEMENT_TEST_ID"
role="status"
/>,
]
`;
exports[`renders correctly with one feature without permission 1`] = `
[
<li
className="MuiListItem-root makeStyles-listItem-1 MuiListItem-gutters"
disabled={false}
>
<span
className="makeStyles-listItemMetric-2"
>
<div
aria-describedby={null}
className="makeStyles-container-8"
onBlur={[Function]}
onFocus={[Function]}
onMouseLeave={[Function]}
onMouseOver={[Function]}
onTouchEnd={[Function]}
onTouchStart={[Function]}
style={
{
"background": "#EDF0F1",
"fontSize": "0.8rem",
}
}
title="No usage reported from connected applications"
>
<span
style={
{
"fontSize": "1.4rem",
}
}
>
</span>
</div>
</span>
<span
className="makeStyles-listItemType-3 _hideLt600_1yorl_42"
>
<svg
aria-describedby={null}
aria-hidden={true}
className="MuiSvgIcon-root makeStyles-icon-9"
data-loading={true}
focusable="false"
onBlur={[Function]}
onFocus={[Function]}
onMouseLeave={[Function]}
onMouseOver={[Function]}
onTouchEnd={[Function]}
onTouchStart={[Function]}
title="This is a \\"\\" toggle"
viewBox="0 0 24 24"
>
<path
d="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0-4.42-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6 0-1.01.25-1.97.7-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4-4-4-4v3z"
/>
</svg>
</span>
<span
className="makeStyles-listItemLink-5"
>
<a
className="_listLink_1yorl_25 _truncate_1yorl_2"
href="/projects/undefined/features/Another"
onClick={[Function]}
>
<span
aria-describedby={null}
className="_toggleName_1yorl_84"
onBlur={[Function]}
onFocus={[Function]}
onMouseLeave={[Function]}
onMouseOver={[Function]}
onTouchEnd={[Function]}
onTouchStart={[Function]}
title="another's description"
>
Another
 
</span>
<span />
<small>
<time
dateTime="2018-02-04T20:27:52.127Z"
title="2018-02-04T20:27:52.127Z"
>
4 years ago
</time>
</small>
<div>
<span
className="_truncate_1yorl_2"
>
<small>
another's description
</small>
</span>
</div>
</a>
</span>
<span
className="makeStyles-listItemStrategies-6 _hideLt920_1yorl_37"
>
<a
className="makeStyles-disabledLink-7"
href="/projects/undefined"
onClick={[Function]}
style={
{
"textDecoration": "none",
}
}
>
<div
className="MuiChip-root MuiChip-colorPrimary MuiChip-outlined MuiChip-outlinedPrimary"
onKeyDown={[Function]}
onKeyUp={[Function]}
style={
{
"cursor": "pointer",
"marginLeft": "8px",
}
}
title="Project: undefined"
>
<span
className="MuiChip-label"
/>
</div>
</a>
</span>
</li>,
<div
aria-atomic={true}
aria-live="polite"
className="makeStyles-container-11"
data-testid="ANNOUNCER_ELEMENT_TEST_ID"
role="status"
/>,
]
`;

View File

@ -0,0 +1,368 @@
// Vitest Snapshot v1
exports[`renders correctly with one feature 1`] = `
[
<div>
<div
className="makeStyles-searchBarContainer-3"
>
<form
className="makeStyles-container-6"
role="search"
>
<div
className="makeStyles-search-7 makeStyles-searchBar-4"
>
<svg
aria-hidden={true}
className="MuiSvgIcon-root makeStyles-searchIcon-8"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"
/>
</svg>
<div
className="MuiInputBase-root makeStyles-inputRoot-9"
onClick={[Function]}
onKeyPress={[Function]}
>
<input
aria-label="search"
className="MuiInputBase-input MuiInputBase-inputTypeSearch"
onAnimationStart={[Function]}
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
placeholder="Search..."
type="search"
value=""
/>
</div>
</div>
</form>
<a
href="/archive"
onClick={[Function]}
>
Archive
</a>
</div>
<div
className="MuiPaper-root MuiPaper-elevation1 MuiPaper-rounded"
style={
{
"borderRadius": "10px",
"boxShadow": "none",
}
}
>
<div
className="makeStyles-headerContainer-10"
>
<div
className="makeStyles-headerTitleContainer-14"
>
<div
className=""
data-loading={true}
>
<h1
className="MuiTypography-root makeStyles-headerTitle-15 MuiTypography-h1"
>
Feature toggles
</h1>
</div>
<div
className="makeStyles-headerActions-16"
>
<div
className="makeStyles-actionsContainer-1"
>
<div
className="makeStyles-actions-17"
>
<p
className="MuiTypography-root MuiTypography-body2"
data-loading={true}
>
Sorted by:
</p>
<button
aria-controls="sorting"
aria-haspopup="true"
className="MuiButtonBase-root MuiButton-root MuiButton-text"
data-loading={true}
disabled={false}
id="sorting"
onBlur={[Function]}
onClick={[Function]}
onDragLeave={[Function]}
onFocus={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
onMouseDown={[Function]}
onMouseLeave={[Function]}
onMouseUp={[Function]}
onTouchEnd={[Function]}
onTouchMove={[Function]}
onTouchStart={[Function]}
style={
{
"fontWeight": "normal",
"textTransform": "lowercase",
}
}
tabIndex={0}
title="Sort by"
type="button"
>
<span
className="MuiButton-label"
>
By Name
<span
className="MuiButton-endIcon MuiButton-iconSizeMedium"
>
<span
aria-hidden={true}
className="material-icons MuiIcon-root"
>
<svg
className="MuiSvgIcon-root"
focusable="false"
role="img"
viewBox="0 0 24 24"
>
<path
d="M7 10l5 5 5-5z"
/>
<title>
Toggle
</title>
</svg>
</span>
</span>
</span>
</button>
</div>
</div>
</div>
</div>
</div>
<div
className="makeStyles-bodyContainer-11"
>
<ul
className="MuiList-root MuiList-padding"
>
<ListItem
feature={
{
"name": "Another",
"reviveName": "Another",
}
}
flags={{}}
hasAccess={[Function]}
/>
</ul>
</div>
</div>
</div>,
<div
aria-atomic={true}
aria-live="polite"
className="makeStyles-container-18"
data-testid="ANNOUNCER_ELEMENT_TEST_ID"
role="status"
/>,
]
`;
exports[`renders correctly with one feature without permissions 1`] = `
[
<div>
<div
className="makeStyles-searchBarContainer-3"
>
<form
className="makeStyles-container-6"
role="search"
>
<div
className="makeStyles-search-7 makeStyles-searchBar-4"
>
<svg
aria-hidden={true}
className="MuiSvgIcon-root makeStyles-searchIcon-8"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"
/>
</svg>
<div
className="MuiInputBase-root makeStyles-inputRoot-9"
onClick={[Function]}
onKeyPress={[Function]}
>
<input
aria-label="search"
className="MuiInputBase-input MuiInputBase-inputTypeSearch"
onAnimationStart={[Function]}
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
placeholder="Search..."
type="search"
value=""
/>
</div>
</div>
</form>
<a
href="/archive"
onClick={[Function]}
>
Archive
</a>
</div>
<div
className="MuiPaper-root MuiPaper-elevation1 MuiPaper-rounded"
style={
{
"borderRadius": "10px",
"boxShadow": "none",
}
}
>
<div
className="makeStyles-headerContainer-10"
>
<div
className="makeStyles-headerTitleContainer-14"
>
<div
className=""
data-loading={true}
>
<h1
className="MuiTypography-root makeStyles-headerTitle-15 MuiTypography-h1"
>
Feature toggles
</h1>
</div>
<div
className="makeStyles-headerActions-16"
>
<div
className="makeStyles-actionsContainer-1"
>
<div
className="makeStyles-actions-17"
>
<p
className="MuiTypography-root MuiTypography-body2"
data-loading={true}
>
Sorted by:
</p>
<button
aria-controls="sorting"
aria-haspopup="true"
className="MuiButtonBase-root MuiButton-root MuiButton-text"
data-loading={true}
disabled={false}
id="sorting"
onBlur={[Function]}
onClick={[Function]}
onDragLeave={[Function]}
onFocus={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
onMouseDown={[Function]}
onMouseLeave={[Function]}
onMouseUp={[Function]}
onTouchEnd={[Function]}
onTouchMove={[Function]}
onTouchStart={[Function]}
style={
{
"fontWeight": "normal",
"textTransform": "lowercase",
}
}
tabIndex={0}
title="Sort by"
type="button"
>
<span
className="MuiButton-label"
>
By Name
<span
className="MuiButton-endIcon MuiButton-iconSizeMedium"
>
<span
aria-hidden={true}
className="material-icons MuiIcon-root"
>
<svg
className="MuiSvgIcon-root"
focusable="false"
role="img"
viewBox="0 0 24 24"
>
<path
d="M7 10l5 5 5-5z"
/>
<title>
Toggle
</title>
</svg>
</span>
</span>
</span>
<span
className="MuiTouchRipple-root"
/>
</button>
</div>
</div>
</div>
</div>
</div>
<div
className="makeStyles-bodyContainer-11"
>
<ul
className="MuiList-root MuiList-padding"
>
<ListItem
feature={
{
"name": "Another",
"reviveName": "Another",
}
}
flags={{}}
hasAccess={[Function]}
/>
</ul>
</div>
</div>
</div>,
<div
aria-atomic={true}
aria-live="polite"
className="makeStyles-container-18"
data-testid="ANNOUNCER_ELEMENT_TEST_ID"
role="status"
>
Navigated to Feature toggles
</div>,
]
`;

View File

@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1
exports[`FeedbackCESForm 1`] = `
<body>

View File

@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1
exports[`renders correctly with empty version 1`] = `
<body>

View File

@ -3,13 +3,16 @@ import renderer from 'react-test-renderer';
import { MemoryRouter } from 'react-router-dom';
import Footer from './Footer';
import { ThemeProvider } from 'themes/ThemeProvider';
import { AnnouncerProvider } from 'component/common/Announcer/AnnouncerProvider/AnnouncerProvider';
test('should render DrawerMenu', () => {
const tree = renderer.create(
<ThemeProvider>
<MemoryRouter>
<Footer />
</MemoryRouter>
<AnnouncerProvider>
<MemoryRouter>
<Footer />
</MemoryRouter>
</AnnouncerProvider>
</ThemeProvider>
);
@ -19,9 +22,11 @@ test('should render DrawerMenu', () => {
test('should render DrawerMenu with "features" selected', () => {
const tree = renderer.create(
<ThemeProvider>
<MemoryRouter initialEntries={['/features']}>
<Footer />
</MemoryRouter>
<AnnouncerProvider>
<MemoryRouter initialEntries={['/features']}>
<Footer />
</MemoryRouter>
</AnnouncerProvider>
</ThemeProvider>
);

View File

@ -1,133 +1,133 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1
exports[`returns all baseRoutes 1`] = `
Array [
Object {
[
{
"component": [Function],
"menu": Object {},
"menu": {},
"path": "/splash/:splashId",
"title": "Unleash",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/projects",
"path": "/projects/create",
"title": "Create",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/projects",
"path": "/projects/:projectId/edit",
"title": ":projectId",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/archive",
"path": "/projects/:projectId/archived",
"title": ":projectId",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/projects/:projectId/features/:featureId/:activeTab",
"path": "/projects/:projectId/features/:featureId/:activeTab/copy",
"title": "Copy",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/projects",
"path": "/projects/:projectId/features/:featureId/edit",
"title": "Edit feature",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/projects",
"path": "/projects/:projectId/features/:featureId/*",
"title": "FeatureView",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/projects/:projectId/features",
"path": "/projects/:projectId/create-toggle",
"title": "Create feature toggle",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/features",
"path": "/projects/:projectId/features2/:featureId",
"title": ":featureId",
"type": "protected",
},
Object {
{
"component": [Function],
"flag": "P",
"menu": Object {},
"menu": {},
"parent": "/projects",
"path": "/projects/:projectId/:activeTab",
"title": ":projectId",
"type": "protected",
},
Object {
{
"component": [Function],
"flag": "P",
"menu": Object {},
"menu": {},
"parent": "/projects",
"path": "/projects/:projectId",
"title": ":projectId",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {
"menu": {
"mobile": true,
},
"path": "/projects",
"title": "Projects",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/features",
"path": "/features/:activeTab/:featureId",
"title": ":featureId",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {
"menu": {
"mobile": true,
},
"path": "/features",
"title": "Feature toggles",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/applications",
"path": "/applications/:name",
"title": ":name",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {
"menu": {
"advanced": true,
"mobile": true,
},
@ -135,28 +135,28 @@ Array [
"title": "Applications",
"type": "protected",
},
Object {
{
"component": [Function],
"flag": "C",
"menu": Object {},
"menu": {},
"parent": "/context",
"path": "/context/create",
"title": "Create",
"type": "protected",
},
Object {
{
"component": [Function],
"flag": "C",
"menu": Object {},
"menu": {},
"parent": "/context",
"path": "/context/edit/:name",
"title": ":name",
"type": "protected",
},
Object {
{
"component": [Function],
"flag": "C",
"menu": Object {
"menu": {
"advanced": true,
"mobile": true,
},
@ -164,33 +164,33 @@ Array [
"title": "Context fields",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/strategies",
"path": "/strategies/create",
"title": "Create",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/strategies",
"path": "/strategies/:name/edit",
"title": ":name",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/strategies",
"path": "/strategies/:name",
"title": ":name",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {
"menu": {
"advanced": true,
"mobile": true,
},
@ -198,25 +198,25 @@ Array [
"title": "Strategies",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/environments",
"path": "/environments/create",
"title": "Environments",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"path": "/environments/:id",
"title": "Edit",
"type": "protected",
},
Object {
{
"component": [Function],
"flag": "EEA",
"menu": Object {
"menu": {
"advanced": true,
"mobile": true,
},
@ -224,25 +224,25 @@ Array [
"title": "Environments",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/tag-types",
"path": "/tag-types/create",
"title": "Create",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/tag-types",
"path": "/tag-types/edit/:name",
"title": ":name",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {
"menu": {
"advanced": true,
"mobile": true,
},
@ -250,26 +250,26 @@ Array [
"title": "Tag types",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/addons",
"path": "/addons/create/:providerId",
"title": "Create",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/addons",
"path": "/addons/edit/:addonId",
"title": "Edit",
"type": "protected",
},
Object {
{
"component": [Function],
"hidden": false,
"menu": Object {
"menu": {
"advanced": true,
"mobile": true,
},
@ -277,31 +277,31 @@ Array [
"title": "Addons",
"type": "protected",
},
Object {
{
"component": [Function],
"flag": "SE",
"hidden": false,
"layout": "main",
"menu": Object {},
"menu": {},
"path": "/segments/create",
"title": "Segments",
"type": "protected",
},
Object {
{
"component": [Function],
"flag": "SE",
"hidden": false,
"layout": "main",
"menu": Object {},
"menu": {},
"path": "/segments/edit/:segmentId",
"title": "Segments",
"type": "protected",
},
Object {
{
"component": [Function],
"flag": "SE",
"hidden": false,
"menu": Object {
"menu": {
"advanced": true,
"mobile": true,
},
@ -309,57 +309,57 @@ Array [
"title": "Segments",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/history",
"path": "/history/:toggleName",
"title": ":toggleName",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {
"menu": {
"adminSettings": true,
},
"path": "/history",
"title": "Event log",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"path": "/archive",
"title": "Archived toggles",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/admin",
"path": "/admin/api/create-token",
"title": "API access",
"type": "protected",
},
Object {
{
"component": [Function],
"flag": "RE",
"menu": Object {},
"menu": {},
"path": "/admin/create-project-role",
"title": "Create",
"type": "protected",
},
Object {
{
"component": [Function],
"flag": "RE",
"menu": Object {},
"menu": {},
"path": "/admin/roles/:id/edit",
"title": "Edit",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {
"menu": {
"advanced": true,
"mobile": true,
},
@ -368,9 +368,9 @@ Array [
"title": "API access",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {
"menu": {
"adminSettings": true,
},
"parent": "/admin",
@ -378,18 +378,18 @@ Array [
"title": "Users",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {},
"menu": {},
"parent": "/admin",
"path": "/admin/create-user",
"title": "Users",
"type": "protected",
},
Object {
{
"component": [Function],
"flag": "RE",
"menu": Object {
"menu": {
"adminSettings": true,
},
"parent": "/admin",
@ -397,9 +397,9 @@ Array [
"title": "Project roles",
"type": "protected",
},
Object {
{
"component": [Function],
"menu": Object {
"menu": {
"adminSettings": true,
},
"parent": "/admin",
@ -407,10 +407,10 @@ Array [
"title": "Single sign-on",
"type": "protected",
},
Object {
{
"component": [Function],
"hidden": false,
"menu": Object {},
"menu": {},
"path": "/admin",
"title": "Admin",
"type": "protected",

View File

@ -1,11 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1
exports[`renders correctly 1`] = `
Array [
[
<div
className="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 mui-1ps6pg7-MuiPaper-root"
style={
Object {
{
"borderRadius": "10px",
"boxShadow": "none",
}
@ -85,7 +85,7 @@ Array [
data-testid="ExtensionIcon"
focusable="false"
style={
Object {
{
"color": "#0000008a",
}
}

View File

@ -6,16 +6,21 @@ import { ADMIN } from 'component/providers/AccessProvider/permissions';
import UIProvider from 'component/providers/UIProvider/UIProvider';
import { ThemeProvider } from 'themes/ThemeProvider';
import { AccessProviderMock } from 'component/providers/AccessProvider/AccessProviderMock';
import { AnnouncerProvider } from 'component/common/Announcer/AnnouncerProvider/AnnouncerProvider';
test('renders an empty list correctly', () => {
const tree = renderer.create(
<MemoryRouter>
<ThemeProvider>
<UIProvider>
<AccessProviderMock permissions={[{ permission: ADMIN }]}>
<TagTypeList />
</AccessProviderMock>
</UIProvider>
<AnnouncerProvider>
<UIProvider>
<AccessProviderMock
permissions={[{ permission: ADMIN }]}
>
<TagTypeList />
</AccessProviderMock>
</UIProvider>
</AnnouncerProvider>
</ThemeProvider>
</MemoryRouter>
);

View File

@ -1,71 +1,80 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1
exports[`renders an empty list correctly 1`] = `
<div
className="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 mui-1ps6pg7-MuiPaper-root"
style={
Object {
"borderRadius": "10px",
"boxShadow": "none",
}
}
>
[
<div
className="tss-8bhpw1-headerContainer"
className="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 mui-1ps6pg7-MuiPaper-root"
style={
{
"borderRadius": "10px",
"boxShadow": "none",
}
}
>
<div
className="tss-14s7qul-headerTitleContainer"
className="tss-8bhpw1-headerContainer"
>
<div
className=""
data-loading={true}
className="tss-14s7qul-headerTitleContainer"
>
<h1
className="MuiTypography-root MuiTypography-h1 tss-whbfmi-headerTitle mui-ylrecv-MuiTypography-root"
<div
className=""
data-loading={true}
>
Tag Types
</h1>
</div>
<div
className="tss-ap2nhp-headerActions"
>
<button
className="MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButtonBase-root mui-1aw3qf3-MuiButtonBase-root-MuiButton-root"
disabled={false}
onBlur={[Function]}
onClick={[Function]}
onContextMenu={[Function]}
onDragLeave={[Function]}
onFocus={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
onMouseDown={[Function]}
onMouseLeave={[Function]}
onMouseUp={[Function]}
onTouchEnd={[Function]}
onTouchMove={[Function]}
onTouchStart={[Function]}
tabIndex={0}
type="button"
<h1
className="MuiTypography-root MuiTypography-h1 tss-whbfmi-headerTitle mui-ylrecv-MuiTypography-root"
>
Tag Types
</h1>
</div>
<div
className="tss-ap2nhp-headerActions"
>
New tag type
</button>
<button
className="MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButtonBase-root mui-1aw3qf3-MuiButtonBase-root-MuiButton-root"
disabled={false}
onBlur={[Function]}
onClick={[Function]}
onContextMenu={[Function]}
onDragLeave={[Function]}
onFocus={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
onMouseDown={[Function]}
onMouseLeave={[Function]}
onMouseUp={[Function]}
onTouchEnd={[Function]}
onTouchMove={[Function]}
onTouchStart={[Function]}
tabIndex={0}
type="button"
>
New tag type
</button>
</div>
</div>
</div>
</div>
<div
className="tss-kiw3z8-bodyContainer"
>
<ul
className="MuiList-root MuiList-padding mui-h4y409-MuiList-root"
<div
className="tss-kiw3z8-bodyContainer"
>
<li
className="MuiListItem-root MuiListItem-gutters MuiListItem-padding mui-vlytkl-MuiListItem-root"
disabled={false}
<ul
className="MuiList-root MuiList-padding mui-h4y409-MuiList-root"
>
No entries
</li>
</ul>
</div>
</div>
<li
className="MuiListItem-root MuiListItem-gutters MuiListItem-padding mui-vlytkl-MuiListItem-root"
disabled={false}
>
No entries
</li>
</ul>
</div>
</div>,
<div
aria-atomic={true}
aria-live="polite"
className="tss-1cl4o05-container"
data-testid="ANNOUNCER_ELEMENT_TEST_ID"
role="status"
/>,
]
`;

View File

@ -1,13 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1
exports[`useFeaturesFilter constraints 1`] = `
Object {
"filter": Object {
{
"filter": {
"project": "*",
"query": "xyz",
},
"filtered": Array [
Object {
"filtered": [
{
"createdAt": 2006-01-02T15:04:05.000Z,
"description": "1",
"enabled": false,
@ -16,45 +16,45 @@ Object {
"name": "1",
"project": "a",
"stale": false,
"strategies": Array [
Object {
"constraints": Array [],
"strategies": [
{
"constraints": [],
"id": "1",
"name": "1",
"parameters": Object {},
"parameters": {},
},
Object {
"constraints": Array [],
{
"constraints": [],
"id": "1",
"name": "1",
"parameters": Object {},
"parameters": {},
},
Object {
"constraints": Array [
Object {
{
"constraints": [
{
"contextName": "",
"operator": "IN",
},
Object {
{
"contextName": "",
"operator": "IN",
"value": "xyz",
},
Object {
{
"contextName": "",
"operator": "IN",
"values": Array [
"values": [
"xyz",
],
},
],
"id": "1",
"name": "1",
"parameters": Object {},
"parameters": {},
},
],
"type": "1",
"variants": Array [],
"variants": [],
},
],
"setFilter": [Function],
@ -62,22 +62,22 @@ Object {
`;
exports[`useFeaturesFilter empty 1`] = `
Object {
"filter": Object {
{
"filter": {
"project": "*",
},
"filtered": Array [],
"filtered": [],
"setFilter": [Function],
}
`;
exports[`useFeaturesFilter equal 1`] = `
Object {
"filter": Object {
{
"filter": {
"project": "*",
},
"filtered": Array [
Object {
"filtered": [
{
"createdAt": 2006-01-02T15:04:05.000Z,
"description": "1",
"enabled": false,
@ -86,11 +86,11 @@ Object {
"name": "1",
"project": "1",
"stale": false,
"strategies": Array [],
"strategies": [],
"type": "1",
"variants": Array [],
"variants": [],
},
Object {
{
"createdAt": 2006-01-02T15:04:05.000Z,
"description": "1",
"enabled": false,
@ -99,11 +99,11 @@ Object {
"name": "1",
"project": "1",
"stale": false,
"strategies": Array [],
"strategies": [],
"type": "1",
"variants": Array [],
"variants": [],
},
Object {
{
"createdAt": 2006-01-02T15:04:05.000Z,
"description": "1",
"enabled": false,
@ -112,9 +112,9 @@ Object {
"name": "1",
"project": "1",
"stale": false,
"strategies": Array [],
"strategies": [],
"type": "1",
"variants": Array [],
"variants": [],
},
],
"setFilter": [Function],
@ -122,12 +122,12 @@ Object {
`;
exports[`useFeaturesFilter project 1`] = `
Object {
"filter": Object {
{
"filter": {
"project": "2",
},
"filtered": Array [
Object {
"filtered": [
{
"createdAt": 2006-01-02T15:04:05.000Z,
"description": "1",
"enabled": false,
@ -136,11 +136,11 @@ Object {
"name": "1",
"project": "2",
"stale": false,
"strategies": Array [],
"strategies": [],
"type": "1",
"variants": Array [],
"variants": [],
},
Object {
{
"createdAt": 2006-01-02T15:04:05.000Z,
"description": "1",
"enabled": false,
@ -149,9 +149,9 @@ Object {
"name": "1",
"project": "2",
"stale": false,
"strategies": Array [],
"strategies": [],
"type": "1",
"variants": Array [],
"variants": [],
},
],
"setFilter": [Function],
@ -159,13 +159,13 @@ Object {
`;
exports[`useFeaturesFilter query 1`] = `
Object {
"filter": Object {
{
"filter": {
"project": "*",
"query": "bc",
},
"filtered": Array [
Object {
"filtered": [
{
"createdAt": 2006-01-02T15:04:05.000Z,
"description": "1",
"enabled": false,
@ -174,11 +174,11 @@ Object {
"name": "1",
"project": "abc",
"stale": false,
"strategies": Array [],
"strategies": [],
"type": "1",
"variants": Array [],
"variants": [],
},
Object {
{
"createdAt": 2006-01-02T15:04:05.000Z,
"description": "1",
"enabled": false,
@ -187,9 +187,9 @@ Object {
"name": "1",
"project": "abcd",
"stale": false,
"strategies": Array [],
"strategies": [],
"type": "1",
"variants": Array [],
"variants": [],
},
],
"setFilter": [Function],

View File

@ -8,15 +8,15 @@ test('useId', () => {
rerender();
expect(result).toMatchInlineSnapshot(`
Object {
"all": Array [
"useId-0",
"useId-0",
"useId-0",
],
"current": "useId-0",
"error": undefined,
}
{
"all": [
"useId-0",
"useId-0",
"useId-0",
],
"current": "useId-0",
"error": undefined,
}
`);
});
@ -27,14 +27,14 @@ test('useId prefix', () => {
rerender();
expect(result).toMatchInlineSnapshot(`
Object {
"all": Array [
"prefix-1",
"prefix-1",
"prefix-1",
],
"current": "prefix-1",
"error": undefined,
}
{
"all": [
"prefix-1",
"prefix-1",
"prefix-1",
],
"current": "prefix-1",
"error": undefined,
}
`);
});

View File

@ -1,5 +1,6 @@
import 'whatwg-fetch';
import 'themes/app.css';
import 'regenerator-runtime/runtime';
import ReactDOM from 'react-dom';
import { BrowserRouter } from 'react-router-dom';

View File

@ -1 +0,0 @@
/// <reference types="react-scripts" />

View File

@ -1,27 +0,0 @@
const { createProxyMiddleware } = require('http-proxy-middleware');
const API_URL = process.env.UNLEASH_API || 'http://localhost:4242';
module.exports = function (app) {
app.use(
'/api',
createProxyMiddleware({
target: API_URL,
changeOrigin: true,
})
);
app.use(
'/auth',
createProxyMiddleware({
target: API_URL,
changeOrigin: true,
})
);
app.use(
'/logout',
createProxyMiddleware({
target: API_URL,
changeOrigin: true,
})
);
};

View File

@ -1,3 +1,4 @@
import '@testing-library/jest-dom';
import 'whatwg-fetch';
process.env.TZ = 'UTC';

2
frontend/src/vite-env.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
/// <reference types="vite/client" />
/// <reference types="vite-plugin-svgr/client" />

View File

@ -1,7 +1,7 @@
{
"compilerOptions": {
"baseUrl": "./src",
"target": "es5",
"target": "esnext",
"lib": [
"dom",
"dom.iterable",
@ -23,5 +23,6 @@
},
"include": [
"src"
]
],
"references": [{ "path": "./tsconfig.node.json" }]
}

View File

@ -0,0 +1,8 @@
{
"compilerOptions": {
"composite": true,
"module": "esnext",
"moduleResolution": "node"
},
"include": ["vite.config.ts"]
}

View File

@ -11,6 +11,7 @@
{
"source": "/auth/:match*",
"destination": "https://unleash4.herokuapp.com/auth/:match*"
}
},
{ "source": "/(.*)", "destination": "/index.html" }
]
}

37
frontend/vite.config.ts Normal file
View File

@ -0,0 +1,37 @@
import { configDefaults, defineConfig } from 'vitest/config';
import tsconfigPaths from 'vite-tsconfig-paths';
import react from '@vitejs/plugin-react';
import svgr from 'vite-plugin-svgr';
import envCompatible from 'vite-plugin-env-compatible';
const API_URL = process.env.UNLEASH_API || 'http://localhost:4242';
// https://vitejs.dev/config/
export default defineConfig({
test: {
globals: true,
setupFiles: 'src/setupTests.ts',
environment: 'jsdom',
exclude: [...configDefaults.exclude, '**/cypress/**'],
},
server: {
proxy: {
'/api': {
target: API_URL,
changeOrigin: true,
},
'/auth': {
target: API_URL,
changeOrigin: true,
},
'/logout': {
target: API_URL,
changeOrigin: true,
},
},
},
build: {
outDir: 'build',
},
plugins: [react(), tsconfigPaths(), svgr(), envCompatible()],
});

File diff suppressed because it is too large Load Diff