Files
threshold-ui/ui/desktop/tests/acceptance/application-test.js
T

77 lines
2.5 KiB
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
2021-09-03 11:32:17 -04:00
import { module, test } from 'qunit';
2022-07-27 10:25:01 -07:00
import { visit, find } from '@ember/test-helpers';
2021-09-03 11:32:17 -04:00
import { setupApplicationTest } from 'ember-qunit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import sinon from 'sinon';
2022-07-27 10:25:01 -07:00
import { invalidateSession } from 'ember-simple-auth/test-support';
2021-09-03 11:32:17 -04:00
import { setupBrowserFakes } from 'ember-browser-services/test-support';
2022-07-27 10:25:01 -07:00
module('Acceptance | index', function (hooks) {
2021-09-03 11:32:17 -04:00
setupApplicationTest(hooks);
setupBrowserFakes(hooks, { window: true });
setupMirage(hooks);
const stubs = {
ipcService: null,
};
const urls = {
2022-07-27 10:25:01 -07:00
clusterUrl: null,
2021-09-03 11:32:17 -04:00
};
hooks.beforeEach(function () {
invalidateSession();
2022-07-27 10:25:01 -07:00
urls.clusterUrl = '/cluster-url';
2021-09-03 11:32:17 -04:00
const ipcService = this.owner.lookup('service:ipc');
stubs.ipcService = sinon.stub(ipcService, 'invoke');
});
hooks.afterEach(function () {
sinon.restore();
});
2021-09-16 10:33:56 -04:00
test('visiting index with chrome disabled hides custom window actions', async function (assert) {
assert.expect(3);
stubs.ipcService.withArgs('showWindowActions').returns(false);
2022-07-27 10:25:01 -07:00
await visit(urls.clusterUrl);
2021-09-15 10:54:28 -04:00
assert.notOk(find('.button-window-close'), 'Window close button');
assert.notOk(find('.button-window-minimize'), 'Window minimize button');
assert.notOk(find('.button-window-fullscreen'), 'Window fullscreen button');
2021-09-16 10:33:56 -04:00
});
test('visiting index with chrome enabled shows custom window actions', async function (assert) {
assert.expect(3);
stubs.ipcService.withArgs('showWindowActions').returns(true);
2022-07-27 10:25:01 -07:00
await visit(urls.clusterUrl);
2021-09-16 10:33:56 -04:00
assert.ok(find('.button-window-close'), 'Window close button');
assert.ok(find('.button-window-minimize'), 'Window minimize button');
assert.ok(find('.button-window-fullscreen'), 'Window fullscreen button');
});
test('visiting index with MacOS chrome enabled', async function (assert) {
assert.expect(1);
stubs.ipcService.withArgs('hasMacOSChrome').returns(true);
2022-07-27 10:25:01 -07:00
await visit(urls.clusterUrl);
2021-09-15 10:54:28 -04:00
assert.ok(
find('.rose-header.header-cushion'),
'Adds header padding around native window actions'
);
2021-09-03 11:32:17 -04:00
});
2021-09-16 10:33:56 -04:00
test('visiting index with MacOS chrome disabled', async function (assert) {
assert.expect(1);
stubs.ipcService.withArgs('hasMacOSChrome').returns(false);
2022-07-27 10:25:01 -07:00
await visit(urls.clusterUrl);
2021-09-15 10:54:28 -04:00
assert.notOk(
find('.rose-header.header-cushion'),
2021-09-16 10:33:56 -04:00
'Does not add header padding around native window actions'
2021-09-15 10:54:28 -04:00
);
2021-09-03 11:32:17 -04:00
});
});