Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segment creation fails when enable_create_realtime_segments = 0 #18181

Merged
merged 2 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion plugins/SegmentEditor/javascripts/Segmentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
31 changes: 31 additions & 0 deletions plugins/SegmentEditor/tests/UI/SegmentSelectorEditor_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.