1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-21 13:47:39 +02: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> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>
<script type="module" src="/src/index.tsx"></script>
</body> </body>
</html> </html>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,71 +1,80 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Vitest Snapshot v1
exports[`renders an empty list correctly 1`] = ` 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 <div
className="tss-8bhpw1-headerContainer" className="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 mui-1ps6pg7-MuiPaper-root"
style={
{
"borderRadius": "10px",
"boxShadow": "none",
}
}
> >
<div <div
className="tss-14s7qul-headerTitleContainer" className="tss-8bhpw1-headerContainer"
> >
<div <div
className="" className="tss-14s7qul-headerTitleContainer"
data-loading={true}
> >
<h1 <div
className="MuiTypography-root MuiTypography-h1 tss-whbfmi-headerTitle mui-ylrecv-MuiTypography-root" className=""
data-loading={true}
> >
Tag Types <h1
</h1> className="MuiTypography-root MuiTypography-h1 tss-whbfmi-headerTitle mui-ylrecv-MuiTypography-root"
</div> >
<div Tag Types
className="tss-ap2nhp-headerActions" </h1>
> </div>
<button <div
className="MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButtonBase-root mui-1aw3qf3-MuiButtonBase-root-MuiButton-root" className="tss-ap2nhp-headerActions"
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
</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>
</div> <div
<div className="tss-kiw3z8-bodyContainer"
className="tss-kiw3z8-bodyContainer"
>
<ul
className="MuiList-root MuiList-padding mui-h4y409-MuiList-root"
> >
<li <ul
className="MuiListItem-root MuiListItem-gutters MuiListItem-padding mui-vlytkl-MuiListItem-root" className="MuiList-root MuiList-padding mui-h4y409-MuiList-root"
disabled={false}
> >
No entries <li
</li> className="MuiListItem-root MuiListItem-gutters MuiListItem-padding mui-vlytkl-MuiListItem-root"
</ul> disabled={false}
</div> >
</div> 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`] = ` exports[`useFeaturesFilter constraints 1`] = `
Object { {
"filter": Object { "filter": {
"project": "*", "project": "*",
"query": "xyz", "query": "xyz",
}, },
"filtered": Array [ "filtered": [
Object { {
"createdAt": 2006-01-02T15:04:05.000Z, "createdAt": 2006-01-02T15:04:05.000Z,
"description": "1", "description": "1",
"enabled": false, "enabled": false,
@ -16,45 +16,45 @@ Object {
"name": "1", "name": "1",
"project": "a", "project": "a",
"stale": false, "stale": false,
"strategies": Array [ "strategies": [
Object { {
"constraints": Array [], "constraints": [],
"id": "1", "id": "1",
"name": "1", "name": "1",
"parameters": Object {}, "parameters": {},
}, },
Object { {
"constraints": Array [], "constraints": [],
"id": "1", "id": "1",
"name": "1", "name": "1",
"parameters": Object {}, "parameters": {},
}, },
Object { {
"constraints": Array [ "constraints": [
Object { {
"contextName": "", "contextName": "",
"operator": "IN", "operator": "IN",
}, },
Object { {
"contextName": "", "contextName": "",
"operator": "IN", "operator": "IN",
"value": "xyz", "value": "xyz",
}, },
Object { {
"contextName": "", "contextName": "",
"operator": "IN", "operator": "IN",
"values": Array [ "values": [
"xyz", "xyz",
], ],
}, },
], ],
"id": "1", "id": "1",
"name": "1", "name": "1",
"parameters": Object {}, "parameters": {},
}, },
], ],
"type": "1", "type": "1",
"variants": Array [], "variants": [],
}, },
], ],
"setFilter": [Function], "setFilter": [Function],
@ -62,22 +62,22 @@ Object {
`; `;
exports[`useFeaturesFilter empty 1`] = ` exports[`useFeaturesFilter empty 1`] = `
Object { {
"filter": Object { "filter": {
"project": "*", "project": "*",
}, },
"filtered": Array [], "filtered": [],
"setFilter": [Function], "setFilter": [Function],
} }
`; `;
exports[`useFeaturesFilter equal 1`] = ` exports[`useFeaturesFilter equal 1`] = `
Object { {
"filter": Object { "filter": {
"project": "*", "project": "*",
}, },
"filtered": Array [ "filtered": [
Object { {
"createdAt": 2006-01-02T15:04:05.000Z, "createdAt": 2006-01-02T15:04:05.000Z,
"description": "1", "description": "1",
"enabled": false, "enabled": false,
@ -86,11 +86,11 @@ Object {
"name": "1", "name": "1",
"project": "1", "project": "1",
"stale": false, "stale": false,
"strategies": Array [], "strategies": [],
"type": "1", "type": "1",
"variants": Array [], "variants": [],
}, },
Object { {
"createdAt": 2006-01-02T15:04:05.000Z, "createdAt": 2006-01-02T15:04:05.000Z,
"description": "1", "description": "1",
"enabled": false, "enabled": false,
@ -99,11 +99,11 @@ Object {
"name": "1", "name": "1",
"project": "1", "project": "1",
"stale": false, "stale": false,
"strategies": Array [], "strategies": [],
"type": "1", "type": "1",
"variants": Array [], "variants": [],
}, },
Object { {
"createdAt": 2006-01-02T15:04:05.000Z, "createdAt": 2006-01-02T15:04:05.000Z,
"description": "1", "description": "1",
"enabled": false, "enabled": false,
@ -112,9 +112,9 @@ Object {
"name": "1", "name": "1",
"project": "1", "project": "1",
"stale": false, "stale": false,
"strategies": Array [], "strategies": [],
"type": "1", "type": "1",
"variants": Array [], "variants": [],
}, },
], ],
"setFilter": [Function], "setFilter": [Function],
@ -122,12 +122,12 @@ Object {
`; `;
exports[`useFeaturesFilter project 1`] = ` exports[`useFeaturesFilter project 1`] = `
Object { {
"filter": Object { "filter": {
"project": "2", "project": "2",
}, },
"filtered": Array [ "filtered": [
Object { {
"createdAt": 2006-01-02T15:04:05.000Z, "createdAt": 2006-01-02T15:04:05.000Z,
"description": "1", "description": "1",
"enabled": false, "enabled": false,
@ -136,11 +136,11 @@ Object {
"name": "1", "name": "1",
"project": "2", "project": "2",
"stale": false, "stale": false,
"strategies": Array [], "strategies": [],
"type": "1", "type": "1",
"variants": Array [], "variants": [],
}, },
Object { {
"createdAt": 2006-01-02T15:04:05.000Z, "createdAt": 2006-01-02T15:04:05.000Z,
"description": "1", "description": "1",
"enabled": false, "enabled": false,
@ -149,9 +149,9 @@ Object {
"name": "1", "name": "1",
"project": "2", "project": "2",
"stale": false, "stale": false,
"strategies": Array [], "strategies": [],
"type": "1", "type": "1",
"variants": Array [], "variants": [],
}, },
], ],
"setFilter": [Function], "setFilter": [Function],
@ -159,13 +159,13 @@ Object {
`; `;
exports[`useFeaturesFilter query 1`] = ` exports[`useFeaturesFilter query 1`] = `
Object { {
"filter": Object { "filter": {
"project": "*", "project": "*",
"query": "bc", "query": "bc",
}, },
"filtered": Array [ "filtered": [
Object { {
"createdAt": 2006-01-02T15:04:05.000Z, "createdAt": 2006-01-02T15:04:05.000Z,
"description": "1", "description": "1",
"enabled": false, "enabled": false,
@ -174,11 +174,11 @@ Object {
"name": "1", "name": "1",
"project": "abc", "project": "abc",
"stale": false, "stale": false,
"strategies": Array [], "strategies": [],
"type": "1", "type": "1",
"variants": Array [], "variants": [],
}, },
Object { {
"createdAt": 2006-01-02T15:04:05.000Z, "createdAt": 2006-01-02T15:04:05.000Z,
"description": "1", "description": "1",
"enabled": false, "enabled": false,
@ -187,9 +187,9 @@ Object {
"name": "1", "name": "1",
"project": "abcd", "project": "abcd",
"stale": false, "stale": false,
"strategies": Array [], "strategies": [],
"type": "1", "type": "1",
"variants": Array [], "variants": [],
}, },
], ],
"setFilter": [Function], "setFilter": [Function],

View File

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

View File

@ -1,5 +1,6 @@
import 'whatwg-fetch'; import 'whatwg-fetch';
import 'themes/app.css'; import 'themes/app.css';
import 'regenerator-runtime/runtime';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import { BrowserRouter } from 'react-router-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 '@testing-library/jest-dom';
import 'whatwg-fetch';
process.env.TZ = 'UTC'; 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": { "compilerOptions": {
"baseUrl": "./src", "baseUrl": "./src",
"target": "es5", "target": "esnext",
"lib": [ "lib": [
"dom", "dom",
"dom.iterable", "dom.iterable",
@ -23,5 +23,6 @@
}, },
"include": [ "include": [
"src" "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*", "source": "/auth/:match*",
"destination": "https://unleash4.herokuapp.com/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