-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UI tests for /utils and /components (#23456)
* Add UI tests for /utils and /components * add test for Table * Address PR feedback * Fix window prompt var * Fix TaskName test from rebase * fix lint errors (cherry picked from commit 694e380)
- Loading branch information
1 parent
abbc0b5
commit c8a4e55
Showing
27 changed files
with
694 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/*! | ||
* 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, test, expect, jest, window */ | ||
|
||
import React from 'react'; | ||
import '@testing-library/jest-dom'; | ||
import { render, fireEvent } from '@testing-library/react'; | ||
|
||
import { ClipboardButton } from './Clipboard'; | ||
|
||
describe('ClipboardButton', () => { | ||
test('Loads button', async () => { | ||
const windowPrompt = window.prompt; | ||
window.prompt = jest.fn(); | ||
const { getByText } = render(<ClipboardButton value="lorem ipsum" />); | ||
|
||
const button = getByText(/copy/i); | ||
fireEvent.click(button); | ||
expect(window.prompt).toHaveBeenCalledWith('Copy to clipboard: Ctrl+C, Enter', 'lorem ipsum'); | ||
window.prompt = windowPrompt; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
airflow/www/static/js/grid/components/InstanceTooltip.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/*! | ||
* 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, test, expect */ | ||
|
||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import InstanceTooltip from './InstanceTooltip'; | ||
import { Wrapper } from '../utils/testUtils'; | ||
|
||
const instance = { | ||
startDate: new Date(), | ||
endDate: new Date(), | ||
state: 'success', | ||
runId: 'run', | ||
}; | ||
|
||
describe('Test Task InstanceTooltip', () => { | ||
test('Displays a normal task', () => { | ||
const { getByText } = render( | ||
<InstanceTooltip | ||
group={{}} | ||
instance={instance} | ||
/>, | ||
{ wrapper: Wrapper }, | ||
); | ||
|
||
expect(getByText('Status: success')).toBeDefined(); | ||
}); | ||
|
||
test('Displays a mapped task with overall status', () => { | ||
const { getByText } = render( | ||
<InstanceTooltip | ||
group={{ isMapped: true }} | ||
instance={{ ...instance, mappedStates: ['success', 'success'] }} | ||
/>, | ||
{ wrapper: Wrapper }, | ||
); | ||
|
||
expect(getByText('Overall Status: success')).toBeDefined(); | ||
expect(getByText('2 mapped tasks')).toBeDefined(); | ||
expect(getByText('success: 2')).toBeDefined(); | ||
}); | ||
|
||
test('Displays a task group with overall status', () => { | ||
const { getByText, queryByText } = render( | ||
<InstanceTooltip | ||
group={{ | ||
children: [ | ||
{ | ||
instances: [ | ||
{ | ||
runId: 'run', | ||
state: 'success', | ||
}, | ||
], | ||
}, | ||
], | ||
}} | ||
instance={instance} | ||
/>, | ||
{ wrapper: Wrapper }, | ||
); | ||
|
||
expect(getByText('Overall Status: success')).toBeDefined(); | ||
expect(queryByText('mapped task')).toBeNull(); | ||
expect(getByText('success: 1')).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.