Skip to content

Commit

Permalink
WIP013
Browse files Browse the repository at this point in the history
  • Loading branch information
dakotablair committed Sep 5, 2023
1 parent fe6c33a commit 622e4b8
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/reusable_build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
run: npm run lint:strict

- name: Run tests
run: npm test . -- --coverage
run: npm test . -- --coverage --verbose

- name: Run multi-enviroment build
run: ./scripts/build_deploy.sh
Expand Down
21 changes: 19 additions & 2 deletions src/app/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,25 @@ import App from './App';
import { Provider } from 'react-redux';
import { createTestStore } from './store';

describe('Europa...', () => {
test('renders Navigator page link', () => {
const consoleInfo = jest.spyOn(console, 'info');
// This mockImplementation supresses console.info calls.
// eslint-disable-next-line @typescript-eslint/no-empty-function
consoleInfo.mockImplementation(() => {});

describe('The main UI for Europa...', () => {
afterAll(() => {
consoleInfo.mockRestore();
});

afterEach(() => {
consoleInfo.mockClear();
});

beforeEach(() => {
consoleInfo.mockClear();
});

test('renders a Navigator page link', () => {
render(
<Provider store={createTestStore()}>
<App />
Expand Down
2 changes: 0 additions & 2 deletions src/common/api/utils/kbaseBaseQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ export const isKBaseBaseQueryError = (
): error is KBaseBaseQueryError => {
const fbq = isFetchBaseQueryError(error);
const condition = fbq && isJsonRpcError(error.data);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
console.log({ error, data: (error as any).data, fbq, condition }); // eslint-disable-line no-console
return condition;
};

Expand Down
7 changes: 5 additions & 2 deletions src/features/layout/LeftNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ const LeftNavBar: FC = () => {
);
};

const devDomains = new Set(['', 'ci-europa.kbase.us']);

const DevNav: FC = () => {
const me = useAppSelector(authMe);
useAuthMe();
console.log({ me }); // eslint-disable-line no-console
const devDomain = !devDomains.has(process.env.REACT_APP_KBASE_DOMAIN || '');
const customroles = me && new Set(me.customroles);
const dev = customroles && customroles.has('UI_COLLECTIONS');
const devRole = customroles && customroles.has('UI_COLLECTIONS');
const dev = devDomain || devRole;
if (!dev) return <></>;
return (
<>
Expand Down
16 changes: 8 additions & 8 deletions src/features/navigator/NarrativeControl/Delete.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ import { noOp } from '../../common';
import { testNarrativeDoc, testNarrativeDocFactory } from '../fixtures';
import { DeleteTemplate } from './NarrativeControl.stories';

const consoleError = jest.spyOn(console, 'error');
// This mockImplementation supresses console.error calls.
// eslint-disable-next-line @typescript-eslint/no-empty-function
// consoleError.mockImplementation(() => {});

const wsIdError = 1111111;

export const testNarrativeDocError = testNarrativeDocFactory({
Expand Down Expand Up @@ -49,6 +44,11 @@ const TestingError: FC<FallbackProps> = ({ error }) => {
return <>Error: {JSON.stringify(error)}</>;
};

const consoleError = jest.spyOn(console, 'error');
// This mockImplementation supresses console.error calls.
// eslint-disable-next-line @typescript-eslint/no-empty-function
consoleError.mockImplementation(() => {});

const logError = (error: Error, info: { componentStack: string }) => {
console.log({ error }); // eslint-disable-line no-console
console.log(info.componentStack); // eslint-disable-line no-console
Expand All @@ -61,17 +61,17 @@ describe('The <Delete /> component...', () => {
});

afterAll(() => {
// consoleError.mockRestore();
consoleError.mockRestore();
disableFetchMocks();
});

afterEach(() => {
// consoleError.mockClear();
consoleError.mockClear();
});

beforeEach(() => {
fetchMock.resetMocks();
// consoleError.mockClear();
consoleError.mockClear();
});

test('renders.', () => {
Expand Down
4 changes: 1 addition & 3 deletions src/features/navigator/NarrativeControl/Delete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ export const Delete: FC<ControlProps> = ({ narrativeDoc, modalClose }) => {
setUserConfirmation(true);
modalClose();
dispatch(deleteNarrative({ wsId }));
console.log({ userConfirmation, wsId }); // eslint-disable-line no-console
try {
const out = await deleteTrigger({ wsId }).unwrap();
console.log({ out }); // eslint-disable-line no-console
await deleteTrigger({ wsId }).unwrap();
dispatch(setLoading(false));
} catch (err) {
if (!isKBaseBaseQueryError(err)) {
Expand Down
17 changes: 17 additions & 0 deletions src/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
import { render } from '@testing-library/react';
import Root from '.';

const consoleInfo = jest.spyOn(console, 'info');
// This mockImplementation supresses console.info calls.
// eslint-disable-next-line @typescript-eslint/no-empty-function
consoleInfo.mockImplementation(() => {});

describe('Europa...', () => {
afterAll(() => {
consoleInfo.mockRestore();
});

afterEach(() => {
consoleInfo.mockClear();
});

beforeEach(() => {
consoleInfo.mockClear();
});

test('exists.', () => {
const { container } = render(<Root />);
expect(container).toBeTruthy();
Expand Down

0 comments on commit 622e4b8

Please sign in to comment.