Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Angular 17 #5

Merged
merged 64 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
8ccb3bb
feat(ct): angular component testing
sand4rt Oct 24, 2023
bc5acba
test(ct): test non-event-emitter outputs
yjaaidi Nov 13, 2023
5c094f5
test(ct): test output listener replacement
yjaaidi Nov 13, 2023
09a0b38
feat(ct): support non-event-emitter outputs
yjaaidi Nov 13, 2023
2f57e08
Merge pull request #3 from yjaaidi/handle-angular-non-event-emitter-o…
sand4rt Nov 24, 2023
285f113
docs(ct): angular
sand4rt Nov 24, 2023
d32a62b
fix(ct): angular source maps
sand4rt Dec 16, 2023
753926a
Merge pull request #4 from sand4rt/angular-docs
sand4rt Dec 16, 2023
9e88b09
chore(ct): new angular logo
sand4rt Dec 16, 2023
d5aa4d5
Merge remote-tracking branch 'origin/main' into hello-angular-ct
yjaaidi Feb 22, 2024
0cb6fe3
refactor(ct-angular): bump to Angular 17 and move out analogjs plugin
yjaaidi Feb 22, 2024
12ed2e7
refactor(ct-angular): fix component resolution by temporary removing …
yjaaidi Feb 22, 2024
c27a034
refactor(ct-angular): fix mount
yjaaidi Feb 23, 2024
994bf21
refactor(ct-angular): disable analog plugin as it breaks component re…
yjaaidi Feb 23, 2024
048cb7d
refactor(ct-angular): fix input forwarding
yjaaidi Feb 23, 2024
d50eb33
refactor(ct-angular): fix angular outputs
yjaaidi Feb 23, 2024
8029022
refactor(ct-angular): fix angular slots
yjaaidi Feb 23, 2024
ea9f612
test(ct-angular): fix all tests
yjaaidi Feb 23, 2024
6ecfba2
test(ct-angular): fix all angular tests
yjaaidi Feb 23, 2024
237d065
test(ct-angular): use analog's vite plugin to handle template files
yjaaidi Feb 23, 2024
9df6900
refactor(ct-angular): remove router-specific code
yjaaidi Feb 23, 2024
aaf8029
refactor(ct-angular): clean up dependencies
yjaaidi Feb 23, 2024
d4a0aea
refactor(ct-angular): remove compiler import
edbzn Feb 23, 2024
dbbbe7c
refactor(ct-angular): fix vite version mismatch in tests
yjaaidi Feb 23, 2024
2c74b60
refactor(ct-angular): bump @playwright/experimental-ct-angular to 1.4…
yjaaidi Feb 23, 2024
d91da7b
test(ct-angular): add tests for template rendering
yjaaidi Feb 23, 2024
e024fba
feat(ct-angular): render simple template
yjaaidi Feb 23, 2024
fdf8595
feat(ct-angular): render template with child components
yjaaidi Feb 23, 2024
0e5dbec
feat(ct-angular): render component with signal inputs
yjaaidi Feb 23, 2024
90c5a17
test(ct-angular): make input required
yjaaidi Feb 23, 2024
a1fee2a
test(ct-angular): remove now useless import
yjaaidi Feb 23, 2024
e22b5cf
feat(ct-angular): allow setting providers
yjaaidi Feb 23, 2024
fb3dd0c
refactor(ct-angular): clean up slots remains
yjaaidi Feb 23, 2024
7a7347a
feat(ct): angular component testing
sand4rt Oct 24, 2023
614aed9
test(ct): test non-event-emitter outputs
yjaaidi Nov 13, 2023
02a5e3a
test(ct): test output listener replacement
yjaaidi Nov 13, 2023
56ec916
feat(ct): support non-event-emitter outputs
yjaaidi Nov 13, 2023
03744bc
fix(ct): angular source maps
sand4rt Dec 16, 2023
37016e2
docs(ct): angular
sand4rt Nov 24, 2023
31e8817
chore(ct): new angular logo
sand4rt Dec 16, 2023
df28845
Merge remote-tracking branch 'sand4rt/hello-angular-ct' into hello-an…
yjaaidi Feb 26, 2024
06867cc
Merge branch 'main' into hello-angular-ct
yjaaidi Mar 22, 2024
10ee5da
Merge remote-tracking branch 'origin/main' into hello-angular-ct
yjaaidi Mar 26, 2024
0443e8c
Merge remote-tracking branch 'sand4rt/hello-angular-ct' into hello-an…
yjaaidi Mar 27, 2024
96258f1
feat(ct-angular): add pw-angular bin
yjaaidi Mar 27, 2024
c352667
test(ct-angular): fix type check
yjaaidi Mar 27, 2024
1fe6c15
refactor(ct-angular): remove useless NODE_ENV=test
yjaaidi Mar 27, 2024
958e893
refactor(ct-angular): use playwright.config.mts as analog vite plugin…
yjaaidi Mar 27, 2024
78596d9
chore(ct-angular): lint
yjaaidi Mar 27, 2024
89b885a
fix(ct-angular): resolve Angular component usages
yjaaidi Mar 27, 2024
fcc1635
fix(ct-angular): resolve Angular imports/providers usages
yjaaidi Mar 27, 2024
a547da5
test(ct-angular): test url change
yjaaidi Mar 27, 2024
20e4d8d
test(ct-angular): remove duplicate test
yjaaidi Mar 27, 2024
16a0df1
chore(ct-angular): remove useless pw-angular cli
yjaaidi Mar 27, 2024
3449eb8
chore(ct-angular): remove duplicate PlaywrightTestConfig type
yjaaidi Mar 27, 2024
2de7a20
feat(ct-angular): export the right types
yjaaidi Apr 11, 2024
89804ad
chore(ct-angular): tidy up
yjaaidi Apr 11, 2024
9d03a51
feat(ct-angular): throw an explicit error when mounting JSX
yjaaidi Apr 11, 2024
ddcf1e1
chore(ct-angular): remove vite from devDependencies as not used anymore
yjaaidi Apr 11, 2024
251ce51
chore(ct-angular): remove useless skipLibCheck flag
yjaaidi Apr 11, 2024
eefd6ea
chore(ct-angular): remove useless @angular/compiler
yjaaidi Apr 11, 2024
d83f9ee
test(ct-angular): improve output listener update test
yjaaidi Apr 11, 2024
69a6db4
chore(ct): revert adapters imports and template
sand4rt May 7, 2024
c7df50b
Merge pull request #1 from sand4rt/revert-template-adapters-imports
yjaaidi May 7, 2024
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
18,240 changes: 5,732 additions & 12,508 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion packages/playwright-ct-angular/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = require('@playwright/experimental-ct-core/cli');

