Skip to content

Commit

Permalink
feat: add support for angular 13 (ngxs#1798)
Browse files Browse the repository at this point in the history
Signed-off-by: Gary Lockett <[email protected]>
  • Loading branch information
Gary Lockett authored Nov 19, 2021
1 parent eb1469e commit 02063f6
Show file tree
Hide file tree
Showing 62 changed files with 11,041 additions and 10 deletions.
12 changes: 12 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,14 @@ jobs:
name: Run integration tests for ng12 (Ivy) application
command: yarn integration:ng12:ivy

integration_ng13_ivy_tests:
<<: *job_defaults
steps:
- *attach_workspace
- run:
name: Run integration tests for ng13 (Ivy) application
command: yarn integration:ng13:ivy

integration_test_types:
<<: *job_defaults
steps:
Expand Down Expand Up @@ -346,6 +354,10 @@ workflows:
requires:
- build

- integration_ng13_ivy_tests:
requires:
- build

- integration_test_types:
requires:
- build
Expand Down
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ script:
# Run integration test with Angular 12 Ivy On
- yarn integration:ng12:ivy

# Run integration test with Angular 13 Ivy On
- yarn integration:ng13:ivy

# Run declaration files linter
- yarn test:types

Expand Down
17 changes: 17 additions & 0 deletions integrations/hello-world-ng13-ivy/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries

# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support

# You can see what browsers were selected by your queries by running:
# npx browserslist

last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major versions
last 2 iOS major versions
Firefox ESR
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
16 changes: 16 additions & 0 deletions integrations/hello-world-ng13-ivy/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single

[*.md]
max_line_length = off
trim_trailing_whitespace = false
47 changes: 47 additions & 0 deletions integrations/hello-world-ng13-ivy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out

# dependencies
/node_modules

# profiling files
chrome-profiler-events*.json
speed-measure-plugin*.json

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# misc
/.angular/cache
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db
27 changes: 27 additions & 0 deletions integrations/hello-world-ng13-ivy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# HelloWorldNg13Ivy

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 11.0.2.

## Development server

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.

## Code scaffolding

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`.

## Build

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.

## Running unit tests

Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).

## Running end-to-end tests

Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
122 changes: 122 additions & 0 deletions integrations/hello-world-ng13-ivy/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"hello-world-ng13-ivy": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
},
"@schematics/angular:application": {
"strict": true
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist-integration",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.scss"],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "hello-world-ng13-ivy:build"
},
"configurations": {
"production": {
"browserTarget": "hello-world-ng13-ivy:build:production"
}
}
},
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist-integration-server",
"main": "server.ts",
"tsConfig": "tsconfig.server.json"
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "none",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
},
"test": {
"builder": "@angular-builders/jest:run",
"options": {
"tsConfig": "tsconfig.spec.json",
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.scss"],
"scripts": []
}
},
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "hello-world-ng13-ivy:serve"
},
"configurations": {
"production": {
"devServerTarget": "hello-world-ng13-ivy:serve:production"
}
}
}
}
}
},
"defaultProject": "hello-world-ng13-ivy"
}
10 changes: 10 additions & 0 deletions integrations/hello-world-ng13-ivy/bundlesize.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"files": [
{
"path": "./dist-integration/main.*.js",
"target": "es2015",
"maxSize": "236.94 kB",
"compression": "none"
}
]
}
7 changes: 7 additions & 0 deletions integrations/hello-world-ng13-ivy/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"baseUrl": "http://localhost:4200",
"video": false,
"responseTimeout": 60000,
"pageLoadTimeout": 120000,
"ignoreTestFiles": ["**/plugins/**.js", "**/tsconfig.json"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// <reference types="cypress" />

describe('Select decorator returning state from the wrong store during SSR (https://github.com/ngxs/store/issues/1646)', () => {
it('should make concurrent requests and app should render correctly for each request', async () => {
const promises: Promise<string>[] = Array.from({ length: 100 }).map(() =>
fetch('/').then(res => res.text())
);

const bodies = await Promise.all(promises);

bodies.forEach(body => {
expect(body).to.contain('Angular 13 (ivy) Integration Test');
expect(body).to.contain('Counter is 0');
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/// <reference types="cypress" />

import { IndexPo } from '../support/index.po';

describe('Index page', () => {
const index = new IndexPo();

beforeEach(() => index.navigateTo());

it('should render application using the latest version', () => {
// Arrange & act & assert
// Expect that the running applicaiton was compiled
// with the necessary Angular version!
cy.get('app-root')
.invoke('attr', 'ng-version')
.should('have.string', '13');
});

it('should click on the button and increase the counter', () => {
// Arrange & act & assert
cy.get('button')
.click()
.click()
.click()
.get('p')
.should('contain.text', 'Counter is 3');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
resolve: {
extensions: ['.js', '.ts']
},
module: {
rules: [
{
test: /\.ts$/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true
}
}
]
}
]
}
};
8 changes: 8 additions & 0 deletions integrations/hello-world-ng13-ivy/cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const webpack = require('@cypress/webpack-preprocessor');

const webpackOptions = require('./cypress-webpack.config');

module.exports = on => {
const options = { webpackOptions };
on('file:preprocessor', webpack(options));
};
7 changes: 7 additions & 0 deletions integrations/hello-world-ng13-ivy/cypress/support/base.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export abstract class BasePo {
abstract pageUrl: string;

navigateTo() {
cy.visit(this.pageUrl);
}
}
5 changes: 5 additions & 0 deletions integrations/hello-world-ng13-ivy/cypress/support/index.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BasePo } from './base.po';

export class IndexPo extends BasePo {
pageUrl = '/';
}
10 changes: 10 additions & 0 deletions integrations/hello-world-ng13-ivy/cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"typeRoots": ["../node_modules/@types"],
"lib": ["es2017", "dom"]
},
"include": ["integration/*.ts", "support/*.ts", "../node_modules/cypress"]
}
Loading

0 comments on commit 02063f6

Please sign in to comment.