Skip to content

Commit 8786d5e

Browse files
committed
updated libraries
1 parent a8b95e8 commit 8786d5e

File tree

9 files changed

+202
-89
lines changed

9 files changed

+202
-89
lines changed

.eslintrc.js

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

.prettierrc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,23 @@
44
"useTabs": false,
55
"semi": true,
66
"singleQuote": true,
7+
"quoteProps": "as-needed",
78
"trailingComma": "es5",
89
"bracketSpacing": true,
10+
"bracketSameLine": false,
911
"arrowParens": "avoid",
1012
"endOfLine": "lf",
13+
"embeddedLanguageFormatting": "auto",
1114
"plugins": [
1215
"@trivago/prettier-plugin-sort-imports"
1316
],
17+
"importOrder": [
18+
"^@playwright/(.*)$",
19+
"^@types/(.*)$",
20+
"^@/(.*)$",
21+
"^[./]"
22+
],
1423
"importOrderSeparation": true,
15-
"importOrderSortSpecifiers": true
24+
"importOrderSortSpecifiers": true,
25+
"importOrderCaseInsensitive": true
1626
}

eslint.config.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import js from '@eslint/js';
2+
import typescript from '@typescript-eslint/eslint-plugin';
3+
import typescriptParser from '@typescript-eslint/parser';
4+
import prettier from 'eslint-config-prettier';
5+
import globals from 'globals';
6+
7+
export default [
8+
js.configs.recommended,
9+
{
10+
files: ['**/*.ts'],
11+
languageOptions: {
12+
parser: typescriptParser,
13+
parserOptions: {
14+
ecmaVersion: 2020,
15+
sourceType: 'module',
16+
project: './tsconfig.json',
17+
},
18+
globals: {
19+
...globals.node,
20+
...globals.es2020,
21+
},
22+
},
23+
plugins: {
24+
'@typescript-eslint': typescript,
25+
},
26+
rules: {
27+
'@typescript-eslint/explicit-function-return-type': 'warn',
28+
'@typescript-eslint/no-explicit-any': 'error',
29+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
30+
'prefer-const': 'error',
31+
'no-console': ['warn', { allow: ['warn', 'error'] }],
32+
'no-var': 'error',
33+
},
34+
},
35+
{
36+
files: ['tests/**/*', '**/*.test.ts'],
37+
rules: {
38+
'@typescript-eslint/no-explicit-any': 'off',
39+
'no-console': 'off',
40+
},
41+
},
42+
prettier,
43+
];

global-setup.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
// Import default logger as fallback
2-
import { closeAllLoggers, defaultLogger } from './src/log/logger';
3-
import { resetTestItemsFile } from './src/utils/testItemExporter';
42
import { FullConfig } from '@playwright/test';
53
import { Logger } from 'pino';
64