const { program } = require('@playwright/experimental-ct-core/lib/program');

program.parse(process.argv);
32 changes: 14 additions & 18 deletions packages/playwright-ct-angular/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,31 @@
*/

import type {
TestType,
Locator,
PlaywrightTestArgs,
PlaywrightTestConfig as BasePlaywrightTestConfig,
PlaywrightTestOptions,
PlaywrightWorkerArgs,
PlaywrightWorkerOptions,
Locator,
TestType,
yjaaidi marked this conversation as resolved.
Show resolved Hide resolved
} from '@playwright/test';
import type { JsonObject } from '@playwright/experimental-ct-core/types/component';
import type { InlineConfig } from 'vite';
import type { Type } from '@angular/core';

export type PlaywrightTestConfig<T = {}, W = {}> = Omit<BasePlaywrightTestConfig<T, W>, 'use'> & {
use?: BasePlaywrightTestConfig<T, W>['use'] & {
ctPort?: number;
ctTemplateDir?: string;
ctCacheDir?: string;
ctViteConfig?: InlineConfig | (() => Promise<InlineConfig>);
};
};
import type { Provider, Type } from '@angular/core';

type ComponentSlot = string | string[];
type ComponentSlots = Record<string, ComponentSlot> & { default?: ComponentSlot };
export type { PlaywrightTestConfig } from '@playwright/experimental-ct-core';

type ComponentEvents = Record<string, Function>;

export interface MountOptions<HooksConfig extends JsonObject, Component> {
props?: Partial<Component>, // TODO: filter props
slots?: ComponentSlots;
props?: Partial<Component> | Record<string, unknown>, // TODO: filter props and handle signals
providers?: Provider[],
yjaaidi marked this conversation as resolved.
Show resolved Hide resolved
on?: ComponentEvents;
hooksConfig?: HooksConfig;
}

export interface MountTemplateOptions<HooksConfig extends JsonObject, Component> extends MountOptions<HooksConfig, Component> {
imports?: Type<unknown>[];
yjaaidi marked this conversation as resolved.
Show resolved Hide resolved
}

