Skip to content

Commit 2359daa

Browse files
Add Playwright tests for Admin application and update build configurations
1 parent 7231379 commit 2359daa

File tree

6 files changed

+56
-35
lines changed

6 files changed

+56
-35
lines changed

angular.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@
171171
},
172172
"development": {
173173
"buildTarget": "web:build:development"
174+
},
175+
"local": {
176+
"buildTarget": "web:build:development"
174177
}
175178
},
176179
"defaultConfiguration": "development"

e2e/admin/admin.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test.describe('Admin Application', () => {
4+
test('admin app loads', async ({ page }) => {
5+
await page.goto('/');
6+
await expect(page).toHaveTitle(/Admin/);
7+
});
8+
9+
test('displays admin dashboard', async ({ page }) => {
10+
await page.goto('/');
11+
await expect(page.getByText('Admin')).toBeVisible();
12+
});
13+
});

e2e/example.spec.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

e2e/tags.spec.ts renamed to e2e/web/tags.spec.ts

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test, expect } from '@playwright/test';
2-
import { acceptCookies } from './helpers/cookie-consent.helper';
3-
import { waitForAngularToLoad, waitForApiCall } from './helpers/debug.helper';
2+
import { acceptCookies } from '../helpers/cookie-consent.helper';
3+
import { waitForAngularToLoad, waitForApiCall } from '../helpers/debug.helper';
44

55
test.describe('Tags Display and API', () => {
66
test('should display tags and verify API call', async ({ page }) => {
@@ -11,13 +11,9 @@ test.describe('Tags Display and API', () => {
1111
status?: number;
1212
}> = [];
1313

14-
page.on('request', (request) => {
14+
page.on('request', request => {
1515
const url = request.url();
16-
if (
17-
url.includes('/rest/v1/tags') ||
18-
url.includes('supabase') ||
19-
url.includes('tag')
20-
) {
16+
if (url.includes('/rest/v1/tags') || url.includes('supabase') || url.includes('tag')) {
2117
apiRequests.push({
2218
url,
2319
method: request.method(),
@@ -26,31 +22,29 @@ test.describe('Tags Display and API', () => {
2622
}
2723
});
2824

29-
page.on('response', (response) => {
25+
page.on('response', response => {
3026
const url = response.url();
3127
if (url.includes('/rest/v1/tags')) {
32-
const existingRequest = apiRequests.find((req) => req.url === url);
28+
const existingRequest = apiRequests.find(req => req.url === url);
3329
if (existingRequest) {
3430
existingRequest.status = response.status();
3531
}
3632
}
3733
});
3834

3935
await page.goto('/', { waitUntil: 'networkidle' });
40-
await acceptCookies(page);
41-
await waitForAngularToLoad(page, 500);
42-
await page.waitForSelector('[data-testid="tags-container"]', {
43-
timeout: 500,
44-
});
36+
// await acceptCookies(page);
37+
// await waitForAngularToLoad(page, 50);
38+
// await page.getByTestId('tags-container')
4539

4640
try {
47-
await waitForApiCall(page, '/rest/v1/tags', 300);
41+
await waitForApiCall(page, '/rest/v1/tags', 30);
4842
} catch (error) {
4943
// Continue test even if API call detection fails
5044
}
5145

52-
await page.waitForTimeout(1000);
53-
await page.waitForSelector('[data-testid="tag-item"]', { timeout: 500 });
46+
// await page.waitForTimeout(100);
47+
// await page.waitForSelector('[data-testid="tag-item"]', { timeout: 500 });
5448

5549
const tagsContainer = page.locator('[data-testid="tags-container"]');
5650
await expect(tagsContainer).toBeVisible();
@@ -62,9 +56,7 @@ test.describe('Tags Display and API', () => {
6256
];
6357

6458
for (const tag of expectedTags) {
65-
const tagItem = page.locator(
66-
`[data-testid="tag-item"][data-tag-name="${tag.name}"]`,
67-
);
59+
const tagItem = page.locator(`[data-testid="tag-item"][data-tag-name="${tag.name}"]`);
6860
await expect(tagItem).toBeVisible();
6961

7062
const tagName = tagItem.locator('[data-testid="tag-name"]');

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@
2424
"users:passwords": "scripts/set-passwords.sh",
2525
"routes:generate": "node scripts/generate-routes.js",
2626
"routes:generate:ts": "tsx scripts/generate-routes.ts",
27-
"e2e": "ng e2e web",
28-
"e2e:local": "ng e2e web -c local",
27+
"e2e": "playwright test",
28+
"e2e:web": "playwright test --project=web",
29+
"e2e:web:local": "playwright test --project=web --project=local",
30+
"e2e:admin": "playwright test --project=admin",
31+
"e2e:admin:local": "playwright test --project=admin",
2932
"lint": "npm run lint:projects",
3033
"lint:fix": "npm run lint:projects -- --fix",
3134
"lint:all": "ng lint admin && ng lint web && ng lint code-samples-mfe",

playwright.config.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,45 @@ export default defineConfig({
3232

3333
/* Configure projects for major browsers */
3434
projects: [
35+
{
36+
name: 'web',
37+
testDir: './e2e/web',
38+
use: {
39+
...devices['Desktop Chrome'],
40+
baseURL: process.env['PLAYWRIGHT_TEST_BASE_URL'] ?? 'http://localhost:4200',
41+
},
42+
},
43+
44+
{
45+
name: 'admin',
46+
testDir: './e2e/admin',
47+
use: {
48+
...devices['Desktop Chrome'],
49+
baseURL: process.env['PLAYWRIGHT_TEST_BASE_URL'] ?? 'http://localhost:4201',
50+
},
51+
},
52+
3553
{
3654
name: 'chromium',
55+
testDir: './e2e/web',
3756
use: { ...devices['Desktop Chrome'] },
3857
},
3958

4059
{
4160
name: 'firefox',
61+
testDir: './e2e/web',
4262
use: { ...devices['Desktop Firefox'] },
4363
},
4464

4565
{
4666
name: 'webkit',
67+
testDir: './e2e/web',
4768
use: { ...devices['Desktop Safari'] },
4869
},
4970

5071
{
5172
name: 'local',
73+
testDir: './e2e/web',
5274
use: {
5375
...devices['Desktop Chrome'],
5476
baseURL: 'http://localhost:4200',

0 commit comments

Comments
 (0)