Skip to content

Commit

Permalink
test: adopt firebase function user-flows, add gh action to test fb fu…
Browse files Browse the repository at this point in the history
…nction
  • Loading branch information
BioPhoton committed Jul 12, 2023
1 parent 4ca8820 commit b65b60c
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 14 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/firebase-function-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

# Deploy to Firebase Preview Channel Hosting on PR and test preview branch
name: E2E Firebase Function on PR
'on': pull_request
jobs:
deploy_firebase_preview:
if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: npm

- name: Install dependencies
run: npm ci

- name: Production build for static file hosting (client + prerender + function)
run: npm run nx firebase-function:build:production

- name: Test firebase preview channel hosting
uses: push-based/[email protected]
with:
verbose: on
url: http://127.0.0.1:4402/angular-movies-a12d3/us-central1/ssr
rcPath: projects/firebase-function/.user-flowrc.json
outPath: dist/user-flow/firebase-function
serveCommand: "nx run firebase-function:serve",
awaitServeStdout: "Other reserved ports"
10 changes: 10 additions & 0 deletions projects/firebase-function/.user-flowrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"collect": {
"ufPath": "projects/firebase-function/user-flows"
},
"persist": {
"format": [
"md"
]
}
}
14 changes: 8 additions & 6 deletions projects/firebase-function/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,24 @@
"{options.outputPath}"
],
"options": {
"url": "http://127.0.0.1:4402/angular-movies-a12d3/us-central1/ssr",
"rcPath": "projects/firebase-function/.user-flowrc.json",
"outputPath": "dist/user-flow/firebase-function",
"ufPath": "projects/movies-user-flows/user-flows/navigation.uf.ts",
"format": [
"html"
]
},
"configurations": {
"emulated": {
"url": "http://127.0.0.1:4402/angular-movies-a12d3/us-central1/ssr",
"development": {
"verbose": true,
"dryRun": true,
"dryRun": true
},
"emulated": {
"serveCommand": "nx run firebase-function:serve",
"awaitServeStdout": "functions[us-central1-ssr]: http function initialized"
"awaitServeStdout": "Other reserved ports"
}
}
},
"defaultConfiguration": "development"
}
},
"tags": []
Expand Down
27 changes: 27 additions & 0 deletions projects/firebase-function/user-flows/ci-flow.uf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {UserFlowContext, UserFlowInteractionsFn, UserFlowOptions, UserFlowProvider,} from '@push-based/user-flow';
import {MovieListPageUFO} from '../../movies-user-flows/src';

const flowOptions: UserFlowOptions = {
name: 'Basic user flow to ensure basic functionality',
};

const interactions: UserFlowInteractionsFn = async (
ctx: UserFlowContext
): Promise<any> => {
const {flow, collectOptions} = ctx;
const url = `${collectOptions.url}/list/category/popular`;
const movieListPage = new MovieListPageUFO(ctx);

await flow.navigate(url, {
stepName: '🧭 Initial navigation'
});
await movieListPage.awaitHeadingContent();
return Promise.resolve();
};

export const userFlowProvider: UserFlowProvider = {
flowOptions,
interactions,
};

module.exports = userFlowProvider;
2 changes: 1 addition & 1 deletion projects/movies-user-flows/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"executor": "@push-based/user-flow-nx-plugin:user-flow",
"options": {
"rcPath": "projects/movies-user-flows/.user-flowrc.json",
"outputPath": "dist/user-flows/movies-user-flows"
"outputPath": "dist/user-flow/movies-user-flows"
},
"configurations": {
"prerender": {
Expand Down
11 changes: 4 additions & 7 deletions projects/movies/user-flows/ci-flow.uf.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {UserFlowContext, UserFlowInteractionsFn, UserFlowOptions, UserFlowProvider,} from '@push-based/user-flow';

import {mergeBudgets} from '../../movies-user-flows/src';
import {MovieDetailPageUFO} from '../../movies-user-flows/src';
import {MovieListPageUFO} from '../../movies-user-flows/src';
import {SidebarUFO} from '../../movies-user-flows/src';
import {mergeBudgets, MovieDetailPageUFO, MovieListPageUFO, SidebarUFO} from '../../movies-user-flows/src';

const flowOptions: UserFlowOptions = {
name: 'Basic user flow to ensure basic functionality',
Expand All @@ -25,9 +22,9 @@ const interactions: UserFlowInteractionsFn = async (
extends: 'lighthouse:default',
settings: {
budgets: mergeBudgets([
'./projects/movies-user-flows/src/configs/angular.budgets.json',
'./projects/movies-user-flows/src/configs/general-timing.budgets.json',
'./projects/movies-user-flows/src/configs/movie-list.budgets.json',
'./projects/movies-user-flows/budgets/angular.budgets.json',
'./projects/movies-user-flows/budgets/general-timing.budgets.json',
'./projects/movies/testing/budgets/movie-list.budgets.json',
]),
},
},
Expand Down

0 comments on commit b65b60c

Please sign in to comment.