Skip to content

Commit 321b0fe

Browse files
committed
Support raising an issue for a specific command from Test Run page
1 parent b8b9c59 commit 321b0fe

File tree

3 files changed

+128
-8
lines changed

3 files changed

+128
-8
lines changed

client/components/TestRun/TestRun.css

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,3 +523,35 @@ a.btn-options:hover {
523523
.form-control.is-invalid {
524524
background-image: none;
525525
}
526+
527+
.raise-issue-container {
528+
display: flex;
529+
flex-direction: column;
530+
font-size: 0.75rem;
531+
}
532+
533+
.raise-issue-container .title {
534+
align-self: flex-start;
535+
font-weight: bold;
536+
}
537+
538+
.raise-issue-container input[type="radio"] {
539+
margin-right: 0.25rem;
540+
vertical-align: middle;
541+
}
542+
543+
.raise-issue-container .options {
544+
display: flex;
545+
}
546+
547+
.raise-issue-container .options.type {
548+
justify-content: space-between;
549+
margin-bottom: 0.5rem;
550+
}
551+
552+
.raise-issue-container .options.command {
553+
flex-direction: column;
554+
align-items: flex-start;
555+
text-align: left;
556+
margin-bottom: 0.5rem;
557+
}

client/components/TestRun/index.jsx

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ const TestRun = () => {
130130
const [currentAtVersion, setCurrentAtVersion] = useState('');
131131
const [currentBrowserVersion, setCurrentBrowserVersion] = useState('');
132132
const [pageReady, setPageReady] = useState(false);
133+
const [selectedIssueType, setSelectedIssueType] = useState('test');
134+
const [selectedCommandForIssue, setSelectedCommandForIssue] = useState('');
133135

134136
const auth = evaluateAuth(data && data.me ? data.me : {});
135137
let { id: userId, isSignedIn, isAdmin } = auth;
@@ -374,7 +376,8 @@ const TestRun = () => {
374376
browserName: testPlanReport.browser.name,
375377
atVersionName: currentAtVersion?.name,
376378
browserVersionName: currentBrowserVersion?.name,
377-
conflictMarkdown: conflictMarkdownRef.current
379+
conflictMarkdown: conflictMarkdownRef.current,
380+
commandString: selectedCommandForIssue
378381
});
379382
}
380383

@@ -885,6 +888,25 @@ const TestRun = () => {
885888
editAtBrowserDetailsButtonRef.current.focus();
886889
};
887890

891+
const onIssueTypeChange = e => {
892+
const type = e.target.value;
893+
if (type === 'command') {
894+
const scenario = currentTest.scenarios[0];
895+
const commandText = scenario.commands
896+
.map(command => command.text)
897+
.join(' then ');
898+
if (!selectedCommandForIssue) setSelectedCommandForIssue(commandText);
899+
} else {
900+
setSelectedCommandForIssue('');
901+
}
902+
setSelectedIssueType(type);
903+
};
904+
905+
const onSelectedCommandForIssueChange = e => {
906+
const command = e.target.value;
907+
setSelectedCommandForIssue(command);
908+
};
909+
888910
const renderTestContent = (testPlanReport, currentTest, heading) => {
889911
const { index } = currentTest;
890912
const isComplete = currentTest.testResult
@@ -963,7 +985,60 @@ const TestRun = () => {
963985
<div role="complementary">
964986
<h2 id="test-options-heading">Test Options</h2>
965987
<ul className="options-wrapper" aria-labelledby="test-options-heading">
966-
<li>
988+
<li className="raise-issue-container">
989+
<span className="title">Raise an issue for ...</span>
990+
<div className="options type" onChange={onIssueTypeChange}>
991+
<label>
992+
<input
993+
id="testIssueType"
994+
name="issueTypeOption"
995+
type="radio"
996+
value="test"
997+
defaultChecked
998+
/>
999+
test
1000+
</label>
1001+
<label>
1002+
<input
1003+
id="commandIssueType"
1004+
name="issueTypeOption"
1005+
type="radio"
1006+
value="command"
1007+
/>
1008+
command
1009+
</label>
1010+
</div>
1011+
{selectedIssueType === 'command' && (
1012+
<>
1013+
<span className="title">Select command ...</span>
1014+
<div
1015+
className="options command"
1016+
onChange={onSelectedCommandForIssueChange}
1017+
>
1018+
{currentTest.scenarios.map((scenario, index) => {
1019+
const commandKey = `${scenario.id}-${scenario.commands
1020+
.map(command => command.id)
1021+
.join('_')}`;
1022+
const commandText = scenario.commands
1023+
.map(command => command.text)
1024+
.join(' then ');
1025+
1026+
return (
1027+
<label key={commandKey}>
1028+
<input
1029+
id={commandKey}
1030+
name="commandOption"
1031+
type="radio"
1032+
value={commandText}
1033+
defaultChecked={index === 0}
1034+
/>
1035+
{commandText}
1036+
</label>
1037+
);
1038+
})}
1039+
</div>
1040+
</>
1041+
)}
9671042
<OptionButton
9681043
text="Raise an Issue"
9691044
icon={

client/utils/createIssueLink.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const atLabelMap = {
2929
* @param {string|null} [options.browserVersionName=null] - The version name of the browser
3030
* @param {string|null} [options.conflictMarkdown=null] - The conflict markdown
3131
* @param {string|null} [options.reportLink=null] - The link to the report
32+
* @param {string|null} [options.command=null] - The command to be included in the report
3233
* @returns {string} The URL for creating a new issue on the GitHub repository
3334
* @throws {Error} If required parameters are missing
3435
*/
@@ -48,7 +49,8 @@ const createIssueLink = ({
4849
browserVersionName = null,
4950
conflictMarkdown = null,
5051
reportLink = null,
51-
testReviewLink = null
52+
testReviewLink = null,
53+
commandString = null
5254
}) => {
5355
if (!(testPlanDirectory || testPlanTitle || versionString || atName)) {
5456
throw new Error('Cannot create issue link due to missing parameters');
@@ -72,9 +74,15 @@ const createIssueLink = ({
7274
titleStart = 'Feedback';
7375
}
7476

75-
title =
76-
`${titleStart}: "${testTitle}" (${testPlanTitle}, ` +
77-
`Test ${testSequenceNumber}, ${versionString})`;
77+
if (commandString) {
78+
title =
79+
`${titleStart}: "${testTitle}" (${testPlanTitle}, ` +
80+
`Test ${testSequenceNumber}, Command "${commandString}", ${versionString})`;
81+
} else {
82+
title =
83+
`${titleStart}: "${testTitle}" (${testPlanTitle}, ` +
84+
`Test ${testSequenceNumber}, ${versionString})`;
85+
}
7886
} else {
7987
title = `General Feedback: ${testPlanTitle} ${versionString}`;
8088
if (atName) title = `${atName} ${title}`;
@@ -120,8 +128,13 @@ const createIssueLink = ({
120128
`[${shortenedUrl}](${modifiedRenderedUrl})\n` +
121129
reportLinkFormatted +
122130
atFormatted +
123-
browserFormatted +
124-
'\n';
131+
browserFormatted;
132+
133+
if (commandString) {
134+
testSetupFormatted = `${testSetupFormatted}` + `- Command: ${commandString}\n`;
135+
}
136+
137+
testSetupFormatted = `${testSetupFormatted}\n`;
125138
}
126139

127140
let metadataFormatted = '';

0 commit comments

Comments
 (0)