Fixed Admin test failures when running in Safari

no issue

- Safari's `innerText` sometimes includes a trailing `\n` depending on the markup used so we need to use `.to.have.rendered.trimmed.text()`
- reproducible when running tests via http://localhost:4200/tests (we don't yet run in Safari via our testem config)
This commit is contained in:
Kevin Ansfield 2024-08-21 12:51:51 +01:00
parent fc501add94
commit b01d4287ad
2 changed files with 19 additions and 19 deletions

View File

@ -645,7 +645,7 @@ describe('Acceptance: Posts / Pages', function () {
expect(find('[data-test-nav-custom="posts-My posts"]')).to.exist; expect(find('[data-test-nav-custom="posts-My posts"]')).to.exist;
// screen has default title and sidebar is showing inactive custom view // screen has default title and sidebar is showing inactive custom view
expect(find('[data-test-screen-title]')).to.have.rendered.text('Posts'); expect(find('[data-test-screen-title]')).to.have.rendered.trimmed.text('Posts');
expect(find('[data-test-nav="posts"]')).to.have.class('active'); expect(find('[data-test-nav="posts"]')).to.have.class('active');
// clicking sidebar custom view link works // clicking sidebar custom view link works
@ -657,7 +657,7 @@ describe('Acceptance: Posts / Pages', function () {
// clicking the main posts link resets // clicking the main posts link resets
await click('[data-test-nav="posts"]'); await click('[data-test-nav="posts"]');
expect(currentURL()).to.equal('/posts'); expect(currentURL()).to.equal('/posts');
expect(find('[data-test-screen-title]')).to.have.rendered.text('Posts'); expect(find('[data-test-screen-title]')).to.have.rendered.trimmed.text('Posts');
expect(find('[data-test-nav-custom="posts-Scheduled"]')).to.not.have.class('active'); expect(find('[data-test-nav-custom="posts-Scheduled"]')).to.not.have.class('active');
// changing a filter to match a custom view shows custom view // changing a filter to match a custom view shows custom view

View File

@ -105,17 +105,17 @@ describe('Acceptance: Publish flow', function () {
expect(find('[data-test-publish-flow="confirm"]'), 'confirm step').to.exist; expect(find('[data-test-publish-flow="confirm"]'), 'confirm step').to.exist;
expect(find('[data-test-text="confirm-details"]'), 'confirmation text') expect(find('[data-test-text="confirm-details"]'), 'confirmation text')
.to.have.rendered.text('Your post will be published on your site.'); .to.have.rendered.trimmed.text('Your post will be published on your site.');
expect(find('[data-test-button="confirm-publish"]'), 'publish button text') expect(find('[data-test-button="confirm-publish"]'), 'publish button text')
.to.have.rendered.text('Publish post, right now'); .to.have.rendered.trimmed.text('Publish post, right now');
await click('[data-test-button="confirm-publish"]'); await click('[data-test-button="confirm-publish"]');
expect(post.status, 'post status after publish').to.equal('published'); expect(post.status, 'post status after publish').to.equal('published');
expect(find('[data-test-publish-flow="complete"]'), 'complete step').to.exist; expect(find('[data-test-publish-flow="complete"]'), 'complete step').to.exist;
expect(find('[data-test-complete-title]'), 'complete title').to.have.rendered.text('Boom. Its out there. Thats 1 post published, keep going!'); expect(find('[data-test-complete-title]'), 'complete title').to.have.rendered.trimmed.text('Boom. Its out there. Thats 1 post published, keep going!');
expect(find('[data-test-complete-bookmark]'), 'bookmark card').to.exist; expect(find('[data-test-complete-bookmark]'), 'bookmark card').to.exist;
// "revert to draft" only shown for scheduled posts // "revert to draft" only shown for scheduled posts
@ -133,7 +133,7 @@ describe('Acceptance: Publish flow', function () {
await click('[data-test-button="update-flow"]'); await click('[data-test-button="update-flow"]');
expect(find('[data-test-modal="update-flow"]'), 'update flow modal').to.exist; expect(find('[data-test-modal="update-flow"]'), 'update flow modal').to.exist;
expect(find('[data-test-update-flow-title]')).to.have.rendered.text('This post has been published'); expect(find('[data-test-update-flow-title]')).to.have.rendered.trimmed.text('This post has been published');
expect(find('[data-test-update-flow-confirmation]')).to.contain.rendered.text('Your post was published on your site'); expect(find('[data-test-update-flow-confirmation]')).to.contain.rendered.text('Your post was published on your site');
const savedPublishAt = moment(post.publishedAt).utc(); const savedPublishAt = moment(post.publishedAt).utc();
expect(find('[data-test-update-flow-confirmation]')).to.contain.rendered.text(`on ${savedPublishAt.format('D MMM YYYY')} at ${savedPublishAt.format('HH:mm')}`); expect(find('[data-test-update-flow-confirmation]')).to.contain.rendered.text(`on ${savedPublishAt.format('D MMM YYYY')} at ${savedPublishAt.format('HH:mm')}`);
@ -257,7 +257,7 @@ describe('Acceptance: Publish flow', function () {
expect(find('[data-test-text="confirm-details"]')).to.contain.rendered expect(find('[data-test-text="confirm-details"]')).to.contain.rendered
.text('will be published on your site, and delivered to all 7 subscribers.'); .text('will be published on your site, and delivered to all 7 subscribers.');
expect(find('[data-test-button="confirm-publish"]')).to.have.rendered expect(find('[data-test-button="confirm-publish"]')).to.have.rendered.trimmed
.text('Publish & send, right now'); .text('Publish & send, right now');
await click('[data-test-button="confirm-publish"]'); await click('[data-test-button="confirm-publish"]');
@ -313,7 +313,7 @@ describe('Acceptance: Publish flow', function () {
expect(find('[data-test-text="confirm-details"]')).to.contain.rendered expect(find('[data-test-text="confirm-details"]')).to.contain.rendered
.text('will be published on your site, and delivered to all 1 subscriber of Second newsletter.'); .text('will be published on your site, and delivered to all 1 subscriber of Second newsletter.');
expect(find('[data-test-button="confirm-publish"]')).to.have.rendered expect(find('[data-test-button="confirm-publish"]')).to.have.rendered.trimmed
.text('Publish & send, right now'); .text('Publish & send, right now');
await click('[data-test-button="confirm-publish"]'); await click('[data-test-button="confirm-publish"]');
@ -328,7 +328,7 @@ describe('Acceptance: Publish flow', function () {
await visit(`/editor/post/${post.id}`); await visit(`/editor/post/${post.id}`);
await click('[data-test-button="publish-flow"]'); await click('[data-test-button="publish-flow"]');
expect(find('[data-test-setting="publish-at"] [data-test-setting-title]')).to.have.rendered expect(find('[data-test-setting="publish-at"] [data-test-setting-title]')).to.have.rendered.trimmed
.text('Right now'); .text('Right now');
const siteTz = this.server.db.settings.findBy({key: 'timezone'}).value; const siteTz = this.server.db.settings.findBy({key: 'timezone'}).value;
@ -356,16 +356,16 @@ describe('Acceptance: Publish flow', function () {
await blur('[data-test-setting="publish-at"] [data-test-date-time-picker-time-input]'); await blur('[data-test-setting="publish-at"] [data-test-date-time-picker-time-input]');
expect(find('[data-test-setting="publish-at"] [data-test-date-time-picker-time-input]')).to.have.value(newDate.format('HH:mm')); expect(find('[data-test-setting="publish-at"] [data-test-date-time-picker-time-input]')).to.have.value(newDate.format('HH:mm'));
expect(find('[data-test-setting="publish-at"] [data-test-setting-title]'), 'publish-at title after change').to.have.rendered expect(find('[data-test-setting="publish-at"] [data-test-setting-title]'), 'publish-at title after change').to.have.rendered.trimmed
.text('In 4 days'); .text('In 4 days');
await click('[data-test-button="continue"]'); await click('[data-test-button="continue"]');
// has correct confirm text // has correct confirm text
expect(find('[data-test-text="confirm-details"]')).to.have.rendered expect(find('[data-test-text="confirm-details"]')).to.have.rendered.trimmed
.text(`On ${newDate.format('D MMM YYYY')} at ${newDate.format('HH:mm')} your post will be published on your site, and delivered to all 7 subscribers.`); .text(`On ${newDate.format('D MMM YYYY')} at ${newDate.format('HH:mm')} your post will be published on your site, and delivered to all 7 subscribers.`);
expect(find('[data-test-button="confirm-publish"]')).to.have.rendered expect(find('[data-test-button="confirm-publish"]')).to.have.rendered.trimmed
.text(`Publish & send, on ${newDate.format('MMMM Do')}`); .text(`Publish & send, on ${newDate.format('MMMM Do')}`);
await click('[data-test-button="confirm-publish"]'); await click('[data-test-button="confirm-publish"]');
@ -385,16 +385,16 @@ describe('Acceptance: Publish flow', function () {
await click('[data-test-setting="publish-type"] [data-test-setting-title]'); await click('[data-test-setting="publish-type"] [data-test-setting-title]');
await click('[data-test-publish-type="send"]'); await click('[data-test-publish-type="send"]');
expect(find('[data-test-setting="publish-type"] [data-test-setting-title]')).to.have.rendered expect(find('[data-test-setting="publish-type"] [data-test-setting-title]')).to.have.rendered.trimmed
.text('Email'); .text('Email');
await click('[data-test-button="continue"]'); await click('[data-test-button="continue"]');
// has correct confirm text // has correct confirm text
expect(find('[data-test-text="confirm-details"]')).to.have.rendered expect(find('[data-test-text="confirm-details"]')).to.have.rendered.trimmed
.text(`Your post will be delivered to all 7 subscribers, and will not be published on your site.`); .text(`Your post will be delivered to all 7 subscribers, and will not be published on your site.`);
expect(find('[data-test-button="confirm-publish"]')).to.have.rendered expect(find('[data-test-button="confirm-publish"]')).to.have.rendered.trimmed
.text(`Send email, right now`); .text(`Send email, right now`);
await click('[data-test-button="confirm-publish"]'); await click('[data-test-button="confirm-publish"]');
@ -411,7 +411,7 @@ describe('Acceptance: Publish flow', function () {
await click('[data-test-setting="publish-type"] [data-test-setting-title]'); await click('[data-test-setting="publish-type"] [data-test-setting-title]');
await click('[data-test-publish-type="send"]'); await click('[data-test-publish-type="send"]');
expect(find('[data-test-setting="publish-type"] [data-test-setting-title]')).to.have.rendered expect(find('[data-test-setting="publish-type"] [data-test-setting-title]')).to.have.rendered.trimmed
.text('Email'); .text('Email');
await click('[data-test-setting="publish-at"] [data-test-setting-title]'); await click('[data-test-setting="publish-at"] [data-test-setting-title]');
@ -425,16 +425,16 @@ describe('Acceptance: Publish flow', function () {
await blur('[data-test-setting="publish-at"] [data-test-date-time-picker-time-input]'); await blur('[data-test-setting="publish-at"] [data-test-date-time-picker-time-input]');
expect(find('[data-test-setting="publish-at"] [data-test-date-time-picker-time-input]')).to.have.value(newDate.format('HH:mm')); expect(find('[data-test-setting="publish-at"] [data-test-date-time-picker-time-input]')).to.have.value(newDate.format('HH:mm'));
expect(find('[data-test-setting="publish-at"] [data-test-setting-title]'), 'publish-at title after change').to.have.rendered expect(find('[data-test-setting="publish-at"] [data-test-setting-title]'), 'publish-at title after change').to.have.rendered.trimmed
.text('In 4 days'); .text('In 4 days');
await click('[data-test-button="continue"]'); await click('[data-test-button="continue"]');
// has correct confirm text // has correct confirm text
expect(find('[data-test-text="confirm-details"]')).to.have.rendered expect(find('[data-test-text="confirm-details"]')).to.have.rendered.trimmed
.text(`On ${newDate.format('D MMM YYYY')} at ${newDate.format('HH:mm')} your post will be delivered to all 7 subscribers, and will not be published on your site.`); .text(`On ${newDate.format('D MMM YYYY')} at ${newDate.format('HH:mm')} your post will be delivered to all 7 subscribers, and will not be published on your site.`);
expect(find('[data-test-button="confirm-publish"]')).to.have.rendered expect(find('[data-test-button="confirm-publish"]')).to.have.rendered.trimmed
.text(`Send email, on ${newDate.format('MMMM Do')}`); .text(`Send email, on ${newDate.format('MMMM Do')}`);
await click('[data-test-button="confirm-publish"]'); await click('[data-test-button="confirm-publish"]');