remove some yarn.lock impurity in master by adjusting msw dep
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -13,7 +13,72 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { Content, Header, HeaderLabel, Page } from '@backstage/core-components';
|
||||
import { createDevApp } from '@backstage/dev-utils';
|
||||
import { EntityProvider } from '@backstage/plugin-catalog-react';
|
||||
import { TestApiProvider } from '@backstage/test-utils';
|
||||
import { Box, Typography } from '@material-ui/core';
|
||||
import SomeIcon from '@material-ui/icons/Storage';
|
||||
import React from 'react';
|
||||
import { VaultApi, vaultApiRef } from '../src/api';
|
||||
import { EntityVaultCard } from '../src/components/EntityVaultCard';
|
||||
import { EntityVaultTable } from '../src/components/EntityVaultTable';
|
||||
import { VAULT_SECRET_PATH_ANNOTATION } from '../src/constants';
|
||||
import { vaultPlugin } from '../src/plugin';
|
||||
|
||||
createDevApp().registerPlugin(vaultPlugin).render();
|
||||
const entity: Entity = {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
kind: 'Component',
|
||||
metadata: {
|
||||
name: 'backstage',
|
||||
annotations: { [VAULT_SECRET_PATH_ANNOTATION]: 'a/b' },
|
||||
},
|
||||
spec: {
|
||||
type: 'service',
|
||||
},
|
||||
};
|
||||
|
||||
const mockedApi: VaultApi = {
|
||||
async listSecrets() {
|
||||
return [
|
||||
{
|
||||
name: 'a::b',
|
||||
editUrl: 'https://example.com',
|
||||
showUrl: 'https://example.com',
|
||||
},
|
||||
{
|
||||
name: 'c::d',
|
||||
editUrl: 'https://example.com',
|
||||
showUrl: 'https://example.com',
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
|
||||
createDevApp()
|
||||
.registerPlugin(vaultPlugin)
|
||||
.addPage({
|
||||
element: (
|
||||
<TestApiProvider apis={[[vaultApiRef, mockedApi]]}>
|
||||
<EntityProvider entity={entity}>
|
||||
<Page themeId="service">
|
||||
<Header title="Mocked Vault">
|
||||
<HeaderLabel label="Mode" value="Development" />
|
||||
</Header>
|
||||
<Content>
|
||||
<Typography variant="h3">As a card</Typography>
|
||||
<EntityVaultCard />
|
||||
<Box mt={4} />
|
||||
<Typography variant="h3">As a table</Typography>
|
||||
<EntityVaultTable entity={entity} />
|
||||
</Content>
|
||||
</Page>
|
||||
</EntityProvider>
|
||||
</TestApiProvider>
|
||||
),
|
||||
title: 'Vault',
|
||||
icon: SomeIcon,
|
||||
})
|
||||
.render();
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
"@types/jest": "*",
|
||||
"@types/node": "*",
|
||||
"cross-fetch": "^3.1.5",
|
||||
"msw": "^0.35.0"
|
||||
"msw": "^0.42.0"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
|
||||
@@ -44,9 +44,9 @@ describe('api', () => {
|
||||
server.use(
|
||||
rest.get(`${mockBaseUrl}/v1/secrets/:path`, (req, res, ctx) => {
|
||||
const { path } = req.params;
|
||||
if (path === 'test%2Fsuccess') {
|
||||
if (path === 'test/success') {
|
||||
return res(ctx.json(mockSecretsResult));
|
||||
} else if (path === 'test%2Ferror') {
|
||||
} else if (path === 'test/error') {
|
||||
return res(ctx.json([]));
|
||||
}
|
||||
return res(ctx.status(400));
|
||||
|
||||
@@ -27,7 +27,7 @@ import { ApiProvider, UrlPatternDiscovery } from '@backstage/core-app-api';
|
||||
import { VaultSecret, vaultApiRef, VaultClient } from '../../api';
|
||||
import { rest } from 'msw';
|
||||
|
||||
describe('EntityVautTable', () => {
|
||||
describe('EntityVaultTable', () => {
|
||||
const server = setupServer();
|
||||
setupRequestMockHandlers(server);
|
||||
let apis: TestApiRegistry;
|
||||
@@ -85,9 +85,9 @@ describe('EntityVautTable', () => {
|
||||
server.use(
|
||||
rest.get(`${mockBaseUrl}/v1/secrets/:path`, (req, res, ctx) => {
|
||||
const { path } = req.params;
|
||||
if (path === 'test%2Fsuccess') {
|
||||
if (path === 'test/success') {
|
||||
return res(ctx.json(mockSecretsResult));
|
||||
} else if (path === 'test%2Ferror') {
|
||||
} else if (path === 'test/error') {
|
||||
return res(ctx.json([]));
|
||||
}
|
||||
return res(ctx.status(400));
|
||||
|
||||
Reference in New Issue
Block a user