<commit_before>/* global describe it browser */
const assert = require('assert');
const nock = require('nock');
const version = require('../../package.json').version;

const percy = require('../../dist/main.js');

class Nock {
  constructor(options) {
    this.options = options;
    this.capture = process.env.NOCK_REC === '1';
    if (this.capture) {
      nock.recorder.rec();
    }
  }
  finalizeSnapshot(options) {
    if (this.capture) {
      return;
    }
    const { snapshotId } = options;
    nock('https://percy.io:443', { encodedQueryParams: true })
      .post(`/api/v1/snapshots/${snapshotId}/finalize`, {})
      .reply(200, { success: true }, []);
  }
  finalizeBuild(options) {
    if (this.capture) {
      return;
    }
    const { buildId } = options;
    nock('https://percy.io:443', { encodedQueryParams: true })
      .post(`/api/v1/builds/${buildId}/finalize`, {})
      .reply(200, { success: true }, []);
  }
  snapshot(options) {
    if (this.capture) {
      return;
    }
    const { buildId, snapshotId } = options;
    const resources = options.resources.map(r => ({
      type: 'resources',
      id: r.id,
      attributes: {
        'resource-url': r.url,
        mimetype: r.mimetype,
        'is-root': r.root ? true : null,
      },
    }));
    const missingResources = options.missing.map(sha => ({ type: 'resources', id: sha }));

    let reply = options.reply || [
      201,
      {
        data: {
          type: 'snapshots',
          id: snapshotId,
          attributes: { name: 'testPercy' },
          links: { self: `/api/v1/snapshots/${snapshotId}` },
          relationships: {
            build: {
              links: {
                self: `/api/v1/snapshots/${snapshotId}/relationships/build`,
                related: `/api/v1/snapshots/${snapshotId}/build`,
              },
            },
            screenshots: {
              links: {
                self: `/api/v1/snapshots/${snapshotId}/relationships/screenshots`,
                related: `/api/v1/snapshots/${snapshotId}/screenshots`,
              },
            },
            'missing-resources': {
              links: {
                self: `/api/v1/snapshots/${snapshotId}/relationships/missing-resources`,
                related: `/api/v1/snapshots/${snapshotId}/missing-resources`,
              },
              data: missingResources,
            },
          },
        },
        included: [],
      },
    ];

    nock('https://percy.io:443', { encodedQueryParams: true })
      .post(`/api/v1/builds/${buildId}/snapshots/`, {
        data: {
          type: 'snapshots',
          attributes: {
            name: 'testPercy',
            'enable-javascript': null,
            widths: null,
            'minimum-height': null,
          },
          relationships: {
            resources: {
              data: resources,
            },
          },
        },
      })
      .reply(reply[0], reply[1], []);
  }
  startBuild(options) {
    if (this.capture) {
      return;
    }
    const { buildId } = options;
    const resources = (options.resources || []).map(r => ({
      type: 'resources',
      id: r.id,
      attributes: {
        'resource-url': r.url,
        mimetype: r.mimetype,
        'is-root': r.root ? true : null,
      },
    }));
    const missingResources = (options.missing || []).map(sha => ({ type: 'resources', id: sha }));
    nock('https://percy.io:443', { encodedQueryParams: true })
      .post('/api/v1/projects/dummy-repo/dummy-project/builds/', {
        data: {
          type: 'builds',
          attributes: { branch: 'master' },
          relationships: { resources: { data: resources } },<commit_msg>Updating the expected attributes for the tests.<commit_after>/* global describe it browser */
const assert = require('assert');
const nock = require('nock');
const version = require('../../package.json').version;

const percy = require('../../dist/main.js');

class Nock {
  constructor(options) {
    this.options = options;
    this.capture = process.env.NOCK_REC === '1';
    if (this.capture) {
      nock.recorder.rec();
    }
  }
  finalizeSnapshot(options) {
    if (this.capture) {
      return;
    }
    const { snapshotId } = options;
    nock('https://percy.io:443', { encodedQueryParams: true })
      .post(`/api/v1/snapshots/${snapshotId}/finalize`, {})
      .reply(200, { success: true }, []);
  }
  finalizeBuild(options) {
    if (this.capture) {
      return;
    }
    const { buildId } = options;
    nock('https://percy.io:443', { encodedQueryParams: true })
      .post(`/api/v1/builds/${buildId}/finalize`, {})
      .reply(200, { success: true }, []);
  }
  snapshot(options) {
    if (this.capture) {
      return;
    }
    const { buildId, snapshotId } = options;
    const resources = options.resources.map(r => ({
      type: 'resources',
      id: r.id,
      attributes: {
        'resource-url': r.url,
        mimetype: r.mimetype,
        'is-root': r.root ? true : null,
      },
    }));
    const missingResources = options.missing.map(sha => ({ type: 'resources', id: sha }));

    let reply = options.reply || [
      201,
      {
        data: {
          type: 'snapshots',
          id: snapshotId,
          attributes: { name: 'testPercy' },
          links: { self: `/api/v1/snapshots/${snapshotId}` },
          relationships: {
            build: {
              links: {
                self: `/api/v1/snapshots/${snapshotId}/relationships/build`,
                related: `/api/v1/snapshots/${snapshotId}/build`,
              },
            },
            screenshots: {
              links: {
                self: `/api/v1/snapshots/${snapshotId}/relationships/screenshots`,
                related: `/api/v1/snapshots/${snapshotId}/screenshots`,
              },
            },
            'missing-resources': {
              links: {
                self: `/api/v1/snapshots/${snapshotId}/relationships/missing-resources`,
                related: `/api/v1/snapshots/${snapshotId}/missing-resources`,
              },
              data: missingResources,
            },
          },
        },
        included: [],
      },
    ];

    nock('https://percy.io:443', { encodedQueryParams: true })
      .post(`/api/v1/builds/${buildId}/snapshots/`, {
        data: {
          type: 'snapshots',
          attributes: {
            name: 'testPercy',
            'enable-javascript': null,
            widths: null,
            'minimum-height': null,
          },
          relationships: {
            resources: {
              data: resources,
            },
          },
        },
      })
      .reply(reply[0], reply[1], []);
  }
  startBuild(options) {
    if (this.capture) {
      return;
    }
    const { buildId } = options;
    const resources = (options.resources || []).map(r => ({
      type: 'resources',
      id: r.id,
      attributes: {
        'resource-url': r.url,
        mimetype: r.mimetype,
        'is-root': r.root ? true : null,
      },
    }));
    const missingResources = (options.missing || []).map(sha => ({ type: 'resources', id: sha }));
    nock('https://percy.io:443', { encodedQueryParams: true })
      .post('/api/v1/projects/dummy-repo/dummy-project/builds/', {
        data: {
          type: 'builds',
          attributes: {
            branch: 'master',
            'target-branch': null,
            'commit-sha': null,
            'pull-request-number': null,
            'parallel-nonce': null,
            'parallel-total-shards': null,
          },
          relationships: { resources: { data: resources } },
{'fraction_non_alphanumeric': 0.1675, 'fraction_numerical': 0.009210526315789473, 'mean_word_length': 1.7650054565296471, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 8, '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': '1036177', 'n_tokens_mistral': 2325, 'n_tokens_neox': 2330, 'n_words': 400}