diff options
3 files changed, 40 insertions, 1 deletions
diff --git a/plugins/SegmentEditor/javascripts/Segmentation.js b/plugins/SegmentEditor/javascripts/Segmentation.js index 620965d6c1..483c05a251 100644 --- a/plugins/SegmentEditor/javascripts/Segmentation.js +++ b/plugins/SegmentEditor/javascripts/Segmentation.js @@ -664,7 +664,12 @@ Segmentation = (function($) { var segmentStr = getSegmentGeneratorController().getSegmentString(); var segmentId = $(self.form).find(".available_segments_select").val() || ""; var user = $(self.form).find(".enable_all_users_select option:selected").val(); - var autoArchive = $(self.form).find(".auto_archive_select option:selected").val() || 0; + // if create realtime segments is disabled, the select field is not available, but we need to use autoArchive = 1 + if ($(self.form).find(".auto_archive_select").length) { + var autoArchive = $(self.form).find(".auto_archive_select option:selected").val() || 0; + } else { + var autoArchive = 1; + } var params = { "name": segmentName, "definition": segmentStr, diff --git a/plugins/SegmentEditor/tests/UI/SegmentSelectorEditor_spec.js b/plugins/SegmentEditor/tests/UI/SegmentSelectorEditor_spec.js index 5e9032d7d0..0c3a9e7bd0 100644 --- a/plugins/SegmentEditor/tests/UI/SegmentSelectorEditor_spec.js +++ b/plugins/SegmentEditor/tests/UI/SegmentSelectorEditor_spec.js @@ -283,4 +283,35 @@ describe("SegmentSelectorEditorTest", function () { await page.waitForNetworkIdle(); expect(await page.screenshotSelector(selectorsToCapture)).to.matchImage('enabled_create_realtime_segments'); }); + + it("should save a new segment when enable_create_realtime_segments = 0", async function() { + // ensure segment won't be archived after saving it. + testEnvironment.overrideConfig('General', 'enable_create_realtime_segments', 0); + testEnvironment.overrideConfig('General', 'enable_browser_archiving_triggering', 0); + testEnvironment.overrideConfig('General', 'browser_archiving_disabled_enforce', 1); + testEnvironment.optionsOverride = { + enableBrowserTriggerArchiving: '0', + }; + testEnvironment.save(); + await page.evaluate(function () { + $('.segmentRow0 .segment-row:first .metricValueBlock input').val('3').change(); + }); + + await page.type('input.edit_segment_name', 'auto archive segment'); + await page.click('.segmentRow0 .segment-or'); // click somewhere else to save new name + + // this is for debug purpose. If segment can't be saved, and alert might be shown, causing the UI test to hang + page.on('dialog', (dialog)=> { + console.log(dialog.message()); + }); + + await page.evaluate(function () { + $('button.saveAndApply').click(); + }); + await page.waitForNetworkIdle(); + await page.waitForSelector('.segmentationContainer'); + + await page.click('.segmentationContainer .title'); + expect(await page.screenshotSelector(selectorsToCapture)).to.matchImage('enabled_create_realtime_segments_saved'); + }); }); diff --git a/plugins/SegmentEditor/tests/UI/expected-screenshots/SegmentSelectorEditorTest_enabled_create_realtime_segments_saved.png b/plugins/SegmentEditor/tests/UI/expected-screenshots/SegmentSelectorEditorTest_enabled_create_realtime_segments_saved.png new file mode 100644 index 0000000000..0ffb486a39 --- /dev/null +++ b/plugins/SegmentEditor/tests/UI/expected-screenshots/SegmentSelectorEditorTest_enabled_create_realtime_segments_saved.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa78bbd9964683cb66588f231ad36130af914fd1ac7393fd311eca9eeafe084a +size 20327 |