@cuppet/core 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -1,183 +1,144 @@
1
- # @cuppet/core
2
-
3
- Core testing framework components for Cuppet - a BDD framework based on Cucumber and Puppeteer.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @cuppet/core
9
- ```
10
-
11
- ## Usage
12
-
13
- ### Basic Setup
14
-
15
- ```javascript
16
- const {
17
- BrowserManager,
18
- elementInteraction,
19
- dataStorage
20
- } = require('@cuppet/core');
21
- ```
22
-
23
- ### In your hooks.js
24
-
25
- ```javascript
26
- const { Before, After } = require('@cucumber/cucumber');
27
- const { BrowserManager, AppiumManager } = require('@cuppet/core');
28
- const config = require('config');
29
-
30
- Before(async function (testCase) {
31
- const browserArgs = config.get('browserOptions.args');
32
- const browserViewport = config.get('browserOptions.viewport.default');
33
-
34
- const browserManager = new BrowserManager(browserViewport, browserArgs);
35
- await browserManager.initialize();
36
- this.browserManager = browserManager;
37
- this.browser = browserManager.browser;
38
- this.page = browserManager.page;
39
-
40
- });
41
- ```
42
-
43
- ### In your step definitions
44
-
45
- ```javascript
46
- const { Given, When, Then } = require('@cucumber/cucumber');
47
- const { elementInteraction, mainFunctions } = require('@cuppet/core');
48
-
49
- Given('I am on the homepage', async function() {
50
- await mainFunctions.visitPath(this.page, 'homepage');
51
- });
52
-
53
- When('I click the {string} button', async function(cssSelector) {
54
- await elementInteraction.click(this.page, cssSelector);
55
- });
56
- ```
57
-
58
- ## Available Components
59
-
60
- ### Core Functions
61
- - `elementInteraction` - Element interaction utilities
62
- - `dataStorage` - Data storage and management
63
- - `mainFunctions` - Main testing functions
64
- - `helperFunctions` - Helper utilities
65
- - `apiFunctions` - API testing functions
66
- - `appiumTesting` - Appium mobile testing
67
- - `accessibilityTesting` - Accessibility testing with Pa11y
68
- - `lighthouse` - Performance testing with Lighthouse
69
- - `visualRegression` - Visual regression testing with BackstopJS
70
-
71
- ### Managers
72
- - `BrowserManager` - Puppeteer browser management
73
- - `AppiumManager` - Appium mobile testing management
74
-
75
- ### Step Definitions
76
- - `stepDefinitions` - Pre-built Cucumber step definitions for common testing scenarios
77
-
78
- ## Using Step Definitions in Other Projects
79
-
80
- The cuppet-core package includes pre-built step definitions that you can use in your main project. Here are several ways to integrate them:
81
-
82
- ### Option 1: Import and use directly in your step definition files
83
-
84
- ```javascript
85
- // In your project's step definition file (e.g., mySteps.js)
86
- const { Given, When, Then } = require('@cucumber/cucumber');
87
- const { stepDefinitions } = require('@cuppet/core');
88
-
89
- // Use the pre-built step definitions
90
- const { generalSteps, helperSteps, apiSteps } = stepDefinitions;
91
-
92
- // You can now use the step definitions directly
93
- Given('I am on the homepage', generalSteps.givenIAmOnTheHomepage);
94
- When('I click the login button', helperSteps.whenIClickTheLoginButton);
95
- Then('I should see the dashboard', generalSteps.thenIShouldSeeTheDashboard);
96
- ```
97
-
98
- ### Option 2: Import step definitions separately
99
-
100
- ```javascript
101
- // Import step definitions directly
102
- const stepDefinitions = require('@cuppet/core/stepDefinitions');
103
-
104
- // Or import specific step definition modules
105
- const generalSteps = require('@cuppet/core/features/app/stepDefinitions/generalSteps');
106
- const apiSteps = require('@cuppet/core/features/app/stepDefinitions/apiSteps');
107
- ```
108
-
109
- ### Option 3: Extend and customize step definitions
110
-
111
- ```javascript
112
- // In your project's step definition file
113
- const { Given, When, Then } = require('@cucumber/cucumber');
114
- const { stepDefinitions } = require('@cuppet/core');
115
-
116
- // Extend the base step definitions with your custom logic
117
- Given('I am logged in as {string}', async function(userType) {
118
- // Your custom login logic
119
- await this.page.goto('https://your-app.com/login');
120
- await this.page.fill('[data-testid="username"]', userType);
121
- await this.page.fill('[data-testid="password"]', 'password');
122
- await this.page.click('[data-testid="login-button"]');
123
-
124
- // Then use the base step definition
125
- await stepDefinitions.generalSteps.thenIShouldSeeTheDashboard.call(this);
126
- });
127
- ```
128
-
129
- ### Available Step Definition Categories
130
-
131
- - `accessibilitySteps` - Accessibility testing steps
132
- - `apiSteps` - API testing and validation steps
133
- - `appiumSteps` - Mobile testing with Appium
134
- - `generalSteps` - Common navigation and interaction steps
135
- - `helperSteps` - Utility and helper steps
136
- - `iframeSteps` - Iframe handling steps
137
- - `ifVisibleSteps` - Conditional visibility steps
138
- - `lighthouseSteps` - Performance testing steps
139
- - `pageElements` - Page element management
140
- - `pageElementsConfig` - Page element configuration
141
- - `pageElementsJson` - JSON-based page elements
142
- - `visualRegressionSteps` - Visual regression testing steps
143
-
144
- ### Cucumber Configuration
145
-
146
- Make sure your Cucumber configuration includes the step definition paths:
147
-
148
- ```javascript
149
- // cucumber.js
150
- module.exports = {
151
- default: {
152
- requireModule: ['@cuppet/core'],
153
- require: [
154
- 'node_modules/@cuppet/core/features/app/stepDefinitions/*.js',
155
- 'features/step-definitions/**/*.js' // Your project's step definitions
156
- ]
157
- }
158
- };
159
- ```
160
-
161
- ## Project-Specific Components
162
-
163
- The following components should be created in your project as they are specific to your application:
164
-
165
- - `commonComponents/` - Common form fields and page paths for your application
166
- - `multilingualStrings/` - Multilingual string support for your application
167
-
168
- ## Peer Dependencies
169
-
170
- This package requires the following peer dependencies:
171
- - `@cucumber/cucumber` ^11.0.0
172
- - `puppeteer` ^24.0.1
173
- - `config` ^3.3.9
174
-
175
- Make sure to install these in your project:
176
-
177
- ```bash
178
- npm install @cucumber/cucumber puppeteer config
179
- ```
180
-
181
- ## License
182
-
183
- ISC
1
+ # @cuppet/core
2
+
3
+ Core testing framework components for Cuppet - a BDD framework based on Cucumber and Puppeteer.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @cuppet/core
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Basic Setup
14
+
15
+ ```bash
16
+ yarn install
17
+ ```
18
+
19
+ ### There is a predefined structure in place made available for testing changes. To execute the example test run:
20
+
21
+ ```bash
22
+ yarn test
23
+ ```
24
+
25
+
26
+ ## Available Components
27
+
28
+ ### Core Functions
29
+
30
+ - `elementInteraction` - Element interaction utilities
31
+ - `dataStorage` - Data storage and management
32
+ - `mainFunctions` - Main testing functions
33
+ - `helperFunctions` - Helper utilities
34
+ - `apiFunctions` - API testing functions
35
+ - `appiumTesting` - Appium mobile testing
36
+ - `accessibilityTesting` - Accessibility testing with Pa11y
37
+ - `lighthouse` - Performance testing with Lighthouse
38
+ - `visualRegression` - Visual regression testing with BackstopJS
39
+
40
+ ### Managers
41
+
42
+ - `BrowserManager` - Puppeteer browser management
43
+ - `AppiumManager` - Appium mobile testing management
44
+
45
+ ### Step Definitions
46
+
47
+ - `stepDefinitions` - Pre-built Cucumber step definitions for common testing scenarios
48
+
49
+ ## Using Step Definitions in Other Projects
50
+
51
+ The cuppet-core package includes pre-built step definitions that you can use in your main project. Here are several ways to integrate them:
52
+
53
+ ### Option 1: Import and use directly in your cucumber based project
54
+
55
+ Make sure your Cucumber configuration includes the step definition paths:
56
+
57
+ ```javascript
58
+ // cucumber.js
59
+ module.exports = {
60
+ default: {
61
+ requireModule: ['@cuppet/core'],
62
+ require: [
63
+ 'node_modules/@cuppet/core/features/app/stepDefinitions/*.js',
64
+ 'features/step-definitions/**/*.js', // Your project's step definitions
65
+ ],
66
+ },
67
+ };
68
+ ```
69
+
70
+ ### Option 2: Import step definitions on bulk or separately and override them
71
+
72
+ ```javascript
73
+ // Import step definitions directly
74
+ const stepDefinitions = require('@cuppet/core/stepDefinitions');
75
+
76
+ // Or import specific step definition modules
77
+ const generalSteps = require('@cuppet/core/features/app/stepDefinitions/generalSteps');
78
+ const apiSteps = require('@cuppet/core/features/app/stepDefinitions/apiSteps');
79
+ const { Then } = require('@cucumber/cucumber');
80
+
81
+ Then('the response should be an {string}', async function (type) {
82
+ console.log("Add your new custom logic", type)
83
+ });
84
+ ```
85
+
86
+ ### Option 3: Extend or customize step definitions
87
+
88
+ ```javascript
89
+ // In your project's step definition file
90
+ const { Given, When, Then } = require('@cucumber/cucumber');
91
+ const generalSteps = require('@cuppet/core/features/app/stepDefinitions/generalSteps');
92
+
93
+ // Extend the base step definitions with your custom logic
94
+ Given('I am logged in as {string}', async function (userName) {
95
+ // Your custom login logic
96
+ await this.page.goto('https://your-app.com/login');
97
+ await this.page.fill('[data-testid="username"]', userName);
98
+ await this.page.fill('[data-testid="password"]', 'password');
99
+ await this.page.click('[data-testid="login-button"]');
100
+
101
+ // Then use a base step definition
102
+ await generalSteps.['I follow {string}'].call(this,userName);
103
+ });
104
+ ```
105
+
106
+ ### Available Step Definition Categories
107
+
108
+ - `accessibilitySteps` - Accessibility testing steps
109
+ - `apiSteps` - API testing and validation steps
110
+ - `appiumSteps` - Mobile testing with Appium
111
+ - `generalSteps` - Common navigation and interaction steps
112
+ - `helperSteps` - Utility and helper steps
113
+ - `iframeSteps` - Iframe handling steps
114
+ - `ifVisibleSteps` - Conditional visibility steps
115
+ - `lighthouseSteps` - Performance testing steps
116
+ - `pageElements` - Page element testing
117
+ - `pageElementsConfig` - Page element testing with values from config
118
+ - `pageElementsJson` - Page element testing with values from locally stored JSON file
119
+ - `visualRegressionSteps` - Visual regression testing steps
120
+
121
+ ## Project-Specific Components
122
+
123
+ The following components should be created in your project as they are specific to your application:
124
+
125
+ - `commonComponents/` - Common form fields and page paths for your application
126
+ - `multilingualStrings/` - Multilingual string support for your application
127
+
128
+ ## Peer Dependencies
129
+
130
+ This package requires the following peer dependencies:
131
+
132
+ - `@cucumber/cucumber` ^11.0.0
133
+ - `puppeteer` ^24.0.1
134
+ - `config` ^3.3.9
135
+
136
+ Make sure to install these in your project:
137
+
138
+ ```bash
139
+ npm install @cucumber/cucumber puppeteer config
140
+ ```
141
+
142
+ ## License
143
+
144
+ ISC
@@ -1,58 +1,58 @@
1
- /**
2
- * Wdio session
3
- *
4
- * @type {import('webdriverio')}
5
- */
6
- const { remote } = require('webdriverio');
7
-
8
- /**
9
- * Appium instance manager for handling Appium sessions and capabilities.
10
- *
11
- * @class AppiumManager
12
- * @typedef {AppiumManager}
13
- */
14
- class AppiumManager {
15
- /**
16
- * Creates an instance of AppiumManager.
17
- *
18
- * @constructor
19
- * @param {*} capabilities
20
- */
21
- constructor(capabilities) {
22
- this.capabilities = capabilities;
23
- this.appiumDriver = null;
24
- this.appiumService = null;
25
- }
26
-
27
- /**
28
- * Description placeholder
29
- *
30
- * @async
31
- * @returns {Promise<void>}
32
- * @throws {Error} If the Appium service fails to start.
33
- */
34
- async initialize() {
35
- const wdOpts = {
36
- hostname: process.env.APPIUM_HOST || 'localhost',
37
- port: parseInt(process.env.APPIUM_PORT, 10) || 4723,
38
- logLevel: 'silent', // Can be: 'trace', 'debug', 'info', 'warn', 'error', or 'silent'
39
- capabilities: this.capabilities,
40
- };
41
- this.appiumDriver = await remote(wdOpts);
42
- }
43
-
44
- /**
45
- * Description placeholder
46
- *
47
- * @async
48
- * @returns {Promise<void>}
49
- */
50
- async stop() {
51
- if (this.appiumDriver) {
52
- await this.appiumDriver.deleteSession();
53
- this.appiumDriver = null;
54
- }
55
- }
56
- }
57
-
58
- module.exports = AppiumManager;
1
+ /**
2
+ * Wdio session
3
+ *
4
+ * @type {import('webdriverio')}
5
+ */
6
+ const { remote } = require('webdriverio');
7
+
8
+ /**
9
+ * Appium instance manager for handling Appium sessions and capabilities.
10
+ *
11
+ * @class AppiumManager
12
+ * @typedef {AppiumManager}
13
+ */
14
+ class AppiumManager {
15
+ /**
16
+ * Creates an instance of AppiumManager.
17
+ *
18
+ * @constructor
19
+ * @param {*} capabilities
20
+ */
21
+ constructor(capabilities) {
22
+ this.capabilities = capabilities;
23
+ this.appiumDriver = null;
24
+ this.appiumService = null;
25
+ }
26
+
27
+ /**
28
+ * Description placeholder
29
+ *
30
+ * @async
31
+ * @returns {Promise<void>}
32
+ * @throws {Error} If the Appium service fails to start.
33
+ */
34
+ async initialize() {
35
+ const wdOpts = {
36
+ hostname: process.env.APPIUM_HOST || 'localhost',
37
+ port: parseInt(process.env.APPIUM_PORT, 10) || 4723,
38
+ logLevel: 'silent', // Can be: 'trace', 'debug', 'info', 'warn', 'error', or 'silent'
39
+ capabilities: this.capabilities,
40
+ };
41
+ this.appiumDriver = await remote(wdOpts);
42
+ }
43
+
44
+ /**
45
+ * Description placeholder
46
+ *
47
+ * @async
48
+ * @returns {Promise<void>}
49
+ */
50
+ async stop() {
51
+ if (this.appiumDriver) {
52
+ await this.appiumDriver.deleteSession();
53
+ this.appiumDriver = null;
54
+ }
55
+ }
56
+ }
57
+
58
+ module.exports = AppiumManager;
@@ -1,54 +1,54 @@
1
- const puppeteer = require('puppeteer');
2
-
3
- class BrowserManager {
4
- constructor(config, args, credentials) {
5
- this.config = config;
6
- this.args = args;
7
- this.credentials = credentials;
8
- this.browser = null;
9
- this.page = null;
10
- }
11
-
12
- async initialize() {
13
- // Launch the browser with the provided arguments and configuration
14
- this.browser = await puppeteer.launch({
15
- headless: false,
16
- args: this.args,
17
- defaultViewport: null,
18
- w3c: false,
19
- });
20
- // Check if the browser was launched successfully and a page is available
21
- const pages = await this.browser.pages();
22
- if (pages.length > 0) {
23
- this.page = pages[0];
24
- } else {
25
- this.page = await this.browser.newPage();
26
- }
27
-
28
- // Set the viewport for headless mode
29
- if (Array.isArray(this.args)) {
30
- const isHeadless = this.args.includes('--headless=new');
31
- if (isHeadless) {
32
- await this.page.setViewport({
33
- width: Number(this.config.width),
34
- height: Number(this.config.height),
35
- });
36
- }
37
- }
38
-
39
- // Pass basic authentication credentials if provided
40
- if (this.credentials) {
41
- await this.page.authenticate(this.credentials);
42
- }
43
- }
44
-
45
- async stop() {
46
- if (this.browser) {
47
- await this.browser.close();
48
- this.browser = null;
49
- this.page = null;
50
- }
51
- }
52
- }
53
-
54
- module.exports = BrowserManager;
1
+ const puppeteer = require('puppeteer');
2
+
3
+ class BrowserManager {
4
+ constructor(config, args, credentials) {
5
+ this.config = config;
6
+ this.args = args;
7
+ this.credentials = credentials;
8
+ this.browser = null;
9
+ this.page = null;
10
+ }
11
+
12
+ async initialize() {
13
+ // Launch the browser with the provided arguments and configuration
14
+ this.browser = await puppeteer.launch({
15
+ headless: false,
16
+ args: this.args,
17
+ defaultViewport: null,
18
+ w3c: false,
19
+ });
20
+ // Check if the browser was launched successfully and a page is available
21
+ const pages = await this.browser.pages();
22
+ if (pages.length > 0) {
23
+ this.page = pages[0];
24
+ } else {
25
+ this.page = await this.browser.newPage();
26
+ }
27
+
28
+ // Set the viewport for headless mode
29
+ if (Array.isArray(this.args)) {
30
+ const isHeadless = this.args.includes('--headless=new');
31
+ if (isHeadless) {
32
+ await this.page.setViewport({
33
+ width: Number(this.config.width),
34
+ height: Number(this.config.height),
35
+ });
36
+ }
37
+ }
38
+
39
+ // Pass basic authentication credentials if provided
40
+ if (this.credentials) {
41
+ await this.page.authenticate(this.credentials);
42
+ }
43
+ }
44
+
45
+ async stop() {
46
+ if (this.browser) {
47
+ await this.browser.close();
48
+ this.browser = null;
49
+ this.page = null;
50
+ }
51
+ }
52
+ }
53
+
54
+ module.exports = BrowserManager;
@@ -0,0 +1,18 @@
1
+ const commonFields = {
2
+ Submit: '[id^="edit-submit"]',
3
+ Delete: '#edit-delete',
4
+ Run: '#edit-run',
5
+ Cancel: '#edit-cancel',
6
+ Deploy: '#edit-deploy',
7
+ Apply: '#edit-submit-admin-views-user',
8
+ Index50: '#edit-cron',
9
+ SubmitFilters: '#edit-filters-submit',
10
+ Confirm: '#edit-confirm',
11
+ Recipe: '#btn_continue',
12
+ Finish: '#edit-return',
13
+ Name: '#edit-name',
14
+ Pass: '#edit-pass',
15
+ TextBox: '.show #item-0',
16
+ };
17
+
18
+ module.exports = commonFields;
@@ -0,0 +1,17 @@
1
+ const commonPaths = {
2
+ Content: '/admin/content',
3
+ CreateUser: '/admin/people/create',
4
+ User: '/user',
5
+ People: '/admin/people',
6
+ NodeAdd: '/node/add',
7
+ Terms: '/admin/structure/taxonomy',
8
+ Media: '/admin/content/media',
9
+ Menus: '/admin/structure/menu',
10
+ Config: '/admin/config',
11
+ CacheClear: '/admin/config/development/performance',
12
+ Cron: '/admin/config/system/cron/jobs',
13
+ BasicSettings: '/admin/config/system/site-information',
14
+ Redirects: '/admin/config/search/redirect',
15
+ };
16
+
17
+ module.exports = commonPaths;