Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Woozl committed Jun 28, 2023
1 parent 6873715 commit bf2e75b
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ USER nru
# Copy the code into the container
COPY . .

ENV BASE_URL /question-builder/
ENV BASE_URL /question-builder

# Build the code and save a production ready copy
CMD npm run prod
2 changes: 1 addition & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function App() {

return (
<div id="pageContainer">
<BrowserRouter basename="/question-builder">
<BrowserRouter basename={process.env.BASE_URL}>
<Auth0Provider
domain="qgraph.us.auth0.com"
clientId="sgJrK1gGAbzrXwUp0WG7jAV0ivCIF6jr"
Expand Down
8 changes: 4 additions & 4 deletions tests/common/mocks/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import biolink from '&/biolink_model.json';
import test_message from '&/test_message.json';

const handlers = [
rest.get(`${process.env.BASE_URL || ''}/api/biolink`, (req, res, ctx) => res(
rest.get('/api/biolink', (req, res, ctx) => res(
ctx.json(biolink),
)),
rest.post(`${process.env.BASE_URL || ''}/api/node_norm`, (req, res, ctx) => {
rest.post('/api/node_norm', (req, res, ctx) => {
const curie = req.body.curies[0];
return res(
ctx.json({
Expand All @@ -21,15 +21,15 @@ const handlers = [
}),
);
}),
rest.post(`${process.env.BASE_URL || ''}/api/name_resolver`, (req, res, ctx) => {
rest.post('/api/name_resolver', (req, res, ctx) => {
const curie = req.url.searchParams.get('string');
return res(
ctx.json({
[curie]: {},
}),
);
}),
rest.post(`${process.env.BASE_URL || ''}/api/quick_answer`, (req, res, ctx) => res(
rest.post('/api/quick_answer', (req, res, ctx) => res(
ctx.json(test_message),
)),
];
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/ask_question.test.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import axios from 'axios';
import userEvent from '@testing-library/user-event';
import {
render, waitFor, screen,
} from '&/test_utils';
import { api } from '~/API/baseUrlProxy';

import App from '~/App';

Expand Down Expand Up @@ -34,7 +34,7 @@ describe('Full question workflow', () => {
jest.clearAllMocks();
});
it('successfully asks a question', async () => {
const spyPost = jest.spyOn(axios, 'post');
const spyPost = jest.spyOn(api, 'post');
render(<App />);

// submit question
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/app.test.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import axios from 'axios';
import { rest } from 'msw';
import '@testing-library/jest-dom';
import { api } from '~/API/baseUrlProxy';
import {
render, screen, waitFor,
} from '&/test_utils';
Expand All @@ -21,7 +21,7 @@ describe('<App />', () => {
jest.clearAllMocks();
});
it('loads the Robokop homepage', async () => {
const spy = jest.spyOn(axios, 'get');
const spy = jest.spyOn(api, 'get');
server.use(
rest.get('/api/biolink', (req, res, ctx) => res(
ctx.status(404),
Expand Down
31 changes: 0 additions & 31 deletions tests/unit/question_page.test.jsx

This file was deleted.

2 changes: 1 addition & 1 deletion tests/unit/utils/resultsTable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Results Table', () => {
expect(sortedNodes).toStrictEqual(['3', '1', '2', '4']);
});
it('makes table headers correctly', () => {
const tableHeaders = resultsUtils.makeTableHeaders(test_message.message, () => {});
const tableHeaders = resultsUtils.makeTableHeaders(test_message.message, () => ['', '']);
expect(tableHeaders.length).toBe(2);
const [header1, header2] = tableHeaders;
expect(header1.id).toBe('n1');
Expand Down
2 changes: 1 addition & 1 deletion webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ module.exports = merge(common, {
devtool: 'source-map',
mode: 'production',
output: {
publicPath: '/question-builder/',
publicPath: process.env.BASE_URL || '/',
},
});

0 comments on commit bf2e75b

Please sign in to comment.