Skip to content

Commit 8501739

Browse files
committed
feat(examples): add noop store example
1 parent 18c317b commit 8501739

33 files changed

+1062
-6
lines changed

.codesandbox/tasks.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919
"command": "pnpm build:docs",
2020
"runAtStart": false
2121
},
22-
"dev:basic-store": {
23-
"name": "dev:basic-store",
24-
"command": "pnpm dev:basic-store",
25-
"runAtStart": true
26-
},
2722
"dev:docs": {
2823
"name": "dev:docs",
2924
"command": "pnpm dev:docs",
3025
"runAtStart": false
3126
},
27+
"dev:basic-store": {
28+
"name": "dev:noop-store",
29+
"command": "pnpm dev:noop-store",
30+
"runAtStart": true
31+
},
3232
"affected:build": {
3333
"name": "build",
3434
"command": "pnpm affected:build",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"extends": ["plugin:playwright/recommended", "../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
},
17+
{
18+
"files": ["src/**/*.{ts,js,tsx,jsx}"],
19+
"rules": {
20+
"testing-library/prefer-screen-queries": "off",
21+
"jest-dom/prefer-in-document": "off"
22+
}
23+
}
24+
]
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import { workspaceRoot } from '@nx/devkit';
2+
import { nxE2EPreset } from '@nx/playwright/preset';
3+
import { defineConfig, devices } from '@playwright/test';
4+
import { fileURLToPath } from 'url';
5+
6+
const __filename = fileURLToPath(import.meta.url);
7+
8+
// For CI, you may want to set BASE_URL to the deployed application.
9+
const baseURL = process.env['BASE_URL'] || 'http://localhost:4200';
10+
11+
/**
12+
* Read environment variables from file.
13+
* https://github.com/motdotla/dotenv
14+
*/
15+
// require('dotenv').config();
16+
17+
/**
18+
* See https://playwright.dev/docs/test-configuration.
19+
*/
20+
export default defineConfig({
21+
...nxE2EPreset(__filename, { testDir: './src' }),
22+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
23+
use: {
24+
baseURL,
25+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
26+
trace: 'on-first-retry',
27+
},
28+
/* Run your local dev server before starting the tests */
29+
webServer: {
30+
command: 'pnpm exec nx serve basic-ngrx-store',
31+
url: 'http://localhost:4200',
32+
reuseExistingServer: !process.env['CI'],
33+
cwd: workspaceRoot,
34+
},
35+
projects: [
36+
{
37+
name: 'chromium',
38+
use: { ...devices['Desktop Chrome'] },
39+
},
40+
41+
{
42+
name: 'firefox',
43+
use: { ...devices['Desktop Firefox'] },
44+
},
45+
46+
{
47+
name: 'webkit',
48+
use: { ...devices['Desktop Safari'] },
49+
},
50+
51+
// Uncomment for mobile browsers support
52+
/* {
53+
name: 'Mobile Chrome',
54+
use: { ...devices['Pixel 5'] },
55+
},
56+
{
57+
name: 'Mobile Safari',
58+
use: { ...devices['iPhone 12'] },
59+
}, */
60+
61+
// Uncomment for branded browsers
62+
/* {
63+
name: 'Microsoft Edge',
64+
use: { ...devices['Desktop Edge'], channel: 'msedge' },
65+
},
66+
{
67+
name: 'Google Chrome',
68+
use: { ...devices['Desktop Chrome'], channel: 'chrome' },
69+
} */
70+
],
71+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "basic-noop-store-e2e",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"projectType": "application",
5+
"sourceRoot": "examples/basic-noop-store-e2e/src",
6+
"implicitDependencies": ["basic-noop-store"],
7+
"// targets": "to see all targets run: nx show project basic-noop-store-e2e --web",
8+
"targets": {}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
test('has title', async ({ page }) => {
4+
await page.goto('/');
5+
6+
// Expect h1 to contain a substring.
7+
expect(page.getByRole('heading', { name: /RTK Query/i })).toBeTruthy();
8+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"allowJs": true,
5+
"outDir": "../../dist/out-tsc",
6+
"module": "es2022",
7+
"sourceMap": false,
8+
"forceConsistentCasingInFileNames": true,
9+
"strict": true,
10+
"noImplicitOverride": true,
11+
"noPropertyAccessFromIndexSignature": true,
12+
"noImplicitReturns": true,
13+
"noFallthroughCasesInSwitch": true
14+
},
15+
"include": [
16+
"**/*.ts",
17+
"**/*.js",
18+
"playwright.config.mts",
19+
"src/**/*.spec.ts",
20+
"src/**/*.spec.js",
21+
"src/**/*.test.ts",
22+
"src/**/*.test.js",
23+
"src/**/*.d.ts"
24+
]
25+
}
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"extends": ["../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts"],
7+
"extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"],
8+
"rules": {
9+
"@angular-eslint/directive-selector": [
10+
"error",
11+
{
12+
"type": "attribute",
13+
"prefix": "app",
14+
"style": "camelCase"
15+
}
16+
],
17+
"@angular-eslint/component-selector": [
18+
"error",
19+
{
20+
"type": "element",
21+
"prefix": "app",
22+
"style": "kebab-case"
23+
}
24+
],
25+
"@angular-eslint/no-host-metadata-property": "off"
26+
}
27+
},
28+
{
29+
"files": ["*.html"],
30+
"extends": ["plugin:@nx/angular-template"],
31+
"rules": {}
32+
}
33+
]
34+
}
+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"name": "basic-noop-store",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"projectType": "application",
5+
"prefix": "app",
6+
"sourceRoot": "examples/basic-noop-store/src",
7+
"tags": [],
8+
"targets": {
9+
"build": {
10+
"executor": "@angular-devkit/build-angular:application",
11+
"outputs": ["{options.outputPath}"],
12+
"options": {
13+
"outputPath": "dist/examples/basic-noop-store",
14+
"index": "examples/basic-noop-store/src/index.html",
15+
"browser": "examples/basic-noop-store/src/main.ts",
16+
"polyfills": ["zone.js"],
17+
"tsConfig": "examples/basic-noop-store/tsconfig.app.json",
18+
"assets": [
19+
"examples/basic-noop-store/src/favicon.ico",
20+
"examples/basic-noop-store/src/assets",
21+
"examples/basic-noop-store/src/mockServiceWorker.js"
22+
],
23+
"styles": ["examples/basic-noop-store/src/styles.css"],
24+
"scripts": []
25+
},
26+
"configurations": {
27+
"production": {
28+
"budgets": [
29+
{
30+
"type": "initial",
31+
"maximumWarning": "500kb",
32+
"maximumError": "1mb"
33+
},
34+
{
35+
"type": "anyComponentStyle",
36+
"maximumWarning": "2kb",
37+
"maximumError": "4kb"
38+
}
39+
],
40+
"outputHashing": "all"
41+
},
42+
"development": {
43+
"optimization": false,
44+
"extractLicenses": false,
45+
"sourceMap": true
46+
}
47+
},
48+
"defaultConfiguration": "production"
49+
},
50+
"serve": {
51+
"executor": "@angular-devkit/build-angular:dev-server",
52+
"configurations": {
53+
"production": {
54+
"buildTarget": "basic-noop-store:build:production"
55+
},
56+
"development": {
57+
"buildTarget": "basic-noop-store:build:development"
58+
}
59+
},
60+
"defaultConfiguration": "development"
61+
},
62+
"extract-i18n": {
63+
"executor": "@angular-devkit/build-angular:extract-i18n",
64+
"options": {
65+
"buildTarget": "basic-noop-store:build"
66+
}
67+
},
68+
"lint": {
69+
"executor": "@nx/eslint:lint"
70+
},
71+
"test": {
72+
"executor": "@analogjs/platform:vitest",
73+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
74+
"configurations": {
75+
"watch": {
76+
"watch": true
77+
}
78+
}
79+
}
80+
}
81+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { ChangeDetectionStrategy, Component, ViewEncapsulation } from '@angular/core';
2+
import { RouterOutlet } from '@angular/router';
3+
4+
@Component({
5+
standalone: true,
6+
imports: [RouterOutlet],
7+
selector: 'app-root',
8+
template: `
9+
<div class="flex h-full min-h-screen flex-col gap-6 p-4">
10+
<header>
11+
<h1 class="text-xl font-bold">RTK Query - Basic example without store</h1>
12+
</header>
13+
<main class="flex-grow overflow-auto">
14+
<router-outlet />
15+
</main>
16+
</div>
17+
`,
18+
encapsulation: ViewEncapsulation.None,
19+
changeDetection: ChangeDetectionStrategy.OnPush,
20+
})
21+
export class AppComponent {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { type ApplicationConfig } from '@angular/core';
2+
import {
3+
PreloadAllModules,
4+
provideRouter,
5+
withComponentInputBinding,
6+
withEnabledBlockingInitialNavigation,
7+
withPreloading,
8+
} from '@angular/router';
9+
import { provideNoopStoreApi } from 'ngrx-rtk-query';
10+
11+
import { appRoutes } from './app.routes';
12+
import { postsApi } from './posts/api';
13+
14+
export const appConfig: ApplicationConfig = {
15+
providers: [
16+
provideNoopStoreApi(postsApi),
17+
18+
provideRouter(
19+
appRoutes,
20+
withPreloading(PreloadAllModules),
21+
withComponentInputBinding(),
22+
withEnabledBlockingInitialNavigation(),
23+
),
24+
],
25+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { type Route } from '@angular/router';
2+
3+
export const appRoutes: Route[] = [
4+
{
5+
path: '',
6+
loadComponent: () => import('./posts/posts-list.component').then((c) => c.PostsListComponent),
7+
},
8+
{
9+
path: ':id',
10+
loadComponent: () => import('./posts/post-details.component').then((c) => c.PostDetailsComponent),
11+
},
12+
];

0 commit comments

Comments
 (0)