@bugzy-ai/bugzy 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +273 -273
- package/dist/cli/index.cjs +269 -13
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +268 -12
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +265 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +265 -10
- package/dist/index.js.map +1 -1
- package/dist/subagents/index.cjs +250 -10
- package/dist/subagents/index.cjs.map +1 -1
- package/dist/subagents/index.js +250 -10
- package/dist/subagents/index.js.map +1 -1
- package/dist/subagents/metadata.cjs +9 -0
- package/dist/subagents/metadata.cjs.map +1 -1
- package/dist/subagents/metadata.js +9 -0
- package/dist/subagents/metadata.js.map +1 -1
- package/dist/tasks/index.cjs.map +1 -1
- package/dist/tasks/index.js.map +1 -1
- package/package.json +95 -95
- package/templates/init/.bugzy/runtime/knowledge-base.md +61 -61
- package/templates/init/.bugzy/runtime/knowledge-maintenance-guide.md +97 -97
- package/templates/init/.bugzy/runtime/project-context.md +35 -35
- package/templates/init/.bugzy/runtime/subagent-memory-guide.md +87 -87
- package/templates/init/.bugzy/runtime/templates/test-plan-template.md +50 -50
- package/templates/init/.bugzy/runtime/templates/test-result-schema.md +498 -498
- package/templates/init/.bugzy/runtime/test-execution-strategy.md +535 -535
- package/templates/init/.bugzy/runtime/testing-best-practices.md +724 -724
- package/templates/init/.env.testdata +18 -18
- package/templates/init/.gitignore-template +24 -24
- package/templates/init/AGENTS.md +155 -155
- package/templates/init/CLAUDE.md +157 -157
- package/templates/init/test-runs/README.md +45 -45
- package/templates/playwright/BasePage.template.ts +190 -190
- package/templates/playwright/auth.setup.template.ts +89 -89
- package/templates/playwright/dataGenerators.helper.template.ts +148 -148
- package/templates/playwright/dateUtils.helper.template.ts +96 -96
- package/templates/playwright/pages.fixture.template.ts +50 -50
- package/templates/playwright/playwright.config.template.ts +97 -97
- package/templates/playwright/reporters/bugzy-reporter.ts +454 -454
- package/dist/templates/init/.bugzy/runtime/knowledge-base.md +0 -61
- package/dist/templates/init/.bugzy/runtime/knowledge-maintenance-guide.md +0 -97
- package/dist/templates/init/.bugzy/runtime/project-context.md +0 -35
- package/dist/templates/init/.bugzy/runtime/subagent-memory-guide.md +0 -87
- package/dist/templates/init/.bugzy/runtime/templates/test-plan-template.md +0 -50
- package/dist/templates/init/.bugzy/runtime/templates/test-result-schema.md +0 -498
- package/dist/templates/init/.bugzy/runtime/test-execution-strategy.md +0 -535
- package/dist/templates/init/.bugzy/runtime/testing-best-practices.md +0 -632
- package/dist/templates/init/.gitignore-template +0 -25
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test Data Generators
|
|
3
|
-
* Generated by Bugzy - https://github.com/bugzy-ai/bugzy
|
|
4
|
-
*
|
|
5
|
-
* Helper functions for generating realistic test data
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Generate a random email address
|
|
10
|
-
* @param prefix - Optional prefix for the email
|
|
11
|
-
*/
|
|
12
|
-
export function generateEmail(prefix = 'test'): string {
|
|
13
|
-
const timestamp = Date.now();
|
|
14
|
-
const random = Math.floor(Math.random() * 10000);
|
|
15
|
-
return `${prefix}-${timestamp}-${random}@example.com`;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Generate a random username
|
|
20
|
-
* @param prefix - Optional prefix for the username
|
|
21
|
-
*/
|
|
22
|
-
export function generateUsername(prefix = 'user'): string {
|
|
23
|
-
const timestamp = Date.now();
|
|
24
|
-
const random = Math.floor(Math.random() * 10000);
|
|
25
|
-
return `${prefix}_${timestamp}_${random}`;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Generate a random phone number (US format)
|
|
30
|
-
*/
|
|
31
|
-
export function generatePhoneNumber(): string {
|
|
32
|
-
const areaCode = Math.floor(Math.random() * 900) + 100;
|
|
33
|
-
const prefix = Math.floor(Math.random() * 900) + 100;
|
|
34
|
-
const lineNumber = Math.floor(Math.random() * 9000) + 1000;
|
|
35
|
-
return `(${areaCode}) ${prefix}-${lineNumber}`;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Generate a random string of specified length
|
|
40
|
-
* @param length - Length of the string
|
|
41
|
-
*/
|
|
42
|
-
export function generateRandomString(length: number): string {
|
|
43
|
-
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
44
|
-
let result = '';
|
|
45
|
-
for (let i = 0; i < length; i++) {
|
|
46
|
-
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
47
|
-
}
|
|
48
|
-
return result;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Generate a random number between min and max (inclusive)
|
|
53
|
-
* @param min - Minimum value
|
|
54
|
-
* @param max - Maximum value
|
|
55
|
-
*/
|
|
56
|
-
export function generateRandomNumber(min: number, max: number): number {
|
|
57
|
-
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Generate a random boolean value
|
|
62
|
-
*/
|
|
63
|
-
export function generateRandomBoolean(): boolean {
|
|
64
|
-
return Math.random() < 0.5;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Generate a unique ID
|
|
69
|
-
*/
|
|
70
|
-
export function generateUniqueId(): string {
|
|
71
|
-
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Generate a random password
|
|
76
|
-
* @param length - Length of the password (default: 12)
|
|
77
|
-
*/
|
|
78
|
-
export function generatePassword(length = 12): string {
|
|
79
|
-
const uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
80
|
-
const lowercase = 'abcdefghijklmnopqrstuvwxyz';
|
|
81
|
-
const numbers = '0123456789';
|
|
82
|
-
const special = '!@#$%^&*';
|
|
83
|
-
const all = uppercase + lowercase + numbers + special;
|
|
84
|
-
|
|
85
|
-
let password = '';
|
|
86
|
-
// Ensure at least one of each type
|
|
87
|
-
password += uppercase.charAt(Math.floor(Math.random() * uppercase.length));
|
|
88
|
-
password += lowercase.charAt(Math.floor(Math.random() * lowercase.length));
|
|
89
|
-
password += numbers.charAt(Math.floor(Math.random() * numbers.length));
|
|
90
|
-
password += special.charAt(Math.floor(Math.random() * special.length));
|
|
91
|
-
|
|
92
|
-
// Fill the rest
|
|
93
|
-
for (let i = password.length; i < length; i++) {
|
|
94
|
-
password += all.charAt(Math.floor(Math.random() * all.length));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Shuffle the password
|
|
98
|
-
return password
|
|
99
|
-
.split('')
|
|
100
|
-
.sort(() => Math.random() - 0.5)
|
|
101
|
-
.join('');
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Generate test user data
|
|
106
|
-
*/
|
|
107
|
-
export interface TestUser {
|
|
108
|
-
email: string;
|
|
109
|
-
username: string;
|
|
110
|
-
password: string;
|
|
111
|
-
firstName: string;
|
|
112
|
-
lastName: string;
|
|
113
|
-
phone: string;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export function generateTestUser(): TestUser {
|
|
117
|
-
const firstNames = ['John', 'Jane', 'Bob', 'Alice', 'Charlie', 'Diana', 'Eve', 'Frank'];
|
|
118
|
-
const lastNames = ['Smith', 'Johnson', 'Williams', 'Brown', 'Jones', 'Garcia', 'Miller', 'Davis'];
|
|
119
|
-
|
|
120
|
-
const firstName = firstNames[Math.floor(Math.random() * firstNames.length)];
|
|
121
|
-
const lastName = lastNames[Math.floor(Math.random() * lastNames.length)];
|
|
122
|
-
|
|
123
|
-
return {
|
|
124
|
-
email: generateEmail(firstName.toLowerCase()),
|
|
125
|
-
username: generateUsername(firstName.toLowerCase()),
|
|
126
|
-
password: generatePassword(),
|
|
127
|
-
firstName,
|
|
128
|
-
lastName,
|
|
129
|
-
phone: generatePhoneNumber(),
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Pick a random item from an array
|
|
135
|
-
* @param array - Array to pick from
|
|
136
|
-
*/
|
|
137
|
-
export function pickRandom<T>(array: T[]): T {
|
|
138
|
-
return array[Math.floor(Math.random() * array.length)];
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Generate a random date between two dates
|
|
143
|
-
* @param start - Start date
|
|
144
|
-
* @param end - End date
|
|
145
|
-
*/
|
|
146
|
-
export function generateRandomDate(start: Date, end: Date): Date {
|
|
147
|
-
return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()));
|
|
148
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Test Data Generators
|
|
3
|
+
* Generated by Bugzy - https://github.com/bugzy-ai/bugzy
|
|
4
|
+
*
|
|
5
|
+
* Helper functions for generating realistic test data
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Generate a random email address
|
|
10
|
+
* @param prefix - Optional prefix for the email
|
|
11
|
+
*/
|
|
12
|
+
export function generateEmail(prefix = 'test'): string {
|
|
13
|
+
const timestamp = Date.now();
|
|
14
|
+
const random = Math.floor(Math.random() * 10000);
|
|
15
|
+
return `${prefix}-${timestamp}-${random}@example.com`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Generate a random username
|
|
20
|
+
* @param prefix - Optional prefix for the username
|
|
21
|
+
*/
|
|
22
|
+
export function generateUsername(prefix = 'user'): string {
|
|
23
|
+
const timestamp = Date.now();
|
|
24
|
+
const random = Math.floor(Math.random() * 10000);
|
|
25
|
+
return `${prefix}_${timestamp}_${random}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Generate a random phone number (US format)
|
|
30
|
+
*/
|
|
31
|
+
export function generatePhoneNumber(): string {
|
|
32
|
+
const areaCode = Math.floor(Math.random() * 900) + 100;
|
|
33
|
+
const prefix = Math.floor(Math.random() * 900) + 100;
|
|
34
|
+
const lineNumber = Math.floor(Math.random() * 9000) + 1000;
|
|
35
|
+
return `(${areaCode}) ${prefix}-${lineNumber}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Generate a random string of specified length
|
|
40
|
+
* @param length - Length of the string
|
|
41
|
+
*/
|
|
42
|
+
export function generateRandomString(length: number): string {
|
|
43
|
+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
44
|
+
let result = '';
|
|
45
|
+
for (let i = 0; i < length; i++) {
|
|
46
|
+
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Generate a random number between min and max (inclusive)
|
|
53
|
+
* @param min - Minimum value
|
|
54
|
+
* @param max - Maximum value
|
|
55
|
+
*/
|
|
56
|
+
export function generateRandomNumber(min: number, max: number): number {
|
|
57
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Generate a random boolean value
|
|
62
|
+
*/
|
|
63
|
+
export function generateRandomBoolean(): boolean {
|
|
64
|
+
return Math.random() < 0.5;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Generate a unique ID
|
|
69
|
+
*/
|
|
70
|
+
export function generateUniqueId(): string {
|
|
71
|
+
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Generate a random password
|
|
76
|
+
* @param length - Length of the password (default: 12)
|
|
77
|
+
*/
|
|
78
|
+
export function generatePassword(length = 12): string {
|
|
79
|
+
const uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
80
|
+
const lowercase = 'abcdefghijklmnopqrstuvwxyz';
|
|
81
|
+
const numbers = '0123456789';
|
|
82
|
+
const special = '!@#$%^&*';
|
|
83
|
+
const all = uppercase + lowercase + numbers + special;
|
|
84
|
+
|
|
85
|
+
let password = '';
|
|
86
|
+
// Ensure at least one of each type
|
|
87
|
+
password += uppercase.charAt(Math.floor(Math.random() * uppercase.length));
|
|
88
|
+
password += lowercase.charAt(Math.floor(Math.random() * lowercase.length));
|
|
89
|
+
password += numbers.charAt(Math.floor(Math.random() * numbers.length));
|
|
90
|
+
password += special.charAt(Math.floor(Math.random() * special.length));
|
|
91
|
+
|
|
92
|
+
// Fill the rest
|
|
93
|
+
for (let i = password.length; i < length; i++) {
|
|
94
|
+
password += all.charAt(Math.floor(Math.random() * all.length));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Shuffle the password
|
|
98
|
+
return password
|
|
99
|
+
.split('')
|
|
100
|
+
.sort(() => Math.random() - 0.5)
|
|
101
|
+
.join('');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Generate test user data
|
|
106
|
+
*/
|
|
107
|
+
export interface TestUser {
|
|
108
|
+
email: string;
|
|
109
|
+
username: string;
|
|
110
|
+
password: string;
|
|
111
|
+
firstName: string;
|
|
112
|
+
lastName: string;
|
|
113
|
+
phone: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function generateTestUser(): TestUser {
|
|
117
|
+
const firstNames = ['John', 'Jane', 'Bob', 'Alice', 'Charlie', 'Diana', 'Eve', 'Frank'];
|
|
118
|
+
const lastNames = ['Smith', 'Johnson', 'Williams', 'Brown', 'Jones', 'Garcia', 'Miller', 'Davis'];
|
|
119
|
+
|
|
120
|
+
const firstName = firstNames[Math.floor(Math.random() * firstNames.length)];
|
|
121
|
+
const lastName = lastNames[Math.floor(Math.random() * lastNames.length)];
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
email: generateEmail(firstName.toLowerCase()),
|
|
125
|
+
username: generateUsername(firstName.toLowerCase()),
|
|
126
|
+
password: generatePassword(),
|
|
127
|
+
firstName,
|
|
128
|
+
lastName,
|
|
129
|
+
phone: generatePhoneNumber(),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Pick a random item from an array
|
|
135
|
+
* @param array - Array to pick from
|
|
136
|
+
*/
|
|
137
|
+
export function pickRandom<T>(array: T[]): T {
|
|
138
|
+
return array[Math.floor(Math.random() * array.length)];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Generate a random date between two dates
|
|
143
|
+
* @param start - Start date
|
|
144
|
+
* @param end - End date
|
|
145
|
+
*/
|
|
146
|
+
export function generateRandomDate(start: Date, end: Date): Date {
|
|
147
|
+
return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()));
|
|
148
|
+
}
|
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Date Utility Functions
|
|
3
|
-
* Generated by Bugzy - https://github.com/bugzy-ai/bugzy
|
|
4
|
-
*
|
|
5
|
-
* Helper functions for working with dates in tests
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Get today's date in YYYY-MM-DD format
|
|
10
|
-
*/
|
|
11
|
-
export function getTodayDate(): string {
|
|
12
|
-
const today = new Date();
|
|
13
|
-
return formatDate(today);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Get tomorrow's date in YYYY-MM-DD format
|
|
18
|
-
*/
|
|
19
|
-
export function getTomorrowDate(): string {
|
|
20
|
-
const tomorrow = new Date();
|
|
21
|
-
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
22
|
-
return formatDate(tomorrow);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Get yesterday's date in YYYY-MM-DD format
|
|
27
|
-
*/
|
|
28
|
-
export function getYesterdayDate(): string {
|
|
29
|
-
const yesterday = new Date();
|
|
30
|
-
yesterday.setDate(yesterday.getDate() - 1);
|
|
31
|
-
return formatDate(yesterday);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Get date N days from now
|
|
36
|
-
* @param days - Number of days (positive for future, negative for past)
|
|
37
|
-
*/
|
|
38
|
-
export function getDateDaysFromNow(days: number): string {
|
|
39
|
-
const date = new Date();
|
|
40
|
-
date.setDate(date.getDate() + days);
|
|
41
|
-
return formatDate(date);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Format date as YYYY-MM-DD
|
|
46
|
-
* @param date - Date object to format
|
|
47
|
-
*/
|
|
48
|
-
export function formatDate(date: Date): string {
|
|
49
|
-
const year = date.getFullYear();
|
|
50
|
-
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
51
|
-
const day = String(date.getDate()).padStart(2, '0');
|
|
52
|
-
return `${year}-${month}-${day}`;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Format date as MM/DD/YYYY
|
|
57
|
-
* @param date - Date object to format
|
|
58
|
-
*/
|
|
59
|
-
export function formatDateUS(date: Date): string {
|
|
60
|
-
const year = date.getFullYear();
|
|
61
|
-
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
62
|
-
const day = String(date.getDate()).padStart(2, '0');
|
|
63
|
-
return `${month}/${day}/${year}`;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Parse date string (YYYY-MM-DD) to Date object
|
|
68
|
-
* @param dateString - Date string in YYYY-MM-DD format
|
|
69
|
-
*/
|
|
70
|
-
export function parseDate(dateString: string): Date {
|
|
71
|
-
const [year, month, day] = dateString.split('-').map(Number);
|
|
72
|
-
return new Date(year, month - 1, day);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Get current timestamp in milliseconds
|
|
77
|
-
*/
|
|
78
|
-
export function getCurrentTimestamp(): number {
|
|
79
|
-
return Date.now();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Get current ISO timestamp string
|
|
84
|
-
*/
|
|
85
|
-
export function getCurrentISOTimestamp(): string {
|
|
86
|
-
return new Date().toISOString();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Wait for a specific amount of time (use sparingly!)
|
|
91
|
-
* Note: Prefer Playwright's built-in waiting mechanisms over this
|
|
92
|
-
* @param ms - Milliseconds to wait
|
|
93
|
-
*/
|
|
94
|
-
export async function wait(ms: number): Promise<void> {
|
|
95
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
96
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Date Utility Functions
|
|
3
|
+
* Generated by Bugzy - https://github.com/bugzy-ai/bugzy
|
|
4
|
+
*
|
|
5
|
+
* Helper functions for working with dates in tests
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Get today's date in YYYY-MM-DD format
|
|
10
|
+
*/
|
|
11
|
+
export function getTodayDate(): string {
|
|
12
|
+
const today = new Date();
|
|
13
|
+
return formatDate(today);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Get tomorrow's date in YYYY-MM-DD format
|
|
18
|
+
*/
|
|
19
|
+
export function getTomorrowDate(): string {
|
|
20
|
+
const tomorrow = new Date();
|
|
21
|
+
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
22
|
+
return formatDate(tomorrow);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Get yesterday's date in YYYY-MM-DD format
|
|
27
|
+
*/
|
|
28
|
+
export function getYesterdayDate(): string {
|
|
29
|
+
const yesterday = new Date();
|
|
30
|
+
yesterday.setDate(yesterday.getDate() - 1);
|
|
31
|
+
return formatDate(yesterday);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get date N days from now
|
|
36
|
+
* @param days - Number of days (positive for future, negative for past)
|
|
37
|
+
*/
|
|
38
|
+
export function getDateDaysFromNow(days: number): string {
|
|
39
|
+
const date = new Date();
|
|
40
|
+
date.setDate(date.getDate() + days);
|
|
41
|
+
return formatDate(date);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Format date as YYYY-MM-DD
|
|
46
|
+
* @param date - Date object to format
|
|
47
|
+
*/
|
|
48
|
+
export function formatDate(date: Date): string {
|
|
49
|
+
const year = date.getFullYear();
|
|
50
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
51
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
52
|
+
return `${year}-${month}-${day}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Format date as MM/DD/YYYY
|
|
57
|
+
* @param date - Date object to format
|
|
58
|
+
*/
|
|
59
|
+
export function formatDateUS(date: Date): string {
|
|
60
|
+
const year = date.getFullYear();
|
|
61
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
62
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
63
|
+
return `${month}/${day}/${year}`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Parse date string (YYYY-MM-DD) to Date object
|
|
68
|
+
* @param dateString - Date string in YYYY-MM-DD format
|
|
69
|
+
*/
|
|
70
|
+
export function parseDate(dateString: string): Date {
|
|
71
|
+
const [year, month, day] = dateString.split('-').map(Number);
|
|
72
|
+
return new Date(year, month - 1, day);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Get current timestamp in milliseconds
|
|
77
|
+
*/
|
|
78
|
+
export function getCurrentTimestamp(): number {
|
|
79
|
+
return Date.now();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Get current ISO timestamp string
|
|
84
|
+
*/
|
|
85
|
+
export function getCurrentISOTimestamp(): string {
|
|
86
|
+
return new Date().toISOString();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Wait for a specific amount of time (use sparingly!)
|
|
91
|
+
* Note: Prefer Playwright's built-in waiting mechanisms over this
|
|
92
|
+
* @param ms - Milliseconds to wait
|
|
93
|
+
*/
|
|
94
|
+
export async function wait(ms: number): Promise<void> {
|
|
95
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
96
|
+
}
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { test as base } from '@playwright/test';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Custom Fixtures for Page Objects
|
|
5
|
-
* Generated by Bugzy - https://github.com/bugzy-ai/bugzy
|
|
6
|
-
*
|
|
7
|
-
* Fixtures provide a way to set up and tear down test dependencies
|
|
8
|
-
* This example shows how to create fixtures for page objects
|
|
9
|
-
*
|
|
10
|
-
* Usage in tests:
|
|
11
|
-
* test('my test', async ({ homePage }) => {
|
|
12
|
-
* await homePage.navigate();
|
|
13
|
-
* // ...
|
|
14
|
-
* });
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
// Define fixture types
|
|
18
|
-
type PageFixtures = {
|
|
19
|
-
// Add your page object fixtures here
|
|
20
|
-
// Example:
|
|
21
|
-
// homePage: HomePage;
|
|
22
|
-
// loginPage: LoginPage;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Extend the base test with custom fixtures
|
|
27
|
-
*
|
|
28
|
-
* Example implementation:
|
|
29
|
-
*
|
|
30
|
-
* import { HomePage } from '@pages/HomePage';
|
|
31
|
-
* import { LoginPage } from '@pages/LoginPage';
|
|
32
|
-
*
|
|
33
|
-
* export const test = base.extend<PageFixtures>({
|
|
34
|
-
* homePage: async ({ page }, use) => {
|
|
35
|
-
* const homePage = new HomePage(page);
|
|
36
|
-
* await use(homePage);
|
|
37
|
-
* },
|
|
38
|
-
*
|
|
39
|
-
* loginPage: async ({ page }, use) => {
|
|
40
|
-
* const loginPage = new LoginPage(page);
|
|
41
|
-
* await use(loginPage);
|
|
42
|
-
* },
|
|
43
|
-
* });
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
export const test = base.extend<PageFixtures>({
|
|
47
|
-
// Add your fixtures here
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
export { expect } from '@playwright/test';
|
|
1
|
+
import { test as base } from '@playwright/test';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Custom Fixtures for Page Objects
|
|
5
|
+
* Generated by Bugzy - https://github.com/bugzy-ai/bugzy
|
|
6
|
+
*
|
|
7
|
+
* Fixtures provide a way to set up and tear down test dependencies
|
|
8
|
+
* This example shows how to create fixtures for page objects
|
|
9
|
+
*
|
|
10
|
+
* Usage in tests:
|
|
11
|
+
* test('my test', async ({ homePage }) => {
|
|
12
|
+
* await homePage.navigate();
|
|
13
|
+
* // ...
|
|
14
|
+
* });
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// Define fixture types
|
|
18
|
+
type PageFixtures = {
|
|
19
|
+
// Add your page object fixtures here
|
|
20
|
+
// Example:
|
|
21
|
+
// homePage: HomePage;
|
|
22
|
+
// loginPage: LoginPage;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Extend the base test with custom fixtures
|
|
27
|
+
*
|
|
28
|
+
* Example implementation:
|
|
29
|
+
*
|
|
30
|
+
* import { HomePage } from '@pages/HomePage';
|
|
31
|
+
* import { LoginPage } from '@pages/LoginPage';
|
|
32
|
+
*
|
|
33
|
+
* export const test = base.extend<PageFixtures>({
|
|
34
|
+
* homePage: async ({ page }, use) => {
|
|
35
|
+
* const homePage = new HomePage(page);
|
|
36
|
+
* await use(homePage);
|
|
37
|
+
* },
|
|
38
|
+
*
|
|
39
|
+
* loginPage: async ({ page }, use) => {
|
|
40
|
+
* const loginPage = new LoginPage(page);
|
|
41
|
+
* await use(loginPage);
|
|
42
|
+
* },
|
|
43
|
+
* });
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
export const test = base.extend<PageFixtures>({
|
|
47
|
+
// Add your fixtures here
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export { expect } from '@playwright/test';
|