Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
33 changes: 33 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Playwright Tests
on:
push:
# Appropriage branches would be placed here, assumming that pushes to develop would trigger test run.
branches: [ develop ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Lint
run: npm run lint
- name: Run Playwright tests
# Multiple browsers would be part of test suite
# setting to only chromiun to prevent concurrency issues.
# Ideally this would be batched.
run: npm run test
- name: Upload report file
run: npx ts-node ./scripts/report-upload.ts
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules/
/test-results/
# In real world html report would not be tracked.
# /playwright-report/
/blob-report/
/playwright/.cache/
# In real world report file would not be tracked.
# test-results.json
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run lint
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*.json
20 changes: 20 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"printWidth": 120,
"tabWidth": 4,
"useTabs": false,
"semi": true,
"singleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always",
"endOfLine": "auto",
"overrides": [
{
"files": "package*.json",
"options": {
"tabWidth": 2
}
}
]
}
Binary file added data/.DS_Store
Binary file not shown.
26 changes: 26 additions & 0 deletions data/users.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export interface IUser {
email: string;
password: string;
companyName?: string;
firstName?: string;
lastName?: string;
role?: string;
}
type IUsers = { [k: string]: IUser };

/**
* In a real world scenarios users may not have the same credentials across environments.
* Thus, this would be a function return that would use the environment to determine
* the appropriate credentials.
* Also if credentials have access to sensitive information, say in production, this
* could either be stored in a secret, or use envelope encryption.
*/
export const users = {
test: {
email: "stev.vargas@gmail.com",
password: "uw6^j:UaG6r+8ur",
companyName: "StevVargasTest",
firstName: "Stev",
lastName: "Vargas",
},
} as const satisfies IUsers;
246 changes: 246 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import prettier from "eslint-plugin-prettier";
import unusedImports from "eslint-plugin-unused-imports";
import jsdoc from "eslint-plugin-jsdoc";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
...fixupConfigRules(
compat.extends(
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:prettier/recommended"
)
),
{
plugins: {
"@typescript-eslint": fixupPluginRules(typescriptEslint),
prettier: fixupPluginRules(prettier),
"unused-imports": unusedImports,
jsdoc,
},

languageOptions: {
globals: {
...globals.browser,
...globals.commonjs,
...globals.node,
...globals.jest,
describe: true,
it: true,
expect: true,
beforeEach: true,
afterEach: true,
beforeAll: true,
afterAll: true,
},

parser: tsParser,
ecmaVersion: 6,
sourceType: "module",

parserOptions: {
ecmaFeatures: {
jsx: true,
generators: true,
experimentalObjectRestSpread: true,
},
},
},

settings: {
"import/ignore": ["node_modules", "\\.(json|css|jpg|png|gif|eot|svg|ttf|woff|woff2|mp4|webm)$"],

"import/extensions": [".js"],

"import/resolver": {
typescript: {
alwaysTryTypes: true,
},
},
},

rules: {
"comma-dangle": ["error", "always-multiline"],
"no-debugger": "warn",
"no-console": "off",
"no-alert": "warn",
"no-empty": "error",
"no-extra-semi": "error",
quotes: [2, "double", "avoid-escape"],
semi: "error",
curly: "error",
"valid-jsdoc": "off",
"space-unary-ops": "error",
"block-scoped-var": "error",
"consistent-return": "off",
"dot-notation": "error",
"one-var-declaration-per-line": "error",
"no-trailing-spaces": "error",
"constructor-super": "error",
"no-var": "error",
"import/no-named-as-default": "off",
"no-prototype-builtins": "off",
"no-case-declarations": "off",
"no-useless-escape": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/member-delimiter-style": "off",
"@typescript-eslint/ban-types": "off",

"@typescript-eslint/naming-convention": [
"warn",
{
selector: "variable",
format: ["camelCase", "StrictPascalCase"],
},
{
selector: "interface",
format: ["PascalCase"],
},
{
selector: "function",
format: ["camelCase", "StrictPascalCase"],
},
],

"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/prefer-as-const": "off",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-namespace": "off",
"unused-imports/no-unused-imports": "error",

"unused-imports/no-unused-vars": [
"off",
{
vars: "all",
varsIgnorePattern: "^_",
args: "after-used",
argsIgnorePattern: "^_",
},
],

"prettier/prettier": [
"error",
{},
{
usePrettierrc: true,
},
],

"max-lines": [
"warn",
{
max: 750,
skipBlankLines: true,
skipComments: true,
},
],

"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-duplicate-enum-values": "warn",
"no-undef": "error",
},
},
{
files: ["**/*.json"],

rules: {
"comma-dangle": "off",
semi: "off",
},
},
{
files: ["**/*.js"],

rules: {
"@typescript-eslint/no-var-requires": "off",
},
},
{
files: [
"config/**/env/*.ts",
"**/*.mock.ts",
"**/*.mockData.ts",
"**/*.mock-data.ts",
"**/*.data.ts",
"**/*.mocks.ts",
"**/*data.ts",
"**/*.js",
"**/legacy/**",
"**/*-legacy/**",
],

rules: {
"max-lines": "off",
"@typescript-eslint/naming-convention": "off",
},
},
{
files: ["constants/**/*.ts", "**/*.js"],

rules: {
"@typescript-eslint/naming-convention": "off",
},
},
{
files: ["**/*.js"],

rules: {
"jsdoc/check-access": 1,
"jsdoc/check-alignment": 1,
"jsdoc/check-param-names": 1,
"jsdoc/check-property-names": 1,
"jsdoc/check-syntax": 1,
"jsdoc/check-tag-names": 1,
"jsdoc/check-types": 1,
"jsdoc/check-values": 1,
"jsdoc/empty-tags": 1,
"jsdoc/implements-on-classes": 1,
"jsdoc/multiline-blocks": 1,
"jsdoc/no-bad-blocks": 1,
"jsdoc/no-multi-asterisks": 1,
"jsdoc/no-undefined-types": 1,
"jsdoc/require-jsdoc": 1,
"jsdoc/require-param": 1,
"jsdoc/require-property": 1,
"jsdoc/require-property-description": 1,
"jsdoc/require-property-name": 1,
"jsdoc/require-property-type": 1,
"jsdoc/require-returns-check": 1,
"jsdoc/require-returns-type": 1,
"jsdoc/require-yields-check": 1,
"jsdoc/sort-tags": 1,
"jsdoc/tag-lines": 1,
"jsdoc/valid-types": 1,
},
},
];
19 changes: 19 additions & 0 deletions helpers/context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Browser, BrowserContext, Page } from "playwright";

export class TestContext {
public browserContext: BrowserContext;
public page: Page;

constructor(private browser: Browser) {}
async initNewContext() {
this.browserContext = await this.browser.newContext();
}

async initNewPage() {
this.page = await this.browserContext.newPage();
}

async dispose() {
await this.browserContext.close();
}
}
Loading