From 121968f092909e05d3b0f0496b3ef2d46667d35d Mon Sep 17 00:00:00 2001 From: Dharmesh Patel Date: Wed, 18 Sep 2024 15:24:18 +0530 Subject: [PATCH] Improvement in E2E tests and fix E2E tests for WP minimum environment. --- .../image-tag-generator.js | 1 + tests/cypress/integration/admin.test.js | 8 +-- .../admin/common-feature-fields.test.js | 4 +- .../image-generation-openai-dalle.test.js | 24 ++----- .../image-processing-microsoft-azure.test.js | 69 +++++++++++-------- .../image-processing/pdf-read.test.js | 20 +++--- ...fy-content-azure-openai-embeddings.test.js | 30 +++----- .../classify-content-ibm-watson.test.js | 67 ++++++------------ ...classify-content-openai-embeddings.test.js | 30 +++----- .../excerpt-generation-azure-openai.test.js | 12 ++-- ...rpt-generation-googleai-gemini-api.test.js | 12 ++-- .../excerpt-generation-openai-chatgpt.test.js | 28 ++++---- .../moderation-openai-moderation.test.js | 28 ++------ .../resize_content-azure-openai.test.js | 8 +-- ...resize_content-googleai-gemini-api.test.js | 8 +-- .../resize_content-openai-chatgpt.test.js | 20 +++--- .../smart-404-azure-openai.test.js | 8 +-- .../smart-404-openai.test.js | 8 +-- .../speech-to-text-openai-whisper.test.js | 20 +++--- .../text-to-speech-amazon-polly.test.js | 4 +- .../text-to-speech-microsoft-azure.test.js | 20 +++--- ...xt-to-speech-openai-text-to-speech.test.js | 20 +++--- .../title-generation-azure-openai.test.js | 8 +-- ...tle-generation-googleai-gemini-api.test.js | 8 +-- .../title-generation-openai-chatgpt.test.js | 24 +++---- tests/cypress/support/commands.js | 39 +++++++---- 26 files changed, 230 insertions(+), 298 deletions(-) diff --git a/src/js/settings/components/feature-additional-settings/image-tag-generator.js b/src/js/settings/components/feature-additional-settings/image-tag-generator.js index 2ce95dee5..a25159d64 100644 --- a/src/js/settings/components/feature-additional-settings/image-tag-generator.js +++ b/src/js/settings/components/feature-additional-settings/image-tag-generator.js @@ -25,6 +25,7 @@ export const ImageTagGeneratorSettings = () => { return ( { setFeatureSettings( { tag_taxonomy: value, diff --git a/tests/cypress/integration/admin.test.js b/tests/cypress/integration/admin.test.js index 6c4dc3727..dbcb89b34 100644 --- a/tests/cypress/integration/admin.test.js +++ b/tests/cypress/integration/admin.test.js @@ -25,9 +25,7 @@ describe( 'Admin can login and make sure plugin is activated', () => { it( 'Can visit "Language Processing" settings page.', () => { // Check Selected Navigation menu - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.get( '.classifai-tabs' ).should( 'exist' ); cy.get( '.classifai-tabs a.active-tab' ) .first() @@ -36,8 +34,8 @@ describe( 'Admin can login and make sure plugin is activated', () => { it( 'Can see "Image Processing" menu and Can visit "Image Processing" settings page.', () => { // Check Selected Navigation menu - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_descriptive_text_generator' + cy.visitFeatureSettings( + 'image_processing/feature_descriptive_text_generator' ); cy.get( '.classifai-tabs' ).should( 'exist' ); cy.get( '.classifai-tabs a.active-tab' ) diff --git a/tests/cypress/integration/admin/common-feature-fields.test.js b/tests/cypress/integration/admin/common-feature-fields.test.js index 3fc936fc6..08e1ddf44 100644 --- a/tests/cypress/integration/admin/common-feature-fields.test.js +++ b/tests/cypress/integration/admin/common-feature-fields.test.js @@ -22,9 +22,7 @@ describe( 'Common Feature Fields', () => { Object.keys( features ).forEach( ( feature ) => { it( `"${ features[ feature ] }" feature common fields`, () => { - cy.visit( - `/wp-admin/tools.php?page=classifai#/language_processing/${ feature }` - ); + cy.visitFeatureSettings( `language_processing/${ feature }` ); cy.get( '.classifai-enable-feature-toggle input' ).should( 'exist' diff --git a/tests/cypress/integration/image-processing/image-generation-openai-dalle.test.js b/tests/cypress/integration/image-processing/image-generation-openai-dalle.test.js index 985640d4f..81ec40843 100644 --- a/tests/cypress/integration/image-processing/image-generation-openai-dalle.test.js +++ b/tests/cypress/integration/image-processing/image-generation-openai-dalle.test.js @@ -1,9 +1,7 @@ describe( 'Image Generation (OpenAI DALL·E) Tests', () => { before( () => { cy.login(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_image_generation' - ); + cy.visitFeatureSettings( 'image_processing/feature_image_generation' ); cy.enableFeature(); cy.selectProvider( 'openai_dalle' ); cy.saveFeatureSettings(); @@ -15,9 +13,7 @@ describe( 'Image Generation (OpenAI DALL·E) Tests', () => { } ); it( 'Can save OpenAI "Image Processing" settings', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_image_generation' - ); + cy.visitFeatureSettings( 'image_processing/feature_image_generation' ); cy.selectProvider( 'openai_dalle' ); cy.get( '#openai_dalle_api_key' ).clear().type( 'password' ); cy.get( 'select#openai_dalle_number_of_images' ).select( '2' ); @@ -97,9 +93,7 @@ describe( 'Image Generation (OpenAI DALL·E) Tests', () => { it( 'Can enable/disable image generation feature', () => { // Disable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_image_generation' - ); + cy.visitFeatureSettings( 'image_processing/feature_image_generation' ); cy.disableFeature(); cy.saveFeatureSettings(); @@ -107,9 +101,7 @@ describe( 'Image Generation (OpenAI DALL·E) Tests', () => { cy.verifyImageGenerationEnabled( false ); // Enable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_image_generation' - ); + cy.visitFeatureSettings( 'image_processing/feature_image_generation' ); cy.enableFeature(); cy.saveFeatureSettings(); @@ -118,9 +110,7 @@ describe( 'Image Generation (OpenAI DALL·E) Tests', () => { } ); it( 'Can generate image directly in media library', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_image_generation' - ); + cy.visitFeatureSettings( 'image_processing/feature_image_generation' ); cy.enableFeature(); cy.get( '.settings-allowed-roles input#administrator' ).check(); @@ -145,9 +135,7 @@ describe( 'Image Generation (OpenAI DALL·E) Tests', () => { it( 'Can enable/disable image generation feature by role', () => { // Enable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_image_generation' - ); + cy.visitFeatureSettings( 'image_processing/feature_image_generation' ); cy.enableFeature(); cy.saveFeatureSettings(); diff --git a/tests/cypress/integration/image-processing/image-processing-microsoft-azure.test.js b/tests/cypress/integration/image-processing/image-processing-microsoft-azure.test.js index cde508b42..79a53a4be 100644 --- a/tests/cypress/integration/image-processing/image-processing-microsoft-azure.test.js +++ b/tests/cypress/integration/image-processing/image-processing-microsoft-azure.test.js @@ -16,9 +16,7 @@ describe( 'Image processing Tests', () => { ]; imageProcessingFeatures.forEach( ( feature ) => { - cy.visit( - `/wp-admin/tools.php?page=classifai#/image_processing/${ feature }` - ); + cy.visitFeatureSettings( `image_processing/${ feature }` ); cy.enableFeature(); cy.selectProvider( 'ms_computer_vision' ); cy.get( '#ms_computer_vision_endpoint_url' ) @@ -26,6 +24,10 @@ describe( 'Image processing Tests', () => { .type( 'http://e2e-test-image-processing.test' ); cy.get( '#ms_computer_vision_api_key' ).clear().type( 'password' ); cy.get( '.settings-allowed-roles input#administrator' ).check(); + cy.get( '.classifai-settings__user-based-opt-out input' ).uncheck(); + // Disable access for all users. + cy.disableFeatureForUsers(); + cy.saveFeatureSettings(); } ); @@ -37,8 +39,8 @@ describe( 'Image processing Tests', () => { } ); it( 'Can see Azure AI Vision Image processing actions on edit media page and verify Generated data.', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_descriptive_text_generator' + cy.visitFeatureSettings( + 'image_processing/feature_descriptive_text_generator' ); cy.get( '.classifai-descriptive-text-fields input#alt' ).check(); cy.saveFeatureSettings(); @@ -113,9 +115,10 @@ describe( 'Image processing Tests', () => { }; // Disable features - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_descriptive_text_generator' + cy.visitFeatureSettings( + 'image_processing/feature_descriptive_text_generator' ); + cy.wait( 1000 ); cy.get( '.classifai-descriptive-text-fields input#alt' ).uncheck(); cy.get( '.classifai-descriptive-text-fields input#caption' ).uncheck(); cy.get( @@ -123,64 +126,63 @@ describe( 'Image processing Tests', () => { ).uncheck(); cy.saveFeatureSettings(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_image_tags_generator' + cy.visitFeatureSettings( + 'image_processing/feature_image_tags_generator' ); cy.wait( 1000 ); cy.disableFeature(); cy.saveFeatureSettings(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_image_cropping' - ); + cy.visitFeatureSettings( 'image_processing/feature_image_cropping' ); cy.wait( 1000 ); cy.disableFeature(); cy.saveFeatureSettings(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_image_to_text_generator' + cy.visitFeatureSettings( + 'image_processing/feature_image_to_text_generator' ); - cy.wait( 1000 ); + cy.wait( 1500 ); // Add delay to avoid flaky test in WP minimum (6.1) environment. cy.disableFeature(); cy.saveFeatureSettings(); // Verify that the feature is not available. + cy.wait( 1000 ); cy.verifyAIVisionEnabled( false, options ); // Enable features. - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_descriptive_text_generator' + cy.visitFeatureSettings( + 'image_processing/feature_descriptive_text_generator' ); cy.get( '.classifai-descriptive-text-fields input#alt' ).check(); cy.get( '.classifai-descriptive-text-fields input#caption' ).check(); cy.get( '.classifai-descriptive-text-fields input#description' ).check(); + cy.wait( 1500 ); cy.enableFeature(); cy.saveFeatureSettings(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_image_tags_generator' + cy.visitFeatureSettings( + 'image_processing/feature_image_tags_generator' ); - cy.wait( 1000 ); + cy.wait( 1500 ); cy.enableFeature(); cy.saveFeatureSettings(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_image_cropping' - ); - cy.wait( 1000 ); + cy.visitFeatureSettings( 'image_processing/feature_image_cropping' ); + cy.wait( 1500 ); cy.enableFeature(); cy.saveFeatureSettings(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_image_to_text_generator' + cy.visitFeatureSettings( + 'image_processing/feature_image_to_text_generator' ); - cy.wait( 1000 ); + cy.wait( 1500 ); cy.enableFeature(); cy.saveFeatureSettings(); // Verify that the feature is available. + cy.wait( 1000 ); cy.verifyAIVisionEnabled( true, options ); } ); @@ -191,11 +193,12 @@ describe( 'Image processing Tests', () => { }; // Enable features. - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_descriptive_text_generator' + cy.visitFeatureSettings( + 'image_processing/feature_descriptive_text_generator' ); - cy.get( '.classifai-descriptive-text-fields input#alt' ).check(); cy.enableFeature(); + cy.get( '.classifai-descriptive-text-fields input#alt' ).check(); + cy.wait( 500 ); cy.saveFeatureSettings(); // Disable access to admin role. @@ -213,6 +216,7 @@ describe( 'Image processing Tests', () => { ] ); // Verify that the feature is not available. + cy.wait( 1000 ); cy.verifyAIVisionEnabled( false, options ); // Enable access to admin role. @@ -230,6 +234,7 @@ describe( 'Image processing Tests', () => { ] ); // Verify that the feature is available. + cy.wait( 1000 ); cy.verifyAIVisionEnabled( true, options ); } ); @@ -254,6 +259,7 @@ describe( 'Image processing Tests', () => { ] ); // Verify that the feature is not available. + cy.wait( 1000 ); cy.verifyAIVisionEnabled( false, options ); cy.enableFeatureForUsers( 'feature_descriptive_text_generator', [ @@ -266,6 +272,7 @@ describe( 'Image processing Tests', () => { ] ); // Verify that the feature is available. + cy.wait( 1000 ); cy.verifyAIVisionEnabled( true, options ); } ); @@ -288,6 +295,7 @@ describe( 'Image processing Tests', () => { cy.optOutFeature( 'feature_image_to_text_generator' ); // Verify that the feature is not available. + cy.wait( 1000 ); cy.verifyAIVisionEnabled( false, options ); // opt-in @@ -297,6 +305,7 @@ describe( 'Image processing Tests', () => { cy.optInFeature( 'feature_image_to_text_generator' ); // Verify that the feature is available. + cy.wait( 1000 ); cy.verifyAIVisionEnabled( true, options ); } ); } ); diff --git a/tests/cypress/integration/image-processing/pdf-read.test.js b/tests/cypress/integration/image-processing/pdf-read.test.js index 102573cd8..2fb39ab24 100644 --- a/tests/cypress/integration/image-processing/pdf-read.test.js +++ b/tests/cypress/integration/image-processing/pdf-read.test.js @@ -3,8 +3,8 @@ import { getPDFData } from '../../plugins/functions'; describe( 'PDF read Tests', () => { before( () => { cy.login(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_pdf_to_text_generation' + cy.visitFeatureSettings( + 'image_processing/feature_pdf_to_text_generation' ); cy.enableFeature(); cy.saveFeatureSettings(); @@ -17,8 +17,8 @@ describe( 'PDF read Tests', () => { let pdfEditLink = ''; it( 'Can save "PDF scanning" settings', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_pdf_to_text_generation' + cy.visitFeatureSettings( + 'image_processing/feature_pdf_to_text_generation' ); cy.selectProvider( 'ms_computer_vision' ); cy.get( '#ms_computer_vision_endpoint_url' ) @@ -60,8 +60,8 @@ describe( 'PDF read Tests', () => { it( 'Can enable/disable PDF scanning feature', () => { // Disable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_pdf_to_text_generation' + cy.visitFeatureSettings( + 'image_processing/feature_pdf_to_text_generation' ); cy.disableFeature(); cy.saveFeatureSettings(); @@ -73,8 +73,8 @@ describe( 'PDF read Tests', () => { ); // Enable admin role. - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_pdf_to_text_generation' + cy.visitFeatureSettings( + 'image_processing/feature_pdf_to_text_generation' ); cy.enableFeature(); cy.saveFeatureSettings(); @@ -88,8 +88,8 @@ describe( 'PDF read Tests', () => { it( 'Can enable/disable PDF scanning feature by role', () => { // Enable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/image_processing/feature_pdf_to_text_generation' + cy.visitFeatureSettings( + 'image_processing/feature_pdf_to_text_generation' ); cy.enableFeature(); cy.saveFeatureSettings(); diff --git a/tests/cypress/integration/language-processing/classify-content-azure-openai-embeddings.test.js b/tests/cypress/integration/language-processing/classify-content-azure-openai-embeddings.test.js index db12de433..dcae06e57 100644 --- a/tests/cypress/integration/language-processing/classify-content-azure-openai-embeddings.test.js +++ b/tests/cypress/integration/language-processing/classify-content-azure-openai-embeddings.test.js @@ -1,9 +1,7 @@ describe( '[Language processing] Classify Content (Azure OpenAI) Tests', () => { before( () => { cy.login(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.enableFeature(); cy.selectProvider( 'azure_openai_embeddings' ); cy.saveFeatureSettings(); @@ -16,9 +14,7 @@ describe( '[Language processing] Classify Content (Azure OpenAI) Tests', () => { } ); it( 'Can save Azure OpenAI Embeddings "Language Processing" settings', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.selectProvider( 'azure_openai_embeddings' ); cy.get( 'input#azure_openai_embeddings_endpoint_url' ) @@ -90,9 +86,7 @@ describe( '[Language processing] Classify Content (Azure OpenAI) Tests', () => { // TODO: Fix this test. it.skip( 'Can see the preview on the settings page', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.saveFeatureSettings(); @@ -105,9 +99,7 @@ describe( '[Language processing] Classify Content (Azure OpenAI) Tests', () => { } ); it( 'Can create category and post and category will not get auto-assigned if feature turned off', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.disableFeature(); cy.saveFeatureSettings(); @@ -161,9 +153,7 @@ describe( '[Language processing] Classify Content (Azure OpenAI) Tests', () => { it( 'Can see the enable button in a post (Classic Editor)', () => { cy.enableClassicEditor(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.enableFeature(); cy.get( '.settings-allowed-post-types input#post' ).check(); @@ -189,9 +179,7 @@ describe( '[Language processing] Classify Content (Azure OpenAI) Tests', () => { cy.disableClassicEditor(); // Disable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.disableFeature(); cy.saveFeatureSettings(); @@ -199,9 +187,7 @@ describe( '[Language processing] Classify Content (Azure OpenAI) Tests', () => { cy.verifyClassifyContentEnabled( false ); // Enable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.enableFeature(); cy.saveFeatureSettings(); @@ -211,7 +197,7 @@ describe( '[Language processing] Classify Content (Azure OpenAI) Tests', () => { it( 'Can enable/disable content classification feature by role', () => { // Remove custom taxonomies so those don't interfere with the test. - cy.visit( '/wp-admin/tools.php?page=classifai#/language_processing' ); + cy.visitFeatureSettings( 'language_processing' ); // Disable access for all users. cy.disableFeatureForUsers(); diff --git a/tests/cypress/integration/language-processing/classify-content-ibm-watson.test.js b/tests/cypress/integration/language-processing/classify-content-ibm-watson.test.js index 235cbd525..f33abe315 100644 --- a/tests/cypress/integration/language-processing/classify-content-ibm-watson.test.js +++ b/tests/cypress/integration/language-processing/classify-content-ibm-watson.test.js @@ -1,9 +1,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', () => { before( () => { cy.login(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.enableFeature(); cy.selectProvider( 'ibm_watson_nlu' ); cy.saveFeatureSettings(); @@ -37,9 +35,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', () it( 'Can save IBM Watson "Language Processing" settings', () => { // Disable content classification by openai. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.disableFeature(); cy.saveFeatureSettings(); @@ -68,8 +64,11 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', () } ); it( 'Can select Watson taxonomies "Language Processing" settings', () => { - cy.visit( '/wp-admin/tools.php?page=classifai#/language_processing' ); + cy.intercept( '/wp-json/wp/v2/taxonomies*' ).as( 'getTaxonomies' ); + cy.visitFeatureSettings( 'language_processing' ); + cy.wait( '@getTaxonomies' ); + cy.enableFeature(); cy.get( '#category-taxonomy' ).select( 'watson-category' ); cy.get( '#keyword-taxonomy' ).select( 'watson-keyword' ); cy.get( '#entity-taxonomy' ).select( 'watson-entity' ); @@ -95,7 +94,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', () } ); it( 'Check Classification Mode toggle button is off, display popup, then add/remove terms', () => { - cy.visit( '/wp-admin/tools.php?page=classifai#/language_processing' ); + cy.visitFeatureSettings( 'language_processing' ); cy.selectProvider( 'ibm_watson_nlu' ); cy.get( @@ -181,9 +180,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', () it( 'Check Classification Mode toggle button is on', () => { cy.deactivatePlugin( 'classic-editor' ); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.selectProvider( 'ibm_watson_nlu' ); cy.get( @@ -259,9 +256,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', () const threshold = 75; // Update Threshold to 75. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.get( '#category-threshold' ).clear().type( threshold ); cy.get( '#keyword-threshold' ).clear().type( threshold ); @@ -303,9 +298,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', () const threshold1 = 75; // Update classification method to "Add recommended terms" and threshold value. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.selectProvider( 'ibm_watson_nlu' ); cy.get( @@ -344,9 +337,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', () // Now create terms with threshold 70 and verify it with threshold 75 to make only existing terms are used in classification and not new terms. const threshold2 = 70; // Update classification method to "Only classify based on existing terms" and threshold value. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.selectProvider( 'ibm_watson_nlu' ); cy.get( @@ -383,9 +374,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', () ); // Update classification method back to "Add recommended terms". - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.get( '.classification-method-radio-control input[value="recommended_terms"]' @@ -395,9 +384,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', () it( 'Can create post and tags get created by ClassifAI', () => { const threshold = 70; - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.selectProvider( 'ibm_watson_nlu' ); cy.get( '.classification-method-radio-control input[value="recommended_terms"]' @@ -435,9 +422,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', () it( 'Can enable/disable Natural Language Understanding features.', () => { // Disable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.disableFeature(); cy.saveFeatureSettings(); @@ -445,9 +430,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', () cy.verifyClassifyContentEnabled( false ); // Enable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.enableFeature(); cy.saveFeatureSettings(); @@ -457,9 +440,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', () it( 'Can limit Natural Language Understanding features by roles', () => { // Disable access to admin role. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); // Disable access for all users. cy.disableFeatureForUsers(); @@ -484,9 +465,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', () it( 'Can limit Natural Language Understanding features by users', () => { // Disable access. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing&provider=watson_nlu' - ); + cy.visitFeatureSettings( 'language_processing&provider=watson_nlu' ); // Disable access for all roles. cy.get( '.settings-allowed-roles input[type="checkbox"]' ).uncheck( { @@ -502,9 +481,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', () cy.verifyClassifyContentEnabled( false ); // Enable access to user. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing&provider=watson_nlu' - ); + cy.visitFeatureSettings( 'language_processing&provider=watson_nlu' ); // Disable access for all roles. cy.get( '.settings-allowed-roles input[type="checkbox"]' ).uncheck( { @@ -537,9 +514,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', () cy.verifyClassifyContentEnabled( true ); // Enable access to admin role. (default) - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing&provider=watson_nlu' - ); + cy.visitFeatureSettings( 'language_processing&provider=watson_nlu' ); // Enable access for all roles. cy.get( '.settings-allowed-roles input[type="checkbox"]' ).check( { @@ -554,9 +529,7 @@ describe( '[Language processing] Classify content (IBM Watson - NLU) Tests', () it( 'Can enable user based opt out for Natural Language Understanding', () => { // Opt Out from feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing&provider=watson_nlu' - ); + cy.visitFeatureSettings( 'language_processing&provider=watson_nlu' ); // Enable access for all roles. cy.get( '.settings-allowed-roles input[type="checkbox"]' ).check( { multiple: true, diff --git a/tests/cypress/integration/language-processing/classify-content-openai-embeddings.test.js b/tests/cypress/integration/language-processing/classify-content-openai-embeddings.test.js index 39892d90e..b158c5cbd 100644 --- a/tests/cypress/integration/language-processing/classify-content-openai-embeddings.test.js +++ b/tests/cypress/integration/language-processing/classify-content-openai-embeddings.test.js @@ -1,9 +1,7 @@ describe( '[Language processing] Classify Content (OpenAI) Tests', () => { before( () => { cy.login(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.enableFeature(); cy.selectProvider( 'openai_embeddings' ); cy.saveFeatureSettings(); @@ -16,9 +14,7 @@ describe( '[Language processing] Classify Content (OpenAI) Tests', () => { } ); it( 'Can save OpenAI Embeddings "Language Processing" settings', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.selectProvider( 'openai_embeddings' ); cy.get( '#openai_api_key' ).clear().type( 'password' ); @@ -81,9 +77,7 @@ describe( '[Language processing] Classify Content (OpenAI) Tests', () => { // TODO: Fix this test. it.skip( 'Can see the preview on the settings page', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.saveFeatureSettings(); @@ -96,9 +90,7 @@ describe( '[Language processing] Classify Content (OpenAI) Tests', () => { } ); it( 'Can create category and post and category will not get auto-assigned if feature turned off', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.disableFeature(); cy.saveFeatureSettings(); @@ -152,9 +144,7 @@ describe( '[Language processing] Classify Content (OpenAI) Tests', () => { it( 'Can see the enable button in a post (Classic Editor)', () => { cy.enableClassicEditor(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.enableFeature(); cy.get( '.settings-allowed-post-types input#post' ).check(); @@ -180,9 +170,7 @@ describe( '[Language processing] Classify Content (OpenAI) Tests', () => { cy.disableClassicEditor(); // Disable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.disableFeature(); cy.saveFeatureSettings(); @@ -190,9 +178,7 @@ describe( '[Language processing] Classify Content (OpenAI) Tests', () => { cy.verifyClassifyContentEnabled( false ); // Enable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_classification' - ); + cy.visitFeatureSettings( 'language_processing/feature_classification' ); cy.enableFeature(); cy.saveFeatureSettings(); @@ -202,7 +188,7 @@ describe( '[Language processing] Classify Content (OpenAI) Tests', () => { it( 'Can enable/disable content classification feature by role', () => { // Remove custom taxonomies so those don't interfere with the test. - cy.visit( '/wp-admin/tools.php?page=classifai#/language_processing' ); + cy.visitFeatureSettings( 'language_processing' ); // Disable access for all users. cy.disableFeatureForUsers(); diff --git a/tests/cypress/integration/language-processing/excerpt-generation-azure-openai.test.js b/tests/cypress/integration/language-processing/excerpt-generation-azure-openai.test.js index 2ef9462b9..9cb4545b4 100644 --- a/tests/cypress/integration/language-processing/excerpt-generation-azure-openai.test.js +++ b/tests/cypress/integration/language-processing/excerpt-generation-azure-openai.test.js @@ -3,8 +3,8 @@ import { getChatGPTData } from '../../plugins/functions'; describe( '[Language processing] Excerpt Generation Tests', () => { before( () => { cy.login(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_excerpt_generation' + cy.visitFeatureSettings( + 'language_processing/feature_excerpt_generation' ); cy.get( '#classifai-logo' ).should( 'exist' ); cy.enableFeature(); @@ -19,8 +19,8 @@ describe( '[Language processing] Excerpt Generation Tests', () => { } ); it( 'Can save Azure OpenAI "Language Processing" settings', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_excerpt_generation' + cy.visitFeatureSettings( + 'language_processing/feature_excerpt_generation' ); cy.get( '#classifai-logo' ).should( 'exist' ); cy.selectProvider( 'azure_openai' ); @@ -85,8 +85,8 @@ describe( '[Language processing] Excerpt Generation Tests', () => { it( 'Can see the generate excerpt button in a post (Classic Editor)', () => { cy.enableClassicEditor(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_excerpt_generation' + cy.visitFeatureSettings( + 'language_processing/feature_excerpt_generation' ); cy.enableFeature(); cy.saveFeatureSettings(); diff --git a/tests/cypress/integration/language-processing/excerpt-generation-googleai-gemini-api.test.js b/tests/cypress/integration/language-processing/excerpt-generation-googleai-gemini-api.test.js index 147eb6546..e4821e466 100644 --- a/tests/cypress/integration/language-processing/excerpt-generation-googleai-gemini-api.test.js +++ b/tests/cypress/integration/language-processing/excerpt-generation-googleai-gemini-api.test.js @@ -3,8 +3,8 @@ import { getGeminiAPIData } from '../../plugins/functions'; describe( '[Language processing] Excerpt Generation Tests', () => { before( () => { cy.login(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_excerpt_generation' + cy.visitFeatureSettings( + 'language_processing/feature_excerpt_generation' ); cy.get( '#classifai-logo' ).should( 'exist' ); cy.enableFeature(); @@ -19,8 +19,8 @@ describe( '[Language processing] Excerpt Generation Tests', () => { } ); it( 'Can save Google AI (Gemini API) "Language Processing" settings', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_excerpt_generation' + cy.visitFeatureSettings( + 'language_processing/feature_excerpt_generation' ); cy.get( '#classifai-logo' ).should( 'exist' ); cy.selectProvider( 'googleai_gemini_api' ); @@ -83,8 +83,8 @@ describe( '[Language processing] Excerpt Generation Tests', () => { it( 'Can see the generate excerpt button in a post (Classic Editor)', () => { cy.enableClassicEditor(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_excerpt_generation' + cy.visitFeatureSettings( + 'language_processing/feature_excerpt_generation' ); cy.enableFeature(); cy.saveFeatureSettings(); diff --git a/tests/cypress/integration/language-processing/excerpt-generation-openai-chatgpt.test.js b/tests/cypress/integration/language-processing/excerpt-generation-openai-chatgpt.test.js index c6036a417..80fca72bb 100644 --- a/tests/cypress/integration/language-processing/excerpt-generation-openai-chatgpt.test.js +++ b/tests/cypress/integration/language-processing/excerpt-generation-openai-chatgpt.test.js @@ -3,8 +3,8 @@ import { getChatGPTData } from '../../plugins/functions'; describe( '[Language processing] Excerpt Generation Tests', () => { before( () => { cy.login(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_excerpt_generation' + cy.visitFeatureSettings( + 'language_processing/feature_excerpt_generation' ); cy.get( '#classifai-logo' ).should( 'exist' ); cy.enableFeature(); @@ -19,8 +19,8 @@ describe( '[Language processing] Excerpt Generation Tests', () => { } ); it( 'Can save OpenAI ChatGPT "Language Processing" settings', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_excerpt_generation' + cy.visitFeatureSettings( + 'language_processing/feature_excerpt_generation' ); cy.get( '#classifai-logo' ).should( 'exist' ); cy.selectProvider( 'openai_chatgpt' ); @@ -81,8 +81,8 @@ describe( '[Language processing] Excerpt Generation Tests', () => { it( 'Can see the generate excerpt button in a post (Classic Editor)', () => { cy.enableClassicEditor(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_excerpt_generation' + cy.visitFeatureSettings( + 'language_processing/feature_excerpt_generation' ); cy.enableFeature(); cy.saveFeatureSettings(); @@ -112,8 +112,8 @@ describe( '[Language processing] Excerpt Generation Tests', () => { it( 'Can set multiple custom excerpt generation prompts, select one as the default and delete one.', () => { cy.disableClassicEditor(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_excerpt_generation' + cy.visitFeatureSettings( + 'language_processing/feature_excerpt_generation' ); // Add three custom prompts. @@ -206,8 +206,8 @@ describe( '[Language processing] Excerpt Generation Tests', () => { it( 'Can enable/disable excerpt generation feature', () => { // Disable features. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_excerpt_generation' + cy.visitFeatureSettings( + 'language_processing/feature_excerpt_generation' ); cy.disableFeature(); cy.saveFeatureSettings(); @@ -216,8 +216,8 @@ describe( '[Language processing] Excerpt Generation Tests', () => { cy.verifyExcerptGenerationEnabled( false ); // Enable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_excerpt_generation' + cy.visitFeatureSettings( + 'language_processing/feature_excerpt_generation' ); cy.enableFeature(); cy.saveFeatureSettings(); @@ -227,8 +227,8 @@ describe( '[Language processing] Excerpt Generation Tests', () => { } ); it( 'Can enable/disable excerpt generation feature by role', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_excerpt_generation' + cy.visitFeatureSettings( + 'language_processing/feature_excerpt_generation' ); cy.enableFeature(); cy.saveFeatureSettings(); diff --git a/tests/cypress/integration/language-processing/moderation-openai-moderation.test.js b/tests/cypress/integration/language-processing/moderation-openai-moderation.test.js index cac60d488..379679b2b 100644 --- a/tests/cypress/integration/language-processing/moderation-openai-moderation.test.js +++ b/tests/cypress/integration/language-processing/moderation-openai-moderation.test.js @@ -1,9 +1,7 @@ describe( '[Language processing] Moderation Tests', () => { before( () => { cy.login(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_moderation' - ); + cy.visitFeatureSettings( 'language_processing/feature_moderation' ); cy.saveFeatureSettings(); cy.optInAllFeatures(); cy.disableClassicEditor(); @@ -14,9 +12,7 @@ describe( '[Language processing] Moderation Tests', () => { } ); it( 'Can save OpenAI Moderation "Language Processing" settings', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_moderation' - ); + cy.visitFeatureSettings( 'language_processing/feature_moderation' ); cy.selectProvider( 'openai_moderation' ); cy.get( '#openai_api_key' ).clear().type( 'password' ); @@ -41,9 +37,7 @@ describe( '[Language processing] Moderation Tests', () => { it( 'Can enable/disable moderation feature', () => { // Disable features. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_moderation' - ); + cy.visitFeatureSettings( 'language_processing/feature_moderation' ); cy.disableFeature(); cy.saveFeatureSettings(); @@ -51,9 +45,7 @@ describe( '[Language processing] Moderation Tests', () => { cy.verifyModerationEnabled( false ); // Enable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_moderation' - ); + cy.visitFeatureSettings( 'language_processing/feature_moderation' ); cy.enableFeature(); cy.saveFeatureSettings(); @@ -62,9 +54,7 @@ describe( '[Language processing] Moderation Tests', () => { } ); it( 'Can enable/disable moderation feature by role', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_moderation' - ); + cy.visitFeatureSettings( 'language_processing/feature_moderation' ); cy.enableFeature(); cy.saveFeatureSettings(); @@ -82,9 +72,7 @@ describe( '[Language processing] Moderation Tests', () => { } ); it( 'Can enable/disable moderation feature by user', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_moderation' - ); + cy.visitFeatureSettings( 'language_processing/feature_moderation' ); cy.enableFeature(); cy.saveFeatureSettings(); @@ -104,9 +92,7 @@ describe( '[Language processing] Moderation Tests', () => { } ); it( 'User can opt-out of moderation feature', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_moderation' - ); + cy.visitFeatureSettings( 'language_processing/feature_moderation' ); cy.enableFeature(); cy.saveFeatureSettings(); diff --git a/tests/cypress/integration/language-processing/resize_content-azure-openai.test.js b/tests/cypress/integration/language-processing/resize_content-azure-openai.test.js index 47d50c351..0431cc4ba 100644 --- a/tests/cypress/integration/language-processing/resize_content-azure-openai.test.js +++ b/tests/cypress/integration/language-processing/resize_content-azure-openai.test.js @@ -1,8 +1,8 @@ describe( '[Language processing] Resize Content Tests', () => { before( () => { cy.login(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_content_resizing' + cy.visitFeatureSettings( + 'language_processing/feature_content_resizing' ); cy.enableFeature(); cy.selectProvider( 'azure_openai' ); @@ -21,8 +21,8 @@ describe( '[Language processing] Resize Content Tests', () => { } ); it( 'Resize content feature can grow and shrink content', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_content_resizing' + cy.visitFeatureSettings( + 'language_processing/feature_content_resizing' ); cy.enableFeature(); diff --git a/tests/cypress/integration/language-processing/resize_content-googleai-gemini-api.test.js b/tests/cypress/integration/language-processing/resize_content-googleai-gemini-api.test.js index 340cb25d2..47ec02c0d 100644 --- a/tests/cypress/integration/language-processing/resize_content-googleai-gemini-api.test.js +++ b/tests/cypress/integration/language-processing/resize_content-googleai-gemini-api.test.js @@ -1,8 +1,8 @@ describe( '[Language processing] Resize Content Tests', () => { before( () => { cy.login(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_content_resizing' + cy.visitFeatureSettings( + 'language_processing/feature_content_resizing' ); cy.enableFeature(); cy.selectProvider( 'googleai_gemini_api' ); @@ -17,8 +17,8 @@ describe( '[Language processing] Resize Content Tests', () => { } ); it( 'Resize content feature can grow and shrink content', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_content_resizing' + cy.visitFeatureSettings( + 'language_processing/feature_content_resizing' ); cy.enableFeature(); diff --git a/tests/cypress/integration/language-processing/resize_content-openai-chatgpt.test.js b/tests/cypress/integration/language-processing/resize_content-openai-chatgpt.test.js index 308aed291..33a061b9c 100644 --- a/tests/cypress/integration/language-processing/resize_content-openai-chatgpt.test.js +++ b/tests/cypress/integration/language-processing/resize_content-openai-chatgpt.test.js @@ -1,8 +1,8 @@ describe( '[Language processing] Resize Content Tests', () => { before( () => { cy.login(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_content_resizing' + cy.visitFeatureSettings( + 'language_processing/feature_content_resizing' ); cy.enableFeature(); cy.selectProvider( 'openai_chatgpt' ); @@ -17,8 +17,8 @@ describe( '[Language processing] Resize Content Tests', () => { } ); it( 'Resize content feature can grow and shrink content', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_content_resizing' + cy.visitFeatureSettings( + 'language_processing/feature_content_resizing' ); cy.enableFeature(); @@ -74,8 +74,8 @@ describe( '[Language processing] Resize Content Tests', () => { } ); it( 'Can set multiple custom resize generation prompts, select one as the default and delete one.', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_content_resizing' + cy.visitFeatureSettings( + 'language_processing/feature_content_resizing' ); // Add three custom shrink prompts. @@ -245,8 +245,8 @@ describe( '[Language processing] Resize Content Tests', () => { it( 'Can enable/disable resize content feature', () => { // Disable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_content_resizing' + cy.visitFeatureSettings( + 'language_processing/feature_content_resizing' ); cy.disableFeature(); cy.saveFeatureSettings(); @@ -255,8 +255,8 @@ describe( '[Language processing] Resize Content Tests', () => { cy.verifyResizeContentEnabled( false ); // Enable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_content_resizing' + cy.visitFeatureSettings( + 'language_processing/feature_content_resizing' ); cy.enableFeature(); cy.saveFeatureSettings(); diff --git a/tests/cypress/integration/language-processing/smart-404-azure-openai.test.js b/tests/cypress/integration/language-processing/smart-404-azure-openai.test.js index e91040f5d..cd275497c 100644 --- a/tests/cypress/integration/language-processing/smart-404-azure-openai.test.js +++ b/tests/cypress/integration/language-processing/smart-404-azure-openai.test.js @@ -11,9 +11,7 @@ describe( '[Language processing] Smart 404 - Azure OpenAI Tests', () => { it( "See error message if ElasticPress isn't activate", () => { cy.disableElasticPress(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_smart_404' - ); + cy.visitFeatureSettings( 'language_processing/feature_smart_404' ); cy.get( '.elasticpress-required-notice.components-notice ' ).should( 'exist' @@ -23,9 +21,7 @@ describe( '[Language processing] Smart 404 - Azure OpenAI Tests', () => { it( 'Can save Smart 404 settings', () => { cy.enableElasticPress(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_smart_404' - ); + cy.visitFeatureSettings( 'language_processing/feature_smart_404' ); // Enabled Feature. cy.enableFeature(); diff --git a/tests/cypress/integration/language-processing/smart-404-openai.test.js b/tests/cypress/integration/language-processing/smart-404-openai.test.js index 899d662e7..9f7a1a9c8 100644 --- a/tests/cypress/integration/language-processing/smart-404-openai.test.js +++ b/tests/cypress/integration/language-processing/smart-404-openai.test.js @@ -11,9 +11,7 @@ describe( '[Language processing] Smart 404 - OpenAI Tests', () => { it( "See error message if ElasticPress isn't activate", () => { cy.disableElasticPress(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_smart_404' - ); + cy.visitFeatureSettings( 'language_processing/feature_smart_404' ); cy.get( '.elasticpress-required-notice.components-notice ' ).should( 'exist' @@ -23,9 +21,7 @@ describe( '[Language processing] Smart 404 - OpenAI Tests', () => { it( 'Can save Smart 404 settings', () => { cy.enableElasticPress(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_smart_404' - ); + cy.visitFeatureSettings( 'language_processing/feature_smart_404' ); // Enabled Feature. cy.enableFeature(); diff --git a/tests/cypress/integration/language-processing/speech-to-text-openai-whisper.test.js b/tests/cypress/integration/language-processing/speech-to-text-openai-whisper.test.js index 5722ee195..159b61c11 100644 --- a/tests/cypress/integration/language-processing/speech-to-text-openai-whisper.test.js +++ b/tests/cypress/integration/language-processing/speech-to-text-openai-whisper.test.js @@ -3,8 +3,8 @@ import { getWhisperData } from '../../plugins/functions'; describe( '[Language processing] Speech to Text Tests', () => { before( () => { cy.login(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_audio_transcripts_generation' + cy.visitFeatureSettings( + 'language_processing/feature_audio_transcripts_generation' ); cy.enableFeature(); cy.saveFeatureSettings(); @@ -17,8 +17,8 @@ describe( '[Language processing] Speech to Text Tests', () => { } ); it( 'Can save OpenAI Whisper "Language Processing" settings', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_audio_transcripts_generation' + cy.visitFeatureSettings( + 'language_processing/feature_audio_transcripts_generation' ); cy.get( '#openai_api_key' ).clear().type( 'password' ); @@ -80,8 +80,8 @@ describe( '[Language processing] Speech to Text Tests', () => { }; // Disable features - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_audio_transcripts_generation' + cy.visitFeatureSettings( + 'language_processing/feature_audio_transcripts_generation' ); cy.disableFeature(); cy.saveFeatureSettings(); @@ -90,8 +90,8 @@ describe( '[Language processing] Speech to Text Tests', () => { cy.verifySpeechToTextEnabled( false, options ); // Enable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_audio_transcripts_generation' + cy.visitFeatureSettings( + 'language_processing/feature_audio_transcripts_generation' ); cy.enableFeature(); cy.saveFeatureSettings(); @@ -102,8 +102,8 @@ describe( '[Language processing] Speech to Text Tests', () => { it( 'Can enable/disable speech to text feature by role', () => { // Enable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_audio_transcripts_generation' + cy.visitFeatureSettings( + 'language_processing/feature_audio_transcripts_generation' ); cy.enableFeature(); cy.saveFeatureSettings(); diff --git a/tests/cypress/integration/language-processing/text-to-speech-amazon-polly.test.js b/tests/cypress/integration/language-processing/text-to-speech-amazon-polly.test.js index 8e579698f..6d94ebef8 100644 --- a/tests/cypress/integration/language-processing/text-to-speech-amazon-polly.test.js +++ b/tests/cypress/integration/language-processing/text-to-speech-amazon-polly.test.js @@ -1,8 +1,8 @@ describe( '[Language Processing] Text to Speech (Amazon Polly) Tests', () => { before( () => { cy.login(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_text_to_speech_generation' + cy.visitFeatureSettings( + 'language_processing/feature_text_to_speech_generation' ); cy.get( '#classifai-logo' ).should( 'exist' ); cy.get( '.settings-allowed-post-types input#post' ).check(); diff --git a/tests/cypress/integration/language-processing/text-to-speech-microsoft-azure.test.js b/tests/cypress/integration/language-processing/text-to-speech-microsoft-azure.test.js index 9a4d317a1..dc47307d7 100644 --- a/tests/cypress/integration/language-processing/text-to-speech-microsoft-azure.test.js +++ b/tests/cypress/integration/language-processing/text-to-speech-microsoft-azure.test.js @@ -1,8 +1,8 @@ describe( '[Language Processing] Text to Speech (Microsoft Azure) Tests', () => { before( () => { cy.login(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_text_to_speech_generation' + cy.visitFeatureSettings( + 'language_processing/feature_text_to_speech_generation' ); cy.get( '#classifai-logo' ).should( 'exist' ); cy.selectProvider( 'ms_azure_text_to_speech' ); @@ -118,8 +118,8 @@ describe( '[Language Processing] Text to Speech (Microsoft Azure) Tests', () => it( 'Disable support for post type Post', () => { cy.disableClassicEditor(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_text_to_speech_generation' + cy.visitFeatureSettings( + 'language_processing/feature_text_to_speech_generation' ); cy.get( '.settings-allowed-post-types input#post' ).uncheck(); cy.saveFeatureSettings(); @@ -130,8 +130,8 @@ describe( '[Language Processing] Text to Speech (Microsoft Azure) Tests', () => it( 'Can enable/disable text to speech feature', () => { // Disable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_text_to_speech_generation' + cy.visitFeatureSettings( + 'language_processing/feature_text_to_speech_generation' ); cy.disableFeature(); cy.saveFeatureSettings(); @@ -140,8 +140,8 @@ describe( '[Language Processing] Text to Speech (Microsoft Azure) Tests', () => cy.verifyTextToSpeechEnabled( false ); // Enable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_text_to_speech_generation' + cy.visitFeatureSettings( + 'language_processing/feature_text_to_speech_generation' ); cy.enableFeature(); cy.get( '.settings-allowed-post-types input#post' ).check(); @@ -153,8 +153,8 @@ describe( '[Language Processing] Text to Speech (Microsoft Azure) Tests', () => it( 'Can enable/disable text to speech feature by role', () => { // Enable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_text_to_speech_generation' + cy.visitFeatureSettings( + 'language_processing/feature_text_to_speech_generation' ); cy.get( '.settings-allowed-post-types input#post' ).check(); cy.saveFeatureSettings(); diff --git a/tests/cypress/integration/language-processing/text-to-speech-openai-text-to-speech.test.js b/tests/cypress/integration/language-processing/text-to-speech-openai-text-to-speech.test.js index 6253b5a74..e8cf3120f 100644 --- a/tests/cypress/integration/language-processing/text-to-speech-openai-text-to-speech.test.js +++ b/tests/cypress/integration/language-processing/text-to-speech-openai-text-to-speech.test.js @@ -1,8 +1,8 @@ describe( '[Language Processing] Text to Speech (OpenAI) Tests', () => { before( () => { cy.login(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_text_to_speech_generation' + cy.visitFeatureSettings( + 'language_processing/feature_text_to_speech_generation' ); cy.get( '#classifai-logo' ).should( 'exist' ); cy.get( '.settings-allowed-post-types input#post' ).check(); @@ -110,8 +110,8 @@ describe( '[Language Processing] Text to Speech (OpenAI) Tests', () => { it( 'Disable support for post type Post', () => { cy.disableClassicEditor(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_text_to_speech_generation' + cy.visitFeatureSettings( + 'language_processing/feature_text_to_speech_generation' ); cy.get( '.settings-allowed-post-types input#post' ).uncheck(); cy.saveFeatureSettings(); @@ -122,8 +122,8 @@ describe( '[Language Processing] Text to Speech (OpenAI) Tests', () => { it( 'Can enable/disable text to speech feature', () => { // Disable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_text_to_speech_generation' + cy.visitFeatureSettings( + 'language_processing/feature_text_to_speech_generation' ); cy.disableFeature(); cy.saveFeatureSettings(); @@ -132,8 +132,8 @@ describe( '[Language Processing] Text to Speech (OpenAI) Tests', () => { cy.verifyTextToSpeechEnabled( false ); // Enable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_text_to_speech_generation' + cy.visitFeatureSettings( + 'language_processing/feature_text_to_speech_generation' ); cy.enableFeature(); cy.get( '.settings-allowed-post-types input#post' ).check(); @@ -145,8 +145,8 @@ describe( '[Language Processing] Text to Speech (OpenAI) Tests', () => { it( 'Can enable/disable text to speech feature by role', () => { // Enable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_text_to_speech_generation' + cy.visitFeatureSettings( + 'language_processing/feature_text_to_speech_generation' ); cy.get( '.settings-allowed-post-types input#post' ).check(); cy.saveFeatureSettings(); diff --git a/tests/cypress/integration/language-processing/title-generation-azure-openai.test.js b/tests/cypress/integration/language-processing/title-generation-azure-openai.test.js index 8a95dd405..54f778c86 100644 --- a/tests/cypress/integration/language-processing/title-generation-azure-openai.test.js +++ b/tests/cypress/integration/language-processing/title-generation-azure-openai.test.js @@ -12,8 +12,8 @@ describe( '[Language processing] Title Generation Tests', () => { } ); it( 'Can save Azure OpenAI "Language Processing" title settings', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_title_generation' + cy.visitFeatureSettings( + 'language_processing/feature_title_generation' ); cy.get( '#classifai-logo' ).should( 'exist' ); @@ -115,8 +115,8 @@ describe( '[Language processing] Title Generation Tests', () => { it( 'Can see the generate titles button in a post (Classic Editor)', () => { cy.enableClassicEditor(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_title_generation' + cy.visitFeatureSettings( + 'language_processing/feature_title_generation' ); cy.enableFeature(); cy.saveFeatureSettings(); diff --git a/tests/cypress/integration/language-processing/title-generation-googleai-gemini-api.test.js b/tests/cypress/integration/language-processing/title-generation-googleai-gemini-api.test.js index 528206c58..801b9f5ff 100644 --- a/tests/cypress/integration/language-processing/title-generation-googleai-gemini-api.test.js +++ b/tests/cypress/integration/language-processing/title-generation-googleai-gemini-api.test.js @@ -12,8 +12,8 @@ describe( '[Language processing] Title Generation Tests', () => { } ); it( 'Can save Google AI (Gemini API) "Language Processing" title settings', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_title_generation' + cy.visitFeatureSettings( + 'language_processing/feature_title_generation' ); cy.get( '#classifai-logo' ).should( 'exist' ); cy.selectProvider( 'googleai_gemini_api' ); @@ -110,8 +110,8 @@ describe( '[Language processing] Title Generation Tests', () => { it( 'Can see the generate titles button in a post (Classic Editor)', () => { cy.enableClassicEditor(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_title_generation' + cy.visitFeatureSettings( + 'language_processing/feature_title_generation' ); cy.enableFeature(); cy.saveFeatureSettings(); diff --git a/tests/cypress/integration/language-processing/title-generation-openai-chatgpt.test.js b/tests/cypress/integration/language-processing/title-generation-openai-chatgpt.test.js index 6bd2baebf..983d35d4a 100644 --- a/tests/cypress/integration/language-processing/title-generation-openai-chatgpt.test.js +++ b/tests/cypress/integration/language-processing/title-generation-openai-chatgpt.test.js @@ -12,8 +12,8 @@ describe( '[Language processing] Title Generation Tests', () => { } ); it( 'Can save OpenAI ChatGPT "Language Processing" title settings', () => { - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_title_generation' + cy.visitFeatureSettings( + 'language_processing/feature_title_generation' ); cy.get( '#classifai-logo' ).should( 'exist' ); cy.selectProvider( 'openai_chatgpt' ); @@ -109,8 +109,8 @@ describe( '[Language processing] Title Generation Tests', () => { it( 'Can see the generate titles button in a post (Classic Editor)', () => { cy.enableClassicEditor(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_title_generation' + cy.visitFeatureSettings( + 'language_processing/feature_title_generation' ); cy.enableFeature(); cy.saveFeatureSettings(); @@ -135,8 +135,8 @@ describe( '[Language processing] Title Generation Tests', () => { it( 'Can set multiple custom title generation prompts, select one as the default and delete one.', () => { cy.disableClassicEditor(); - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_title_generation' + cy.visitFeatureSettings( + 'language_processing/feature_title_generation' ); // Add three custom prompts. @@ -268,8 +268,8 @@ describe( '[Language processing] Title Generation Tests', () => { it( 'Can enable/disable title generation feature', () => { // Disable features. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_title_generation' + cy.visitFeatureSettings( + 'language_processing/feature_title_generation' ); cy.disableFeature(); cy.saveFeatureSettings(); @@ -278,8 +278,8 @@ describe( '[Language processing] Title Generation Tests', () => { cy.verifyTitleGenerationEnabled( false ); // Enable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_title_generation' + cy.visitFeatureSettings( + 'language_processing/feature_title_generation' ); cy.enableFeature(); cy.saveFeatureSettings(); @@ -290,8 +290,8 @@ describe( '[Language processing] Title Generation Tests', () => { it( 'Can enable/disable title generation feature by role', () => { // Enable feature. - cy.visit( - '/wp-admin/tools.php?page=classifai#/language_processing/feature_title_generation' + cy.visitFeatureSettings( + 'language_processing/feature_title_generation' ); cy.enableFeature(); cy.saveFeatureSettings(); diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 3275f09ba..21904e1ed 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -143,7 +143,7 @@ Cypress.Commands.add( 'enableFeatureForRoles', ( feature, roles ) => { if ( imageProcessingFeatures.includes( feature ) ) { tab = 'image_processing'; } - cy.visit( `/wp-admin/tools.php?page=classifai#/${ tab }/${ feature }` ); + cy.visitFeatureSettings( `${ tab }/${ feature }` ); cy.get( '#classifai-logo' ).should( 'exist' ); // Disable access for all roles. @@ -157,6 +157,7 @@ Cypress.Commands.add( 'enableFeatureForRoles', ( feature, roles ) => { roles.forEach( ( role ) => { cy.get( `.settings-allowed-roles input#${ role }` ).check(); } ); + cy.wait( 100 ); cy.saveFeatureSettings(); } ); @@ -171,11 +172,14 @@ Cypress.Commands.add( 'disableFeatureForRoles', ( feature, roles ) => { if ( imageProcessingFeatures.includes( feature ) ) { tab = 'image_processing'; } - cy.visit( `/wp-admin/tools.php?page=classifai#/${ tab }/${ feature }` ); - cy.get( '.classifai-enable-feature-toggle input' ).check(); + cy.visitFeatureSettings( `${ tab }/${ feature }` ); + cy.wait( 100 ); + cy.enableFeature(); roles.forEach( ( role ) => { - cy.get( `.settings-allowed-roles input#${ role }` ).uncheck(); + cy.get( `.settings-allowed-roles input#${ role }` ).uncheck( { + force: true, + } ); } ); // Disable access for all users. @@ -195,7 +199,7 @@ Cypress.Commands.add( 'enableFeatureForUsers', ( feature, users ) => { if ( imageProcessingFeatures.includes( feature ) ) { tab = 'image_processing'; } - cy.visit( `/wp-admin/tools.php?page=classifai#/${ tab }/${ feature }` ); + cy.visitFeatureSettings( `${ tab }/${ feature }` ); // Disable access for all roles. cy.get( '.settings-allowed-roles input[type="checkbox"]' ).uncheck( { @@ -242,7 +246,8 @@ Cypress.Commands.add( 'enableFeatureOptOut', ( feature ) => { if ( imageProcessingFeatures.includes( feature ) ) { tab = 'image_processing'; } - cy.visit( `/wp-admin/tools.php?page=classifai#/${ tab }/${ feature }` ); + cy.visitFeatureSettings( `${ tab }/${ feature }` ); + cy.wait( 100 ); cy.get( '.settings-allowed-roles input#administrator' ).check(); cy.get( '.classifai-settings__user-based-opt-out input' ).check(); @@ -582,25 +587,27 @@ Cypress.Commands.add( 'selectProvider', ( provider ) => { * Save the feature settings. */ Cypress.Commands.add( 'saveFeatureSettings', () => { + cy.intercept( 'POST', '/wp-json/classifai/v1/settings/*' ).as( + 'saveSettings' + ); cy.get( '.classifai-settings-footer button.save-settings-button' ).click(); + cy.wait( '@saveSettings' ); } ); /** * Enable Feature. */ Cypress.Commands.add( 'enableFeature', () => { - cy.get( '.classifai-enable-feature-toggle input[type="checkbox"]' ).check( { - force: true, - } ); + cy.get( '.classifai-enable-feature-toggle input[type="checkbox"]' ).check(); } ); /** * Disable Feature. */ Cypress.Commands.add( 'disableFeature', () => { - cy.get( '.classifai-enable-feature-toggle input[type="checkbox"]' ).uncheck( - { force: true } - ); + cy.get( + '.classifai-enable-feature-toggle input[type="checkbox"]' + ).uncheck(); } ); /** @@ -626,3 +633,11 @@ Cypress.Commands.add( 'disableElasticPress', () => { } } ); } ); + +/** + * Visit the settings page for a feature. + */ +Cypress.Commands.add( 'visitFeatureSettings', ( featurePath ) => { + cy.visit( `/wp-admin/tools.php?page=classifai#/${ featurePath }` ); + cy.get( '.components-panel__header h2' ).should( 'exist' ); +} );