Skip to content

Commit ecfdc3c

Browse files
committed
initial commit
0 parents  commit ecfdc3c

27 files changed

+11778
-0
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
max_line_length = off
13+
trim_trailing_whitespace = false

.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
8+
# dependencies
9+
/node_modules
10+
11+
# profiling files
12+
chrome-profiler-events.json
13+
speed-measure-plugin.json
14+
15+
# IDEs and editors
16+
/.idea
17+
.project
18+
.classpath
19+
.c9/
20+
*.launch
21+
.settings/
22+
*.sublime-workspace
23+
24+
# IDE - VSCode
25+
.vscode/*
26+
!.vscode/settings.json
27+
!.vscode/tasks.json
28+
!.vscode/launch.json
29+
!.vscode/extensions.json
30+
31+
# misc
32+
/.sass-cache
33+
/connect.lock
34+
/coverage
35+
/libpeerconnection.log
36+
npm-debug.log
37+
yarn-error.log
38+
testem.log
39+
/typings
40+
41+
# System Files
42+
.DS_Store
43+
Thumbs.db

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SziaApp
2+
3+
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.1.2.
4+
5+
## Development server
6+
7+
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
8+
9+
## Code scaffolding
10+
11+
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
12+
13+
## Build
14+
15+
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
16+
17+
## Running unit tests
18+
19+
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20+
21+
## Running end-to-end tests
22+
23+
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
24+
25+
## Further help
26+
27+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).

angular.json

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"szia-app": {
7+
"root": "",
8+
"sourceRoot": "src",
9+
"projectType": "application",
10+
"prefix": "szia",
11+
"schematics": {
12+
"@schematics/angular:component": {
13+
"styleext": "scss"
14+
}
15+
},
16+
"architect": {
17+
"build": {
18+
"builder": "@angular-devkit/build-angular:browser",
19+
"options": {
20+
"outputPath": "dist/szia-app",
21+
"index": "src/index.html",
22+
"main": "src/main.ts",
23+
"polyfills": "src/polyfills.ts",
24+
"tsConfig": "src/tsconfig.app.json",
25+
"assets": [
26+
"src/favicon.ico",
27+
"src/assets"
28+
],
29+
"styles": [
30+
"src/styles.scss"
31+
],
32+
"scripts": []
33+
},
34+
"configurations": {
35+
"production": {
36+
"fileReplacements": [
37+
{
38+
"replace": "src/environments/environment.ts",
39+
"with": "src/environments/environment.prod.ts"
40+
}
41+
],
42+
"optimization": true,
43+
"outputHashing": "all",
44+
"sourceMap": false,
45+
"extractCss": true,
46+
"namedChunks": false,
47+
"aot": true,
48+
"extractLicenses": true,
49+
"vendorChunk": false,
50+
"buildOptimizer": true,
51+
"budgets": [
52+
{
53+
"type": "initial",
54+
"maximumWarning": "2mb",
55+
"maximumError": "5mb"
56+
}
57+
]
58+
}
59+
}
60+
},
61+
"serve": {
62+
"builder": "@angular-devkit/build-angular:dev-server",
63+
"options": {
64+
"browserTarget": "szia-app:build",
65+
"proxyConfig": "proxy.conf.json"
66+
},
67+
"configurations": {
68+
"production": {
69+
"browserTarget": "szia-app:build:production"
70+
}
71+
}
72+
},
73+
"extract-i18n": {
74+
"builder": "@angular-devkit/build-angular:extract-i18n",
75+
"options": {
76+
"browserTarget": "szia-app:build"
77+
}
78+
},
79+
"test": {
80+
"builder": "@angular-devkit/build-angular:karma",
81+
"options": {
82+
"main": "src/test.ts",
83+
"polyfills": "src/polyfills.ts",
84+
"tsConfig": "src/tsconfig.spec.json",
85+
"karmaConfig": "src/karma.conf.js",
86+
"styles": [
87+
"src/styles.scss"
88+
],
89+
"scripts": [],
90+
"assets": [
91+
"src/favicon.ico",
92+
"src/assets"
93+
]
94+
}
95+
},
96+
"lint": {
97+
"builder": "@angular-devkit/build-angular:tslint",
98+
"options": {
99+
"tsConfig": [
100+
"src/tsconfig.app.json",
101+
"src/tsconfig.spec.json"
102+
],
103+
"exclude": [
104+
"**/node_modules/**"
105+
]
106+
}
107+
}
108+
}
109+
},
110+
"szia-app-e2e": {
111+
"root": "e2e/",
112+
"projectType": "application",
113+
"prefix": "",
114+
"architect": {
115+
"e2e": {
116+
"builder": "@angular-devkit/build-angular:protractor",
117+
"options": {
118+
"protractorConfig": "e2e/protractor.conf.js",
119+
"devServerTarget": "szia-app:serve"
120+
},
121+
"configurations": {
122+
"production": {
123+
"devServerTarget": "szia-app:serve:production"
124+
}
125+
}
126+
},
127+
"lint": {
128+
"builder": "@angular-devkit/build-angular:tslint",
129+
"options": {
130+
"tsConfig": "e2e/tsconfig.e2e.json",
131+
"exclude": [
132+
"**/node_modules/**"
133+
]
134+
}
135+
}
136+
}
137+
}
138+
},
139+
"defaultProject": "szia-app"
140+
}

e2e/protractor.conf.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Protractor configuration file, see link for more information
2+
// https://github.com/angular/protractor/blob/master/lib/config.ts
3+
4+
const { SpecReporter } = require('jasmine-spec-reporter');
5+
6+
exports.config = {
7+
SELENIUM_PROMISE_MANAGER: false,
8+
allScriptsTimeout: 11000,
9+
specs: [
10+
'./src/**/*.e2e-spec.ts'
11+
],
12+
capabilities: {
13+
'browserName': 'chrome'
14+
},
15+
directConnect: true,
16+
baseUrl: 'http://localhost:4200/',
17+
framework: 'jasmine',
18+
jasmineNodeOpts: {
19+
showColors: true,
20+
defaultTimeoutInterval: 30000,
21+
print: function() {}
22+
},
23+
onPrepare() {
24+
require('ts-node').register({
25+
project: require('path').join(__dirname, './tsconfig.e2e.json')
26+
});
27+
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
28+
}
29+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { element, by } from 'protractor';
2+
import { complaintListPage } from './ complaint-list.po';
3+
4+
export const complaintEditPage = {
5+
navigateTo: async () => {
6+
await complaintListPage.navigeTo();
7+
await complaintListPage.getAddComplaintButton().click();
8+
},
9+
10+
getNameInput: () => element(by.name('name')),
11+
12+
getEmailInput: () => element(by.name('email')),
13+
14+
getPhoneNumberInput: () => element(by.name('phoneNumber')),
15+
16+
getSubjectInput: () => element(by.name('subject')),
17+
18+
getContentInput: () => element(by.name('content')),
19+
20+
getImageUrlInput: () => element(by.name('imageSource')),
21+
22+
getSubmitButton: () => element(by.id('submit'))
23+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { complaintEditPage } from './complaint-edit.po';
2+
import { logIn } from '../utils';
3+
import { complaintListPage } from './ complaint-list.po';
4+
5+
describe('Complaint', () => {
6+
beforeEach(async () => {
7+
await logIn();
8+
});
9+
10+
it('should save complaint', async () => {
11+
await complaintEditPage.navigateTo();
12+
13+
const subject = 'Test' + Math.random();
14+
await complaintEditPage.getNameInput().sendKeys('Reuben Saunders');
15+
await complaintEditPage.getEmailInput().sendKeys('[email protected]');
16+
await complaintEditPage.getPhoneNumberInput().sendKeys('+1-202-555-0152');
17+
await complaintEditPage.getSubjectInput().sendKeys(subject);
18+
await complaintEditPage.getContentInput().sendKeys('I had to wait 3 hours in the plane for take-off, I will surely never coming back to this airport again');
19+
await complaintEditPage.getImageUrlInput().sendKeys('https://source.unsplash.com/random/1500x700');
20+
await complaintEditPage.getSubmitButton().click();
21+
22+
await complaintListPage.navigeTo();
23+
const element = await complaintListPage.getComplaintSubject(subject);
24+
expect(await element.isPresent()).toBe(true);
25+
});
26+
27+
it('should edit complaint', async () => {
28+
await complaintListPage.navigeTo();
29+
const element = await complaintListPage.getComplaints().first();
30+
await complaintListPage.getComplaintEditButton(element).click();
31+
32+
const changedSubject = 'E2e test' + Math.random();
33+
await complaintEditPage.getSubjectInput().clear();
34+
await complaintEditPage.getSubjectInput().sendKeys(changedSubject);
35+
await complaintEditPage.getSubmitButton().click();
36+
37+
const changedElement = complaintListPage.getComplaintSubject(changedSubject);
38+
expect(await changedElement.isPresent()).toBe(true);
39+
});
40+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { element, by, ElementFinder } from 'protractor';
2+
import { menuPage } from '../menu.po';
3+
4+
export const complaintListPage = {
5+
navigeTo: () => {
6+
return menuPage.getComplaintsMenuItem().click();
7+
},
8+
9+
getComplaints: () => {
10+
return element.all(by.tagName('mat-card'));
11+
},
12+
13+
getAddComplaintButton: () => {
14+
return element.all(by.id('add'));
15+
},
16+
17+
getComplaintSubject: (text: string) => {
18+
return element(by.cssContainingText('mat-card-title', text));
19+
},
20+
21+
getComplaintEditButton: (e: ElementFinder) => {
22+
return e.element(by.buttonText('EDIT'));
23+
}
24+
}

e2e/src/login.e2e-spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { browser } from 'protractor';
2+
import { userCredentials } from './utils';
3+
import { loginPage } from './login.po';
4+
import { notificationPage } from './notification.po';
5+
6+
describe('Login', () => {
7+
8+
beforeEach(async () => {
9+
await loginPage.navigateTo();
10+
await browser.executeScript('localStorage.clear()');
11+
});
12+
13+
it('should log in', async () => {
14+
await loginPage.getUsernameInput().sendKeys(userCredentials.username);
15+
await loginPage.getPasswordInput().sendKeys(userCredentials.password);
16+
await loginPage.getSubmitButton().click();
17+
expect(await browser.getCurrentUrl()).toContain('/flights');
18+
});
19+
20+
it('should not log in if invalid user credentails are stored', async () => {
21+
await loginPage.getUsernameInput().sendKeys(userCredentials.username + 't');
22+
await loginPage.getPasswordInput().sendKeys(userCredentials.password);
23+
await loginPage.getSubmitButton().click();
24+
await browser.waitForAngular();
25+
expect(await notificationPage.getNotification().isDisplayed()).toBe(true);
26+
});
27+
});

0 commit comments

Comments
 (0)