pierrejeambrun commented on code in PR #23392: URL: https://github.com/apache/airflow/pull/23392#discussion_r868219400
########## airflow/www/static/js/grid/utils/useFilters.test.jsx: ########## @@ -0,0 +1,78 @@ +/*! + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* global describe, expect, jest, test, moment */ +import { act, renderHook } from '@testing-library/react-hooks'; + +import useFilters from './useFilters'; +import { RouterWrapper } from './testUtils'; + +const date = new Date(); Review Comment: Moving this to a `beforeEach` or something similar does not fix the issue. The problem is we patch the date after importing 'useFilters' in the test. useFitlers defines `now` without the patch. By the time we arrive to the patch in the test, we may have changed from 1seconde to another. I pushed a change where we patch before we import the `useFilters` in the test. This is not very elegant, let me know if you see another solution. I tested it without the `date.setMilliseconds(0);` and it's working so we may even remove that if we want. I kept it because otherwise it gives a bad looking date format with milliseconds. (Same for the date picker) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
