Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: display error details even if test has successful assertView results #516

Merged
merged 10 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/static/components/icons/view-in-browser/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
display: inline-block;
width: 16px;
height: 19px;
vertical-align: middle;
margin-left: 4px;
margin-right: 0;
padding: 0 2px;
Expand Down
3 changes: 1 addition & 2 deletions lib/static/components/section/body/tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class Tabs extends Component {
id: PropTypes.string.isRequired,
status: PropTypes.string.isRequired,
imageIds: PropTypes.array.isRequired,
multipleTabs: PropTypes.bool.isRequired,
shadowusr marked this conversation as resolved.
Show resolved Hide resolved
screenshot: PropTypes.bool.isRequired,
error: PropTypes.object
}).isRequired
Expand All @@ -20,7 +19,7 @@ class Tabs extends Component {
_shouldAddErrorTab() {
const {result} = this.props;

return result.multipleTabs && isErrorStatus(result.status) && !result.screenshot;
return isErrorStatus(result.status);
}

_drawTab({key, imageId = null}) {
Expand Down
6 changes: 3 additions & 3 deletions lib/static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

.report {
font: 15px YS Text, Helvetica Neue, Arial, sans-serif;
line-height: 20px;
line-height: 15px;
margin-bottom: 15px;
}

Expand Down Expand Up @@ -320,7 +320,7 @@ main.container {

.section__body .section__title {
font-size: 15px;
line-height: 20px;
line-height: 15px;
}

.section__body .section__title.section__title_type_browser {
Expand All @@ -335,7 +335,7 @@ main.container {
.sticky-header__wrap:before {
content: '';
width: 18px;
height: 16px;
height: 18px;
display: inline-block;
margin-right: 5px;
vertical-align: middle;
Expand Down
2 changes: 1 addition & 1 deletion test/func/common.hermione.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports.getCommonConfig = (projectDir) => ({
desiredCapabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
args: ['headless', 'no-sandbox'],
args: ['headless', 'no-sandbox', 'hide-scrollbars'],
binary: CHROME_BINARY_PATH
}
},
Expand Down
Binary file not shown.
8 changes: 8 additions & 0 deletions test/func/fixtures/hermione/failed-describe.hermione.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ describe('failed describe', function() {
throw new Error(`long_error_message ${'0123456789'.repeat(20)}\n message content`);
});

it('test with successful assertView and error', async ({browser}) => {
await browser.url(browser.options.baseUrl);

await browser.assertView('header', 'header');

throw new Error('Some error');
});

it.skip('test skipped', async ({browser}) => {
await browser.url(browser.options.baseUrl);
});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions test/func/fixtures/playwright/tests/failed-describe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ test.describe('failed describe', () => {
test.skip(true, 'foo-bar');
});

test('test with successful assertView and error', async ({page, baseURL}) => {
await page.goto(baseURL as string);

await expect(page.locator('header')).toHaveScreenshot('header-success.png');

throw new Error('Some error');
});

test.skip('test skipped', async ({page, baseURL}) => {
await page.goto(baseURL as string);
});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion test/func/tests/common-gui/index.hermione.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const {promisify} = require('util');
const treeKill = promisify(require('tree-kill'));

const {PORTS} = require('../../utils/constants');
const {getTestSectionByNameSelector, getSpoilerByNameSelector, getElementWithTextSelector} = require('../utils');
const {getTestSectionByNameSelector, getSpoilerByNameSelector, getElementWithTextSelector, hideScreenshots} = require('../utils');

const serverHost = process.env.SERVER_HOST ?? 'host.docker.internal';

Expand Down Expand Up @@ -139,6 +139,7 @@ describe('GUI mode', () => {
getTestSectionByNameSelector(fullTestName) +
'//button[@data-test-id="retry-switcher"]';
const retrySwitcher = browser.$(`(${allRetryButtonsSelector})[last()]`);
await hideScreenshots(browser);

await retrySwitcher.assertView('retry-switcher');

Expand All @@ -155,13 +156,15 @@ describe('GUI mode', () => {
);

await retryButton.click();
await retryButton.waitForClickable({reverse: true, timeout: 10000});
await retryButton.waitForClickable({timeout: 10000});

// Verify green retry button
const allRetryButtonsSelector =
getTestSectionByNameSelector(fullTestName) +
'//button[@data-test-id="retry-switcher"]';
const retrySwitcher = browser.$(`(${allRetryButtonsSelector})[last()]`);
await hideScreenshots(browser);

await retrySwitcher.assertView('retry-switcher');

Expand Down
29 changes: 27 additions & 2 deletions test/func/tests/common/test-results-appearance.hermione.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
const {getTestSectionByNameSelector, getImageSectionSelector, getTestStateByNameSelector, getElementWithTextSelector, hideHeader} = require('../utils');
const {
getTestSectionByNameSelector,
getImageSectionSelector,
getTestStateByNameSelector,
getElementWithTextSelector,
hideHeader, hideScreenshots
} = require('../utils');

describe('Test results appearance', () => {
beforeEach(async ({browser}) => {
Expand All @@ -13,6 +19,7 @@ describe('Test results appearance', () => {
);

await hideHeader(browser);
await hideScreenshots(browser);

await retrySelectorButton.assertView('retry-selector');
});
Expand All @@ -26,6 +33,7 @@ describe('Test results appearance', () => {
);

await hideHeader(browser);
await hideScreenshots(browser);

await retrySelectorButton.assertView('retry-selector');
});
Expand Down Expand Up @@ -66,7 +74,8 @@ describe('Test results appearance', () => {
);

await hideHeader(browser);
await browser.execute(() =>{
await hideScreenshots(browser);
await browser.execute(() => {
window.scrollTo(0, 10000);
});

Expand Down Expand Up @@ -106,6 +115,7 @@ describe('Test results appearance', () => {
);

await hideHeader(browser);
await hideScreenshots(browser);

await retrySelectorButton.assertView('retry-selector');
});
Expand All @@ -121,4 +131,19 @@ describe('Test results appearance', () => {
}
});
});

describe('Test with successful assertView and error', () => {
// eslint-disable-next-line no-undef
hermione.only.in('chrome');
it('should display error message, name and stack', async ({browser}) => {
for (const field of ['message', 'name', 'stack']) {
const errorMessage = browser.$(
getTestSectionByNameSelector('test with successful assertView and error') +
getElementWithTextSelector('span', field) + '/..'
);

await expect(errorMessage).toBeDisplayed();
}
});
});
});
Binary file modified test/func/tests/screens/0049570/chrome/retry-switcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/07c99c0/chrome/retry-switcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/1361a92/chrome-pwt/retry-selector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/1361a92/chrome/retry-selector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/42ea26d/chrome-pwt/retry-selector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/42ea26d/chrome/retry-selector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/45b9477/chrome/retry-switcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/5c90021/chrome/basic plugins.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/67cd8d8/chrome/retry-switcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/972e9ff/chrome/menu bar plugins.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/c0db305/chrome-pwt/details summary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/c0db305/chrome/details summary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/d8c5b8a/chrome/redux plugin clicked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/d90f7de/chrome-pwt/retry-selector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/d90f7de/chrome/retry-selector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/ff4deba/chrome-pwt/retry-selector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/ff4deba/chrome/retry-selector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion test/func/tests/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,20 @@ const hideHeader = async (browser) => {
});
};

const hideScreenshots = async (browser) => {
await browser.execute(() => {
document.querySelectorAll('.image-box__image').forEach(el => {
el.style.display = 'none';
});
});
};

module.exports = {
getTestSectionByNameSelector,
getTestStateByNameSelector,
getImageSectionSelector,
getElementWithTextSelector,
getSpoilerByNameSelector,
hideHeader
hideHeader,
hideScreenshots
};
10 changes: 4 additions & 6 deletions test/unit/lib/static/components/section/body/tabs.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import proxyquire from 'proxyquire';
import {defaultsDeep} from 'lodash';
import {ERROR, SUCCESS} from 'lib/constants/test-statuses';
import {ERROR, FAIL, SUCCESS} from 'lib/constants/test-statuses';
import {mkConnectedComponent} from '../../utils';

describe('<Tabs />', () => {
Expand All @@ -13,9 +13,7 @@ describe('<Tabs />', () => {
result: {
id: 'default-result-id',
status: SUCCESS,
imageIds: [],
multipleTabs: true,
screenshot: true
imageIds: []
}
});

Expand Down Expand Up @@ -64,7 +62,7 @@ describe('<Tabs />', () => {
});

it('should render image tab for each image id', () => {
const result = {status: ERROR, imageIds: ['img-1', 'img-2']};
const result = {status: FAIL, imageIds: ['img-1', 'img-2']};

const component = mkTabs({result});

Expand All @@ -75,7 +73,7 @@ describe('<Tabs />', () => {
});

it('should not render additional error tab if test errored with screenshot on reject', () => {
const result = {status: ERROR, imageIds: ['img-1'], screenshot: true};
const result = {status: FAIL, imageIds: ['img-1'], screenshot: true};

const component = mkTabs({result});

Expand Down
Loading