Repository: hashicorp/vault
File: ui/tests/acceptance/clients/counts/overview-test.js (JavaScript)

Code before:
    assert
      .dom(CLIENT_COUNT.dateRange.dateDisplay('end'))
      .hasText('January 2024', 'billing start month is correctly parsed from license');
    assert.dom(CLIENT_COUNT.attributionBlock()).exists({ count: 2 });
    assert
      .dom(CHARTS.container('Vault client counts'))
      .exists('Shows running totals with monthly breakdown charts');
    assert
      .dom(`${CHARTS.container('Vault client counts')} ${CHARTS.xAxisLabel}`)
      .hasText('7/23', 'x-axis labels start with billing start date');
    assert.dom(CHARTS.xAxisLabel).exists({ count: 7 }, 'chart months matches query');
  });

  // TODO revisit once CE changes are finalized
  test.skip('it should update charts when querying date ranges', async function (assert) {
    // query for single, historical month with no new counts (July 2023)
    const licenseStartMonth = format(LICENSE_START, 'yyyy-MM');
    const upgradeMonth = format(UPGRADE_DATE, 'yyyy-MM');
    await click(CLIENT_COUNT.dateRange.edit);
    await fillIn(CLIENT_COUNT.dateRange.editDate('start'), licenseStartMonth);
    await fillIn(CLIENT_COUNT.dateRange.editDate('end'), licenseStartMonth);

    await click(GENERAL.saveButton);
    assert
      .dom(CLIENT_COUNT.usageStats('Vault client counts'))
      .doesNotExist('running total single month stat boxes do not show');
    assert
      .dom(CHARTS.container('Vault client counts'))
      .doesNotExist('running total month over month charts do not show');
    assert.dom(CLIENT_COUNT.attributionBlock()).exists({ count: 2 });
    assert.dom(CHARTS.container('namespace')).exists('namespace attribution chart shows');
    assert.dom(CHARTS.container('mount')).exists('mount attribution chart shows');

    // reset to billing period
    await click(CLIENT_COUNT.dateRange.edit);
    await click(CLIENT_COUNT.dateRange.reset);
    await click(GENERAL.saveButton);

    // change to start on month/year of upgrade to 1.10
    await click(CLIENT_COUNT.dateRange.edit);
    await fillIn(CLIENT_COUNT.dateRange.editDate('start'), upgradeMonth);
    await click(GENERAL.saveButton);

    assert
      .dom(CLIENT_COUNT.dateRange.dateDisplay('start'))
      .hasText('September 2023', 'billing start month is correctly parsed from license');
    assert
      .dom(CLIENT_COUNT.dateRange.dateDisplay('end'))
      .hasText('January 2024', 'billing start month is correctly parsed from license');
    assert.dom(CLIENT_COUNT.attributionBlock()).exists({ count: 2 });
    assert

Review comment (suggestion):
Just an FYI there's a `subMonths` [function that exists ](https://date-fns.org/v4.1.0/docs/subMonths) as well

Code after:
        'Shows warning from API about client count estimations'
      );
    assert
      .dom(CLIENT_COUNT.dateRange.dateDisplay('start'))
      .hasText('July 2023', 'billing start month is correctly parsed from license');
    assert
      .dom(CLIENT_COUNT.dateRange.dateDisplay('end'))
      .hasText('January 2024', 'billing start month is correctly parsed from license');
    assert.dom(CLIENT_COUNT.attributionBlock()).exists({ count: 2 });
    assert
      .dom(CHARTS.container('Vault client counts'))
      .exists('Shows running totals with monthly breakdown charts');
    assert
      .dom(`${CHARTS.container('Vault client counts')} ${CHARTS.xAxisLabel}`)
      .hasText('7/23', 'x-axis labels start with billing start date');
    assert.dom(CHARTS.xAxisLabel).exists({ count: 7 }, 'chart months matches query');
  });

  test('it should update charts when querying date ranges', async function (assert) {
    // query for single, historical month with no new counts (July 2023)
    const service = this.owner.lookup('service:version');
    service.type = 'community';

    const licenseStartMonth = format(LICENSE_START, 'yyyy-MM');
    const upgradeMonth = format(UPGRADE_DATE, 'yyyy-MM');
    const endMonth = format(STATIC_PREVIOUS_MONTH, 'yyyy-MM');
    await click(CLIENT_COUNT.dateRange.edit);
    await fillIn(CLIENT_COUNT.dateRange.editDate('start'), licenseStartMonth);
    await fillIn(CLIENT_COUNT.dateRange.editDate('end'), licenseStartMonth);

    await click(GENERAL.saveButton);
    assert
      .dom(CLIENT_COUNT.usageStats('Vault client counts'))
      .doesNotExist('running total single month stat boxes do not show');
    assert
      .dom(CHARTS.container('Vault client counts'))
      .doesNotExist('running total month over month charts do not show');
    assert.dom(CLIENT_COUNT.attributionBlock()).exists({ count: 2 });
    assert.dom(CHARTS.container('namespace')).exists('namespace attribution chart shows');
    assert.dom(CHARTS.container('mount')).exists('mount attribution chart shows');

    // change to start on month/year of upgrade to 1.10
    await click(CLIENT_COUNT.dateRange.edit);
    await fillIn(CLIENT_COUNT.dateRange.editDate('start'), upgradeMonth);
    await fillIn(CLIENT_COUNT.dateRange.editDate('end'), endMonth);
    await click(GENERAL.saveButton);
    assert
      .dom(CLIENT_COUNT.dateRange.dateDisplay('start'))
      .hasText('September 2023', 'billing start month is correctly parsed from license');
    assert.dom(CLIENT_COUNT.attributionBlock()).exists({ count: 2 });
    assert