|
| 1 | +import { currentRouteName, visit } from '@ember/test-helpers'; |
| 2 | +import { module, test } from 'qunit'; |
| 3 | +import { setupAuthentication } from 'ilios-common'; |
| 4 | +import { setupApplicationTest } from 'frontend/tests/helpers'; |
| 5 | +import page from 'ilios-common/page-objects/dashboard-week'; |
| 6 | + |
| 7 | +module('Acceptance | performance', function (hooks) { |
| 8 | + setupApplicationTest(hooks); |
| 9 | + |
| 10 | + hooks.beforeEach(async function () { |
| 11 | + this.set('durationQuick', 1000); |
| 12 | + this.set('durationModerate', 2000); |
| 13 | + |
| 14 | + this.school = this.server.create('school'); |
| 15 | + this.user = await setupAuthentication({ school: this.school }); |
| 16 | + }); |
| 17 | + |
| 18 | + test('/dashboard/week', async function (assert) { |
| 19 | + let start = performance.now(); |
| 20 | + |
| 21 | + await page.visit({ show: 'week' }); |
| 22 | + |
| 23 | + let end = performance.now(); |
| 24 | + let duration = end - start; |
| 25 | + |
| 26 | + assert.strictEqual(currentRouteName(), 'dashboard.week'); |
| 27 | + assert.ok(duration < this.durationQuick, `Render time was ${duration}ms`); |
| 28 | + }); |
| 29 | + |
| 30 | + test('/courses', async function (assert) { |
| 31 | + let start = performance.now(); |
| 32 | + |
| 33 | + await visit('/courses'); |
| 34 | + |
| 35 | + let end = performance.now(); |
| 36 | + let duration = end - start; |
| 37 | + |
| 38 | + assert.strictEqual(currentRouteName(), 'courses'); |
| 39 | + assert.ok(duration < this.durationModerate, `Render time was ${duration}ms`); |
| 40 | + }); |
| 41 | + |
| 42 | + test('/learnergroups', async function (assert) { |
| 43 | + let start = performance.now(); |
| 44 | + |
| 45 | + await visit('/learnergroups'); |
| 46 | + |
| 47 | + let end = performance.now(); |
| 48 | + let duration = end - start; |
| 49 | + |
| 50 | + assert.strictEqual(currentRouteName(), 'learner-groups'); |
| 51 | + assert.ok(duration < this.durationQuick, `Render time was ${duration}ms`); |
| 52 | + }); |
| 53 | + |
| 54 | + test('/instructorgroups', async function (assert) { |
| 55 | + let start = performance.now(); |
| 56 | + |
| 57 | + await visit('/instructorgroups'); |
| 58 | + |
| 59 | + let end = performance.now(); |
| 60 | + let duration = end - start; |
| 61 | + |
| 62 | + assert.strictEqual(currentRouteName(), 'instructor-groups'); |
| 63 | + assert.ok(duration < this.durationQuick, `Render time was ${duration}ms`); |
| 64 | + }); |
| 65 | + |
| 66 | + test('/schools', async function (assert) { |
| 67 | + let start = performance.now(); |
| 68 | + |
| 69 | + await visit('/schools'); |
| 70 | + |
| 71 | + let end = performance.now(); |
| 72 | + let duration = end - start; |
| 73 | + |
| 74 | + assert.strictEqual(currentRouteName(), 'schools'); |
| 75 | + assert.ok(duration < this.durationQuick, `Render time was ${duration}ms`); |
| 76 | + }); |
| 77 | + |
| 78 | + test('/programs', async function (assert) { |
| 79 | + let start = performance.now(); |
| 80 | + |
| 81 | + await visit('/programs'); |
| 82 | + |
| 83 | + let end = performance.now(); |
| 84 | + let duration = end - start; |
| 85 | + |
| 86 | + assert.strictEqual(currentRouteName(), 'programs'); |
| 87 | + assert.ok(duration < this.durationQuick, `Render time was ${duration}ms`); |
| 88 | + }); |
| 89 | + |
| 90 | + test('/reports', async function (assert) { |
| 91 | + let start = performance.now(); |
| 92 | + |
| 93 | + await visit('/reports'); |
| 94 | + |
| 95 | + let end = performance.now(); |
| 96 | + let duration = end - start; |
| 97 | + |
| 98 | + assert.strictEqual(currentRouteName(), 'reports'); |
| 99 | + assert.ok(duration < this.durationQuick, `Render time was ${duration}ms`); |
| 100 | + }); |
| 101 | + |
| 102 | + test('/admin', async function (assert) { |
| 103 | + let start = performance.now(); |
| 104 | + |
| 105 | + await visit('/admin'); |
| 106 | + |
| 107 | + let end = performance.now(); |
| 108 | + let duration = end - start; |
| 109 | + |
| 110 | + assert.strictEqual(currentRouteName(), 'admin'); |
| 111 | + assert.ok(duration < this.durationQuick, `Render time was ${duration}ms`); |
| 112 | + }); |
| 113 | + |
| 114 | + test('/curricum-inventory-reports', async function (assert) { |
| 115 | + let start = performance.now(); |
| 116 | + |
| 117 | + await visit('/curricum-inventory-reports'); |
| 118 | + |
| 119 | + let end = performance.now(); |
| 120 | + let duration = end - start; |
| 121 | + |
| 122 | + assert.ok(duration < this.durationQuick, `Render time was ${duration}ms`); |
| 123 | + }); |
| 124 | +}); |
0 commit comments