diff --git a/tests/acceptance/crate-test.js b/tests/acceptance/crate-test.js index 0eb22cce8d6..c1f53492cdd 100644 --- a/tests/acceptance/crate-test.js +++ b/tests/acceptance/crate-test.js @@ -4,6 +4,7 @@ import { setupApplicationTest } from 'ember-qunit'; import { click, fillIn, currentURL, currentRouteName, visit } from '@ember/test-helpers'; import a11yAudit from 'ember-a11y-testing/test-support/audit'; import axeConfig from '../axe-config'; +import { title } from '../helpers/dom'; import setupMirage from '../helpers/setup-mirage'; import { percySnapshot } from 'ember-percy'; @@ -66,7 +67,7 @@ module('Acceptance | crate page', function(hooks) { await click('[data-test-just-updated] [data-test-crate-link="0"]'); assert.equal(currentURL(), '/crates/nanomsg'); - assert.equal(document.title, 'nanomsg - crates.io: Rust Package Registry'); + assert.equal(title(), 'nanomsg - crates.io: Rust Package Registry'); }); test('visiting /crates/nanomsg', async function(assert) { @@ -78,7 +79,7 @@ module('Acceptance | crate page', function(hooks) { assert.equal(currentURL(), '/crates/nanomsg'); assert.equal(currentRouteName(), 'crate.index'); - assert.equal(document.title, 'nanomsg - crates.io: Rust Package Registry'); + assert.equal(title(), 'nanomsg - crates.io: Rust Package Registry'); assert.dom('[data-test-heading] [data-test-crate-name]').hasText('nanomsg'); assert.dom('[data-test-heading] [data-test-crate-version]').hasText('0.6.1'); @@ -93,7 +94,7 @@ module('Acceptance | crate page', function(hooks) { assert.equal(currentURL(), '/crates/nanomsg/'); assert.equal(currentRouteName(), 'crate.index'); - assert.equal(document.title, 'nanomsg - crates.io: Rust Package Registry'); + assert.equal(title(), 'nanomsg - crates.io: Rust Package Registry'); assert.dom('[data-test-heading] [data-test-crate-name]').hasText('nanomsg'); assert.dom('[data-test-heading] [data-test-crate-version]').hasText('0.6.1'); @@ -108,7 +109,7 @@ module('Acceptance | crate page', function(hooks) { assert.equal(currentURL(), '/crates/nanomsg/0.6.0'); assert.equal(currentRouteName(), 'crate.version'); - assert.equal(document.title, 'nanomsg - crates.io: Rust Package Registry'); + assert.equal(title(), 'nanomsg - crates.io: Rust Package Registry'); assert.dom('[data-test-heading] [data-test-crate-name]').hasText('nanomsg'); assert.dom('[data-test-heading] [data-test-crate-version]').hasText('0.6.0'); diff --git a/tests/acceptance/crates-test.js b/tests/acceptance/crates-test.js index ab4ad585fe1..b5ceeb449e6 100644 --- a/tests/acceptance/crates-test.js +++ b/tests/acceptance/crates-test.js @@ -3,6 +3,7 @@ import { setupApplicationTest } from 'ember-qunit'; import { click, currentURL, visit } from '@ember/test-helpers'; import a11yAudit from 'ember-a11y-testing/test-support/audit'; import axeConfig from '../axe-config'; +import { title } from '../helpers/dom'; import setupMirage from '../helpers/setup-mirage'; import { percySnapshot } from 'ember-percy'; @@ -42,7 +43,7 @@ module('Acceptance | crates page', function(hooks) { await click('[data-test-all-crates-link]'); assert.equal(currentURL(), '/crates'); - assert.equal(document.title, 'Crates - crates.io: Rust Package Registry'); + assert.equal(title(), 'Crates - crates.io: Rust Package Registry'); }); test('visiting the crates page directly', async function(assert) { @@ -52,7 +53,7 @@ module('Acceptance | crates page', function(hooks) { await click('[data-test-all-crates-link]'); assert.equal(currentURL(), '/crates'); - assert.equal(document.title, 'Crates - crates.io: Rust Package Registry'); + assert.equal(title(), 'Crates - crates.io: Rust Package Registry'); }); test('listing crates', async function(assert) { diff --git a/tests/acceptance/front-page-test.js b/tests/acceptance/front-page-test.js index 173a6d79e6a..f31eeb9a0b5 100644 --- a/tests/acceptance/front-page-test.js +++ b/tests/acceptance/front-page-test.js @@ -3,6 +3,7 @@ import { setupApplicationTest } from 'ember-qunit'; import { currentURL, visit } from '@ember/test-helpers'; import a11yAudit from 'ember-a11y-testing/test-support/audit'; import axeConfig from '../axe-config'; +import { title } from '../helpers/dom'; import setupMirage from '../helpers/setup-mirage'; import { percySnapshot } from 'ember-percy'; @@ -25,7 +26,7 @@ module('Acceptance | front page', function(hooks) { await visit('/'); assert.equal(currentURL(), '/'); - assert.equal(document.title, 'crates.io: Rust Package Registry'); + assert.equal(title(), 'crates.io: Rust Package Registry'); assert.dom('[data-test-install-cargo-link]').exists(); assert.dom('[data-test-all-crates-link]').exists(); diff --git a/tests/acceptance/search-test.js b/tests/acceptance/search-test.js index dfe168ba0e5..08093da8580 100644 --- a/tests/acceptance/search-test.js +++ b/tests/acceptance/search-test.js @@ -4,6 +4,7 @@ import { fillIn, currentURL, triggerEvent, visit, blur } from '@ember/test-helpe import a11yAudit from 'ember-a11y-testing/test-support/audit'; import { triggerKeyDown, triggerKeyPress } from 'ember-keyboard'; import axeConfig from '../axe-config'; +import { title } from '../helpers/dom'; import setupMirage from '../helpers/setup-mirage'; import { percySnapshot } from 'ember-percy'; @@ -30,7 +31,7 @@ module('Acceptance | search', function(hooks) { await triggerEvent('[data-test-search-form]', 'submit'); assert.equal(currentURL(), '/search?q=rust'); - assert.equal(document.title, "Search Results for 'rust' - crates.io: Rust Package Registry"); + assert.equal(title(), "Search Results for 'rust' - crates.io: Rust Package Registry"); assert.dom('[data-test-heading]').hasText("Search Results for 'rust'"); assert.dom('[data-test-search-nav]').hasText('Displaying 1-8 of 8 total results'); @@ -53,7 +54,7 @@ module('Acceptance | search', function(hooks) { await visit('/search?q=rust'); assert.equal(currentURL(), '/search?q=rust'); - assert.equal(document.title, "Search Results for 'rust' - crates.io: Rust Package Registry"); + assert.equal(title(), "Search Results for 'rust' - crates.io: Rust Package Registry"); assert.dom('[data-test-search-input]').hasValue('rust'); assert.dom('[data-test-heading]').hasText("Search Results for 'rust'"); diff --git a/tests/helpers/dom.js b/tests/helpers/dom.js new file mode 100644 index 00000000000..623190bdc17 --- /dev/null +++ b/tests/helpers/dom.js @@ -0,0 +1,8 @@ +// Because Testem adds own title element +// https://github.com/adopted-ember-addons/ember-page-title/blob/4732cdb2c9f673e4714334b33c5b4c5056dfcb8f/tests/acceptance/posts-test.js#L11 +function title() { + let titles = document.head.getElementsByTagName('title'); + return titles[titles.length - 1].innerText; +} + +export { title };