Skip to content

Commit

Permalink
Update E2E tests for Smart 404 feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdharmesh committed Sep 17, 2024
1 parent 713dc42 commit 492cbaf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,47 @@ describe( '[Language processing] Smart 404 - Azure OpenAI Tests', () => {
cy.disableElasticPress();

cy.visit(
'/wp-admin/tools.php?page=classifai&tab=language_processing&feature=feature_smart_404'
'/wp-admin/tools.php?page=classifai#/language_processing/feature_smart_404'
);

cy.get( '.classifai-nlu-sections .notice-error' ).should( 'exist' );
cy.get( '.elasticpress-required-notice.components-notice ' ).should(
'exist'
);
} );

it( 'Can save Smart 404 settings', () => {
cy.enableElasticPress();

cy.visit(
'/wp-admin/tools.php?page=classifai&tab=language_processing&feature=feature_smart_404'
'/wp-admin/tools.php?page=classifai#/language_processing/feature_smart_404'
);

// Enabled Feature.
cy.get( '#status' ).check();
cy.get( '.classifai-enable-feature-toggle input' ).check();

// Setup Provider.
cy.get( '#provider' ).select( 'azure_openai_embeddings' );
cy.get(
'input[name="classifai_feature_smart_404[azure_openai_embeddings][endpoint_url]"]'
)
cy.selectProvider( 'azure_openai_embeddings' );
cy.get( 'input#azure_openai_embeddings_endpoint_url' )
.clear()
.type( 'https://e2e-test-azure-openai.test/' );
cy.get(
'input[name="classifai_feature_smart_404[azure_openai_embeddings][api_key]"]'
)
cy.get( 'input#azure_openai_embeddings_api_key' )
.clear()
.type( 'password' );
cy.get(
'input[name="classifai_feature_smart_404[azure_openai_embeddings][deployment]"]'
)
cy.get( 'input#azure_openai_embeddings_deployment' )
.clear()
.type( 'test' );

// Change all settings.
cy.get( '#num' ).clear().type( 4 );
cy.get( '#num_search' ).clear().type( 7000 );
cy.get( '#threshold' ).clear().type( 3.25 );
cy.get( '#rescore' ).uncheck();
cy.get( '#fallback' ).check();
cy.get( '#score_function' ).select( 'l1_norm' );
cy.get( '#classifai_feature_smart_404_roles_administrator' ).check();
cy.get( '#feature_smart_404_num' ).clear().type( 4 );
cy.get( '#feature_smart_404_num_search' ).clear().type( 7000 );
cy.get( '#feature_smart_404_threshold' ).clear().type( 3.25 );
cy.get( '#feature_smart_404_rescore' ).uncheck();
cy.get( '#feature_smart_404_fallback' ).check();
cy.get( '#feature_smart_404_score_function' ).select( 'l1_norm' );
cy.get( '.settings-allowed-roles input#administrator' ).check();

// Save settings.
cy.get( '#submit' ).click();
cy.saveFeatureSettings();

cy.disableElasticPress();
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,39 @@ describe( '[Language processing] Smart 404 - OpenAI Tests', () => {
cy.disableElasticPress();

cy.visit(
'/wp-admin/tools.php?page=classifai&tab=language_processing&feature=feature_smart_404'
'/wp-admin/tools.php?page=classifai#/language_processing/feature_smart_404'
);

cy.get( '.classifai-nlu-sections .notice-error' ).should( 'exist' );
cy.get( '.elasticpress-required-notice.components-notice ' ).should(
'exist'
);
} );

it( 'Can save Smart 404 settings', () => {
cy.enableElasticPress();

cy.visit(
'/wp-admin/tools.php?page=classifai&tab=language_processing&feature=feature_smart_404'
'/wp-admin/tools.php?page=classifai#/language_processing/feature_smart_404'
);

// Enabled Feature.
cy.get( '#status' ).check();
cy.get( '.classifai-enable-feature-toggle input' ).check();

// Setup Provider.
cy.get( '#provider' ).select( 'openai_embeddings' );
cy.get( '#api_key' ).clear().type( 'password' );
cy.selectProvider( 'azure_openai_embeddings' );
cy.get( '#openai_api_key' ).clear().type( 'password' );

// Change all settings.
cy.get( '#num' ).clear().type( 5 );
cy.get( '#num_search' ).clear().type( 8000 );
cy.get( '#threshold' ).clear().type( 2.55 );
cy.get( '#rescore' ).check();
cy.get( '#fallback' ).uncheck();
cy.get( '#score_function' ).select( 'dot_product' );
cy.get( '#classifai_feature_smart_404_roles_administrator' ).check();
cy.get( '#feature_smart_404_num' ).clear().type( 5 );
cy.get( '#feature_smart_404_num_search' ).clear().type( 8000 );
cy.get( '#feature_smart_404_threshold' ).clear().type( 2.55 );
cy.get( '#feature_smart_404_rescore' ).check();
cy.get( '#feature_smart_404_fallback' ).uncheck();
cy.get( '#feature_smart_404_score_function' ).select( 'dot_product' );
cy.get( '.settings-allowed-roles input#administrator' ).check();

// Save settings.
cy.get( '#submit' ).click();
cy.saveFeatureSettings();

cy.disableElasticPress();
} );
Expand Down

0 comments on commit 492cbaf

Please sign in to comment.