зеркало из https://github.com/mozilla/treeherder.git
Bug 1576966 - Convert app switch test to React Testing Library (#5383)
This commit is contained in:
Родитель
adffd63a27
Коммит
10a351a587
|
@ -1,16 +0,0 @@
|
|||
from pages.treeherder import Treeherder
|
||||
|
||||
|
||||
def test_switch_app(base_url, selenium, test_repository):
|
||||
"""Switch between Treeherder and Perfherder using header dropdown"""
|
||||
page = Treeherder(selenium, base_url).open()
|
||||
assert page.header.active_app == 'Treeherder'
|
||||
page = page.switch_to_perfherder()
|
||||
assert page.header.active_app == 'Perfherder'
|
||||
page = page.switch_to_treeherder()
|
||||
# Be aware that when switching back from Perfherder, it will try to
|
||||
# default to mozilla-inbound, which does not exist in this test scenario.
|
||||
# So part of this test is to ensure what happens when the ``repo`` param
|
||||
# in the url is an invalid repo. We should still display the nav bars
|
||||
# and a meaningful error message.
|
||||
assert page.header.active_app == 'Treeherder'
|
|
@ -1,9 +0,0 @@
|
|||
from pages.treeherder import Treeherder
|
||||
|
||||
|
||||
def test_switch_repo(base_url, selenium, test_repository, test_repository_2):
|
||||
"""Switch to new active watched repo"""
|
||||
page = Treeherder(selenium, base_url).open()
|
||||
assert test_repository.name == page.active_watched_repo
|
||||
page.select_repository(test_repository_2.name)
|
||||
assert test_repository_2.name == page.active_watched_repo
|
|
@ -1,14 +0,0 @@
|
|||
from pages.treeherder import Treeherder
|
||||
|
||||
|
||||
def test_open_single_result(base_url, selenium, test_commit):
|
||||
page = Treeherder(selenium, base_url).open()
|
||||
page.wait.until(lambda _: 1 == len(page.pushes))
|
||||
page.pushes[0].view()
|
||||
page.wait.until(lambda _: len(page.pushes))
|
||||
assert 1 == len(page.pushes)
|
||||
assert test_commit.author == page.pushes[0].author
|
||||
assert test_commit.push.time.strftime('%a, %b %-d, %H:%M:%S') == page.pushes[0].datestamp
|
||||
assert 1 == len(page.pushes[0].commits)
|
||||
assert test_commit.revision[:12] == page.pushes[0].commits[0].revision
|
||||
assert test_commit.comments == page.pushes[0].commits[0].comment
|
|
@ -1,6 +1,11 @@
|
|||
import React from 'react';
|
||||
import { fetchMock } from 'fetch-mock';
|
||||
import { render, cleanup, waitForElement } from '@testing-library/react';
|
||||
import {
|
||||
render,
|
||||
cleanup,
|
||||
waitForElement,
|
||||
fireEvent,
|
||||
} from '@testing-library/react';
|
||||
|
||||
import App from '../../../ui/job-view/App';
|
||||
import reposFixture from '../mock/repositories';
|
||||
|
@ -49,10 +54,30 @@ describe('App', () => {
|
|||
},
|
||||
],
|
||||
});
|
||||
fetchMock.get(
|
||||
`begin:${getProjectUrl(
|
||||
'/push/?full=true&count=11&push_timestamp',
|
||||
'try',
|
||||
)}`,
|
||||
{
|
||||
results: [],
|
||||
},
|
||||
);
|
||||
fetchMock.get(`begin:${getApiUrl('/jobs/')}`, {
|
||||
results: [],
|
||||
meta: { repository: repoName, offset: 0, count: 2000 },
|
||||
});
|
||||
|
||||
// Need to mock this function for the app switching tests.
|
||||
// Source: https://github.com/mui-org/material-ui/issues/15726#issuecomment-493124813
|
||||
document.createRange = () => ({
|
||||
setStart: () => {},
|
||||
setEnd: () => {},
|
||||
commonAncestorContainer: {
|
||||
nodeName: 'BODY',
|
||||
ownerDocument: document,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(() => cleanup);
|
||||
|
@ -73,4 +98,20 @@ describe('App', () => {
|
|||
'https://hg.mozilla.org/try/rev/3333333333335143b8df3f4b3e9b504dfbc589a0',
|
||||
);
|
||||
});
|
||||
|
||||
test('should have links to Perfherder and Intermittent Failures View', async () => {
|
||||
const { getByText, getByAltText } = render(<App />);
|
||||
const appMenu = await waitForElement(() => getByAltText('Treeherder'));
|
||||
|
||||
expect(appMenu).toBeInTheDocument();
|
||||
fireEvent.click(appMenu);
|
||||
|
||||
const phMenu = await waitForElement(() => getByText('Perfherder'));
|
||||
expect(phMenu.getAttribute('href')).toBe('/perf.html');
|
||||
|
||||
const ifvMenu = await waitForElement(() =>
|
||||
getByText('Intermittent Failures View'),
|
||||
);
|
||||
expect(ifvMenu.getAttribute('href')).toBe('/intermittent-failures.html');
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче