Skip to content

Commit

Permalink
add grocery list app
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmojicatech committed Jan 11, 2023
1 parent 65776cc commit bd79aae
Show file tree
Hide file tree
Showing 35 changed files with 516 additions and 30,979 deletions.
10 changes: 10 additions & 0 deletions apps/grocery-list-e2e/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": ["plugin:cypress/recommended", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
}
]
}
12 changes: 12 additions & 0 deletions apps/grocery-list-e2e/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"fileServerFolder": ".",
"fixturesFolder": "./src/fixtures",
"integrationFolder": "./src/integration",
"modifyObstructiveCode": false,
"supportFile": "./src/support/index.ts",
"pluginsFile": false,
"video": true,
"videosFolder": "../../dist/cypress/apps/grocery-list-e2e/videos",
"screenshotsFolder": "../../dist/cypress/apps/grocery-list-e2e/screenshots",
"chromeWebSecurity": false
}
29 changes: 29 additions & 0 deletions apps/grocery-list-e2e/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/grocery-list-e2e/src",
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nrwl/cypress:cypress",
"options": {
"cypressConfig": "apps/grocery-list-e2e/cypress.json",
"devServerTarget": "grocery-list:serve:development",
"testingType": "e2e"
},
"configurations": {
"production": {
"devServerTarget": "grocery-list:serve:production"
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/grocery-list-e2e/**/*.{js,ts}"]
}
}
},
"tags": [],
"implicitDependencies": ["grocery-list"]
}
4 changes: 4 additions & 0 deletions apps/grocery-list-e2e/src/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io"
}
13 changes: 13 additions & 0 deletions apps/grocery-list-e2e/src/integration/app.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { getGreeting } from '../support/app.po';

describe('grocery-list', () => {
beforeEach(() => cy.visit('/'));

it('should display welcome message', () => {
// Custom command example, see `../support/commands.ts` file
cy.login('my-email@something.com', 'myPassword');

// Function helper example, see `../support/app.po.ts` file
getGreeting().contains('Welcome grocery-list');
});
});
1 change: 1 addition & 0 deletions apps/grocery-list-e2e/src/support/app.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const getGreeting = () => cy.get('h1');
33 changes: 33 additions & 0 deletions apps/grocery-list-e2e/src/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************

// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> {
login(email: string, password: string): void;
}
}
//
// -- This is a parent command --
Cypress.Commands.add('login', (email, password) => {
console.log('Custom command example: Login', email, password);
});
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
17 changes: 17 additions & 0 deletions apps/grocery-list-e2e/src/support/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example support/index.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.ts using ES2015 syntax:
import './commands';
10 changes: 10 additions & 0 deletions apps/grocery-list-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"sourceMap": false,
"outDir": "../../dist/out-tsc",
"allowJs": true,
"types": ["cypress", "node"]
},
"include": ["src/**/*.ts", "src/**/*.js"]
}
11 changes: 11 additions & 0 deletions apps/grocery-list/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic"
}
]
],
"plugins": []
}
16 changes: 16 additions & 0 deletions apps/grocery-list/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This file is used by:
# 1. autoprefixer to adjust CSS to support the below specified browsers
# 2. babel preset-env to adjust included polyfills
#
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
#
# If you need to support different browsers in production, you may tweak the list below.

