From 1361389435fbe1d9b02c41f5e58bcc9029b64326 Mon Sep 17 00:00:00 2001 From: Guilherme Mangabeira Gregio Date: Fri, 16 Feb 2024 19:14:19 -0300 Subject: [PATCH] feat: wip user-flows with puppeteer replay --- .github/actions/replay/Dockerfile | 8 ++++++++ .github/actions/replay/entrypoint.sh | 11 +++++++++++ .github/workflows/on_prs.yaml | 5 +++++ user-flows/navigation.json | 24 ++++++++++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 .github/actions/replay/Dockerfile create mode 100644 .github/actions/replay/entrypoint.sh create mode 100644 user-flows/navigation.json diff --git a/.github/actions/replay/Dockerfile b/.github/actions/replay/Dockerfile new file mode 100644 index 0000000..97832d3 --- /dev/null +++ b/.github/actions/replay/Dockerfile @@ -0,0 +1,8 @@ +FROM node:iron-alpine + +RUN npm install -g puppeteer @puppeteer/replay + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] + diff --git a/.github/actions/replay/entrypoint.sh b/.github/actions/replay/entrypoint.sh new file mode 100644 index 0000000..c0b571b --- /dev/null +++ b/.github/actions/replay/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh -l + +read -d '' COMMAND <<-EOF + if [ -f "$HOME/ignore" ] && grep "^ignore:$BUILD_DIR" "$HOME/ignore"; then + echo "$BUILD_DIR didn't change" + else + ${BUILD_COMMAND:-echo} && npx @puppeteer/replay $* + fi +EOF + +OUTPUT=$(sh -c "$COMMAND") diff --git a/.github/workflows/on_prs.yaml b/.github/workflows/on_prs.yaml index c391ed3..dd0886c 100644 --- a/.github/workflows/on_prs.yaml +++ b/.github/workflows/on_prs.yaml @@ -24,6 +24,11 @@ jobs: uses: ./.github/actions/affected id: checkForAffected + replay: + uses: ./github/actions/replay + with: + args: user-flows + articles-app: needs: [affected] if: contains(needs.affected.outputs.affected, 'articles-app') diff --git a/user-flows/navigation.json b/user-flows/navigation.json new file mode 100644 index 0000000..a37da78 --- /dev/null +++ b/user-flows/navigation.json @@ -0,0 +1,24 @@ +{ + "title": "creditas-site navigation", + "steps": [ + { + "type": "navigate", + "url": "" + }, + { + "type": "waitForElement", + "target": "main", + "selectors": [ + "aria/Use seu carro, imóvel ou salário e tenha o melhor crédito" + ], + "visible": true + }, + { + "type": "click", + "target": "main", + "selectors": [["xpath///*[@data-testid=\"button-cta\"]"]], + "offsetY": 18, + "offsetX": 111 + } + ] +}