7-
async function globalSetup(config: FullConfig) {
5+
import { closeAllLoggers, defaultLogger } from './src/log/logger';
6+
import { resetTestItemsFile } from './src/utils/testItemExporter';
7+
8+
/**
9+
* Global setup function for Playwright tests
10+
*/
11+
async function globalSetup(config: FullConfig): Promise<void> {
812
const log: Logger = defaultLogger;
913

1014
log.info('Starting test suite setup (Global Setup)');
@@ -14,20 +18,31 @@ async function globalSetup(config: FullConfig) {
1418
const isUITest = process.env.UI_TEST === 'true';
1519

1620
if (!isUITest) {
21+
log.info('Resetting test items file...');
1722
resetTestItemsFile();
23+
} else {
24+
log.info('Skipping test items reset for UI tests');
1825
}
1926

20-
log.info('Global setup completed successfully.');
27+
log.info('Global setup completed successfully');
2128
} catch (error) {
22-
log.error({ err: error }, 'Global setup failed!'); // Use err serializer
23-
// Re-throw the error to fail the setup process
29+
log.error({ err: error }, 'Global setup failed!');
2430
throw error;
2531
}
2632
}
2733

28-
async function globalTeardown(config: FullConfig) {
34+
/**
35+
* Global teardown function for Playwright tests
36+
*/
37+
async function globalTeardown(config: FullConfig): Promise<void> {
2938
console.log('Ensuring all logs are properly flushed to disk...');
30-
await closeAllLoggers();
39+
40+
try {
41+
await closeAllLoggers();
42+
console.log('All loggers closed successfully');
43+
} catch (error) {
44+
console.error('Error closing loggers:', error);
45+
}
3146
}
3247

3348
export { globalTeardown };

package.json

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,68 @@
11
{
22
"name": "tssc-test",
33
"version": "1.0.0",
4+
"type": "module",
45
"description": "TSSC Test is a testing framework for TSSC API using Playwright and TypeScript.",
56
"scripts": {
6-
"lint": "eslint --ext .ts src tests",
7-
"lint:fix": "eslint --ext .ts src tests --fix",
8-
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
9-
"check-types": "tsc --noEmit",
10-
"validate": "npm run lint && npm run format && npm run check-types",
7+
"lint": "eslint \"src/**/*.ts\" \"tests/**/*.ts\"",
8+
"lint:fix": "eslint \"src/**/*.ts\" \"tests/**/*.ts\" --fix",
9+
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\" \"*.json\" \"*.js\" \"*.md\"",
10+
"format:check": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\" \"*.json\" \"*.js\" \"*.md\"",
11+
"type-check": "tsc --noEmit",
12+
"validate": "npm run type-check && npm run lint && npm run format:check",
1113
"test": "playwright test",
1214
"test:report": "playwright show-report",
1315
"test:tssc": "playwright test tests/tssc/full_workflow.test.ts",
14-
"test:ui": "UI_TEST=true playwright test tests/tssc/ui.test.ts",
15-
"ui": "UI_TEST=true playwright test --ui tests/tssc/ui.test.ts"
16+
"test:ui": "UI_TEST=true playwright test tests/ui/ui.test.ts",
17+
"test:ui-interactive": "UI_TEST=true playwright test --ui tests/ui/ui.test.ts",
18+
"pretest": "npm run validate"
1619
},
1720
"keywords": [
1821
"typescript",
1922
"playwright",
2023
"testing",
21-
"api"
24+
"api",
25+
"e2e"
2226
],
2327
"author": "TSSC Team",
24-
"license": "Apache License 2.0",
28+
"license": "Apache-2.0",
2529
"dependencies": {
26-
"@gitbeaker/rest": "^42.5.0",
30+
"@gitbeaker/rest": "^43.0.0",
2731
"@janus-idp/shared-react": "^2.18.0",
2832
"@types/async-retry": "^1.4.9",
2933
"async-retry": "^1.3.3",
3034
"p-retry": "^6.2.1",
31-
"sodium-native": "^5.0.4",
32-
"typescript": "^5.8.3"
35+
"sodium-native": "^5.0.6"
3336
},
3437
"devDependencies": {
35-
"@backstage/plugin-scaffolder-react": "^1.16.0",
36-
"@kubernetes/client-node": "^1.2.0",
38+
"@backstage/plugin-scaffolder-react": "^1.18.0",
39+
"@kubernetes/client-node": "^1.3.0",
3740
"@octokit/plugin-retry": "^8.0.1",
3841
"@octokit/plugin-throttling": "^11.0.1",
3942
"@octokit/rest": "^22.0.0",
40-
"@playwright/test": "^1.52.0",
43+
"@playwright/test": "^1.54.1",
4144
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
42-
"@types/node": "^20.12.14",
45+
"@types/node": "^24.0.14",
4346
"@types/sodium-native": "^2.3.9",
44-
"@typescript-eslint/eslint-plugin": "^7.18.0",
45-
"@typescript-eslint/parser": "^7.18.0",
46-
"axios": "^1.9.0",
47-
"dotenv": "^16.5.0",
47+
"@typescript-eslint/eslint-plugin": "^8.37.0",
48+
"@typescript-eslint/parser": "^8.37.0",
49+
"axios": "^1.10.0",
50+
"dotenv": "^17.2.0",
4851
"eslint": "^8.57.0",
49-
"eslint-config-prettier": "^9.1.0",
50-
"eslint-plugin-prettier": "^5.2.0",
51-
"glob": "^11.0.2",
52-
"nock": "^14.0.4",
52+
"eslint-config-prettier": "^10.1.5",
53+
"eslint-plugin-prettier": "^5.5.1",
54+
"glob": "^11.0.3",
55+
"nock": "^14.0.5",
5356
"otplib": "^12.0.1",
5457
"pino": "^9.7.0",
5558
"pino-pretty": "^13.0.0",
56-
"prettier": "^3.5.3",
59+
"prettier": "^3.6.2",
5760
"rimraf": "^6.0.1",
5861
"ts-node": "^10.9.2",
5962
"typescript": "^5.8.3"
63+
},
64+
"engines": {
65+
"node": ">=18.0.0",
66+
"npm": ">=8.0.0"
6067
}
6168
}

playwright.config.ts

Lines changed: 71 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { defineConfig, PlaywrightTestConfig, PlaywrightTestOptions, PlaywrightWorkerOptions } from '@playwright/test';
1+
import { defineConfig, PlaywrightTestConfig } from '@playwright/test';
22
import { existsSync, readFileSync } from 'fs';
33
import path from 'path';
4-
import { TestPlan } from './src/playwright/testplan';
4+
55
import { TestItem } from './src/playwright/testItem';
6+
import { TestPlan } from './src/playwright/testplan';
67

78
// Extend Playwright types to include testItem
89
declare module '@playwright/test' {
@@ -11,47 +12,89 @@ declare module '@playwright/test' {
1112
}
1213
}
1314

14-
// Load the test plan for e2e tests
15-
const testPlanPath = process.env.TESTPLAN_PATH || path.resolve(process.cwd(), 'testplan.json');
16-
const testPlanData = JSON.parse(readFileSync(testPlanPath, 'utf-8'));
17-
const testPlan = new TestPlan(testPlanData);
15+
// Configuration constants
16+
const DEFAULT_TIMEOUT = 2100000; // 35 minutes
17+
const DEFAULT_WORKERS = 6;
18+
const DEFAULT_TESTPLAN_PATH = path.resolve(process.cwd(), 'testplan.json');
1819

19-
// Create projects using the TestPlan class
20-
const e2eProjects = testPlan.getProjectConfigs().map(config => ({
21-
name: config.name,
22-
use: {
23-
testItem: config.testItem,
24-
},
25-
}));
20+
/**
21+
* Load test plan configuration
22+
*/
23+
function loadTestPlan(): TestPlan {
24+
const testPlanPath = process.env.TESTPLAN_PATH || DEFAULT_TESTPLAN_PATH;
25+
26+
if (!existsSync(testPlanPath)) {
27+
console.warn(`Test plan not found at ${testPlanPath}, using default configuration`);
28+
return new TestPlan({ templates: [], tssc: [], tests: [] });
29+
}
30+
31+
try {
32+
const testPlanData = JSON.parse(readFileSync(testPlanPath, 'utf-8'));
33+
return new TestPlan(testPlanData);
34+
} catch (error) {
35+
console.error(`Failed to parse test plan: ${error}`);
36+
throw error;
37+
}
38+
}
2639

27-
// Create ui projects for UI tests from exported test items
28-
let uiProjects: any[] = [];
29-
const exportedTestItemsPath = './tmp/test-items.json';
30-
if (existsSync(exportedTestItemsPath)) {
40+
/**
41+
* Load exported test items for UI tests
42+
*/
43+
function loadUIProjects(): Array<{ name: string; testMatch: string; use: { testItem: TestItem } }> {
44+
const exportedTestItemsPath = './tmp/test-items.json';
45+
46+
if (!existsSync(exportedTestItemsPath)) {
47+
return [];
48+
}
49+
3150
try {
3251
const exportedData = JSON.parse(readFileSync(exportedTestItemsPath, 'utf-8'));
33-
if (exportedData.testItems && Array.isArray(exportedData.testItems)) {
34-
uiProjects = exportedData.testItems.map((itemData: any) => ({
35-
name: `ui-${itemData.name}`,
36-
testMatch: '**/ui.test.ts',
37-
use: {
38-
testItem: TestItem.fromJSON(itemData),
39-
},
40-
}));
52+
53+
if (!exportedData.testItems || !Array.isArray(exportedData.testItems)) {
54+
return [];
4155
}
56+
57+
return exportedData.testItems.map((itemData: any) => ({
58+
name: `ui-${(itemData as { name: string }).name}`,
59+
testMatch: '**/ui.test.ts',
60+
use: {
61+
testItem: TestItem.fromJSON(itemData),
62+
},
63+
}));
4264
} catch (error) {
4365
console.warn('Could not load exported test items for UI tests:', error);
66+
return [];
4467
}
4568
}
4669

70+
// Load configurations
71+
const testPlan = loadTestPlan();
72+
const e2eProjects = testPlan.getProjectConfigs().map(config => ({
73+
name: config.name,
74+
use: {
75+
testItem: config.testItem,
76+
},
77+
}));
78+
79+
const uiProjects = loadUIProjects();
4780
const allProjects = [...e2eProjects, ...uiProjects];
4881

4982
export default defineConfig({
5083
testDir: './tests',
5184
testMatch: '**/*.test.ts',
52-
workers: 6,
85+
workers: DEFAULT_WORKERS,
86+
timeout: DEFAULT_TIMEOUT,
87+
88+
// Use specific projects or fallback to default
5389
projects: allProjects.length ? allProjects : [{ name: 'default' }],
54-
reporter: [['html', { open: 'never' }], ['list']],
55-
timeout: 2100000, // Default to 35 minutes (2100000ms)
90+
91+
// Reporter configuration
92+
reporter: [
93+
['html', { open: 'never', outputFolder: 'playwright-report' }],
94+
['list'],
95+
['junit', { outputFile: 'test-results/junit.xml' }],
96+
],
97+
98+
// Global setup and teardown
5699
globalSetup: './global-setup.ts',
57100
});

src/rhtap/core/integration/cd/argocd.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ export class ArgoCD {
5757
const success = await this.argoCDClient.syncApplication(applicationName, this.NAMESPACE);
5858

5959
if (!success) {
60+
const status = await this.getApplicationStatus(environment);
61+
console.log(status);
6062
throw new Error(`Failed to sync application ${applicationName}`);
6163
}
6264
}

src/rhtap/core/integration/git/templates/templateFactory.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,4 +247,3 @@ export class TemplateFactory {
247247
}
248248
}
249249
}
250-
export { ContentModifications };

0 commit comments

Comments
 (0)