Skip to content

Commit

Permalink
fix: display error details even if test has successful assertView res…
Browse files Browse the repository at this point in the history
…ults
  • Loading branch information
shadowusr committed Oct 19, 2023
1 parent ee9d0f4 commit 643285b
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 8 deletions.
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,
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
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.
13 changes: 13 additions & 0 deletions test/func/tests/common/test-results-appearance.hermione.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,17 @@ describe('Test results appearance', () => {
}
});
});

describe('Test with successful describe and error', () => {
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();
}
});
});
});
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

0 comments on commit 643285b

Please sign in to comment.