<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// @flow

import {
  attemptToPublish,
  resetUploadState,
  abortUpload,
  toggleCheckedSharingOptions,
  revertToPrePublishedState,
} from '../../actions/publish';
import { changeSelectedTab } from '../../actions/app';
import {
  viewProfileFromPathInZipFile,
  returnToZipFileList,
} from '../../actions/zipped-profiles';
import {
  getCheckedSharingOptions,
  getUploadPhase,
  getUploadError,
  getUploadProgress,
  getUploadGeneration,
} from '../../selectors/publish';
import {
  getSelectedTab,
  getDataSource,
  getProfileName,
} from '../../selectors/url-state';
import { getHasZipFile } from '../../selectors/zipped-profiles';
import { getProfileFromTextSamples } from '../fixtures/profiles/processed-profile';
import { storeWithProfile } from '../fixtures/stores';
import { TextEncoder } from 'util';
import { ensureExists } from '../../utils/flow';
import { waitUntilState } from '../fixtures/utils';
import { storeWithZipFile } from '../fixtures/profiles/zip-file';

import type { Store } from '../../types/store';

// Mocks:
import { uploadBinaryProfileData } from '../../profile-logic/profile-store';
jest.mock('../../profile-logic/profile-store');

describe('getCheckedSharingOptions', function() {
  describe('default filtering by channel', function() {
    const isFiltering = {
      includeExtension: false,
      includeFullTimeRange: false,
      includeHiddenThreads: false,
      includeScreenshots: false,
      includeUrls: false,
      includePreferenceValues: false,
    };
    const isNotFiltering = {
      includeExtension: true,
      includeFullTimeRange: true,
      includeHiddenThreads: true,
      includeScreenshots: true,
      includeUrls: true,
      includePreferenceValues: true,
    };
    function getDefaultsWith(updateChannel: string) {
      const { profile } = getProfileFromTextSamples('A');
      profile.meta.updateChannel = updateChannel;
      const { getState } = storeWithProfile(profile);
      return getCheckedSharingOptions(getState());
    }

    it('does not filter with nightly', function() {
      expect(getDefaultsWith('nightly')).toEqual(isNotFiltering);
    });

    it('does not filter with nightly-try', function() {
      expect(getDefaultsWith('nightly-try')).toEqual(isNotFiltering);
    });

    it('does not filter with default', function() {
      expect(getDefaultsWith('default')).toEqual(isNotFiltering);
    });

    it('does filter with aurora', function() {
      expect(getDefaultsWith('aurora')).toEqual(isFiltering);
    });
<commit_msg>Add test<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// @flow

import {
  attemptToPublish,
  resetUploadState,
  abortUpload,
  toggleCheckedSharingOptions,
  revertToPrePublishedState,
} from '../../actions/publish';
import { changeSelectedTab } from '../../actions/app';
import {
  viewProfileFromPathInZipFile,
  returnToZipFileList,
} from '../../actions/zipped-profiles';
import {
  getCheckedSharingOptions,
  getUploadPhase,
  getUploadError,
  getUploadProgress,
  getUploadGeneration,
} from '../../selectors/publish';
import {
  getSelectedTab,
  getDataSource,
  getProfileName,
} from '../../selectors/url-state';
import { getHasZipFile } from '../../selectors/zipped-profiles';
import { getProfileFromTextSamples } from '../fixtures/profiles/processed-profile';
import { storeWithProfile } from '../fixtures/stores';
import { TextEncoder } from 'util';
import { ensureExists } from '../../utils/flow';
import { waitUntilState } from '../fixtures/utils';
import { storeWithZipFile } from '../fixtures/profiles/zip-file';

import type { Store } from '../../types/store';

// Mocks:
import { uploadBinaryProfileData } from '../../profile-logic/profile-store';
jest.mock('../../profile-logic/profile-store');

describe('getCheckedSharingOptions', function() {
  describe('default filtering by channel', function() {
    const isFiltering = {
      includeExtension: false,
      includeFullTimeRange: false,
      includeHiddenThreads: false,
      includeScreenshots: false,
      includeUrls: false,
      includePreferenceValues: false,
    };
    const isNotFiltering = {
      includeExtension: true,
      includeFullTimeRange: true,
      includeHiddenThreads: true,
      includeScreenshots: true,
      includeUrls: true,
      includePreferenceValues: true,
    };
    function getDefaultsWith(updateChannel: string) {
      const { profile } = getProfileFromTextSamples('A');
      profile.meta.updateChannel = updateChannel;
      const { getState } = storeWithProfile(profile);
      return getCheckedSharingOptions(getState());
    }

    it('does not filter with nightly', function() {
      expect(getDefaultsWith('nightly')).toEqual(isNotFiltering);
    });

    it('does not filter with nightly-try', function() {
      expect(getDefaultsWith('nightly-try')).toEqual(isNotFiltering);
    });

    it('does not filter with default', function() {
      expect(getDefaultsWith('default')).toEqual(isNotFiltering);
    });

    it('does not filter local builds', function() {
      expect(getDefaultsWith('nightly-autoland')).toEqual(isNotFiltering);
    });

    it('does filter with aurora', function() {
      expect(getDefaultsWith('aurora')).toEqual(isFiltering);
    });

{'fraction_non_alphanumeric': 0.13645258850738304, 'fraction_numerical': 0.0014232342999466287, 'mean_word_length': 3.7243697478991598, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4127585', 'n_tokens_mistral': 1604, 'n_tokens_neox': 1599, 'n_words': 370}