diff --git a/routes/_components/dialog/AccountProfileOptionsDialog.html b/routes/_components/dialog/components/AccountProfileOptionsDialog.html similarity index 64% rename from routes/_components/dialog/AccountProfileOptionsDialog.html rename to routes/_components/dialog/components/AccountProfileOptionsDialog.html index 9a925a6..65d68b9 100644 --- a/routes/_components/dialog/AccountProfileOptionsDialog.html +++ b/routes/_components/dialog/components/AccountProfileOptionsDialog.html @@ -1,20 +1,27 @@ \ No newline at end of file diff --git a/routes/_components/dialog/ComposeDialog.html b/routes/_components/dialog/components/ComposeDialog.html similarity index 54% rename from routes/_components/dialog/ComposeDialog.html rename to routes/_components/dialog/components/ComposeDialog.html index eb947cc..4b0f466 100644 --- a/routes/_components/dialog/ComposeDialog.html +++ b/routes/_components/dialog/components/ComposeDialog.html @@ -1,41 +1,37 @@ \ No newline at end of file diff --git a/routes/_components/dialog/ConfirmationDialog.html b/routes/_components/dialog/components/ConfirmationDialog.html similarity index 69% rename from routes/_components/dialog/ConfirmationDialog.html rename to routes/_components/dialog/components/ConfirmationDialog.html index ff72f0d..f678878 100644 --- a/routes/_components/dialog/ConfirmationDialog.html +++ b/routes/_components/dialog/components/ConfirmationDialog.html @@ -1,9 +1,7 @@

@@ -36,16 +34,23 @@ \ No newline at end of file diff --git a/routes/_components/dialog/EmojiDialog.html b/routes/_components/dialog/components/EmojiDialog.html similarity index 84% rename from routes/_components/dialog/EmojiDialog.html rename to routes/_components/dialog/components/EmojiDialog.html index e3be736..e90ef48 100644 --- a/routes/_components/dialog/EmojiDialog.html +++ b/routes/_components/dialog/components/EmojiDialog.html @@ -1,10 +1,8 @@

