Files
threshold-ui/ui/admin/tests/acceptance/develop-test.js
T

47 lines
1.5 KiB
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
2023-03-17 14:34:37 -07:00
import { module, test } from 'qunit';
import { visit, getContext } from '@ember/test-helpers';
import { setupApplicationTest } from 'admin/tests/helpers';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
2025-04-14 14:27:02 -07:00
import { setupIndexedDb } from 'api/test-support/helpers/indexed-db';
import { authenticateSession } from 'ember-simple-auth/test-support';
2023-03-17 14:34:37 -07:00
module('Acceptance | develop', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
2025-04-14 14:27:02 -07:00
setupIndexedDb(hooks);
2023-03-17 14:34:37 -07:00
let featuresService;
2025-03-10 13:35:13 -05:00
const DEV_TOGGLE_SELECTOR = '[data-test-dev-edition-toggle]';
2023-03-17 14:34:37 -07:00
2025-04-14 14:27:02 -07:00
hooks.beforeEach(async function () {
2023-03-17 14:34:37 -07:00
const { owner } = getContext();
featuresService = owner.lookup('service:features');
2025-04-14 14:27:02 -07:00
this.server.create('scope', { id: 'global' });
this.server.create('scope', {
type: 'org',
scope: { id: 'global', type: 'global' },
});
await authenticateSession({});
2023-03-17 14:34:37 -07:00
});
test('edition toggle is hidden when `dev-edition-toggle` is false', async function (assert) {
await visit('/');
2025-03-10 13:35:13 -05:00
2023-03-17 14:34:37 -07:00
assert.false(featuresService.isEnabled('dev-edition-toggle'));
2025-03-10 13:35:13 -05:00
assert.dom(DEV_TOGGLE_SELECTOR).doesNotExist();
2023-03-17 14:34:37 -07:00
});
test('edition toggle is visible when `dev-edition-toggle` is true', async function (assert) {
assert.false(featuresService.isEnabled('dev-edition-toggle'));
featuresService.enable('dev-edition-toggle');
2025-03-10 13:35:13 -05:00
2023-03-17 14:34:37 -07:00
await visit('/');
2025-03-10 13:35:13 -05:00
assert.dom(DEV_TOGGLE_SELECTOR).isVisible();
2023-03-17 14:34:37 -07:00
});
});