Skip to content

Commit f877ffd

Browse files
committed
fix(wizard): Correct default behavior for field values
1 parent 21a7bc7 commit f877ffd

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

src/sentry/static/sentry/app/views/installWizard.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@ export default class InstallWizard extends AsyncView {
6161
const data = {};
6262
Object.keys(options).forEach(optionName => {
6363
const option = options[optionName];
64-
if (!option.field.isSet) {
64+
// XXX(dcramer): we need the user to explicitly choose beacon.anonymous
65+
// vs using an implied default so effectively this is binding
66+
// all values to their server-defaults (as client-side defaults dont really work)
67+
if (
68+
option.value !== undefined &&
69+
(option.field.isSet || optionName != 'beacon.anonymous')
70+
) {
6571
data[optionName] = option.value;
6672
}
6773
});

tests/js/spec/views/installWizard.spec.jsx

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('InstallWizard', function() {
3131
expect(wrapper).toMatchSnapshot();
3232
});
3333

34-
it('has "Send my contact information..." when beacon.anonymous is false', function() {
34+
it('has no option selected when beacon.anonymous is unset', function() {
3535
MockApiClient.addMockResponse({
3636
url: '/internal/options/?query=is:required',
3737
body: TestStubs.InstallWizard({
@@ -50,6 +50,34 @@ describe('InstallWizard', function() {
5050
});
5151
const wrapper = mount(<InstallWizard onConfigured={jest.fn()} />);
5252

53+
expect(
54+
wrapper.find('input[name="beacon.anonymous"][value="false"]').prop('checked')
55+
).toBe(false);
56+
57+
expect(
58+
wrapper.find('input[name="beacon.anonymous"][value="true"]').prop('checked')
59+
).toBe(false);
60+
});
61+
62+
it('has "Send my contact information..." when beacon.anonymous is false', function() {
63+
MockApiClient.addMockResponse({
64+
url: '/internal/options/?query=is:required',
65+
body: TestStubs.InstallWizard({
66+
'beacon.anonymous': {
67+
field: {
68+
disabledReason: null,
69+
default: false,
70+
required: true,
71+
disabled: false,
72+
allowEmpty: true,
73+
isSet: true,
74+
},
75+
value: false,
76+
},
77+
}),
78+
});
79+
const wrapper = mount(<InstallWizard onConfigured={jest.fn()} />);
80+
5381
expect(
5482
wrapper.find('input[name="beacon.anonymous"][value="false"]').prop('checked')
5583
).toBe(true);
@@ -70,7 +98,7 @@ describe('InstallWizard', function() {
7098
required: true,
7199
disabled: false,
72100
allowEmpty: true,
73-
isSet: false,
101+
isSet: true,
74102
},
75103
value: true,
76104
},

0 commit comments

Comments
 (0)