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 #3250 - Makes form wizard the default #3252

Merged
merged 5 commits into from
Mar 30, 2020
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
15 changes: 6 additions & 9 deletions config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ def get_variation(variation_key, variations_dict, defaults_dict):
'browser-fenix',
'browser-focus-geckoview',
'browser-firefox-reality',
'form-v2-experiment',
'type-fastclick',
'type-google',
'type-marfeel',
Expand All @@ -226,25 +225,23 @@ def get_variation(variation_key, variations_dict, defaults_dict):

# Get AB experiment variation values from the environement.
AB_VARIATIONS = {
'FORM_V1_VARIATION': os.environ.get('FORM_V1_VARIATION', '0 100'),
'FORM_V2_VARIATION': os.environ.get('FORM_V2_VARIATION', '100 100'),
'V1_VARIATION': os.environ.get('V1_VARIATION', '0 100'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karlcow can you make sure to update the environment variables on the server to match this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(i did this)

'V2_VARIATION': os.environ.get('V2_VARIATION', '100 100'),
}
# We define default values here, as a fallback.
# By default, v1 will be served 100% of the time.
AB_DEFAULTS = {
'FORM_V1_VARIATION': (0, 100),
'FORM_V2_VARIATION': (100, 100),
'V1_VARIATION': (0, 100),
'V2_VARIATION': (100, 100),
}
EXP_MAX_AGE = int(os.environ.get('EXP_MAX_AGE', 0))

# AB testing config
AB_EXPERIMENTS = {
'exp': {
'variations': {
'form-v1': get_variation('FORM_V1_VARIATION', AB_VARIATIONS,
AB_DEFAULTS),
'form-v2': get_variation('FORM_V2_VARIATION', AB_VARIATIONS,
AB_DEFAULTS),
'v1': get_variation('V1_VARIATION', AB_VARIATIONS, AB_DEFAULTS),
'v2': get_variation('V2_VARIATION', AB_VARIATIONS, AB_DEFAULTS),
},
'max-age': EXP_MAX_AGE
}
Expand Down
103 changes: 0 additions & 103 deletions tests/functional/image-uploads-non-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@ const intern = require("intern").default;
const { assert } = intern.getPlugin("chai");
const { registerSuite } = intern.getInterface("object");
const FunctionalHelpers = require("./lib/helpers.js");
const path = require("path");
const url = intern.config.siteRoot + "/issues/new";
const cwd = intern.config.basePath;

// This string is executed by calls to `execute()` in various tests
// it postMessages a small green test square.
const POSTMESSAGE_TEST_SQUARE =
'postMessage("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAIAAABLixI0AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAB3RJTUUH3gYSAig452t/EQAAAClJREFUOMvtzkENAAAMg0A25ZU+E032AQEXoNcApCGFLX5paWlpaWl9dqq9AS6CKROfAAAAAElFTkSuQmCC", "http://localhost:5000")';
const VALID_IMAGE_PATH = path.join(cwd, "tests/fixtures", "green_square.png");
const BAD_IMAGE_PATH = path.join(cwd, "tests/fixtures", "evil.py");

registerSuite("Image Uploads (non-auth)", {
tests: {
Expand Down Expand Up @@ -158,31 +154,6 @@ registerSuite("Image Uploads (non-auth)", {
.end();
},

"remove image upload button is shown"() {
return (
FunctionalHelpers.openPage(this, url, ".js-remove-upload")
// send a small base64 encoded green test square
.execute(POSTMESSAGE_TEST_SQUARE)
.sleep(1000)
.findByCssSelector(".js-remove-upload")
.isDisplayed()
.then(function(isDisplayed) {
assert.equal(isDisplayed, true, "Remove button is displayed");
})
.end()
.findByCssSelector(".js-image-upload")
.getAttribute("class")
.then(function(className) {
assert.notInclude(
"is-validated",
className,
"parent container got the right class after an image was postMessage'd"
);
})
.end()
);
},

"clicking remove image upload button removes preview"() {
return (
FunctionalHelpers.openPage(this, url, ".js-remove-upload")
Expand Down Expand Up @@ -256,80 +227,6 @@ registerSuite("Image Uploads (non-auth)", {
);
})
.end();
},

"Image extension validation"() {
return (
FunctionalHelpers.openPage(this, url, ".js-report-buttons")
.findByCssSelector("#image")
.type(BAD_IMAGE_PATH)
.end()
.findByCssSelector(".form-upload-error")
.getVisibleText()
.then(function(text) {
assert.include(
text,
"Image must be one of the following",
"Image type validation message is shown"
);
})
.end()
// pick a valid file type
.findByCssSelector("#image")
.type(VALID_IMAGE_PATH)
.end()
// validation message should be gone
.waitForDeletedByCssSelector(".form-upload-error")
.end()
);
},

"Selecting an invalid image after a valid one"() {
return (
FunctionalHelpers.openPage(this, url, ".js-report-buttons")
.findByCssSelector("#image")
.type(VALID_IMAGE_PATH)
.end()
.findByCssSelector("#image")
.type(BAD_IMAGE_PATH)
.end()
.findByCssSelector(".form-upload-error")
.getVisibleText()
.then(function(text) {
assert.include(
text,
"Image must be one of the following",
"Image type validation message is shown"
);
})
.end()
.findByCssSelector(".js-image-upload")
.getAttribute("style")
.then(function(inlineStyle) {
assert.notInclude(
inlineStyle,
"data:image/png;base64,iVBOR",
"The previous valid image preview should be removed."
);
})
.end()
.findByCssSelector(".js-label-upload")
.isDisplayed()
.then(function(isDisplayed) {
assert.isFalse(
isDisplayed,
"Upload label is hidden while the error is displayed"
);
})
.end()
// pick a valid file type
.findByCssSelector("#image")
.type(VALID_IMAGE_PATH)
.end()
// validation message should be gone
.waitForDeletedByCssSelector(".form-upload-error")
.end()
);
}
}
});
84 changes: 72 additions & 12 deletions tests/functional/reporting-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,78 @@ registerSuite("Reporting (auth)", {
},

tests: {
"Report button shows name"() {
return FunctionalHelpers.openPage(
this,
url("/issues/new"),
".js-Navbar-link"
)
.findByCssSelector("#submitgithub")
.getVisibleText()
.then(function(text) {
assert.include(text, "Report as"); //Report as FooUser (logged in)
})
.end();
"Wizard stepper - scenario 1"() {
return (
FunctionalHelpers.openPage(this, url("/issues/new"), "#js-ReportForm")
// Manual url enter
.findByCssSelector("#url")
.type("http://example.com")
.end()
// Click on "Confirm"
.findByCssSelector(".button.step-1")
.click()
.end()
.execute(function() {
// Click on "Desktop site instead of mobile site"
$("[for=problem_category-0]")[0].click();
})
.sleep(1000)
// Click on "Yes"
.findByCssSelector(".button.step-4")
.click()
.end()
.sleep(500)
.findByCssSelector(".button.step-6")
.getAttribute("class")
.then(function(className) {
// Make sure that "Confirm" button is disabled if browser is not selected
assert.include(className, "disabled");
})
.execute(function() {
// Click on "Chrome"
$("[for=tested_browsers-0]")[0].click();
})
.end()
.sleep(500)
// Click on "Confirm"
.findByCssSelector(".button.step-6")
.click()
.end()
// Enter less than 30 characters in the description field
.findById("steps_reproduce")
.type("not enough characters")
.end()
.sleep(500)
.findDisplayedByCssSelector(".button.step-8")
.getAttribute("class")
.then(function(className) {
// Make sure "Continue" is disabled if there are not enough characters
assert.include(className, "disabled");
})
.end()
.findById("steps_reproduce")
.clearValue()
// Enter more than 30 characters in the description field
.type("This paragraph contains more than 30 characters")
.end()
.sleep(500)
// Click on "Continue"
.findByCssSelector(".button.step-8")
.click()
.end()
.sleep(500)
.findDisplayedByCssSelector(".button.step-10")
// Click on "Continue without"
.click()
.end()
.sleep(500)
// Make sure Report as FooUser (logged in)
.findByCssSelector("#submitgithub")
.getVisibleText()
.then(function(text) {
assert.include(text, "Report as");
})
);
}
}
});
50 changes: 42 additions & 8 deletions tests/functional/reporting-issue-wizard-non-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,13 @@ const path = require("path");

const cwd = intern.config.basePath;
const VALID_IMAGE_PATH = path.join(cwd, "tests/fixtures", "green_square.png");
const BAD_IMAGE_PATH = path.join(cwd, "tests/fixtures", "evil.py");

const url = function(path) {
return intern.config.siteRoot + path;
};

registerSuite("Reporting with wizard", {
before() {
return FunctionalHelpers.setCookie(this, { name: "exp", value: "form-v2" });
},

after() {
return FunctionalHelpers.deleteCookie(this, "exp");
},

tests: {
"Space in domain name validation"() {
return FunctionalHelpers.openPage(
Expand Down Expand Up @@ -368,6 +361,47 @@ registerSuite("Reporting with wizard", {
.findByCssSelector("#image")
.type(VALID_IMAGE_PATH)
.end()
// Change for a bad image
.findByCssSelector("#image")
.type(BAD_IMAGE_PATH)
.end()
// check the error message
.findByCssSelector(".form-upload-error")
.getVisibleText()
.then(function(text) {
assert.include(
text,
"Image must be one of the following",
"Image type validation message is shown"
);
})
.end()
.findByCssSelector(".js-image-upload")
.getAttribute("style")
.then(function(inlineStyle) {
assert.notInclude(
inlineStyle,
"data:image/png;base64,iVBOR",
"The previous valid image preview should be removed."
);
})
.end()
.findByCssSelector(".js-label-upload")
.isDisplayed()
.then(function(isDisplayed) {
assert.isFalse(
isDisplayed,
"Upload label is hidden while the error is displayed"
);
})
.end()
// pick a valid file type
.findByCssSelector("#image")
.type(VALID_IMAGE_PATH)
.end()
// validation message should be gone
.waitForDeletedByCssSelector(".form-upload-error")
.end()
.sleep(500)
.findDisplayedByCssSelector(".button.step-10")
.getVisibleText()
Expand Down
Loading