diff --git a/tests/spec/12-compose-limits.js b/tests/spec/12-compose-limits.js new file mode 100644 index 00000000..d2addedd --- /dev/null +++ b/tests/spec/12-compose-limits.js @@ -0,0 +1,34 @@ +import { + composeButton, composeInput, composeLengthIndicator, getUrl, homeNavButton, notificationsNavButton +} from '../utils' +import { foobarRole } from '../roles' +import times from 'lodash/times' + +fixture`12-compose-limits.js` + .page`http://localhost:4002` + +test('shows compose limits', async t => { + await t.useRole(foobarRole) + .hover(composeInput) + .expect(composeLengthIndicator.innerText).eql('0') + .expect(composeButton.getAttribute('disabled')).eql('') + .typeText(composeInput, 'typing some text') + .expect(composeLengthIndicator.innerText).eql('16') + .expect(composeButton.hasAttribute('disabled')).notOk() + .typeText(composeInput, times(50, () => 'hello world').join(' '), {replace: true, paste: true}) + .expect(composeLengthIndicator.innerText).eql('-99') + .expect(composeButton.getAttribute('disabled')).eql('') + .typeText(composeInput, 'hello world', {replace: true}) + .click(notificationsNavButton) + .expect(getUrl()).contains('/notifications') + .click(homeNavButton) + .expect(getUrl()).eql('http://localhost:4002/') + .expect(composeInput.value).eql('hello world') + .expect(composeLengthIndicator.innerText).eql('11') + .expect(composeButton.hasAttribute('disabled')).notOk() + .selectText(composeInput) + .pressKey('delete') + .expect(composeInput.value).eql('') + .expect(composeLengthIndicator.innerText).eql('0') + .expect(composeButton.getAttribute('disabled')).eql('') +}) diff --git a/tests/utils.js b/tests/utils.js index a573cd7f..5221cbdc 100644 --- a/tests/utils.js +++ b/tests/utils.js @@ -10,6 +10,9 @@ export const closeDialogButton = $('.close-dialog-button') export const notificationsNavButton = $('nav a[href="/notifications"]') export const homeNavButton = $('nav a[href="/"]') export const formError = $('.form-error-user-error') +export const composeInput = $('.compose-box-input') +export const composeButton = $('.compose-box-button') +export const composeLengthIndicator = $('.compose-box-length') export const favoritesCountElement = $('.status-favs-reblogs:nth-child(3)').addCustomDOMProperties({ innerCount: el => parseInt(el.innerText, 10)