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

Enhancement/4619 backstopjs image #5692

Merged
merged 15 commits into from
Sep 2, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/visual-regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:
- '.nvmrc'
- '**/package.json'
- 'package-lock.json'
- 'src/tests/backstop/config.js'
types:
- opened
- reopened
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const Template = ( { setupRegistry } ) => (
</WithRegistrySetup>
);

const delay = 350; // Needed for fonts to render properly.

const notification1 = {
id: 'test-notification',
title: 'Google Analytics 5 Beta',
Expand Down Expand Up @@ -67,7 +69,7 @@ NotificationCTA.args = {
NotificationCTA.scenario = {
label: 'Global/CoreSiteBannerNotifications1',
readySelector: '.googlesitekit-publisher-win',
delay: 250, // Needed for fonts to render properly.
delay,
};

export const NoNotifications = Template.bind( {} );
Expand All @@ -79,7 +81,7 @@ NoNotifications.args = {
};
NoNotifications.scenario = {
label: 'Global/CoreSiteBannerNotifications2',
delay: 250,
delay,
};

export const NotificationCTAWithSurvey = Template.bind( {} );
Expand All @@ -100,7 +102,7 @@ NotificationCTAWithSurvey.args = {
};
NotificationCTAWithSurvey.scenario = {
label: 'Global/CoreSiteBannerNotifications3',
delay: 250,
delay,
};

export const NotificationCTAWithSurveyShortDelay = Template.bind( {} );
Expand All @@ -124,7 +126,7 @@ NotificationCTAWithSurveyShortDelay.args = {
};
NotificationCTAWithSurveyShortDelay.scenario = {
label: 'Global/CoreSiteBannerNotifications4',
delay: 250,
delay,
};

export const NotificationCTAWithSurveyLongerDelay = Template.bind( {} );
Expand All @@ -149,7 +151,7 @@ NotificationCTAWithSurveyLongerDelay.args = {
NotificationCTAWithSurveyLongerDelay.scenario = {
label: 'Global/CoreSiteBannerNotifications5',
readySelector: '.googlesitekit-publisher-win',
delay: 250,
delay,
};

export default {
Expand Down
34 changes: 34 additions & 0 deletions bin/backstop
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

# Site Kit by Google, Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

BIN_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
ROOT_DIR=$(dirname "$BIN_DIR")

VERSION=6.1.1
IMAGE=googlesitekit/vrt:$VERSION

# Build the backstopjs image if it doesn't exist yet.
docker image inspect $IMAGE -f "{{.Id}}" >/dev/null 2>&1 ||
docker build -t $IMAGE --build-arg BACKSTOPJS_VERSION=$VERSION $ROOT_DIR/docker/backstopjs

# Run the backstopjs command.
docker run --rm -it --mount type=bind,source="$ROOT_DIR",target="/src" $IMAGE $1 --config=/src/tests/backstop/config.js

# Display a link to the report only after the "test" command.
if [ $1 == "test" ]; then
echo ""
echo "To see the VRT report open this URL in your browser: file://$ROOT_DIR/tests/backstop/html_report/index.html"
fi
15 changes: 15 additions & 0 deletions docker/backstopjs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM alpine:latest

ARG BACKSTOPJS_VERSION=6.1.1

ENV BACKSTOPJS_VERSION=$BACKSTOPJS_VERSION

RUN apk upgrade --no-cache --available && \
apk add --no-cache chromium nodejs npm && \
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm i -g backstopjs@${BACKSTOPJS_VERSION} && \
npm cache clean -f && \
rm -rf /root/.cache

WORKDIR /src

ENTRYPOINT ["backstop"]