Skip to content

Commit cf013b7

Browse files
akzmoududmrabbaniShamim-97kzamanbd
authored
E2E testing and make synchronization between old and new settings page (#2927)
* set ids * test case * e2e testing for newGeneralMarketplace * e2e testing for vendor onboarding section * Construct mapping new social onboarding page with old setting page and fixing this page bugs * fix bugs and enhancement of vendor - vendor capabilities page * e2e test for vendor capabilities page * admin settings: Data driven test * Re-organized the test cases and fix the menu DOM id duplication * update: general settings * Add aria label for radio * Add e2e tests for new General > marketplace settings * fix: e2e admin page inheritance * e2e: Update test steps * feat: Add checkbox field type support for toggle switches in admin settings tests - Add new 'checkbox' field type to adminSettingsPageNew.ts to handle DOM elements with 'enabled' class - Update selector logic to click on visible label while checking state from hidden input element - Add Enable Single Seller Mode field to old dataset in generalMarketplace.spec.ts - Update test values and selectors for marketplace settings synchronization testing - Add debug logging for checkbox state verification * Updated radio type for handling old and new radio buttons * debug: Add console logging for checkbox state verification in admin settings tests * fix: resolve E2E test timeout errors in General settings migration test - Fix async iteration by replacing forEach with for...of loop to properly await operations - Increase element visibility timeout from 10s to 15s for old admin page - Add explicit wait for element attachment before scrolling - Improve page stabilization with longer waits for old admin interface - Add conditional navigation check to prevent unnecessary operations Resolves timeout errors: - TimeoutError on #dokan_settings_general selector - Test ended error due to unwaited async operations * feat: add reloadUrl method and optimize E2E test performance - Add reloadUrl method to AdminSettingsPageNew for forced page reload - Fix missing await statements in updateSettings method - Remove unnecessary waitForTimeout calls to improve test speed - Restructure General settings migration test with two separate tests: * Test 1: New settings to old settings synchronization * Test 2: Old settings to new settings synchronization - Optimize element visibility checks and navigation timing This improves test reliability and reduces overall test execution time. * Rename the steps * e2e test for generalMarketplace page * Vendor Onboarding Page * pages of vendor section * Set ID of showHide fields * test: add E2E testcases for General pages * Social Onboarding Page * improvement * test: add E2E testcases for General pages * Delete tests/pw/tests/e2e/productAdvertisement.spec.ts * Vendor Capabilities Page * Vendor Subscription Page * Single Product Milti-vendor Page * Moderation RMA Page * Updated VendorSubscription Page * Moderation pages templets * Moderation Store Support Page * Moderation Live Chat Page * Moderation Abuse Report Page * Implement mapping of delivery time page between new and old page * Implement mapping of new shipment settings page with old setting page * Shipment settings Page * Shipment Delivery Time Page * Updated Shipment Settings Page * Implement proper option filed of Privacy Policy Page (Compliance -> Privacy ) * Complaince Privacy Page * Compliance EU Complaince Page * Fix keys of Shipping Fee, Product Tax Fee and Shipping Tax Fee from vendor to seller as old page * Transaction Fees Page * Fixed Commission Page Mapping * Transaction Commission Page * Transaction reverse Withdrawal * Implement mapping of Minimum Withdraw Limit and Withdraw Threshold of transaction withdraw page * Transaction Withdraw Page * updated e2e test for Available Vendor Section Display Position field ( Vendor SPMV ) * Fix component for tooltip * fix mb * updated * Testing (fix mapping) * Make code workable for callback functions and map customer details visibility * Callback function for COD Payments * Fix (add_tooptip) function for text type field * Make dokanFieldLabel component ready for haldeling tooltip using our DokanTooltip component * Make tooltip message correct(helper_text to tooltip) of dokan component (DokanFieldLabel and DokanSwitch) * Give and fix tooltip message of Vendor Onboarding page * Fix 'textarea' field tooltip section * Fixed 'copy' component tooltip section * fix 'showhide' component tooltip section * updated * Implement settings for keeping existing data with updated data * Implement Callback Functions for Moderation -> Abuse and RMA reasons field * Implement callback function for Welcome Wizard field * Implement callback function for Eendor Extra Fields * Implement callback function for Customer Extra Fields * Implement callback function for Delivery support * Implement Callback Function for Penalty Actions After Grace Period filed and fix option names * new-admin-settings-printful-ai-wholesale-page-e2e-testing (#2973) * in progress * Ai Content generation page e2e * Add SMS gateway and Email vendor verification settings mapper (#2977) * e2e test for generalMarketplace page * Vendor Onboarding Page * pages of vendor section * Set ID of showHide fields * Social Onboarding Page * Vendor Capabilities Page * Vendor Subscription Page * Single Product Milti-vendor Page * Moderation RMA Page * Updated VendorSubscription Page * Moderation pages templets * Moderation Store Support Page * Moderation Live Chat Page * Moderation Abuse Report Page * Implement mapping of delivery time page between new and old page * Implement mapping of new shipment settings page with old setting page * Shipment settings Page * Add SMS gateway and Email vendor verification settings mapper * Update mapper for change Ui design --------- Co-authored-by: Moudud Ahmed <abdulkader225704@gmail.com> Co-authored-by: Kamruzzaman <kzamanbn@gmail.com> * Implement callback function for Discount Editing field * Implement callback function for Shipment Status field * Set tooltips of filelds of vendor capabilities and vendor subscription page * Set comission page Heading description and tooltips of this page fields * Complete Quote Settings and Product Advertisement Settings test (#2972) * Vendor verification email sms page e2e test (#2982) * Add SMS gateway and Email vendor verification settings mapper * EmailAndSmsGatewayPagee2eTest * Appearance tab e2e test (#2995) * Add SMS gateway and Email vendor verification settings mapper * EmailAndSmsGatewayPagee2eTest * e2etesting in progress * appearance_tab_e2e_test * Vendor verification e2e test (#2998) * Vendor verification page e2e test * Vendor Verification page e2e test * Appearance > Color Customizer mapper (#2999) * Verification Sms Gateways Page Redegin (#3021) * feat: add single product preview settings mapper with legacy compatibility (#3034) * Add tooltip in new admin settings and redesign (#3036) * Doc link update (#3001) * Appearance > Color Customizer mapper * New ui doc link updated In Ai Assist page * fix curly brace * fix store Page Store Header Template (#3037) * fix e2e for field 'Show Customer info' * fix e2e for field 'welcome wizard' (Inverted value) * remove subscription cancel and alert email locators from e2e --------- Co-authored-by: Md Mahbub Rabbani <mahbub.rucse@gmail.com> Co-authored-by: SHAMIM <111671483+Shamim-97@users.noreply.github.com> Co-authored-by: Kamruzzaman <kzamanbn@gmail.com>
1 parent d29b315 commit cf013b7

68 files changed

Lines changed: 8678 additions & 219 deletions

File tree

Some content is hidden

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

assets/src/images/store/store-page-template-four.svg

Lines changed: 31 additions & 0 deletions
Loading

assets/src/images/store/store-page-template-three.svg

Lines changed: 119 additions & 0 deletions
Loading

assets/src/images/store/store-page-template-two.svg

Lines changed: 114 additions & 0 deletions
Loading

assets/src/images/verification/twilio.svg

Lines changed: 10 additions & 0 deletions
Loading
Lines changed: 10 additions & 0 deletions
Loading

includes/Admin/Settings.php

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function get_settings_value() {
127127
$settings = [];
128128

129129
// Ensure new settings are populated from legacy if currently blank
130-
$this->ensure_new_settings_populated_from_legacy();
130+
//$this->ensure_new_settings_populated_from_legacy();
131131

132132
// Build legacy-style values from the new settings storage.
133133
$legacy_from_new = $this->get_legacy_values_from_new();
@@ -138,7 +138,7 @@ public function get_settings_value() {
138138
$new_mapped = isset( $legacy_from_new[ $legacy_option_id ] ) && is_array( $legacy_from_new[ $legacy_option_id ] ) ? $legacy_from_new[ $legacy_option_id ] : [];
139139

140140
// Prefer new mapped values and fall back to existing legacy options for unmapped fields.
141-
$merged = array_merge( $old_stored, $new_mapped );
141+
$merged = array_replace_recursive( $old_stored, $new_mapped );
142142

143143
$settings[ $legacy_option_id ] = apply_filters( 'dokan_get_settings_values', $merged, $legacy_option_id );
144144
}
@@ -195,12 +195,35 @@ public function save_settings_value() {
195195

196196
// Transform legacy section values to new settings storage and save
197197
$transformer = new LegacyTransformer();
198-
$new_data = $transformer->transform( [ 'from' => 'old', 'data' => [ $option_name => $option_value ] ] );
198+
$new_data = $transformer->transform(
199+
[
200+
'from' => 'old',
201+
'data' => [ $option_name => $option_value ],
202+
]
203+
);
199204

200205
if ( ! empty( $new_data ) ) {
201206
/** @var NewAdminSettingsManager $settings_manager */
202207
$settings_manager = dokan_get_container()->get( NewAdminSettingsManager::class );
203-
$settings_manager->save( $new_data );
208+
209+
array_walk(
210+
$new_data,
211+
function ( &$fields, $page_id ) {
212+
if ( ! is_array( $fields ) ) {
213+
return;
214+
}
215+
216+
$existing = get_option( 'dokan_settings_' . $page_id, [] );
217+
218+
if ( ! is_array( $existing ) ) {
219+
$existing = [];
220+
}
221+
222+
$fields = array_replace_recursive( $existing, $fields );
223+
}
224+
);
225+
226+
$settings_manager->save( $new_data, false );
204227

205228
// Fallback: if pages are not registered/available, write directly to new storage options
206229
$available_ids = [];
@@ -1325,9 +1348,9 @@ protected function ensure_new_settings_populated_from_legacy(): void {
13251348
if ( ! is_array( $existing ) ) {
13261349
$existing = [];
13271350
}
1328-
$wrapped = [ $page_id => $page_values ];
1351+
$wrapped = [ $page_id => $page_values ];
13291352
// Merge so we don't drop any pre-existing values.
1330-
$merged = array_replace_recursive( $existing, $wrapped );
1353+
$merged = array_replace_recursive( $existing, $wrapped );
13311354
update_option( $storage_key, $merged );
13321355
}
13331356
}

includes/Admin/Settings/Pages/AIAssistPage.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function describe_settings(): void {
7979
->set_title( esc_html__( 'Content Generation', 'dokan-lite' ) )
8080
->set_priority( 100 )
8181
->set_description( esc_html__( 'Set up AI to elevate your platform with enhanced capabilities.', 'dokan-lite' ) )
82-
->set_doc_link( 'https://wedevs.com/docs/dokan-lite/ai-assist/' )
82+
->set_doc_link( 'https://dokan.co/docs/wordpress/settings/dokan-ai-assistant/' )
8383
->add(
8484
ElementFactory::section( 'product_image_section' )
8585
->add(
@@ -129,7 +129,7 @@ public function describe_settings(): void {
129129
->add(
130130
ElementFactory::field( 'openai_api_key', 'show_hide' )
131131
->set_title( esc_html__( 'API Key', 'dokan-lite' ) )
132-
->set_description( esc_html__( 'Enter your OpenAI API key for content generation.', 'dokan-lite' ) )
132+
->set_tooltip( __( 'Enter your OpenAI API key for content generation.', 'dokan-lite' ) )
133133
->set_placeholder( esc_html__( 'Enter your OpenAI API key', 'dokan-lite' ) )
134134
->add_dependency( 'product_info_engine', 'chatgpt', true, 'display', 'show', '===' )
135135
)
@@ -176,26 +176,27 @@ public function describe_settings(): void {
176176
ElementFactory::field( 'leonardo_api_info', 'base_field_label' )
177177
->set_title( esc_html__( 'Leonardo AI API', 'dokan-lite' ) )
178178
->set_image_url( plugin_dir_url( DOKAN_FILE ) . 'assets/src/images/ai-assist/leonardo-ai-thumbnail.svg' )
179-
->set_description( esc_html__( 'Connect to your Leonardo AI account with your website.', 'dokan-lite' ) )
180-
->add_dependency( 'product_image_engine', 'leonardo', true, 'display', 'show', '===' )
181-
)
182-
->add(
183-
ElementFactory::field( 'leonardo_api_notice', 'info' )
184-
->set_title( esc_html__( 'You can get your API Keys in your Leonardo AI account', 'dokan-lite' ) )
185179
->set_description(
186180
sprintf(
187181
/* translators: 1. Link start tag, 2. Link end tag */
188-
esc_html__( 'Access your Leonardo AI dashboard to generate API keys for integration. %1$sGet Help%2$s', 'dokan-lite' ),
182+
esc_html__( 'Connect to your Leonardo AI account with your website. %1$sGet Help%2$s', 'dokan-lite' ),
189183
'<a href="https://wedevs.com/docs/dokan-lite/leonardo-integration/" target="_blank" rel="noopener noreferrer">',
190184
'</a>'
191185
)
192186
)
193187
->add_dependency( 'product_image_engine', 'leonardo', true, 'display', 'show', '===' )
194188
)
189+
->add(
190+
ElementFactory::field( 'leonardo_api_notice', 'info' )
191+
->set_title( esc_html__( 'You can get your API Keys in your', 'dokan-lite' ) )
192+
->set_link_text( esc_html__( 'Leonardo AI Account', 'dokan-lite' ) )
193+
->set_link_url( 'https://leonardo.ai' )
194+
->add_dependency( 'product_image_engine', 'leonardo', true, 'display', 'show', '===' )
195+
)
195196
->add(
196197
ElementFactory::field( 'leonardo_api_key', 'show_hide' )
197198
->set_title( esc_html__( 'API Key', 'dokan-lite' ) )
198-
->set_description( esc_html__( 'Enter your Leonardo AI API key for image generation.', 'dokan-lite' ) )
199+
->set_tooltip( __( 'Enter your Leonardo AI API key for image generation.', 'dokan-lite' ) )
199200
->set_placeholder( esc_html__( 'Enter your Leonardo AI API key', 'dokan-lite' ) )
200201
->add_dependency( 'product_image_engine', 'leonardo', true, 'display', 'show', '===' )
201202
)

includes/Admin/Settings/Pages/AppearancePage.php

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function describe_settings(): void {
9191
ElementFactory::section( 'products_page' )
9292
->add(
9393
ElementFactory::field( 'store_product_per_page', 'number' )
94-
->set_title( esc_html__( 'Products Per Page', 'dokan-lite' ) )
94+
->set_title( esc_html__( 'Store Products Per Page', 'dokan-lite' ) )
9595
->set_description(
9696
esc_html__(
9797
'Set how many products to display per page on the
@@ -102,7 +102,7 @@ public function describe_settings(): void {
102102
->set_placeholder( esc_html__( 'Products Per Page', 'dokan-lite' ) )
103103
->set_minimum( 1 )
104104
->set_step( 1 )
105-
->set_helper_text( esc_html__( 'Set the number of products to display per page on the vendor store page.', 'dokan-lite' ) )
105+
->set_tooltip( esc_html__( 'Set the number of products to display per page on the vendor store page.', 'dokan-lite' ) )
106106
)
107107
)
108108
->add(
@@ -115,14 +115,15 @@ public function describe_settings(): void {
115115
->set_description(
116116
sprintf(
117117
/* translators: 1. Link to Google reCaptcha */
118-
esc_html__( 'Connect to enable spam protection that works automatically in the background. %1$sGet Help%2$s', 'dokan-lite' ),
118+
esc_html__( 'Connect to enable spam protection that works automatically in the background %1$sGet Help%2$s', 'dokan-lite' ),
119119
'<a href="https://www.google.com/recaptcha/about/" target="_blank" rel="noopener noreferrer">',
120120
'</a>'
121121
)
122122
)
123123
->set_default( 'off' )
124124
->set_enable_state( esc_html__( 'Enable', 'dokan-lite' ), 'on' )
125125
->set_disable_state( esc_html__( 'Disable', 'dokan-lite' ), 'off' )
126+
->set_image_url( plugin_dir_url( DOKAN_FILE ) . 'assets/src/images/social-onboarding/google.svg' )
126127
)
127128
->add(
128129
ElementFactory::field( 'recaptcha_info', 'info' )
@@ -196,29 +197,33 @@ public function describe_settings(): void {
196197
ElementFactory::field( 'store_template', 'customize_radio' )
197198
->set_title( esc_html__( 'Store Header Template', 'dokan-lite' ) )
198199
->set_description( esc_html__( 'Select a store header for your store.', 'dokan-lite' ) )
199-
->set_default( 'template-1' )
200+
->set_default( 'default' )
200201
->add_enhanced_option(
201202
[
202203
'title' => esc_html__( 'Template 1', 'dokan-lite' ),
203-
'value' => 'template-1',
204-
'description' => esc_html__( 'A clean and modern template with a focus on product display.', 'dokan-lite' ),
204+
'value' => 'default',
205205
'image' => DOKAN_PLUGIN_ASSEST . '/src/images/store/store-page-template-one.svg',
206206
]
207207
)
208208
->add_enhanced_option(
209209
[
210210
'title' => esc_html__( 'Template 2', 'dokan-lite' ),
211-
'value' => 'template-2',
212-
'description' => esc_html__( 'A stylish template with emphasis on vendor branding.', 'dokan-lite' ),
213-
'image' => DOKAN_PLUGIN_ASSEST . '/src/images/store/store-page-template-one.svg',
211+
'value' => 'layout1',
212+
'image' => DOKAN_PLUGIN_ASSEST . '/src/images/store/store-page-template-two.svg',
214213
]
215214
)
216215
->add_enhanced_option(
217216
[
218217
'title' => esc_html__( 'Template 3', 'dokan-lite' ),
219-
'value' => 'template-3',
220-
'description' => esc_html__( 'A minimalistic template for a sleek shopping experience.', 'dokan-lite' ),
221-
'image' => DOKAN_PLUGIN_ASSEST . '/src/images/store/store-page-template-one.svg',
218+
'value' => 'layout2',
219+
'image' => DOKAN_PLUGIN_ASSEST . '/src/images/store/store-page-template-three.svg',
220+
]
221+
)
222+
->add_enhanced_option(
223+
[
224+
'title' => esc_html__( 'Template 4', 'dokan-lite' ),
225+
'value' => 'layout3',
226+
'image' => DOKAN_PLUGIN_ASSEST . '/src/images/store/store-page-template-four.svg',
222227
]
223228
)
224229
->set_variant( 'template' )

includes/Admin/Settings/Pages/CompliancePage.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace WeDevs\Dokan\Admin\Settings\Pages;
44

55
use WeDevs\Dokan\Admin\Settings\Elements\ElementFactory;
6+
use WeDevs\Dokan\Admin\Settings;
67

78
class CompliancePage extends AbstractPage {
89

@@ -78,6 +79,15 @@ public function settings(): array {
7879
* @return void
7980
*/
8081
public function describe_settings(): void {
82+
$legacy_settings = dokan_get_container()->get( Settings::class );
83+
$pages_array = $legacy_settings->get_post_type( 'page' );
84+
$options = [];
85+
foreach ( $pages_array as $key => $label ) {
86+
$options[] = [
87+
'title' => $label,
88+
'value' => $key,
89+
];
90+
}
8191
// Create Privacy subpage
8292
$privacy_page = ElementFactory::sub_page( 'privacy' )
8393
->set_priority( 100 )
@@ -106,10 +116,7 @@ public function describe_settings(): void {
106116
->set_title( esc_html__( 'Privacy Policy Page', 'dokan-lite' ) )
107117
->set_description( esc_html__( 'Choose which page displays your privacy policy', 'dokan-lite' ) )
108118
->set_placeholder( esc_html__( 'Select a page', 'dokan-lite' ) )
109-
->add_option( esc_html__( 'Privacy Policy', 'dokan-lite' ), 'privacy-policy' )
110-
->add_option( esc_html__( 'Terms of Service', 'dokan-lite' ), 'terms-of-service' )
111-
->add_option( esc_html__( 'Legal Information', 'dokan-lite' ), 'legal-information' )
112-
->set_default( 'privacy-policy' )
119+
->set_options( $options )
113120
);
114121

115122
// Create Privacy Policy Content section

includes/Admin/Settings/Pages/GeneralPage.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,13 @@ public function describe_settings(): void {
218218
->add(
219219
ElementFactory::field( 'google_map_base', 'base_field_label' )
220220
->set_title( esc_html__( 'Google Map API Key', 'dokan-lite' ) )
221-
->set_description( esc_html__( 'Enter your Google Maps API key to enable map functionality.', 'dokan-lite' ) )
221+
->set_description(
222+
sprintf(
223+
__( '<a href="%s" target="_blank" rel="noopener noreferrer">API Key</a> is needed to display map on store page.', 'dokan-lite' ),
224+
'https://developers.google.com/maps/documentation/javascript/'
225+
)
226+
)
227+
->set_tooltip( __( 'Insert Google API Key (with hyperlink) to display store map.', 'dokan-lite' ) )
222228
)
223229
->add(
224230
ElementFactory::field( 'google_map_api_key', 'show_hide' )

0 commit comments

Comments
 (0)