Skip to content

Commit 11e6786

Browse files
final update with working storybook and vr tests
1 parent 3b130cd commit 11e6786

33 files changed

+2937
-504
lines changed

Diff for: .storybook/preview-head.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<link
2+
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap"
3+
rel="stylesheet"
4+
/>
5+
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
6+
<style>
7+
div#root {
8+
background: white;
9+
padding: 2em;
10+
}
11+
</style>

Diff for: .storybook/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"exclude": [
99
"../src/test.ts",
1010
"../src/**/*.spec.ts",
11+
"../src/**/*.spec-vr.ts",
1112
"../projects/**/*.spec.ts"
1213
],
1314
"include": [

Diff for: documentation.json

+714-23
Large diffs are not rendered by default.

Diff for: jest.config-story.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
moduleNameMapper: {
3+
'@core/(.*)': '<rootDir>/src/app/core/$1',
4+
},
5+
testMatch: ['**/stories/storyshot.spec.ts'],
6+
preset: 'jest-preset-angular'
7+
};
8+

Diff for: jest.config-vr.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const ts_preset = require("ts-jest/jest-preset");
2+
const puppeteer_preset = require("jest-puppeteer/jest-preset");
3+
4+
const
5+
config = {
6+
...ts_preset, ...puppeteer_preset,
7+
testMatch: ["**/*.spec-vr.ts"],
8+
setupFilesAfterEnv: ["<rootDir>/setup-jest-vr.ts"]
9+
};
10+
11+
module.exports = config;

Diff for: package.json

+15-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"start": "ng serve",
77
"build": "ng build",
88
"test": "ng test",
9+
"test:vr": "jest --config jest.config-vr.js",
10+
"test:vr:watch": "jest --watch --config jest.config-vr.js",
11+
"test:story": "jest --config jest.config-story.js",
912
"lint": "ng lint",
1013
"e2e": "ng e2e",
1114
"docs:json": "compodoc -p ./tsconfig.json -e json -d .",
@@ -40,19 +43,30 @@
4043
"@storybook/addon-actions": "^6.1.20",
4144
"@storybook/addon-essentials": "^6.1.20",
4245
"@storybook/addon-links": "^6.1.20",
46+
"@storybook/addon-storyshots": "^6.1.21",
47+
"@storybook/addon-storyshots-puppeteer": "^6.1.21",
4348
"@storybook/angular": "^6.1.20",
44-
"@types/jasmine": "~3.6.0",
49+
"@types/jest": "^26.0.20",
50+
"@types/jest-environment-puppeteer": "^4.4.1",
51+
"@types/jest-image-snapshot": "^4.3.0",
4552
"@types/node": "^12.11.1",
53+
"@types/puppeteer": "^5.4.3",
4654
"babel-loader": "^8.2.2",
4755
"codelyzer": "^6.0.0",
4856
"jasmine-core": "~3.6.0",
4957
"jasmine-spec-reporter": "~5.0.0",
58+
"jest": "^26.6.3",
59+
"jest-image-snapshot": "^4.4.0",
60+
"jest-preset-angular": "^8.3.2",
61+
"jest-puppeteer": "^4.4.0",
5062
"karma": "~6.1.0",
5163
"karma-chrome-launcher": "~3.1.0",
5264
"karma-coverage": "~2.0.3",
5365
"karma-jasmine": "~4.0.0",
5466
"karma-jasmine-html-reporter": "^1.5.0",
5567
"protractor": "~7.0.0",
68+
"puppeteer": "^8.0.0",
69+
"ts-jest": "^26.5.2",
5670
"ts-node": "~8.3.0",
5771
"tslint": "~6.1.0",
5872
"typescript": "~4.1.2"

Diff for: setup-jest-vr.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const { toMatchImageSnapshot } = require('jest-image-snapshot');
2+
expect.extend({ toMatchImageSnapshot });

Diff for: src/app/app.component.spec.ts

-35
This file was deleted.

Diff for: src/app/holidays/+state/holidays.effects.spec.ts

-22
This file was deleted.

Diff for: src/app/holidays/+state/holidays.reducer.spec.ts

-38
This file was deleted.

Diff for: src/app/holidays/+state/holidays.selectors.spec.ts

-19
This file was deleted.

Diff for: src/app/holidays/+state/state.spec.ts

-37
This file was deleted.

Diff for: src/app/holidays/holiday-card/holiday-card.component.scss

+4
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ mat-card {
44
mat-card-actions {
55
text-align: center;
66
}
7+
8+
mat-button {
9+
10+
}
711
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
describe('Holidays', () => {
2+
it('should make a single snapshot', async () => {
3+
await page.setViewport({width: 1280, height: 720});
4+
await page.goto('http://localhost:4200/holidays', {waitUntil: 'networkidle0'});
5+
const image = await page.screenshot();
6+
expect(image).toMatchImageSnapshot();
7+
});
8+
});
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { MatButtonModule } from '@angular/material/button';
2-
import { MatCardModule } from '@angular/material/card';
3-
import { RouterTestingModule } from '@angular/router/testing';
4-
import { Meta, moduleMetadata, Story } from '@storybook/angular';
5-
import { HolidayCardComponent } from './holiday-card.component';
1+
import {MatButtonModule} from '@angular/material/button';
2+
import {MatCardModule} from '@angular/material/card';
3+
import {RouterTestingModule} from '@angular/router/testing';
4+
import {Meta, moduleMetadata, Story} from '@storybook/angular';
5+
import {HolidayCardComponent} from './holiday-card.component';
66

77
export default {
88
title: 'Eternal/HolidayCard',
99
component: HolidayCardComponent,
10-
decorators: [moduleMetadata({ imports: [MatButtonModule, MatCardModule, RouterTestingModule] })],
11-
argTypes: { holiday: { name: 'Holiday', description: 'JSON object for the Holiday' } }
10+
decorators: [moduleMetadata({imports: [MatButtonModule, MatCardModule, RouterTestingModule]})],
11+
argTypes: {holiday: {name: 'Holiday', description: 'JSON object for the Holiday'}}
1212
} as Meta;
1313

1414
const Template: Story<HolidayCardComponent> = (args: HolidayCardComponent) => ({
@@ -21,7 +21,8 @@ Default.args = {
2121
holiday: {
2222
id: 1,
2323
title: 'Holiday',
24+
teaser: 'Experience an Old Empire',
2425
description: 'A holiday',
25-
imageUrl: 'https://eternal-app.s3.eu-central-1.amazonaws.com/assets/AngkorWatSmall.jpg'
26+
imageUrl: 'https://eternal-app.s3.eu-central-1.amazonaws.com/assets/AngkorWatSmall.jpg',
2627
}
2728
};

Diff for: src/app/holidays/holiday-card/holiday-card.component.ts

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ interface Holiday {
66
teaser: string;
77
description: string;
88
imageUrl: string;
9-
typeId: number;
10-
durationInDays: number;
11-
minCount: number;
12-
maxCount: number;
139
}
1410

1511
@Component({

Diff for: src/app/holidays/holidays/holidays.component.spec-vr.ts

-23
This file was deleted.

0 commit comments

Comments
 (0)