interface MountResult<Component> extends Locator {
unmount(): Promise<void>;
update(options: {
Expand All @@ -57,6 +49,10 @@ interface MountResult<Component> extends Locator {
}

export interface ComponentFixtures {
mount<HooksConfig extends JsonObject, Component = unknown>(
template: string,
yjaaidi marked this conversation as resolved.
Show resolved Hide resolved
options?: MountTemplateOptions<HooksConfig, Component>
): Promise<MountResult<Component>>;
mount<HooksConfig extends JsonObject, Component = unknown>(
component: Type<Component>,
options?: MountOptions<HooksConfig, Component>
Expand Down
28 changes: 11 additions & 17 deletions packages/playwright-ct-angular/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,16 @@
const { test, expect, devices, defineConfig: originalDefineConfig } = require('@playwright/experimental-ct-core');
const path = require('path');

process.env['NODE_ENV'] = 'test';

function plugin() {
// Only fetch upon request to avoid resolution in workers.
const { createPlugin } = require('@playwright/experimental-ct-core/lib/vitePlugin');
return createPlugin(
path.join(__dirname, 'registerSource.mjs'),
() => import('@analogjs/vite-plugin-angular').then(plugin => {
// TODO: remove the typeof plugin.default check
if (typeof plugin.default === 'function')
return plugin.default({ jit: false });
return plugin.default.default({ jit: false });
})
);
}

const defineConfig = config => originalDefineConfig({ ...config, _plugins: [plugin] });
const defineConfig = (config, ...configs) => {
return originalDefineConfig({
...config,
'@playwright/test': {
packageJSON: require.resolve('./package.json'),
},
'@playwright/experimental-ct-core': {
registerSourceFile: path.join(__dirname, 'registerSource.mjs')
},
}, ...configs);
};

module.exports = { test, expect, devices, defineConfig };
39 changes: 14 additions & 25 deletions packages/playwright-ct-angular/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@playwright/experimental-ct-angular",
"version": "1.42.0-next",
"version": "1.43.0-next",
"description": "Playwright Component Testing for Angular",
"repository": {
"type": "git",
"url": "git+https://github.com/sand4rt/playwright-ct-angular.git"
"url": "git+https://github.com/microsoft/playwright.git"
},
"homepage": "https://playwright.dev",
"engines": {
Expand All @@ -29,35 +29,24 @@
}
},
"dependencies": {
"@analogjs/vite-plugin-angular": "0.2.28",
"@angular-devkit/build-angular": "^16.1.0",
"@playwright/experimental-ct-core": "1.42.0-next",
"vite": "^4.4.9"
"@playwright/experimental-ct-core": "1.43.0-next"
},
"devDependencies": {
"@angular/animations": "^16.1.7",
"@angular/common": "^16.1.7",
"@angular/compiler": "^16.1.7",
"@angular/compiler-cli": "^16.1.7",
"@angular/core": "^16.1.7",
"@angular/platform-browser": "^16.1.7",
"@angular/platform-browser-dynamic": "^16.1.7",
"@angular/router": "^16.1.7",
"@playwright/test": "1.38.1",
"@angular/compiler": "^17.0.0",
"@angular/core": "^17.0.0",
"@angular/platform-browser-dynamic": "^17.0.0",
"rxjs": "~7.8.1",
"tslib": "^2.5.0",
"typescript": "^5.0.4",
"zone.js": "~0.13.1"
"typescript": "~5.2.0",
"vite": "~5.0.12",
yjaaidi marked this conversation as resolved.
Show resolved Hide resolved
"zone.js": "~0.14.0"
},
"peerDependencies": {
"@playwright/test": ">=1.38.1",
"typescript": ">=4.9.3",
"@angular/common": ">=15.1.0 || >=16.0.0",
"@angular/platform-browser": ">=15.1.0 || >=16.0.0",
"@angular/router": ">=15.1.0 || >=16.0.0",
"@angular/core": ">=15.1.0 || >=16.0.0"
"@angular/compiler": "^17.0.0",
"@angular/core": "^17.0.0",
"@angular/platform-browser-dynamic": "^17.0.0",
"typescript": ">=5.2.0"
},
"bin": {
"playwright": "./cli.js"
"playwright": "cli.js"
}
}
Loading