last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major version
last 2 iOS major versions
Firefox ESR
not IE 9-11 # For IE 9-11 support, remove 'not'.
18 changes: 18 additions & 0 deletions apps/grocery-list/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
11 changes: 11 additions & 0 deletions apps/grocery-list/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */
export default {
displayName: 'grocery-list',
preset: '../../jest.preset.js',
transform: {
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest',
'^.+\\.[tj]sx?$': 'babel-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/apps/grocery-list',
};
83 changes: 83 additions & 0 deletions apps/grocery-list/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/grocery-list/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nrwl/web:webpack",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"compiler": "babel",
"outputPath": "dist/apps/grocery-list",
"index": "apps/grocery-list/src/index.html",
"baseHref": "/",
"main": "apps/grocery-list/src/main.tsx",
"polyfills": "apps/grocery-list/src/polyfills.ts",
"tsConfig": "apps/grocery-list/tsconfig.app.json",
"assets": [
"apps/grocery-list/src/favicon.ico",
"apps/grocery-list/src/assets"
],
"styles": ["apps/grocery-list/src/styles.scss"],
"scripts": [],
"webpackConfig": "@nrwl/react/plugins/webpack"
},
"configurations": {
"development": {
"extractLicenses": false,
"optimization": false,
"sourceMap": true,
"vendorChunk": true
},
"production": {
"fileReplacements": [
{
"replace": "apps/grocery-list/src/environments/environment.ts",
"with": "apps/grocery-list/src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false
}
}
},
"serve": {
"executor": "@nrwl/web:dev-server",
"defaultConfiguration": "development",
"options": {
"buildTarget": "grocery-list:build",
"hmr": true
},
"configurations": {
"development": {
"buildTarget": "grocery-list:build:development"
},
"production": {
"buildTarget": "grocery-list:build:production",
"hmr": false
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/grocery-list/**/*.{ts,tsx,js,jsx}"]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/apps/grocery-list"],
"options": {
"jestConfig": "apps/grocery-list/jest.config.ts",
"passWithNoTests": true
}
}
},
"tags": []
}
1 change: 1 addition & 0 deletions apps/grocery-list/src/app/app.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Your styles goes here. */
17 changes: 17 additions & 0 deletions apps/grocery-list/src/app/app.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { render } from '@testing-library/react';

import App from './app';

describe('App', () => {
it('should render successfully', () => {
const { baseElement } = render(<App />);

expect(baseElement).toBeTruthy();
});

it('should have a greeting as the title', () => {
const { getByText } = render(<App />);

expect(getByText(/Welcome grocery-list/gi)).toBeTruthy();
});
});
16 changes: 16 additions & 0 deletions apps/grocery-list/src/app/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import styles from './app.module.scss';
import GroceryList from './components/GroceryList';
import Header from './components/Header/Header';

export function App() {
return (
<>
<Header />
<GroceryList />
<div />
</>
);
}

export default App;
7 changes: 7 additions & 0 deletions apps/grocery-list/src/app/components/GroceryList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function GroceryList() {
return (
<main>
Hello World
</main>
)
}
10 changes: 10 additions & 0 deletions apps/grocery-list/src/app/components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import styles from './header.module.scss';

export default function Header(): React.ReactElement {
return (
<header className={styles['headerContainer']}>
<h1>Grocery List</h1>
<input className={styles['searchInput']} type="text" placeholder="Search" />
</header>
)
}
15 changes: 15 additions & 0 deletions apps/grocery-list/src/app/components/Header/header.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.headerContainer {
justify-content: space-between;
align-items: center;

h1 {
margin-left: 2rem;
}
}

.searchInput {
height: 2rem;
border-radius: 1rem;
padding: .5rem;
margin-right: 2rem;
}
Empty file.
3 changes: 3 additions & 0 deletions apps/grocery-list/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const environment = {
production: true,
};
6 changes: 6 additions & 0 deletions apps/grocery-list/src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file can be replaced during build by using the `fileReplacements` array.
// When building for production, this file is replaced with `environment.prod.ts`.

export const environment = {
production: false,
};
Binary file added apps/grocery-list/src/favicon.ico
Binary file not shown.
14 changes: 14 additions & 0 deletions apps/grocery-list/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>GroceryList</title>
<base href="/" />

<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
</head>
<body>
<div id="root"></div>
</body>
</html>
13 changes: 13 additions & 0 deletions apps/grocery-list/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { StrictMode } from 'react';
import * as ReactDOM from 'react-dom/client';

import App from './app/app';

const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<StrictMode>
<App />
</StrictMode>
);
Loading

0 comments on commit bd79aae

Please sign in to comment.