Repository: hashicorp/vault
File: ui/tests/integration/components/recovery/page/snapshots-test.js (JavaScript)

Code before:
    };
    this.version = this.owner.lookup('service:version');
    this.version.type = 'enterprise';
  });

  test('it displays empty state in CE', async function (assert) {
    this.version.type = 'community';
    await render(hbs`<Recovery::Page::Snapshots @model={{this.model}}/>`);
    assert
      .dom(GENERAL.emptyStateTitle)
      .hasText('Secrets Recovery is an enterprise feature', 'CE empty state title renders');
    assert
      .dom(GENERAL.emptyStateMessage)
      .hasText(
        'Secrets Recovery allows you to restore accidentally deleted or lost secrets from a snapshot. The snapshots can be provided via upload or loaded from external storage.',
        'CE empty state message renders'
      );
    assert
      .dom(GENERAL.emptyStateActions)
      .hasText('Learn more about upgrading', 'CE empty state action renders');

    assert.dom(SELECTORS.badge('enterprise')).exists();
  });

  test('it displays empty state in non root namespace', async function (assert) {
    this.nsService = this.owner.lookup('service:namespace');
    this.nsService.path = 'parent1/child1';
    this.server.get('/sys/internal/ui/namespaces', () => {
      return { data: { keys: ['parent1/', 'parent1/child1/'] } };
    });

    await render(hbs`<Recovery::Page::Snapshots @model={{this.model}}/>`);

    assert
      .dom(GENERAL.emptyStateTitle)
      .hasText('Snapshot upload is restricted', 'non root namespace empty state title renders');
    assert
      .dom(GENERAL.emptyStateMessage)
      .hasText(
        'Snapshot uploading is only available in root namespace. Please navigate to root and upload your snapshot. ',
        'non root empty state message renders'
      );
    assert
      .dom(GENERAL.emptyStateActions)
      .hasText('Take me to root namespace', 'non root empty state action renders');

    this.nsService.path = '';
  });

  test('it displays empty state when user cannot load snapshot', async function (assert) {
    await render(hbs`<Recovery::Page::Snapshots @model={{this.model}}/>`);

Review comment (suggestion):
this should be a const so it's just updated for this test, then I think we can remove the `this.nsService.path = ''` below

Code after:
    };
    this.version = this.owner.lookup('service:version');
    this.version.type = 'enterprise';
  });

  test('it displays empty state in CE', async function (assert) {
    this.version.type = 'community';
    await render(hbs`<Recovery::Page::Snapshots @model={{this.model}}/>`);
    assert
      .dom(GENERAL.emptyStateTitle)
      .hasText('Secrets Recovery is an enterprise feature', 'CE empty state title renders');
    assert
      .dom(GENERAL.emptyStateMessage)
      .hasText(
        'Secrets Recovery allows you to restore accidentally deleted or lost secrets from a snapshot. The snapshots can be provided via upload or loaded from external storage.',
        'CE empty state message renders'
      );
    assert
      .dom(GENERAL.emptyStateActions)
      .hasText('Learn more about upgrading', 'CE empty state action renders');

    assert.dom(SELECTORS.badge('enterprise')).exists();
  });

  test('it displays empty state in non root namespace', async function (assert) {
    const nsService = this.owner.lookup('service:namespace');
    nsService.setNamespace('test-ns');

    await render(hbs`<Recovery::Page::Snapshots @model={{this.model}}/>`);

    assert
      .dom(GENERAL.emptyStateTitle)
      .hasText('Snapshot upload is restricted', 'non root namespace empty state title renders');
    assert
      .dom(GENERAL.emptyStateMessage)
      .hasText(
        'Snapshot uploading is only available in root namespace. Please navigate to root and upload your snapshot. ',
        'non root empty state message renders'
      );
    assert
      .dom(GENERAL.emptyStateActions)
      .hasText('Take me to root namespace', 'non root empty state action renders');
  });

  test('it displays empty state when user cannot load snapshot', async function (assert) {
    await render(hbs`<Recovery::Page::Snapshots @model={{this.model}}/>`);
    assert.dom(GENERAL.emptyStateTitle).hasText('No snapshot available', 'empty state title renders');
    assert
      .dom(GENERAL.emptyStateMessage)
      .hasText(
        'Ready to restore secrets? Please contact your admin to either upload a snapshot or grant you uploading permissions to get started.',