chore: Add window actions test
This commit is contained in:
5 files changed
+82
-12
No files matched your search
@@ -34,3 +34,5 @@ change-origin: Change Origin URL
|
||||
change-state: Change State
|
||||
close: Close
|
||||
toggle-secret: Toggle secret visibility
|
||||
minimize: Minimize
|
||||
fullscreen: Fullscreen
|
||||
@@ -32,13 +32,13 @@ export default class ApplicationRoute extends Route {
|
||||
|
||||
/**
|
||||
* Add OS config on controller.
|
||||
* Display OS container actions (minimize, fullscreen, close) for
|
||||
* Display OS window actions (minimize, fullscreen, close) for
|
||||
* Windows and Linux. Not enabled for MacOS.
|
||||
*/
|
||||
async setupController(controller) {
|
||||
controller.set('isMacOS', await this.ipc.invoke('isMacOS'));
|
||||
controller.set('isWindowsOS', await this.ipc.invoke('isWindowsOS'));
|
||||
controller.set('showFrameActions', !controller.isMacOS);
|
||||
controller.set('showWindowActions', !controller.isMacOS);
|
||||
}
|
||||
|
||||
// =actions
|
||||
|
||||
@@ -19,23 +19,26 @@
|
||||
{{/if}}
|
||||
|
||||
<header.utilities as |utilities|>
|
||||
{{#if this.showFrameActions}}
|
||||
{{#if this.showWindowActions}}
|
||||
<Rose::Button
|
||||
@iconOnly='flight-icons/x-16'
|
||||
@style='warning'
|
||||
class='button-window-close'
|
||||
title={{t 'actions.close'}}
|
||||
{{on 'click' (route-action 'close')}}
|
||||
/>
|
||||
<Rose::Button
|
||||
@iconOnly='box-outline'
|
||||
@iconOnly='flight-icons/square-16'
|
||||
@style='secondary'
|
||||
class='button-window-fullscreen'
|
||||
title={{t 'actions.fullscreen'}}
|
||||
{{on 'click' (route-action 'toggleFullScreen')}}
|
||||
/>
|
||||
<Rose::Button
|
||||
@iconOnly='minus-plain'
|
||||
@iconOnly='flight-icons/minus-16'
|
||||
@style='secondary'
|
||||
class='button-window-minimize'
|
||||
title={{t 'actions.minimize'}}
|
||||
{{on 'click' (route-action 'minimize')}}
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import { module, test } from 'qunit';
|
||||
import {
|
||||
visit,
|
||||
// currentURL,
|
||||
// fillIn,
|
||||
// click,
|
||||
find,
|
||||
//findAll,
|
||||
//getRootElement
|
||||
//setupOnerror,
|
||||
} from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'ember-qunit';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
// import { Response } from 'miragejs';
|
||||
// import a11yAudit from 'ember-a11y-testing/test-support/audit';
|
||||
import sinon from 'sinon';
|
||||
import {
|
||||
// currentSession,
|
||||
// authenticateSession,
|
||||
invalidateSession,
|
||||
} from 'ember-simple-auth/test-support';
|
||||
import { setupBrowserFakes } from 'ember-browser-services/test-support';
|
||||
|
||||
module('Acceptance | origin', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupBrowserFakes(hooks, { window: true });
|
||||
setupMirage(hooks);
|
||||
|
||||
const stubs = {
|
||||
ipcService: null,
|
||||
};
|
||||
|
||||
const urls = {
|
||||
origin: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
invalidateSession();
|
||||
|
||||
urls.origin = '/origin';
|
||||
|
||||
const ipcService = this.owner.lookup('service:ipc');
|
||||
stubs.ipcService = sinon.stub(ipcService, 'invoke');
|
||||
});
|
||||
|
||||
hooks.afterEach(function () {
|
||||
sinon.restore();
|
||||
});
|
||||
|
||||
test('visiting index on MacOS hides custom window actions', async function (assert) {
|
||||
assert.expect(3);
|
||||
stubs.ipcService.withArgs('isMacOS').returns(true);
|
||||
await visit(urls.origin);
|
||||
assert.notOk(find('.button-window-close'));
|
||||
assert.notOk(find('.button-window-minimize'));
|
||||
assert.notOk(find('.button-window-fullscreen'));
|
||||
});
|
||||
|
||||
test('visiting index on non-MacOS shows custom window actions', async function (assert) {
|
||||
assert.expect(3);
|
||||
stubs.ipcService.withArgs('isMacOS').returns(false);
|
||||
await visit(urls.origin);
|
||||
assert.ok(find('.button-window-close'));
|
||||
assert.ok(find('.button-window-minimize'));
|
||||
assert.ok(find('.button-window-fullscreen'));
|
||||
});
|
||||
});
|
||||
@@ -12,8 +12,8 @@ import {
|
||||
import { run, later } from '@ember/runloop';
|
||||
import { setupApplicationTest } from 'ember-qunit';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
//import { Response } from 'miragejs';
|
||||
//import a11yAudit from 'ember-a11y-testing/test-support/audit';
|
||||
// import { Response } from 'miragejs';
|
||||
import a11yAudit from 'ember-a11y-testing/test-support/audit';
|
||||
import {
|
||||
currentSession,
|
||||
authenticateSession,
|
||||
@@ -43,8 +43,6 @@ module('Acceptance | targets', function (hooks) {
|
||||
};
|
||||
|
||||
const urls = {
|
||||
index: '/',
|
||||
origin: '/origin',
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
@@ -113,7 +111,7 @@ module('Acceptance | targets', function (hooks) {
|
||||
invalidateSession();
|
||||
assert.expect(2);
|
||||
await visit(urls.targets);
|
||||
//await a11yAudit();
|
||||
await a11yAudit();
|
||||
assert.notOk(currentSession().isAuthenticated);
|
||||
assert.equal(currentURL(), urls.authenticate.methods.global);
|
||||
});
|
||||
@@ -123,11 +121,11 @@ module('Acceptance | targets', function (hooks) {
|
||||
// This later/cancelTimers technique allows us to test a page with
|
||||
// active polling. Normally an acceptance test waits for all runloop timers
|
||||
// to stop before returning from an awaited test, but polling means that
|
||||
// runloop timers exist indefinitely. We thus schedule a cancelation before
|
||||
// runloop timers exist indefinitely. We thus schedule a cancellation before
|
||||
// proceeding with our tests.
|
||||
later(async () => {
|
||||
run.cancelTimers();
|
||||
//await a11yAudit();
|
||||
await a11yAudit();
|
||||
assert.equal(currentURL(), urls.targets);
|
||||
}, 750);
|
||||
await visit(urls.targets);
|
||||
|
||||
Reference in new issue
Block a user