Skip to content

Commit 36014b4

Browse files
authored
Merge pull request #409 from gemini-testing/FEI-23991.copy_muted_test
fix: copy link for skipped test
2 parents 808d355 + b3b6575 commit 36014b4

File tree

4 files changed

+111
-2
lines changed

4 files changed

+111
-2
lines changed

lib/static/components/section/section-browser.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class SectionBrowser extends Component {
8585
<BrowserTitle
8686
title={title}
8787
browserId={browser.id}
88+
browserName={browser.name}
8889
lastResultId={lastResult.id}
8990
handler={this.onToggleSection}
9091
/>

lib/static/components/section/title/browser.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class BrowserTitle extends Component {
1414
static propTypes = {
1515
title: PropTypes.node.isRequired,
1616
browserId: PropTypes.string.isRequired,
17+
browserName: PropTypes.string.isRequired,
1718
lastResultId: PropTypes.string.isRequired,
1819
handler: PropTypes.func.isRequired,
1920
// from store
@@ -30,10 +31,10 @@ class BrowserTitle extends Component {
3031
}
3132

3233
_getTestUrl() {
33-
const {title, testName, retryIndex} = this.props;
34+
const {browserName, testName, retryIndex} = this.props;
3435

3536
return appendQuery(window.location.href, {
36-
browser: title,
37+
browser: browserName,
3738
testNameFilter: testName,
3839
strictMatchFilter: true,
3940
retryIndex,

test/unit/lib/static/components/section/section-browser.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,30 @@ describe('<SectionBrowser/>', () => {
154154
assert.calledOnceWith(actionsStub.toggleBrowserSection, {browserId: 'yabro-1', shouldBeOpened: true});
155155
});
156156
});
157+
158+
describe('<ClipboardButton/>', () => {
159+
let BrowserTitle;
160+
161+
beforeEach(() => {
162+
BrowserTitle = sandbox.stub().returns(null);
163+
SectionBrowser = proxyquire('lib/static/components/section/section-browser', {
164+
'./title/browser': {default: BrowserTitle}
165+
}).default;
166+
});
167+
168+
it('should render "BrowserTitle" with "browserName" for correctly working clipboard button', () => {
169+
const browsersById = mkBrowser({id: 'yabro', name: 'yabro', resultIds: ['res']});
170+
const browsersStateById = {'yabro': {shouldBeShown: true, shouldBeOpened: false}};
171+
const resultsById = mkResult({id: 'res', status: SUCCESS});
172+
const tree = mkStateTree({browsersById, browsersStateById, resultsById});
173+
174+
mkSectionBrowserComponent({browserId: 'yabro'}, {tree});
175+
176+
assert.calledOnceWith(BrowserTitle, {
177+
browserId: 'yabro', browserName: 'yabro', handler: sinon.match.any,
178+
lastResultId: 'res', title: 'yabro'
179+
});
180+
});
181+
});
157182
});
183+
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import React from 'react';
2+
import {defaults} from 'lodash';
3+
import proxyquire from 'proxyquire';
4+
import {mkConnectedComponent} from 'test/unit/lib/static/components/utils';
5+
import {mkBrowser, mkResult, mkStateTree} from 'test/unit/lib/static/state-utils';
6+
import {SKIPPED} from 'lib/constants/test-statuses';
7+
import actionNames from 'lib/static/modules/action-names';
8+
import viewModes from 'lib/constants/view-modes';
9+
import {EXPAND_ALL} from 'lib/constants/expand-modes';
10+
11+
describe('<BrowserTitle/>', () => {
12+
const sandbox = sinon.sandbox.create();
13+
let BrowserTitle, actionsStub, queryParams;
14+
15+
const mkBrowserTitleComponent = (props = {}, initialState = {}) => {
16+
props = defaults(props, {
17+
title: 'default_title',
18+
browserId: 'default_bro',
19+
browserName: 'default_name',
20+
lastResultId: 'default_res',
21+
handler: () => {}
22+
});
23+
initialState = defaults(initialState, {
24+
tree: mkStateTree()
25+
});
26+
27+
return mkConnectedComponent(<BrowserTitle {...props} />, {initialState});
28+
};
29+
30+
beforeEach(() => {
31+
actionsStub = {
32+
copyTestLink: sandbox.stub().returns({type: actionNames.COPY_TEST_LINK})
33+
};
34+
35+
queryParams = {
36+
appendQuery: sandbox.stub().returns(null)
37+
};
38+
39+
BrowserTitle = proxyquire('lib/static/components/section/title/browser', {
40+
'../../../modules/actions': actionsStub,
41+
'../../../modules/query-params': queryParams
42+
}).default;
43+
});
44+
45+
describe('<ClipboardButton/>', () => {
46+
it('should call action "onCopyTestLink" on click', () => {
47+
const browsersById = mkBrowser({id: 'yabro', name: 'yabro', resultIds: ['default_res']});
48+
const resultsById = mkResult({id: 'default_res', status: SKIPPED, skipReason: 'some-reason'});
49+
const tree = mkStateTree({browsersById, resultsById});
50+
51+
const component = mkBrowserTitleComponent({browserId: 'yabro'}, {tree});
52+
component.find('ClipboardButton').simulate('click');
53+
54+
assert.calledOnce(actionsStub.copyTestLink);
55+
assert.calledWithExactly(actionsStub.copyTestLink);
56+
});
57+
58+
it('should call "appendQuery" with correct arguments', () => {
59+
const browsersById = mkBrowser({id: 'yabro', name: 'yabro', parentId: 'test'});
60+
const resultsById = mkResult({id: 'default_res', status: SKIPPED, skipReason: 'some-reason'});
61+
const tree = mkStateTree({browsersById, resultsById});
62+
63+
const component = mkBrowserTitleComponent({browserId: 'yabro', browserName: 'yabro'}, {tree});
64+
65+
// call prop to simulate click due to multiple requires in ClipboardButton
66+
component.find('ClipboardButton').prop('option-text')();
67+
68+
assert.calledOnce(queryParams.appendQuery);
69+
assert.calledWithExactly(queryParams.appendQuery, 'about:blank', {
70+
browser: 'yabro',
71+
testNameFilter: 'test',
72+
strictMatchFilter: true,
73+
retryIndex: 0,
74+
viewModes: viewModes.ALL,
75+
expand: EXPAND_ALL,
76+
groupByError: false
77+
});
78+
});
79+
});
80+
});
81+

0 commit comments

Comments
 (0)