diff --git a/tests/acceptance/basic-test.js b/tests/acceptance/basic-test.js index fa723bf..b772c64 100644 --- a/tests/acceptance/basic-test.js +++ b/tests/acceptance/basic-test.js @@ -27,12 +27,26 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) { openSelector: '#example-basic button', dialogText: 'Basic', closeSelector: overlaySelector, + whileOpen: async function () { + assert.hasDataTest( + dialogSelector, + 'my-data-test', + 'dialog has data-test attribute' + ); + }, }); await assert.dialogOpensAndCloses({ openSelector: '#example-basic button', dialogText: 'Basic', closeSelector: dialogCloseButton, + whileOpen: async function () { + assert.hasDataTest( + dialogSelector, + 'my-data-test', + 'dialog has data-test attribute' + ); + }, }); }); @@ -41,12 +55,26 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) { openSelector: '#example-translucent button', dialogText: 'With Translucent Overlay', closeSelector: overlaySelector, + whileOpen: async function () { + assert.hasDataTest( + dialogSelector, + 'my-data-test', + 'dialog has data-test attribute' + ); + }, }); await assert.dialogOpensAndCloses({ openSelector: '#example-translucent button', dialogText: 'With Translucent Overlay', closeSelector: dialogCloseButton, + whileOpen: async function () { + assert.hasDataTest( + dialogSelector, + 'my-data-test', + 'dialog has data-test attribute' + ); + }, }); }); @@ -55,12 +83,26 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) { openSelector: '#example-without-overlay button', dialogText: 'Without Overlay', closeSelector: '#example-without-overlay', + whileOpen: async function () { + assert.hasDataTest( + dialogSelector, + 'my-data-test', + 'dialog has data-test attribute' + ); + }, }); await assert.dialogOpensAndCloses({ openSelector: '#example-without-overlay button', dialogText: 'Without Overlay', closeSelector: dialogCloseButton, + whileOpen: async function () { + assert.hasDataTest( + dialogSelector, + 'my-data-test', + 'dialog has data-test attribute' + ); + }, }); }); @@ -69,12 +111,26 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) { openSelector: '#example-translucent button', dialogText: 'With Translucent Overlay', closeSelector: overlaySelector, + whileOpen: async function () { + assert.hasDataTest( + dialogSelector, + 'my-data-test', + 'dialog has data-test attribute' + ); + }, }); await assert.dialogOpensAndCloses({ openSelector: '#example-translucent button', dialogText: 'With Translucent Overlay', closeSelector: dialogCloseButton, + whileOpen: async function () { + assert.hasDataTest( + dialogSelector, + 'my-data-test', + 'dialog has data-test attribute' + ); + }, }); }); @@ -83,12 +139,26 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) { openSelector: '#example-overlay-sibling button', dialogText: 'With Translucent Overlay as Sibling', closeSelector: overlaySelector, + whileOpen: async function () { + assert.hasDataTest( + dialogSelector, + 'my-data-test', + 'dialog has data-test attribute' + ); + }, }); await assert.dialogOpensAndCloses({ openSelector: '#example-overlay-sibling button', dialogText: 'With Translucent Overlay as Sibling', closeSelector: dialogCloseButton, + whileOpen: async function () { + assert.hasDataTest( + dialogSelector, + 'my-data-test', + 'dialog has data-test attribute' + ); + }, }); }); @@ -121,12 +191,24 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) { 'custom-styles-modal-container', 'has provided container-class' ); + assert.hasDataTest( + dialogSelector, + 'my-data-test', + 'dialog has data-test attribute' + ); }, }); await assert.dialogOpensAndCloses({ openSelector: '#example-custom-styles button', dialogText: 'Custom Styles', closeSelector: dialogCloseButton, + whileOpen: async function () { + assert.hasDataTest( + dialogSelector, + 'my-data-test', + 'dialog has data-test attribute' + ); + }, }); }); @@ -142,6 +224,11 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) { 'ember-modal-dialog-target-attachment-left', 'has targetAttachment class name' ); + assert.hasDataTest( + dialogSelector, + 'my-data-test', + 'dialog has data-test attribute' + ); }, }); }); @@ -151,6 +238,13 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) { openSelector: '#example-target-element button', dialogText: 'Target - Element', closeSelector: dialogCloseButton, + whileOpen: async function () { + assert.hasDataTest( + dialogSelector, + 'my-data-test', + 'dialog has data-test attribute' + ); + }, }); }); @@ -163,6 +257,11 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) { assert .dom(dialogSelector) .hasClass('my-cool-modal', 'has provided containerClassNames'); + assert.hasDataTest( + dialogSelector, + 'my-data-test', + 'dialog has data-test attribute' + ); }, }); }); @@ -179,6 +278,11 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) { assert .dom(dialogSelector) .hasClass('my-cool-modal-2', 'has provided containerClassNames'); + assert.hasDataTest( + dialogSelector, + 'my-data-test', + 'dialog has data-test attribute' + ); }, }); }); @@ -198,6 +302,11 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) { assert .dom(inPlaceDialogSelector) .hasClass('my-custom-class', 'has provided containerClass'); + assert.hasDataTest( + inPlaceDialogSelector, + 'my-data-test', + 'dialog has data-test attribute' + ); assert.strictEqual( getComputedStyle(dialogElement).getPropertyValue('position'), 'static', @@ -247,6 +356,11 @@ module('Acceptance: modal-dialog | no animation, no tether', function (hooks) { assert .dom(inPlaceDialogSelector) .hasClass('my-custom-class-2', 'has provided containerClassNames'); + assert.hasDataTest( + inPlaceDialogSelector, + 'my-data-test', + 'dialog has data-test attribute' + ); await click(inPlaceCloseButton); }); }); diff --git a/tests/dummy/app/templates/index.hbs b/tests/dummy/app/templates/index.hbs index db30ff2..b042952 100644 --- a/tests/dummy/app/templates/index.hbs +++ b/tests/dummy/app/templates/index.hbs @@ -16,7 +16,7 @@ {{#if this.isShowingBasic}} {{!-- BEGIN-SNIPPET basic-modal-dialog --}} - +

Stop! Modal Time!

Basic

@@ -31,7 +31,7 @@ {{#if this.isShowingTranslucent}} {{!-- BEGIN-SNIPPET translucent-modal-dialog --}} - +

Stop! Modal Time!

With Translucent Overlay

@@ -46,7 +46,7 @@ {{#if this.isShowingTranslucentWithCallback}} {{!-- BEGIN-SNIPPET translucent-modal-dialog-with-callback --}} - +

Stop! Modal Time!

Translucent Overlay with Callback

@@ -61,7 +61,7 @@ {{#if this.isShowingWithoutOverlay}} {{!-- BEGIN-SNIPPET modal-dialog-without-overlay --}} - +

Stop! Modal Time!

Without Overlay

@@ -76,7 +76,7 @@ {{#if this.isShowingSibling}} {{!-- BEGIN-SNIPPET translucent-modal-dialog-sibling --}} - +

Stop! Modal Time!

With Translucent Overlay as Sibling

@@ -92,7 +92,7 @@ {{#if this.isShowingCustomStyles}} {{!-- BEGIN-SNIPPET custom-styles-modal-dialog --}} - +

Stop! Modal Time!

Custom Styles

@@ -109,7 +109,7 @@ {{#if this.isShowingTargetSelector}} {{!-- BEGIN-SNIPPET target-selector-modal-dialog --}} - +

Stop! Modal Time!

Target - Selector: "#alignModalDialogToMe"

Target Attachment: {{this.exampleTargetAttachment}}

@@ -130,7 +130,7 @@ {{#if this.isShowingTargetElement}} {{!-- BEGIN-SNIPPET target-element-modal-dialog --}} - +

Stop! Modal Time!

Target - Element #bwmde

Target Attachment: {{this.exampleTargetAttachment}}

@@ -149,7 +149,7 @@ {{#if this.isShowingSubclassed}} {{!-- BEGIN-SNIPPET subclass-modal-dialog --}} - +

Stop! Modal Time!

Via Subclass

@@ -166,7 +166,7 @@ {{#if this.isShowingSubclassed2}} {{!-- BEGIN-SNIPPET subclass-modal-dialog-2 --}} - +

Stop! Modal Time!

Via Subclass

@@ -184,7 +184,7 @@ I AM THE CONTAINER {{#if this.isShowingInPlace}} {{!-- BEGIN-SNIPPET in-place-modal-dialog --}} - +

Stop! Modal Time!

In Place

@@ -196,17 +196,17 @@

In Place

- +
I AM THE CONTAINER - {{#if this.isShowingInPlace}} + {{#if this.isShowingInPlace2}} {{!-- BEGIN-SNIPPET in-place-modal-dialog --}} - +

Stop! Modal Time!

In Place

- +
{{!-- END-SNIPPET --}} {{/if}} @@ -221,7 +221,7 @@
{{#if this.isShowingCenteredScrolling}} {{!-- BEGIN-SNIPPET centered-scrolling-modal-dialog --}} - +

Really Long Content To Demonstrate Scrolling

  • Hover over modal and scroll
  • @@ -243,7 +243,7 @@ {{#if this.isShowingElementCenterModal}} {{!-- BEGIN-SNIPPET element-centered-modal-dialog --}} - +

    Centered on element.

    {{!-- END-SNIPPET --}} diff --git a/tests/helpers/modal-asserts.js b/tests/helpers/modal-asserts.js index 55d4225..72d751d 100644 --- a/tests/helpers/modal-asserts.js +++ b/tests/helpers/modal-asserts.js @@ -20,6 +20,11 @@ export default function registerAssertHelpers(assert) { return this.dom(selector).isVisible(message); }; + assert.hasDataTest = function (selector, dataTest, message) { + message = message || `${selector} has data-test attribute`; + return this.dom(selector).hasAttribute('data-test', dataTest, message); + }; + assert.dialogOpensAndCloses = async function (options) { const self = this; await click(options.openSelector, options.context);