Skip to content

Commit

Permalink
#11015 remove more params causing re-renders, fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
siemiatj committed Sep 8, 2021
1 parent a4bfd39 commit 330305f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 27 deletions.
17 changes: 13 additions & 4 deletions frontend/src/__tests__/containers/DocList.test.js
Expand Up @@ -62,6 +62,10 @@ import attributesData from '../../../test_setup/fixtures/attributes.json';

jest.mock(`../../components/app/QuickActions`);

// so that we don't have collision with other tests running in parallel
const serverPort = serverTestPort + 2;
global.config.WS_URL = `ws://localhost:${serverPort}/ws`;

// jest.useFakeTimers();

const middleware = [thunk];
Expand Down Expand Up @@ -114,7 +118,7 @@ describe.skip('DocList', () => {
path: '/ws',
});

server.listen(serverTestPort+1); // this is defined in the jestSetup file
server.listen(serverPort); // this is defined in the jestSetup file
});

// afterEach stop server
Expand Down Expand Up @@ -152,6 +156,11 @@ describe.skip('DocList', () => {
.get('/userSession')
.reply(200, userSessionData);

nock(config.API_URL)
.defaultReplyHeaders({ 'access-control-allow-origin': '*' })
.get('/login/isLoggedIn')
.reply(200, true);

nock(config.API_URL)
.defaultReplyHeaders({ 'access-control-allow-origin': '*' })
.get(`/notifications/websocketEndpoint`)
Expand Down Expand Up @@ -255,7 +264,7 @@ describe.skip('DocList', () => {
);
});

await act( async() => {
await act(async() => {
wrapper.update();

await waitFor(async () => {
Expand All @@ -264,7 +273,7 @@ describe.skip('DocList', () => {
});
});

await act( async() => {
await act(async() => {
wrapper.update();

await waitFor(async () => {
Expand All @@ -282,7 +291,7 @@ describe.skip('DocList', () => {

const quickActionsId = getQuickActionsId({ windowId: includedWindowId, viewId: includedViewId });

await act( async() => {
await act(async() => {
waitFor(() => {
expect(
store.getState().actionsHandler[quickActionsId]
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/__tests__/containers/MasterWindow.test.js
Expand Up @@ -142,6 +142,11 @@ describe.skip('MasterWindowContainer', () => {
.get('/userSession')
.reply(200, userSessionData);

nock(config.API_URL)
.defaultReplyHeaders({ 'access-control-allow-origin': '*' })
.get('/login/isLoggedIn')
.reply(200, true);

nock(config.API_URL)
.defaultReplyHeaders({ 'access-control-allow-origin': '*' })
.get(`/notifications/websocketEndpoint`)
Expand Down
34 changes: 17 additions & 17 deletions frontend/src/containers/Dashboard.js
Expand Up @@ -37,27 +37,27 @@ export class Dashboard extends Component {
rawModal: PropTypes.any,
};

componentDidUpdate() {
// TODO: Resolve this hotfix
return;
// componentDidUpdate() {
// TODO: Resolve this hotfix
// return;

/*
const { me } = this.props;
/*
const { me } = this.props;
if (me) {
let docIntroHints;
if (me) {
let docIntroHints;
if (Array.isArray(introHints['default'])) {
docIntroHints = introHints['default'];
}
if (Array.isArray(introHints['default'])) {
docIntroHints = introHints['default'];
}
this.setState({
hintsEnabled: (docIntroHints && (docIntroHints.length > 0)),
introHints: docIntroHints,
});
}
*/
}
this.setState({
hintsEnabled: (docIntroHints && (docIntroHints.length > 0)),
introHints: docIntroHints,
});
}
*/
// }

toggleEditMode = () => {
this.setState((prevState) => ({ editmode: !prevState.editmode }));
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/containers/DocList.js
Expand Up @@ -50,10 +50,10 @@ class DocList extends PureComponent {
* @summary Update the url with query params if needed (ie add viewId, page etc)
*/
updateUriCallback = (updatedQuery) => {
const { query } = this.props;
const { query, pathname } = this.props;
const { viewId } = updatedQuery;

viewId && updateUri(location.pathname, query, updatedQuery);
viewId && updateUri(pathname, query, updatedQuery);
};

render() {
Expand Down Expand Up @@ -160,7 +160,7 @@ class DocList extends PureComponent {
* @prop {object} query - routing query
* @prop {object} rawModal
* @prop {string} windowId
* @prop {object} location
* @prop {string} pathname
*/
DocList.propTypes = {
includedView: PropTypes.object,
Expand All @@ -170,7 +170,7 @@ DocList.propTypes = {
rawModal: PropTypes.object.isRequired,
windowId: PropTypes.string,
getWindowBreadcrumb: PropTypes.func.isRequired,
location: PropTypes.object.isRequired,
pathname: PropTypes.string.isRequired,
query: PropTypes.object.isRequired,
};

Expand Down
6 changes: 4 additions & 2 deletions frontend/src/routes/KeyRoutes.js
Expand Up @@ -43,13 +43,15 @@ function queriesAreEqual(prevProps, nextProps) {
* @description Route for the document's lists
*/
const RawDocListRoute = ({ location, match }) => {
const { search } = location;
const { search, pathname } = location;
const { params } = match;
const query = queryString.parse(search, {
ignoreQueryPrefix: true,
});

return <DocList query={query} windowId={params.windowId} />;
return (
<DocList query={query} windowId={params.windowId} pathname={pathname} />
);
};

RawDocListRoute.propTypes = {
Expand Down

0 comments on commit 330305f

Please sign in to comment.