Skip to content

Instantly share code, notes, and snippets.

View hoangsetup's full-sized avatar
🎯
Work until you no longer have to represent yourself.!

Hoang Dinh hoangsetup

🎯
Work until you no longer have to represent yourself.!
View GitHub Profile
diff --git a/src/application.ts b/src/application.ts
index e9b2e72..4eb841f 100644
--- a/src/application.ts
+++ b/src/application.ts
@@ -1,4 +1,7 @@
-import express, { Application as ExApplication } from 'express';
+import express, { Application as ExApplication, Handler } from 'express';
+import { controllers } from './controllers';
+import { MetadataKeys } from './utils/metadata.keys';
+import { IRouter } from './utils/decorators/handlers.decorator';
import { Handler, Request } from 'express';
import { CognitoIdentityServiceProvider } from 'aws-sdk';
const identityServiceProvider = new CognitoIdentityServiceProvider({
region: process.env.REGION || 'ap-northeast-1',
});
export interface IUser {
id: string;
email: string;
import express from 'express';
import cognitoUserPoolHelper from './cognito.user.pool.helper';
interface IUserController {
signUp: express.Handler,
signIn: express.Handler,
confirmSignUp: express.Handler,
getProfile: express.Handler,
}
import 'cross-fetch/polyfill';
import { AuthenticationDetails, CognitoUser, CognitoUserAttribute, CognitoUserPool } from 'amazon-cognito-identity-js';
export interface IUserToken {
accessToken: string;
refreshToken: string;
}
class CognitoUserPoolHelper {
public userPool: CognitoUserPool;
import { IProduct } from '../interfaces';
import BasePO from './base.po';
class CartPO extends BasePO {
private readonly $cartItem = '.cart_item';
private readonly $cart = {
$name: '.inventory_item_name',
$price: '.inventory_item_price',
};
import { IProduct } from '../interfaces';
import BasePO from './base.po';
class InventoryPO extends BasePO {
private readonly $productItem = '.inventory_item';
private readonly $addCart = '.btn_inventory';
private readonly $cartCount = '.shopping_cart_badge';
private readonly $product = {
$name: '.inventory_item_name',
$price: '.inventory_item_price',
import cartPo from './pages/cart.po';
import inventoryPo from './pages/inventory.po';
describe('Cart', () => {
beforeEach(async () => {
await inventoryPo.go();
});
it('should add correct products to cart', async () => {
const products = await inventoryPo.getProducts();
import loginPo from './pages/login.po';
describe('Login', () => {
beforeEach(async () => {
await loginPo.go();
});
it.each`
username | password | message
${'wrong_username'}| ${'secret_sauce'} | ${'Epic sadface: Username and password do not match any user in this service'},
import BasePO from './base.po';
class LoginPO extends BasePO {
private readonly $usernameInput = '#user-name';
private readonly $passwordInput = '#password';
private readonly $loginButton = '#login-button';
private readonly $errorMessageContainer = '.error-message-container';
async go() {
await this.navigate('/');
import { ElementHandle } from 'puppeteer';
export default abstract class BasePO {
protected readonly BASE_URL = 'https://www.saucedemo.com';
abstract go(): Promise<void>;
async navigate(url: string) {
await page.goto(`${this.BASE_URL}${url}`);
}