Skip to content

Add toggle to run test without downloading embedded resources #239

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
37 changes: 27 additions & 10 deletions source/console/src/Components/Create/Create.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ class Create extends React.Component {
endpoint,
method,
onSchedule,
retrieveEmbeddedResources,
} = this.state.formValues;

if (!this.form.current.reportValidity()) {
Expand Down Expand Up @@ -261,7 +262,17 @@ class Create extends React.Component {
console.log("Payload", payload);
if (!!parseInt(onSchedule)) payload = this.onSchedulePayloadUpdate(payload);

await this.setPayloadTestScenario({ testType, testName, endpoint, method, headers, body, payload, testId });
await this.setPayloadTestScenario({
testType,
testName,
endpoint,
method,
headers,
body,
payload,
retrieveEmbeddedResources,
testId,
});

this.alertsForBadCronInputs();
this.setState({ isLoading: true });
Expand All @@ -284,7 +295,7 @@ class Create extends React.Component {
};

async setPayloadTestScenario(props) {
let { testType, testName, endpoint, method, headers, body, payload, testId } = props;
let { testType, testName, endpoint, method, headers, body, payload, retrieveEmbeddedResources, testId } = props;
if (testType === "simple") {
headers = headers || "{}";
body = body || "{}";
Expand All @@ -297,6 +308,7 @@ class Create extends React.Component {
}

payload.testScenario.scenarios[testName] = {
"retrieve-resources": retrieveEmbeddedResources ?? true,
requests: [
{
url: endpoint,
Expand Down Expand Up @@ -361,7 +373,9 @@ class Create extends React.Component {
handleInputChange(event) {
this.setState({ submitFailure: false });

const value = event.target.name === "showLive" ? event.target.checked : event.target.value;
const value = ["showLive", "retrieveEmbeddedResources"].includes(event.target.name)
? event.target.checked
: event.target.value;
const name = event.target.name;
const id = event.target.id;

Expand Down Expand Up @@ -1331,13 +1345,6 @@ class Create extends React.Component {
</Collapse>
{this.state.activeTab === "3" && this.schedulingErrors()}
<FormGroup check>
<Input
name="showLive"
id="showLive"
type="checkbox"
checked={this.state.formValues.showLive}
onChange={this.handleInputChange}
/>
<Label check>
<Input
name="showLive"
Expand Down Expand Up @@ -1384,6 +1391,16 @@ class Create extends React.Component {
<FormText color="muted">
Target URL to run tests against, supports http and https. i.e. https://example.com:8080.
</FormText>
<div className="mt-2">
<Input
name="retrieveEmbeddedResources"
id="retrieveEmbeddedResources"
type="checkbox"
onChange={this.handleInputChange}
defaultChecked={true}
/>{" "}
<Label for="retrieveEmbeddedResources">Retrieve embedded resources</Label>
</div>
</FormGroup>
<FormGroup>
<Label for="method">HTTP Method</Label>
Expand Down
1 change: 1 addition & 0 deletions source/console/src/Components/Create/Create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ describe("Functions Testing", () => {
testScenario: {
scenarios: {
testName: {
"retrieve-resources": true,
requests: [
{
url: "endpoint",
Expand Down
5 changes: 5 additions & 0 deletions source/console/src/Components/Details/DetailsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ class DetailsTable extends React.Component {
</Col>
<Col id="testEndpoint" sm="9">
{data.endpoint}
<div className="mt-1">
{Object.values(data.testScenario.scenarios)[0]["retrieve-resources"] === false
? "Without retrieving embedded resources"
: "Including embedded resources"}
</div>
</Col>
</Row>
<Row className="detail">
Expand Down