From 73002a38c45350e9d6e54c67378a6efcc1a1b435 Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Fri, 3 Sep 2021 11:32:17 -0400 Subject: [PATCH] chore: Add window actions test --- addons/core/translations/actions/en-us.yaml | 2 + ui/desktop/app/routes/application.js | 4 +- ui/desktop/app/templates/application.hbs | 9 ++- .../tests/acceptance/application-test.js | 67 +++++++++++++++++++ ui/desktop/tests/acceptance/targets-test.js | 12 ++-- 5 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 ui/desktop/tests/acceptance/application-test.js diff --git a/addons/core/translations/actions/en-us.yaml b/addons/core/translations/actions/en-us.yaml index 49bde4799..9b7a8561d 100644 --- a/addons/core/translations/actions/en-us.yaml +++ b/addons/core/translations/actions/en-us.yaml @@ -34,3 +34,5 @@ change-origin: Change Origin URL change-state: Change State close: Close toggle-secret: Toggle secret visibility +minimize: Minimize +fullscreen: Fullscreen diff --git a/ui/desktop/app/routes/application.js b/ui/desktop/app/routes/application.js index 311765c56..1ea18ec04 100644 --- a/ui/desktop/app/routes/application.js +++ b/ui/desktop/app/routes/application.js @@ -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 diff --git a/ui/desktop/app/templates/application.hbs b/ui/desktop/app/templates/application.hbs index 9ab80e5b8..24293ed6d 100644 --- a/ui/desktop/app/templates/application.hbs +++ b/ui/desktop/app/templates/application.hbs @@ -19,23 +19,26 @@ {{/if}} - {{#if this.showFrameActions}} + {{#if this.showWindowActions}} {{/if}} diff --git a/ui/desktop/tests/acceptance/application-test.js b/ui/desktop/tests/acceptance/application-test.js new file mode 100644 index 000000000..23a254e0e --- /dev/null +++ b/ui/desktop/tests/acceptance/application-test.js @@ -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')); + }); +}); diff --git a/ui/desktop/tests/acceptance/targets-test.js b/ui/desktop/tests/acceptance/targets-test.js index f92168c3a..1e8967543 100644 --- a/ui/desktop/tests/acceptance/targets-test.js +++ b/ui/desktop/tests/acceptance/targets-test.js @@ -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);