Skip to content

Commit

Permalink
Add playwright (#55)
Browse files Browse the repository at this point in the history
* Add playwright

* Eslint in playwright

* Add eslint fix to scripts

* Lint plawright during review

* Fix package.json

* Cleanup config

* Base spec

* Gotta rename

* Package log

* Working playwright tests

* Remove root route

* Playwright test in pipeline
  • Loading branch information
NChitty authored Apr 2, 2024
1 parent 81ed5e5 commit 6618e2b
Show file tree
Hide file tree
Showing 11 changed files with 2,046 additions and 19 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,18 @@ jobs:
reporter: github-pr-review
filter_mode: diff_context
workdir: cdk

playwright:
name: "Playwright Lint"
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: reviewdog/action-eslint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
filter_mode: diff_context
workdir: playwright
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ cdk.out
.idea

.env
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
13 changes: 9 additions & 4 deletions cdk/lib/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import {
ShellStep,
} from 'aws-cdk-lib/pipelines';
import path = require('path');
import { HostedZone } from 'aws-cdk-lib/aws-route53';
import { HostedZoneDelegate } from './constructs/delegate-wrapper';

export interface ProjectEnvironment extends Environment {
/**
Expand Down Expand Up @@ -81,7 +79,14 @@ export default class PipelineStack extends Stack {
env: prodEnvironment,
});

pipeline.addStage(stagingStage);
pipeline.addStage(prodStage).addPre(new ManualApprovalStep('ProdApproval'));
pipeline.addStage(stagingStage)
.addPost(new ShellStep('Playwright E2E Test', {
commands: [
'cd playwright',
'npm ci',
'npx playwright test',
],
}));
pipeline.addStage(prodStage);
}
}
15 changes: 0 additions & 15 deletions lambda/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use axum::extract::Query;
use axum::response::Json;
use axum::routing::get;
use axum::Router;
use lambda::services;
use lambda_http::{run, Error};
use serde::Deserialize;
use serde_json::{json, Value};
use tower_http::trace::{
DefaultMakeSpan,
Expand All @@ -16,18 +14,6 @@ use tower_http::trace::{
use tower_http::LatencyUnit;
use tracing::{info, Level};

#[derive(Debug, Deserialize)]
struct Root {
name: String,
}

async fn root(query: Option<Query<Root>>) -> Json<Value> {
if let Some(query) = query {
return Json(json!({ "msg": "Hello ".to_string() + &query.0.name + "!" }));
}
Json(json!({ "msg": "Hello world!" }))
}

async fn ping() -> Json<Value> { Json(json!({ "msg": "Pong" })) }

#[tokio::main]
Expand All @@ -41,7 +27,6 @@ async fn main() -> Result<(), Error> {
info!("Starting services:");
let recipe_service = services::recipes().await;
let app = Router::new()
.route("/", get(root))
.route("/ping", get(ping))
.nest("/recipes", recipe_service)
.layer(
Expand Down
Empty file added playwright/.eslintignore
Empty file.
14 changes: 14 additions & 0 deletions playwright/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
'parser': '@typescript-eslint/parser',
'parserOptions': {
'sourceType': 'module',
'ecmaVersion': 2020,
},
'rules': {
'max-len': ['error', 100],
'object-curly-spacing': ['error', 'always'],
'jsx-quotes': ['error', 'prefer-single'],
},
'plugins': ['@typescript-eslint'],
'extends': ['google'],
};
Loading

0 comments on commit 6618e2b

Please sign in to comment.