{{#if emojis.length}} @@ -60,10 +58,14 @@ \ No newline at end of file diff --git a/routes/_components/dialog/ModalDialog.html b/routes/_components/dialog/components/ModalDialog.html similarity index 82% rename from routes/_components/dialog/ModalDialog.html rename to routes/_components/dialog/components/ModalDialog.html index 5311a3a..8702d21 100644 --- a/routes/_components/dialog/ModalDialog.html +++ b/routes/_components/dialog/components/ModalDialog.html @@ -116,10 +116,21 @@ \ No newline at end of file diff --git a/routes/_components/dialog/PostPrivacyDialog.html b/routes/_components/dialog/components/PostPrivacyDialog.html similarity index 74% rename from routes/_components/dialog/PostPrivacyDialog.html rename to routes/_components/dialog/components/PostPrivacyDialog.html index c8a04f7..7c7f724 100644 --- a/routes/_components/dialog/PostPrivacyDialog.html +++ b/routes/_components/dialog/components/PostPrivacyDialog.html @@ -1,21 +1,23 @@ \ No newline at end of file diff --git a/routes/_components/dialog/showAccountProfileOptionsDialog.js b/routes/_components/dialog/creators/showAccountProfileOptionsDialog.js similarity index 51% rename from routes/_components/dialog/showAccountProfileOptionsDialog.js rename to routes/_components/dialog/creators/showAccountProfileOptionsDialog.js index 8e0593c..9083201 100644 --- a/routes/_components/dialog/showAccountProfileOptionsDialog.js +++ b/routes/_components/dialog/creators/showAccountProfileOptionsDialog.js @@ -1,10 +1,12 @@ -import AccountProfileOptionsDialog from './AccountProfileOptionsDialog.html' -import { createDialogElement } from './createDialogElement' +import AccountProfileOptionsDialog from '../components/AccountProfileOptionsDialog.html' +import { createDialogElement } from '../helpers/createDialogElement' +import { createDialogId } from '../helpers/createDialogId' export function showAccountProfileOptionsDialog (account) { let dialog = new AccountProfileOptionsDialog({ target: createDialogElement(), data: { + id: createDialogId(), label: 'Profile options dialog', title: '', account: account diff --git a/routes/_components/dialog/creators/showComposeDialog.js b/routes/_components/dialog/creators/showComposeDialog.js new file mode 100644 index 0000000..ee45775 --- /dev/null +++ b/routes/_components/dialog/creators/showComposeDialog.js @@ -0,0 +1,14 @@ +import ComposeDialog from '../components/ComposeDialog.html' +import { createDialogElement } from '../helpers/createDialogElement' +import { createDialogId } from '../helpers/createDialogId' + +export function showComposeDialog () { + let dialog = new ComposeDialog({ + target: createDialogElement(), + data: { + id: createDialogId(), + label: 'Compose dialog' + } + }) + dialog.show() +} diff --git a/routes/_components/dialog/showConfirmationDialog.js b/routes/_components/dialog/creators/showConfirmationDialog.js similarity index 50% rename from routes/_components/dialog/showConfirmationDialog.js rename to routes/_components/dialog/creators/showConfirmationDialog.js index 1fd6be0..e023e12 100644 --- a/routes/_components/dialog/showConfirmationDialog.js +++ b/routes/_components/dialog/creators/showConfirmationDialog.js @@ -1,10 +1,12 @@ -import ConfirmationDialog from './ConfirmationDialog.html' -import { createDialogElement } from './createDialogElement' +import ConfirmationDialog from '../components/ConfirmationDialog.html' +import { createDialogElement } from '../helpers/createDialogElement' +import { createDialogId } from '../helpers/createDialogId' export function showConfirmationDialog (options) { let dialog = new ConfirmationDialog({ target: createDialogElement(), data: Object.assign({ + id: createDialogId(), label: 'Confirmation dialog' }, options) }) diff --git a/routes/_components/dialog/showEmojiDialog.js b/routes/_components/dialog/creators/showEmojiDialog.js similarity index 52% rename from routes/_components/dialog/showEmojiDialog.js rename to routes/_components/dialog/creators/showEmojiDialog.js index ba56e0d..7bead1f 100644 --- a/routes/_components/dialog/showEmojiDialog.js +++ b/routes/_components/dialog/creators/showEmojiDialog.js @@ -1,10 +1,12 @@ -import EmojiDialog from './EmojiDialog.html' -import { createDialogElement } from './createDialogElement' +import EmojiDialog from '../components/EmojiDialog.html' +import { createDialogElement } from '../helpers/createDialogElement' +import { createDialogId } from '../helpers/createDialogId' export function showEmojiDialog (realm) { let emojiDialog = new EmojiDialog({ target: createDialogElement(), data: { + id: createDialogId(), label: 'Emoji dialog', title: 'Custom emoji', realm diff --git a/routes/_components/dialog/showImageDialog.js b/routes/_components/dialog/creators/showImageDialog.js similarity index 59% rename from routes/_components/dialog/showImageDialog.js rename to routes/_components/dialog/creators/showImageDialog.js index 530cda6..4338350 100644 --- a/routes/_components/dialog/showImageDialog.js +++ b/routes/_components/dialog/creators/showImageDialog.js @@ -1,10 +1,12 @@ -import ImageDialog from './ImageDialog.html' -import { createDialogElement } from './createDialogElement' +import ImageDialog from '../components/ImageDialog.html' +import { createDialogElement } from '../helpers/createDialogElement' +import { createDialogId } from '../helpers/createDialogId' export function showImageDialog (poster, src, type, width, height, description) { let imageDialog = new ImageDialog({ target: createDialogElement(), data: { + id: createDialogId(), label: 'Image dialog', poster, src, diff --git a/routes/_components/dialog/showPostPrivacyDialog.js b/routes/_components/dialog/creators/showPostPrivacyDialog.js similarity index 52% rename from routes/_components/dialog/showPostPrivacyDialog.js rename to routes/_components/dialog/creators/showPostPrivacyDialog.js index 6c38490..bfeab4d 100644 --- a/routes/_components/dialog/showPostPrivacyDialog.js +++ b/routes/_components/dialog/creators/showPostPrivacyDialog.js @@ -1,10 +1,12 @@ -import PostPrivacyDialog from './PostPrivacyDialog.html' -import { createDialogElement } from './createDialogElement' +import PostPrivacyDialog from '../components/PostPrivacyDialog.html' +import { createDialogElement } from '../helpers/createDialogElement' +import { createDialogId } from '../helpers/createDialogId' export function showPostPrivacyDialog (realm) { let dialog = new PostPrivacyDialog({ target: createDialogElement(), data: { + id: createDialogId(), label: 'Post privacy dialog', title: 'Post privacy', realm: realm diff --git a/routes/_components/dialog/showStatusOptionsDialog.js b/routes/_components/dialog/creators/showStatusOptionsDialog.js similarity index 52% rename from routes/_components/dialog/showStatusOptionsDialog.js rename to routes/_components/dialog/creators/showStatusOptionsDialog.js index 66e6166..358d134 100644 --- a/routes/_components/dialog/showStatusOptionsDialog.js +++ b/routes/_components/dialog/creators/showStatusOptionsDialog.js @@ -1,10 +1,12 @@ -import StatusOptionsDialog from './StatusOptionsDialog.html' -import { createDialogElement } from './createDialogElement' +import StatusOptionsDialog from '../components/StatusOptionsDialog.html' +import { createDialogElement } from '../helpers/createDialogElement' +import { createDialogId } from '../helpers/createDialogId' export function showStatusOptionsDialog (statusId) { let dialog = new StatusOptionsDialog({ target: createDialogElement(), data: { + id: createDialogId(), label: 'Status options dialog', title: '', statusId: statusId diff --git a/routes/_components/dialog/showVideoDialog.js b/routes/_components/dialog/creators/showVideoDialog.js similarity index 58% rename from routes/_components/dialog/showVideoDialog.js rename to routes/_components/dialog/creators/showVideoDialog.js index 28a0295..7e36ec2 100644 --- a/routes/_components/dialog/showVideoDialog.js +++ b/routes/_components/dialog/creators/showVideoDialog.js @@ -1,10 +1,12 @@ -import VideoDialog from './VideoDialog.html' -import { createDialogElement } from './createDialogElement' +import VideoDialog from '../components/VideoDialog.html' +import { createDialogElement } from '../helpers/createDialogElement' +import { createDialogId } from '../helpers/createDialogId' export function showVideoDialog (poster, src, width, height, description) { let videoDialog = new VideoDialog({ target: createDialogElement(), data: { + id: createDialogId(), label: 'Video dialog', poster, src, diff --git a/routes/_components/dialog/dialogs.js b/routes/_components/dialog/dialogs.js index 691541e..6bea445 100644 --- a/routes/_components/dialog/dialogs.js +++ b/routes/_components/dialog/dialogs.js @@ -1,8 +1,8 @@ -export * from './showConfirmationDialog' -export * from './showImageDialog' -export * from './showVideoDialog' -export * from './showEmojiDialog' -export * from './showPostPrivacyDialog' -export * from './showStatusOptionsDialog' -export * from './showComposeDialog' -export * from './showAccountProfileOptionsDialog' +export * from './creators/showConfirmationDialog' +export * from './creators/showImageDialog' +export * from './creators/showVideoDialog' +export * from './creators/showEmojiDialog' +export * from './creators/showPostPrivacyDialog' +export * from './creators/showStatusOptionsDialog' +export * from './creators/showComposeDialog' +export * from './creators/showAccountProfileOptionsDialog' diff --git a/routes/_components/dialog/helpers/closeDialog.js b/routes/_components/dialog/helpers/closeDialog.js new file mode 100644 index 0000000..351d1c0 --- /dev/null +++ b/routes/_components/dialog/helpers/closeDialog.js @@ -0,0 +1,6 @@ +import { emit } from '../../../_utils/eventBus' + +export function close () { + let id = this.get('id') + emit('closeDialog', id) +} diff --git a/routes/_components/dialog/createDialogElement.js b/routes/_components/dialog/helpers/createDialogElement.js similarity index 100% rename from routes/_components/dialog/createDialogElement.js rename to routes/_components/dialog/helpers/createDialogElement.js diff --git a/routes/_components/dialog/helpers/createDialogId.js b/routes/_components/dialog/helpers/createDialogId.js new file mode 100644 index 0000000..12f63da --- /dev/null +++ b/routes/_components/dialog/helpers/createDialogId.js @@ -0,0 +1,5 @@ +let count = -1 + +export function createDialogId () { + return ++count +} \ No newline at end of file diff --git a/routes/_components/dialog/helpers/onCreateDialog.js b/routes/_components/dialog/helpers/onCreateDialog.js new file mode 100644 index 0000000..6a04a06 --- /dev/null +++ b/routes/_components/dialog/helpers/onCreateDialog.js @@ -0,0 +1,12 @@ +import { on } from '../../../_utils/eventBus' + +function onDestroy (id) { + if (this.get('id') !== id) { + return + } + this.destroy() +} + +export function oncreate () { + on('destroyDialog', this, onDestroy) +} diff --git a/routes/_components/dialog/helpers/showDialog.js b/routes/_components/dialog/helpers/showDialog.js new file mode 100644 index 0000000..651a785 --- /dev/null +++ b/routes/_components/dialog/helpers/showDialog.js @@ -0,0 +1,6 @@ +import { emit } from '../../../_utils/eventBus' + +export function show () { + let id = this.get('id') + emit('showDialog', id) +} diff --git a/routes/_components/dialog/showComposeDialog.js b/routes/_components/dialog/showComposeDialog.js deleted file mode 100644 index bd4612c..0000000 --- a/routes/_components/dialog/showComposeDialog.js +++ /dev/null @@ -1,12 +0,0 @@ -import ComposeDialog from './ComposeDialog.html' -import { createDialogElement } from './createDialogElement' - -export function showComposeDialog () { - let dialog = new ComposeDialog({ - target: createDialogElement(), - data: { - label: 'Compose dialog' - } - }) - dialog.show() -} diff --git a/tests/spec/108-compose-dialog.js b/tests/spec/108-compose-dialog.js index 516de28..0218a88 100644 --- a/tests/spec/108-compose-dialog.js +++ b/tests/spec/108-compose-dialog.js @@ -3,6 +3,7 @@ import { scrollContainerToTop } from '../utils' import { foobarRole } from '../roles' +import { Selector as $ } from 'testcafe' fixture`108-compose-dialog.js` .page`http://localhost:4002` @@ -27,3 +28,24 @@ test('can compose using a dialog', async t => { .click(showMoreButton) await t.expect(getNthStatus(0).innerText).contains('hello from the modal', {timeout: 20000}) }) + +test('can use emoji dialog within compose dialog', async t => { + await t.useRole(foobarRole) + await scrollToStatus(t, 15) + await t.expect(composeButton.getAttribute('aria-label')).eql('Compose') + await sleep(2000) + await t.click(composeButton) + .click(modalDialog.find('.compose-box-toolbar button:nth-child(1)')) + .click($('button img[title=":blobpats:"]')) + .expect(modalDialog.find('.compose-box-input').value).eql(':blobpats: ') + .click(modalDialog.find('.compose-box-button-compose')) + .expect(modalDialog.exists).notOk() + await sleep(5000) + await scrollToTopOfTimeline(t) + await t.hover(getNthStatus(0)) + await scrollContainerToTop() + await t + .expect(showMoreButton.innerText).contains('Show 1 more') + .click(showMoreButton) + await t.expect(getNthStatus(0).find('img[alt=":blobpats:"]').exists).ok({timeout: 20000}) +}) \ No newline at end of file