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

Mock variableService getMacros #26300

Merged
merged 10 commits into from
Feb 14, 2020

Conversation

micajuine-ho
Copy link
Contributor

@micajuine-ho micajuine-ho commented Jan 10, 2020

For #26302

Mocked getMacros(), so that amp-analytics variables get bound to a name transformation, instead of their resolving function:

$IF(blah, blah, blah) =>  _IF(blah%2Cblah%2Cblah)_      **notice that commas get encoded**
$NOT(true) => _NOT(true)_
COOKIE(sp_id) => __COOKIE(sp_id)__
$HASH($NOT(true)) => _HASH(_NOT(true)_)_

Only 3 vendors in vendor-requests.js needed to be changed.

@micajuine-ho
Copy link
Contributor Author

micajuine-ho commented Jan 13, 2020

Added the mock getMacros to test-vendors.js for backward compatibility's sake.

We should rerun these tests before merging.

@micajuine-ho micajuine-ho changed the title Mock variableService getMacros [WIP] Mock variableService getMacros Jan 13, 2020
@micajuine-ho micajuine-ho force-pushed the mock_variable_service branch 2 times, most recently from a1cfeff to eaf4333 Compare February 13, 2020 22:45
@micajuine-ho micajuine-ho changed the title [WIP] Mock variableService getMacros Mock variableService getMacros Feb 13, 2020
Copy link
Contributor

@zhouyx zhouyx left a comment

Choose a reason for hiding this comment

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

Thank you! The improvement to the test is going to be really helpful!

extensions/amp-analytics/0.1/test/test-vendors-new.js Outdated Show resolved Hide resolved
if (params) {
params = '(' + params + ')';
}
return `_${key.replace('$', '')}${params}_`;
Copy link
Contributor

Choose a reason for hiding this comment

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

To confirm:
analytics macros like EXAMPLE(FAKE, param1, param2) is replaced to _EXAMPLE(_fake_, param1,param2)_
global macros like CLIENT_ID(param) is replaced with _client_id_

To get the same behavior across all variables, can we please

  1. Resolve convert analytics macro to lower case as well.
  2. Include the param value for global variables like CLIENT_ID.

Feel free to address 2 in a separate PR. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added 1 (which solved the double expansion problem actually!)
Will address 2 in a separate PR as part of this project.

Copy link
Contributor

@zhouyx zhouyx left a comment

Choose a reason for hiding this comment

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

LGTM

@micajuine-ho micajuine-ho merged commit 2baa308 into ampproject:master Feb 14, 2020
robinvanopstal added a commit to jungvonmatt/amphtml that referenced this pull request Feb 17, 2020
* master: (181 commits)
  🏗 Ensure valid flag usage for `gulp` tasks (ampproject#26814)
  build-system: Fix autocomplete error response (ampproject#26824)
  application/json is ab allowed type for <script> (ampproject#26815)
  🚮 Removing amp-consent-v2 experiment logic (ampproject#26162)
  Fix more arrow functions that are passed in as "constructors" (ampproject#26795)
  Variable substitution tester  (ampproject#26695)
  Turn on restrict fullscreen canary (ampproject#26766)
  Mock variableService getMacros  (ampproject#26300)
  Sync from Google (ampproject#26805)
  Sync from Google (ampproject#26803)
  Move video_state macro (ampproject#26212)
  🚀 Move ads variables to amp-analytics (ampproject#25113)
  Sync from Google (ampproject#26800)
  Sync from Google (ampproject#26798)
  Sync from Google (ampproject#26792)
  Another set of example.com change (ampproject#26753)
  Add PWA multidoc loader to examples (ampproject#26680)
  🐛Check for window null before creating tracking pixel (ampproject#26749)
  trying to update Sauce timeouts (ampproject#26737)
  🐛Fixes swipe to dismiss badly ordered swipes on `amp-lightbox-gallery` (ampproject#26788)
  ...

# Conflicts:
#	extensions/amp-accordion/amp-accordion.md
#	extensions/amp-bind/amp-bind.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants