Skip to content

Commit c6641f7

Browse files
authored
Merge pull request #9 from AutomateThePlanet/bellatrix-extras
Added extras project, added Services hooks and added onError listener for all hooks
2 parents 2f43318 + 9a0425b commit c6641f7

File tree

75 files changed

+616
-149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+616
-149
lines changed

@bellatrix/appium/tsconfig.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
"baseUrl": "src",
44
"rootDir": "src",
55
"outDir": "lib",
6-
"paths": {
7-
"*": [ "@bellatrix/appium/*" ],
8-
"@bellatrix/core/*": [ "../../core/src/*" ]
9-
},
106
"lib": [ "ESNext" ],
117
"module": "esnext",
128
"target": "esnext",
@@ -24,9 +20,6 @@
2420
"forceConsistentCasingInFileNames": true,
2521
"allowJs": false
2622
},
27-
"references": [
28-
{ "path": "../core" }
29-
],
3023
"include": ["**/*.ts"],
3124
"exclude": ["node_modules"]
3225
}

@bellatrix/core/src/types/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export type BellatrixConfigurationOverride = BellatrixConfiguration
4545
// "delayBeforeAction": 0
4646
// },
4747
// "executionSettings": {
48-
// "browserAutomationTool": "playwright", // selenium, cypress
48+
// "browserController": "playwright", // selenium, cypress
4949
// "browser": "chrome", // firefox, safari, edge
5050
// "headless": false,
5151
// "executionType": "local" // remote

@bellatrix/extras/package-lock.json

Lines changed: 79 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

@bellatrix/extras/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "@bellatrix/extras",
3+
"version": "0.0.1",
4+
"type": "module",
5+
"exports": {
6+
"./hooks": "./src/hooks/index.ts",
7+
"./plugins": "./src/plugins/index.ts"
8+
},
9+
"dependencies": {
10+
"@bellatrix/core": "file:../core",
11+
"@bellatrix/web": "file:../web"
12+
},
13+
"peerDependencies": {
14+
"typescript": "^5.0.0"
15+
}
16+
}

@bellatrix/web/src/components/hooks/DefaultWebComponentHooks.ts renamed to @bellatrix/extras/src/hooks/ExtraWebHooks.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { WebComponentHooks } from '@bellatrix/web/components/utilities';
22
import { Anchor, Button, CheckBox, ColorInput, DateInput, DateTimeInput, EmailField, FileInput, MonthInput, NumberInput, PasswordField, PhoneField, RangeInput, SearchField, Select, TextArea, TextField, TimeInput, UrlField, WebComponent, WeekInput } from '@bellatrix/web/components';
33

4-
export class DefaultWebComponentHooks {
4+
// TODO: maybe decouple it in different web-extras plugin so extras does not import @bellatrix/web too?
5+
export class ExtraWebHooks {
56
static addComponentBDDLogging(): void {
6-
const locale = Intl.DateTimeFormat().resolvedOptions().locale;// TODO: make it configurable
7-
const shouldObfuscatePassword = true; // TODO: add as option in configuration
7+
const locale = Intl.DateTimeFormat().resolvedOptions().locale; // TODO: add locale option in the config
88

99
WebComponentHooks.addListenerTo(Anchor).before('click', (anchor) => console.log(`clicking ${anchor.componentName}`));
1010
WebComponentHooks.addListenerTo(Button).before('click', (button) => console.log(`clicking ${button.componentName}`));
@@ -17,7 +17,7 @@ export class DefaultWebComponentHooks {
1717
WebComponentHooks.addListenerTo(FileInput).before('upload', (fileInput, filePath) => console.log(`uploading '${filePath}' into ${fileInput.componentName}`));
1818
WebComponentHooks.addListenerTo(MonthInput).before('setMonth', (monthInput, year, month) => console.log(`setting ${monthInput} to ${new Date(year, month - 1).toLocaleDateString(locale, { month: 'long', year: 'numeric' })}`));
1919
WebComponentHooks.addListenerTo(NumberInput).before('setNumber', (numberInput, number) => console.log(`setting ${numberInput.componentName} to ${number}`));
20-
WebComponentHooks.addListenerTo(PasswordField).before('setPassword', (passwordField, password) => console.log(`typing ${shouldObfuscatePassword ? '********' : password} into ${passwordField.componentName}`));
20+
WebComponentHooks.addListenerTo(PasswordField).before('setPassword', (passwordField, _) => console.log(`typing '********' into ${passwordField.componentName}`));
2121
WebComponentHooks.addListenerTo(PhoneField).before('setPhone', (phoneField, phone) => console.log(`typing '${phone}' into ${phoneField.componentName}`));
2222
WebComponentHooks.addListenerTo(RangeInput).before('setValue', (rangeInput, value) => console.log(`setting ${rangeInput.componentName} to ${value}`));
2323
WebComponentHooks.addListenerTo(SearchField).before('setSearch', (searchField, search) => console.log(`typing '${search}' into ${searchField.componentName}`));
@@ -29,7 +29,8 @@ export class DefaultWebComponentHooks {
2929
WebComponentHooks.addListenerTo(TimeInput).before('setTime', (timeInput, hours, minutes, seconds) => console.log(`setting ${timeInput.componentName} to ${[hours, minutes, seconds].map(n => String(n ?? 0).padStart(2, '0')).join(':')}`));
3030
WebComponentHooks.addListenerTo(UrlField).before('setUrl', (urlField, url) => console.log(`typing '${url}' into ${urlField.componentName}`));
3131
WebComponentHooks.addListenerTo(WeekInput).before('setWeek', (weekInput, year, weekNumber) => console.log(`setting ${weekInput.componentName} to ${year}-W${weekNumber.toString().padStart(2, '0')}`));
32-
WebComponentHooks.addListenerTo(WebComponent).before('scrollToVisible', (component) => console.log(`scrolling ${component} into view`));
33-
WebComponentHooks.addListenerTo(WebComponent).before('hover', (component) => console.log(`hovering ${component}`)); // TODO: add focus method?
32+
WebComponentHooks.addListenerTo(WebComponent).before('scrollIntoView', (component) => console.log(`scrolling ${component} into view`));
33+
WebComponentHooks.addListenerTo(WebComponent).before('hover', (component) => console.log(`hovering ${component}`));
34+
WebComponentHooks.addListenerTo(WebComponent).before('focus', (component) => console.log(`focusing ${component}`));
3435
}
3536
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './ExtraWebHooks';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Plugin } from '@bellatrix/core/infrastructure';
2+
import { TestMetadata } from '@bellatrix/core/test/props';
3+
4+
export class LogLifecyclePlugin extends Plugin {
5+
override async preBeforeTest(testMetadata: TestMetadata): Promise<void> {
6+
console.log('\n==================================================================================\n' +
7+
`starting test: ${testMetadata.suiteClass.name} > ${testMetadata.testMethod.name}\n`);
8+
}
9+
10+
override async postAfterTest(_: TestMetadata): Promise<void> {
11+
console.log('\n==================================================================================\n');
12+
}
13+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './LogLifecyclePlugin';

@bellatrix/extras/tsconfig.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": "src",
4+
"rootDir": "src",
5+
"outDir": "lib",
6+
"lib": [ "ESNext", "DOM" ],
7+
"module": "esnext",
8+
"target": "esnext",
9+
"moduleResolution": "bundler",
10+
"moduleDetection": "force",
11+
"noImplicitOverride": true,
12+
"experimentalDecorators": true,
13+
"emitDecoratorMetadata": true,
14+
"composite": true,
15+
"sourceMap": true,
16+
"strict": true,
17+
"downlevelIteration": true,
18+
"skipLibCheck": true,
19+
"allowSyntheticDefaultImports": true,
20+
"forceConsistentCasingInFileNames": true,
21+
"allowJs": false
22+
},
23+
"include": ["**/*.ts"],
24+
"exclude": ["node_modules"]
25+
}

@bellatrix/web/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
"./infrastructure": "./src/infrastructure/index.ts",
1212
"./pages": "./src/pages/index.ts",
1313
"./pages/decorators": "./src/pages/decorators/index.ts",
14-
"./infrastructure/browserautomationtools/core": "./src/infrastructure/browserautomationtools/core/index.ts",
15-
"./infrastructure/browserautomationtools/playwright": "./src/infrastructure/browserautomationtools/playwright/index.ts",
16-
"./infrastructure/browserautomationtools/selenium": "./src/infrastructure/browserautomationtools/selenium/index.ts",
14+
"./infrastructure/browsercontroller/core": "./src/infrastructure/browsercontroller/core/index.ts",
15+
"./infrastructure/browsercontroller/playwright": "./src/infrastructure/browsercontroller/playwright/index.ts",
16+
"./infrastructure/browsercontroller/selenium": "./src/infrastructure/browsercontroller/selenium/index.ts",
1717
"./services": "./src/services/index.ts",
18+
"./services/decorators": "./src/services/decorators/index.ts",
19+
"./services/utilities": "./src/services/utilities/index.ts",
1820
"./plugins": "./src/plugins/index.ts",
1921
"./test": "./src/test/index.ts",
2022
"./types": "./src/types/index.ts",

0 commit comments

Comments
 (0)