From a288a77a900cb1fd3cbb573ce47b129ff38ebc25 Mon Sep 17 00:00:00 2001 From: nmanu1 <88398086+nmanu1@users.noreply.github.com> Date: Tue, 26 Apr 2022 16:54:03 -0400 Subject: [PATCH 1/3] Use reusable workflows (#1064) Update the github workflows to use the callable workflows in the `slapshot-reusable-workflows` repo. J=SLAP-2005 TEST=auto - See that the `coverage`, `percy_snapshots`, `run_tests`, and `wcag_test` workflows run on this PR as expected. - Fork the repo and commit to master. See that the `sync_develop_and_main` workflow creates a PR as expected. Push to a hotfix branch and see that the `version-update` workflow creates a PR only when the package version doesn't match the branch --- .github/workflows/coverage.yml | 25 +---- .github/workflows/percy-snapshots.yml | 118 ++++++-------------- .github/workflows/run-tests.yml | 20 +--- .github/workflows/sync_develop_and_main.yml | 26 +---- .github/workflows/version-update.yml | 49 +------- .github/workflows/wcag_test.yml | 21 +--- translations/messages.pot | 30 ++--- 7 files changed, 75 insertions(+), 214 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 1b4b984f7..f7429f2be 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -9,22 +9,9 @@ on: pull_request: jobs: - Coveralls: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [15.x] - - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm ci - - run: npx jest tests/static/ --coverage - - name: Coveralls - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + call_coveralls: + uses: yext/slapshot-reusable-workflows/.github/workflows/coverage.yml@v1 + with: + test_script: npx jest tests/static/ --coverage + secrets: + caller_github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/percy-snapshots.yml b/.github/workflows/percy-snapshots.yml index f71776293..a5053af80 100644 --- a/.github/workflows/percy-snapshots.yml +++ b/.github/workflows/percy-snapshots.yml @@ -1,6 +1,6 @@ name: Percy Snapshots -on: +on: push: branches-ignore: dev/* pull_request: @@ -14,90 +14,46 @@ jobs: - id: nonce run: echo "::set-output name=result::${{ github.run_id }}-$(date +%s)" - default-snapshots: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [12.18] + call_snapshots_default: needs: nonce - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm ci - - run: npm run setup-test-site - - run: npm run build-test-site - - name: Percy snapshots - run: npx percy exec --parallel -- node tests/percy/index.js - env: - PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} - PERCY_PARALLEL_NONCE: ${{ needs.nonce.outputs.result }} - PERCY_PARALLEL_TOTAL: 4 + uses: yext/slapshot-reusable-workflows/.github/workflows/percy_snapshots.yml@v1 + with: + build_script: npm run setup-test-site && npm run build-test-site + percy_script: npx percy exec --parallel -- node tests/percy/index.js + PERCY_PARALLEL_NONCE: ${{ needs.nonce.outputs.result }} + PERCY_PARALLEL_TOTAL: 4 + secrets: + PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} - iframe-snapshots: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [12.18] + call_snapshots_iframe: needs: nonce - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm ci - - run: npm run setup-test-site - - run: npm run build-test-site - - name: Percy snapshots - run: npx percy exec --parallel -- node tests/percy/index.js iframe - env: - PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} - PERCY_PARALLEL_NONCE: ${{ needs.nonce.outputs.result }} - PERCY_PARALLEL_TOTAL: 4 + uses: yext/slapshot-reusable-workflows/.github/workflows/percy_snapshots.yml@v1 + with: + build_script: npm run setup-test-site && npm run build-test-site + percy_script: npx percy exec --parallel -- node tests/percy/index.js iframe + PERCY_PARALLEL_NONCE: ${{ needs.nonce.outputs.result }} + PERCY_PARALLEL_TOTAL: 4 + secrets: + PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} - spanish-snapshots: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [12.18] + call_snapshots_spanish: needs: nonce - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm ci - - run: npm run setup-test-site - - run: npm run build-test-site - - name: Percy snapshots - run: npx percy exec --parallel -- node tests/percy/index.js spanish - env: - PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} - PERCY_PARALLEL_NONCE: ${{ needs.nonce.outputs.result }} - PERCY_PARALLEL_TOTAL: 4 + uses: yext/slapshot-reusable-workflows/.github/workflows/percy_snapshots.yml@v1 + with: + build_script: npm run setup-test-site && npm run build-test-site + percy_script: npx percy exec --parallel -- node tests/percy/index.js spanish + PERCY_PARALLEL_NONCE: ${{ needs.nonce.outputs.result }} + PERCY_PARALLEL_TOTAL: 4 + secrets: + PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} - rtl-snapshots: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [12.18] + call_snapshots_rtl: needs: nonce - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm ci - - run: npm run setup-test-site - - run: npm run build-test-site - - name: Percy snapshots - run: npx percy exec --parallel -- node tests/percy/index.js rtl - env: - PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} - PERCY_PARALLEL_NONCE: ${{ needs.nonce.outputs.result }} - PERCY_PARALLEL_TOTAL: 4 + uses: yext/slapshot-reusable-workflows/.github/workflows/percy_snapshots.yml@v1 + with: + build_script: npm run setup-test-site && npm run build-test-site + percy_script: npx percy exec --parallel -- node tests/percy/index.js rtl + PERCY_PARALLEL_NONCE: ${{ needs.nonce.outputs.result }} + PERCY_PARALLEL_TOTAL: 4 + secrets: + PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 48caaf756..2ecb067ec 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -6,19 +6,7 @@ name: Run Tests on: [push, pull_request] jobs: - build: - - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [12.x, 14.x, 15.x] - - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm ci - - run: npm test + call_run_tests: + uses: yext/slapshot-reusable-workflows/.github/workflows/run_tests.yml@v1 + with: + build_script: '' diff --git a/.github/workflows/sync_develop_and_main.yml b/.github/workflows/sync_develop_and_main.yml index 3c1bfb9d1..45808a607 100644 --- a/.github/workflows/sync_develop_and_main.yml +++ b/.github/workflows/sync_develop_and_main.yml @@ -1,27 +1,11 @@ -name: create PR from main to develop +name: Create PR from main to develop on: push: branches: [main, master] -permissions: - contents: read - pull-requests: write - jobs: - createPullRequest: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: extract package version - id: vars - run: | - PACKAGE_VERSION="v$(cat ./package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')" - echo ::set-output name=tag::${PACKAGE_VERSION} - - uses: repo-sync/pull-request@v2 - with: - source_branch: "${{ github.event.repository.default_branch }}" - destination_branch: "develop" - pr_title: "Merge ${{ github.event.repository.default_branch }} (${{ steps.vars.outputs.tag }}) into develop" - pr_body: "Merge ${{ github.event.repository.default_branch }} (${{ steps.vars.outputs.tag }}) into develop" - github_token: ${{ secrets.GITHUB_TOKEN }} + call_sync_develop_and_main: + uses: yext/slapshot-reusable-workflows/.github/workflows/sync_develop_and_main.yml@v1 + secrets: + caller_github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/version-update.yml b/.github/workflows/version-update.yml index e4a944be6..a246e47fa 100644 --- a/.github/workflows/version-update.yml +++ b/.github/workflows/version-update.yml @@ -4,49 +4,8 @@ on: push: branches: [release/*, hotfix/*] -permissions: - contents: write - pull-requests: write - jobs: - update-version: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - - name: update package version - id: vars - run: | - BRANCH_NAME="${GITHUB_REF#refs/heads/}" - PACKAGE_VERSION="${GITHUB_REF##*/}" - echo ::set-output name=branch::${BRANCH_NAME} - if [[ $PACKAGE_VERSION =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?$ ]] - then - if [[ $PACKAGE_VERSION =~ ^v[0-9]+\.[0-9]+$ ]] - then - PACKAGE_VERSION="${PACKAGE_VERSION}.0" - fi - echo ::set-output name=version::${PACKAGE_VERSION} - git config user.name 'github-actions[bot]' - git config user.email 'github-actions[bot]@users.noreply.github.com' - if npm version ${PACKAGE_VERSION} | tee >( grep -q 'npm ERR! Version not changed' ) - then - echo "Package version is already in sync with branch name." - echo ::set-output name=should_create_pr::0 - exit 0 - fi - echo ::set-output name=should_create_pr::1 - git push -u origin HEAD:"dev/update-version-${PACKAGE_VERSION}" - else - echo "Branch name ${BRANCH_NAME} does not have the correct format with package version." - exit 1 - fi - - name: create version update pr - if: steps.vars.outputs.should_create_pr == 1 - uses: repo-sync/pull-request@v2 - with: - source_branch: "dev/update-version-${{ steps.vars.outputs.version }}" - destination_branch: "${{ steps.vars.outputs.branch }}" - pr_title: "Update Package Version to ${{ steps.vars.outputs.version }}" - pr_body: "*An automated PR which updates the version number in package.json and package-lock.json files*" - github_token: ${{ secrets.GITHUB_TOKEN }} + call_version_update: + uses: yext/slapshot-reusable-workflows/.github/workflows/version_update.yml@v1 + secrets: + caller_github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/wcag_test.yml b/.github/workflows/wcag_test.yml index c0a7aa60d..e2c267310 100644 --- a/.github/workflows/wcag_test.yml +++ b/.github/workflows/wcag_test.yml @@ -5,20 +5,7 @@ on: branches: [develop, hotfix/*, release/*, support/*] jobs: - WCAG-test: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [14.x] - - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node-version }} - - run: npm ci - - run: npm run setup-test-site - - run: npm run build-test-site - - run: npm run wcag \ No newline at end of file + call_wcag_test: + uses: yext/slapshot-reusable-workflows/.github/workflows/wcag_test.yml@v1 + with: + build_script: npm run setup-test-site && npm run build-test-site diff --git a/translations/messages.pot b/translations/messages.pot index 232e48e2f..18c7bad3f 100644 --- a/translations/messages.pot +++ b/translations/messages.pot @@ -105,9 +105,9 @@ msgstr "" #: cards/multilang-job-standard/component.js:31 #: cards/multilang-link-standard/component.js:28 #: cards/multilang-menuitem-standard/component.js:36 -#: cards/multilang-product-prominentimage/component.js:39 -#: cards/multilang-product-prominentvideo/component.js:34 -#: cards/multilang-product-standard/component.js:38 +#: cards/multilang-product-prominentimage/component.js:38 +#: cards/multilang-product-prominentvideo/component.js:33 +#: cards/multilang-product-standard/component.js:37 #: cards/multilang-professional-location/component.js:44 #: cards/multilang-professional-standard/component.js:36 #: cards/multilang-standard/component.js:31 @@ -119,9 +119,9 @@ msgstr "" #: cards/multilang-job-standard/component.js:30 #: cards/multilang-link-standard/component.js:27 #: cards/multilang-menuitem-standard/component.js:35 -#: cards/multilang-product-prominentimage/component.js:38 -#: cards/multilang-product-prominentvideo/component.js:33 -#: cards/multilang-product-standard/component.js:37 +#: cards/multilang-product-prominentimage/component.js:37 +#: cards/multilang-product-prominentvideo/component.js:32 +#: cards/multilang-product-standard/component.js:36 #: cards/multilang-professional-location/component.js:43 #: cards/multilang-professional-standard/component.js:35 #: cards/multilang-standard/component.js:30 @@ -154,9 +154,9 @@ msgstr "" #: cards/multilang-location-standard/component.js:58 #: cards/multilang-menuitem-standard/component.js:59 #: cards/multilang-product-prominentimage-clickable/component.js:44 -#: cards/multilang-product-prominentimage/component.js:62 -#: cards/multilang-product-prominentvideo/component.js:57 -#: cards/multilang-product-standard/component.js:61 +#: cards/multilang-product-prominentimage/component.js:61 +#: cards/multilang-product-prominentvideo/component.js:56 +#: cards/multilang-product-standard/component.js:60 #: cards/multilang-professional-location/component.js:69 #: cards/multilang-professional-standard/component.js:59 #: cards/multilang-standard/component.js:54 @@ -178,9 +178,9 @@ msgstr[1] "" #: cards/multilang-location-standard/component.js:59 #: cards/multilang-menuitem-standard/component.js:60 #: cards/multilang-product-prominentimage-clickable/component.js:45 -#: cards/multilang-product-prominentimage/component.js:63 -#: cards/multilang-product-prominentvideo/component.js:58 -#: cards/multilang-product-standard/component.js:62 +#: cards/multilang-product-prominentimage/component.js:62 +#: cards/multilang-product-prominentvideo/component.js:57 +#: cards/multilang-product-standard/component.js:61 #: cards/multilang-professional-location/component.js:70 #: cards/multilang-professional-standard/component.js:60 #: cards/multilang-standard/component.js:55 @@ -198,9 +198,9 @@ msgstr "" #: cards/multilang-location-standard/component.js:60 #: cards/multilang-menuitem-standard/component.js:61 #: cards/multilang-product-prominentimage-clickable/component.js:46 -#: cards/multilang-product-prominentimage/component.js:64 -#: cards/multilang-product-prominentvideo/component.js:59 -#: cards/multilang-product-standard/component.js:63 +#: cards/multilang-product-prominentimage/component.js:63 +#: cards/multilang-product-prominentvideo/component.js:58 +#: cards/multilang-product-standard/component.js:62 #: cards/multilang-professional-location/component.js:71 #: cards/multilang-professional-standard/component.js:61 #: cards/multilang-standard/component.js:56 From 31df08d5a1ca166892fb53521c99bb310922b0da Mon Sep 17 00:00:00 2001 From: Yen Truong <36055303+yen-tt@users.noreply.github.com> Date: Tue, 3 May 2022 14:29:45 -0400 Subject: [PATCH 2/3] remove wcag2aaa (#1066) Product confirmed only wcag standards up to level AA is required. Remove wcag2aaa check for wcag tests. J=none TEST=none --- tests/wcag/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/wcag/index.js b/tests/wcag/index.js index 12be4986f..c4fbcf77f 100755 --- a/tests/wcag/index.js +++ b/tests/wcag/index.js @@ -13,14 +13,14 @@ const PORT = 5042; * API documentation: https://github.com/dequelabs/axe-core/blob/master/doc/API.md * - set reporter to 'no-passes' to only return violation results * - set runOnly with tag values below to run WCAG standards: - * - WCAG 2.0 Level A, AA, AAA + * - WCAG 2.0 Level A, AA * - WCAG 2.1 Level A, AA */ const config = { reporter: "no-passes", runOnly: { type: 'tag', - values: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag2aaa'], + values: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa'], } } From de6108aff1405f4c31ad7a7a0dc7535915b809f9 Mon Sep 17 00:00:00 2001 From: Yen Truong <36055303+yen-tt@users.noreply.github.com> Date: Fri, 6 May 2022 14:14:21 -0400 Subject: [PATCH 3/3] keep parent's domain for tab navigation on new tab in iframe experience (#1067) This pr ensures tab navigation open to a new tab in an iframe experience should still be under the domain of the iFrame's parent for the new page's url. After ANSWERS is initialized or in onReady stage, when iframeLoaded promise is resolved - indicating this is an iframe experience - a message is sent to the parent (in iframe-messaging.js) to send its url to the iframe telling it to update its tab navigation (iframe-common.js). In the iframe's onMessage hook, `setParentUrl` is invoked for every navigation component on the page to properly update the tabs' link to navigate under the domain of the iframe's parent. This require changes in [SDK](https://github.com/yext/answers-search-ui/pull/1731) pr. acceptance test in this pr will fail until SDK changes is merge to develop J=SLAP-2089 TEST=manual Tested along with the changes in theme. Deployed two test sites in storm, with [one being from the theme dev branch](https://devtabnaviniframe-theme-slapshot-pagescdn-com.preview.pagescdn.com/?query=virginia&referrerPageUrl=) that points to the SDK pr dev branch, under the staging commit: dev/tab-nav-in-iframe[@65f09b10](https://github.com/yext/answers-hitchhiker-theme/commit/65f09b101f882c597389717d4a8b8d814edb1bda). That is used in the src script of iframe_test.html of the [other site](https://devyttesting-theme-slapshot-pagescdn-com.preview.pagescdn.com/?query=virginia&referrerPageUrl=) under the staging commit: dev/yt-testing[@517e852f](https://github.com/yext/answers-hitchhiker-theme/commit/517e852fe3ff2f7961704090e11118273ba162b3). Navigate to different tabs in the same tab and opening them in new tab. See that the page is still under the domain of the iFrame's parent. --- layouts/html.hbs | 6 +++++- script/iframe-messaging.js | 6 +++++- static/js/iframe-common.js | 7 +++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/layouts/html.hbs b/layouts/html.hbs index 56d870766..7920c919f 100644 --- a/layouts/html.hbs +++ b/layouts/html.hbs @@ -146,9 +146,13 @@ } else if (window.isOverlay) { window.Overlay.onMessage(message); } else if (message.eventType && message.eventType === 'click') { - ANSWERS.components + ANSWERS?.components .getActiveComponents('AutoComplete') .forEach(autocompleteComponent => autocompleteComponent.close()); + } else if (message.action === 'update-tab-navigation') { + ANSWERS?.components + .getActiveComponents('Navigation') + .forEach(navigationComponent => navigationComponent.setParentUrl(message.parentUrl)); } } }; diff --git a/script/iframe-messaging.js b/script/iframe-messaging.js index ac14fc3e4..3c86e8087 100644 --- a/script/iframe-messaging.js +++ b/script/iframe-messaging.js @@ -13,4 +13,8 @@ ANSWERS.core.storage.registerListener({ sessionId: ANSWERS.core.getOrSetupSessionId() })); } -}); \ No newline at end of file +}); + +window.parentIFrame.sendMessage(JSON.stringify({ + action: 'answers-initialized' +})); diff --git a/static/js/iframe-common.js b/static/js/iframe-common.js index d4e9f1c4f..ec9960f24 100644 --- a/static/js/iframe-common.js +++ b/static/js/iframe-common.js @@ -115,6 +115,13 @@ export function generateIFrame(domain, answersExperienceFrame) { document.body.scrollTop = iframeOffsetTop; // For Safari return; } + if (message.action === 'answers-initialized') { + sendToIframe({ + action: 'update-tab-navigation', + parentUrl: window.location.href + }); + return; + } const params = message.params; const pageTitle = message.pageTitle; pageTitle && (iframe.title = pageTitle);