-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
smoke: introduce automated smoke tests
- Loading branch information
Showing
13 changed files
with
188 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: smoke | ||
|
||
on: | ||
push: | ||
# schedule: | ||
# # every 6 hours | ||
# - cron: 0 */6 * * * | ||
|
||
jobs: | ||
smoke: | ||
name: smoke | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: notify slack test | ||
env: | ||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_API_TOKEN }} | ||
uses: pullreminders/slack-action@master | ||
with: | ||
args: '{\"channel\":\"G6007H2NM\",\"text\":\"testing, 1, 2, 3\"}' | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
- name: install pnpm | ||
uses: pnpm/action-setup@v2 | ||
- name: get pnpm store path | ||
id: pnpm-cache | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
${{ steps.pnpm-cache.outputs.STORE_PATH }} | ||
~/.cache/Cypress | ||
key: pnpm-cache-v1-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: pnpm-cache-v1- | ||
- name: install deps | ||
run: pnpm --filter @gertie/smoke-tests install | ||
- name: setup just | ||
uses: extractions/setup-just@v1 | ||
- name: run smoke tests | ||
run: just smoke-run | ||
- name: upload-videos | ||
uses: actions/upload-artifact@v3 | ||
if: failure() | ||
with: | ||
name: smoke-videos | ||
path: smoke/cypress/videos | ||
- name: notify slack | ||
if: failure() | ||
env: | ||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_API_TOKEN }} | ||
uses: pullreminders/slack-action@master | ||
with: | ||
args: '{\"channel\":\"G6007H2NM\",\"text\":\"Gertrude smoke test *FAILED*\"}' | ||
|
||
env: | ||
CYPRESS_BASE_URL: https://parents.gertrude.app | ||
CYPRESS_SMOKE_TEST_API_URL: https://api.gertrude.app | ||
CYPRESS_SMOKE_TEST_EMAIL_INBOX_URL: ${{ secrets.SMOKE_TEST_EMAIL_INBOX_URL }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ packages: | |
- 'site/*' | ||
- 'shared/*' | ||
- 'storybook' | ||
- 'smoke' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { defineConfig } from 'cypress'; | ||
|
||
export default defineConfig({ | ||
e2e: { baseUrl: `http://localhost:8081` }, | ||
video: true, | ||
viewportHeight: 800, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/// <reference types="cypress" /> | ||
describe(`Smoke test`, () => { | ||
const email = `82uii.smoke-test-${Date.now()}@inbox.testmail.app`; | ||
const password = `_pw_${Date.now()}`; | ||
|
||
it(`critical flows`, () => { | ||
// signup | ||
cy.visit(`/signup`); | ||
cy.get(`input[name=email]`).type(email); | ||
cy.get(`input[name=password]`).type(`${password}{enter}`); | ||
cy.contains(`Verification email sent`); | ||
cy.wait(Cypress.env(`CI`) ? 10000 : 2500); | ||
|
||
// verify email | ||
cy.request({ url: Cypress.env(`SMOKE_TEST_EMAIL_INBOX_URL`) }).then((response) => { | ||
const body: string = response.body; | ||
if (!body.includes(email)) { | ||
throw new Error(`Expected to find email ${email} in ${body}`); | ||
} | ||
const match = body.match(/"([^" ]+verify-signup-email[^" ]+)"/); | ||
if (!match) { | ||
throw new Error(`Expected to find verify link in ${body}`); | ||
} | ||
cy.wrap(match[1]).as(`verifyLink`); | ||
}); | ||
cy.get(`@verifyLink`).then((verifyLink) => { | ||
cy.visit({ url: verifyLink as any }); | ||
}); | ||
cy.contains(`Welcome to the parent website!`); | ||
|
||
// log out, then back in w/ email/pass | ||
cy.contains(`Log out`).click(); | ||
cy.visit(`/`); | ||
cy.location(`pathname`).should(`eq`, `/login`); | ||
cy.get(`input[name=email]`).type(email); | ||
cy.get(`input[name=password]`).type(`${password}{enter}`); | ||
cy.location(`pathname`).should(`eq`, `/`); | ||
|
||
// create a child | ||
cy.contains(`Add a child`).click(); | ||
cy.get(`[data-test=user-name]`).type(`Franny`); | ||
cy.contains(`Save child`).click(); | ||
|
||
// get the connection code | ||
cy.contains(`Get connection code`).click(); | ||
cy.get(`[data-test=connection-code]`).invoke(`text`).as(`connectionCode`); | ||
|
||
// simulate that they installed the app and connected successfully | ||
cy.get(`@connectionCode`).then((connectionCode) => { | ||
cy.log(`connectionCode`, connectionCode); | ||
cy.request({ | ||
method: `POST`, | ||
url: `${Cypress.env(`SMOKE_TEST_API_URL`)}/pairql/macos-app/ConnectUser`, | ||
headers: { 'Content-Type': `application/json` }, | ||
body: { | ||
verificationCode: Number(connectionCode), | ||
appVersion: `2.1.2`, | ||
modelIdentifier: `MacBookPro16,1`, | ||
username: `franny`, | ||
fullUsername: `Franny`, | ||
numericId: 502, | ||
serialNumber: `C02ZL0J${Math.random()}`, | ||
}, | ||
}) | ||
.its(`status`) | ||
.should(`eq`, 200); | ||
}); | ||
|
||
// dismiss connection modal | ||
cy.get(`[data-test="modal-primary-btn"]`).click(); | ||
cy.visit(`/children`); | ||
cy.contains(`MacBook Pro`); | ||
|
||
// edit the user | ||
cy.contains(`Edit`).click(); | ||
cy.get(`[data-test=user-name]`).clear().type(`Franny (edited)`); | ||
cy.contains(`Save child`).click(); | ||
cy.contains(`Child saved`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference types="cypress" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './commands'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@gertie/smoke-tests", | ||
"version": "1.0.0", | ||
"main": "src/index.ts", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"cypress": "13.6.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Gertie Smoke Tests | ||
|
||
For local testing, add a `./smoke/cypress.env.json` with values like: | ||
|
||
```json | ||
{ | ||
"SMOKE_TEST_EMAIL_INBOX_URL": "http://localhost:1111/test-email-inbox", | ||
"SMOKE_TEST_API_URL": "http://localhost:2222" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "../tsconfig.json" | ||
} |