Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

chore(search): Closes #3321 Change contentSearchUIController to better match existing tests #3325

Merged
merged 1 commit into from Sep 1, 2017

Conversation

sarracini
Copy link
Contributor

@sarracini sarracini commented Aug 31, 2017

Fix #3321.

  1. Exposes gContentSearchcontroller to window so that various tests in browser_aboutHome.js can find it (and removes it on unmount)
  2. Adds a healthReportKey and a source depending on the document uri. see -> http://searchfox.org/mozilla-central/source/browser/base/content/abouthome/aboutHome.js#235-236

@sarracini
Copy link
Contributor Author

@k88hudson can i get your eyes on this too to make sure it looks ok

Copy link
Member

@Mardak Mardak left a comment

Choose a reason for hiding this comment

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

This doesn't actually fix #3320 which is actually a something like a special "activitystream-home" healthreport key different from the existing "abouthome" key

@@ -48,13 +54,15 @@ class Search extends React.Component {
<span className="sr-only"><FormattedMessage id="search_web_placeholder" /></span>
</label>
<input
autoFocus="autofocus"
Copy link
Member

Choose a reason for hiding this comment

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

we want this only for about:home

Copy link
Member

Choose a reason for hiding this comment

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

and only on first visible ?

Copy link
Contributor Author

@sarracini sarracini Aug 31, 2017

Choose a reason for hiding this comment

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

Ah yes you're right, I'll just remove this because it's broken anyways and there's a ticket to do autofocus anyways #2007

@@ -28,11 +31,14 @@ class Search extends React.Component {
// this name, and can add the appropriate telemetry probes for search. Without the
// correct name, certain tests like browser_UsageTelemetry_content.js will fail (See
// github ticket #2348 for more details)
this.controller = new ContentSearchUIController(input, input.parentNode,
"newtab", "newtab");
const isDocumentNewtabOrHome = document.documentURI === "about:newtab";
Copy link
Member

@Mardak Mardak Aug 31, 2017

Choose a reason for hiding this comment

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

from a programmer "or", this should always be true ;) maybe just isNewtab but we'll want it available in render or elsewhere too for autofocus

@Mardak Mardak assigned sarracini and unassigned Mardak Aug 31, 2017
@sarracini sarracini changed the title chore(search): Closes #3320 Add special healthReportKey for abouthome search chore(search): Closes #3321 Change contentSearchUIController to better match existing tests Sep 1, 2017
@sarracini sarracini assigned Mardak and k88hudson and unassigned sarracini Sep 1, 2017
Copy link
Member

@Mardak Mardak left a comment

Choose a reason for hiding this comment

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

Looks good. Just more comments so hopefully people are careful when touching this stuff.

// probes for search. Without the correct name, certain tests like
// browser_UsageTelemetry_content.js will fail (See github ticket #2348 for more details)
const healthReportKey = IS_NEWTAB ? "newtab" : "abouthome";
const source = IS_NEWTAB ? "newtab" : "homepage";
Copy link
Member

Choose a reason for hiding this comment

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

Let's name this searchSource and also have a comment describing that it's so search engine plugins can correctly attribute referrals especially.

@@ -50,7 +50,7 @@ describe("<Search>", () => {

wrapper.find(".search-button").simulate("click");

const {search} = wrapper.node.controller;
const {search} = window.gContentSearchController;
Copy link
Member

Choose a reason for hiding this comment

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

I suppose this effectively tests that we place it on the global. Might make sense to have a test dedicated to just making sure window.gContentSearchController exists after mounting with a description of it being an expected global.

// browser_UsageTelemetry_content.js will fail (See github ticket #2348 for more details)
const healthReportKey = IS_NEWTAB ? "newtab" : "abouthome";
const source = IS_NEWTAB ? "newtab" : "homepage";
window.gContentSearchController = new ContentSearchUIController(input, input.parentNode,
Copy link
Member

Choose a reason for hiding this comment

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

Just to be extra safe, an extra comment here saying this gContentSearchController global is to allow existing about:home tests to pass, but potentially could be renamed / refactored when only activity stream is the only about:home.

@as-pine-proxy
Copy link
Collaborator

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants