Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.

test: latest angular project #46

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: '16.x'
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
scope: '@sand4rt'

Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: '16.x'
node-version: '18.x'

- name: Install dependencies
run: pnpm install --frozen-lockfile
Expand All @@ -26,7 +26,10 @@ jobs:
run: pnpm build

- name: Install Playwright Browsers
run: npx playwright install --with-deps
run: (cd ct-angular && pnpm exec playwright install --with-deps)

- name: Install Playwright Browsers
run: (cd ct-angular15 && pnpm exec playwright install --with-deps)

- name: Run Playwright tests
run: pnpm test
Expand Down
26 changes: 13 additions & 13 deletions ct-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@
"test": "npx playwright test"
},
"dependencies": {
"@angular/animations": "^15.1.0",
"@angular/common": "^15.1.0",
"@angular/compiler": "^15.1.0",
"@angular/core": "^15.1.0",
"@angular/forms": "^15.1.0",
"@angular/platform-browser": "^15.1.0",
"@angular/platform-browser-dynamic": "^15.1.0",
"@angular/router": "^15.1.0",
"@angular/animations": "^17.1.0",
"@angular/common": "^17.1.0",
"@angular/compiler": "^17.1.0",
"@angular/core": "^17.1.0",
"@angular/forms": "^17.1.0",
"@angular/platform-browser": "^17.1.0",
"@angular/platform-browser-dynamic": "^17.1.0",
"@angular/router": "^17.1.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.12.0"
"zone.js": "~0.14.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "^15.1.0",
"@angular/cli": "~15.1.0",
"@angular/compiler-cli": "^15.1.0",
"@angular-devkit/build-angular": "^17.1.2",
"@angular/cli": "^17.1.2",
"@angular/compiler-cli": "^17.1.0",
"@playwright/test": "1.41.2",
"@sand4rt/experimental-ct-angular": "workspace:*",
"typescript": "~4.9.4"
"typescript": "~5.3.2"
}
}
45 changes: 45 additions & 0 deletions ct-angular15/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# Compiled output
/dist
/tmp
/out-tsc
/bazel-out

# Node
/node_modules
npm-debug.log
yarn-error.log

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

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings

# System files
.DS_Store
Thumbs.db
/test-results/
/playwright-report/
/playwright/.cache/
19 changes: 19 additions & 0 deletions ct-angular15/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ct-angular

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

## Development server

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application 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.

## 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.
80 changes: 80 additions & 0 deletions ct-angular15/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"ct-angular": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/ct-angular",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"assets": [
"src/assets/favicon.ico",
"src/assets"
],
"styles": [
"src/assets/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "ct-angular:build:production"
},
"development": {
"browserTarget": "ct-angular:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "ct-angular:build"
}
}
}
}
}
}
33 changes: 33 additions & 0 deletions ct-angular15/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "ct-angular15",
"version": "0.0.0",
"private": true,
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "npx playwright test"
},
"dependencies": {
"@angular/animations": "^15.1.0",
"@angular/common": "^15.1.0",
"@angular/compiler": "^15.1.0",
"@angular/core": "^15.1.0",
"@angular/forms": "^15.1.0",
"@angular/platform-browser": "^15.1.0",
"@angular/platform-browser-dynamic": "^15.1.0",
"@angular/router": "^15.1.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.12.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^15.1.0",
"@angular/cli": "~15.1.0",
"@angular/compiler-cli": "^15.1.0",
"@playwright/test": "1.41.2",
"@sand4rt/experimental-ct-angular": "workspace:*",
"typescript": "~4.9.4"
}
}
36 changes: 36 additions & 0 deletions ct-angular15/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { defineConfig, devices } from '@sand4rt/experimental-ct-angular';
import { resolve } from 'path';

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: 'tests',
forbidOnly: !!process.env['CI'],
retries: process.env['CI'] ? 2 : 0,
reporter: process.env['CI'] ? 'html' : 'line',
use: {
trace: 'on-first-retry',
ctViteConfig: {
resolve: {
alias: {
'@': resolve('./src'),
}
}
}
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
],
});
12 changes: 12 additions & 0 deletions ct-angular15/playwright/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Testing Page</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="./index.ts"></script>
</body>
</html>
31 changes: 31 additions & 0 deletions ct-angular15/playwright/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { beforeMount, afterMount } from '@sand4rt/experimental-ct-angular/hooks';
import { provideRouter } from '@angular/router';
import { ButtonComponent } from '@/components/button.component';
import { TOKEN } from '@/components/inject.component';
import { routes } from '@/router';
import '@/assets/styles.css';

export type HooksConfig = {
routing?: boolean;
injectToken?: boolean;
};

beforeMount<HooksConfig>(async ({ hooksConfig, TestBed }) => {
TestBed.configureTestingModule({
imports: [ButtonComponent],
});

if (hooksConfig?.routing)
TestBed.configureTestingModule({
providers: [provideRouter(routes)],
});

if (hooksConfig?.injectToken)
TestBed.configureTestingModule({
providers: [{ provide: TOKEN, useValue: { text: 'has been overwritten' }}]
})
});

afterMount<HooksConfig>(async () => {
console.log('After mount');
});
17 changes: 17 additions & 0 deletions ct-angular15/src/app.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Component } from '@angular/core';
import { RouterModule } from '@angular/router';

@Component({
standalone: true,
imports: [RouterModule],
selector: 'app-root',
template: `
<header>
<img alt="Angular logo" class="logo" src="./assets/logo.svg" width="125" height="125" />
<a routerLink="/">Login</a>
<a routerLink="/dashboard">Dashboard</a>
</header>
<router-outlet></router-outlet>
`
})
export class AppComponent {}
Binary file added ct-angular15/src/assets/favicon.ico
Binary file not shown.
23 changes: 23 additions & 0 deletions ct-angular15/src/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions ct-angular15/src/assets/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}

@media (prefers-color-scheme: light) {
:root {
color: #e3e3e3;
background-color: #1b1b1d;
}
}
1 change: 1 addition & 0 deletions ct-angular15/src/components/button.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<button (click)="submit.emit('hello')">{{title}}</button>
Loading