2018-04-14 19:08:43 +02:00
|
|
|
import {
|
|
|
|
composeButton,
|
|
|
|
composeInput,
|
2018-06-09 06:54:21 +02:00
|
|
|
getNthStatus, getNthStatusSelector
|
2018-04-14 19:08:43 +02:00
|
|
|
} from '../utils'
|
2018-05-26 22:51:41 +02:00
|
|
|
import { loginAsFoobar } from '../roles'
|
2018-06-09 06:54:21 +02:00
|
|
|
import { Selector as $ } from 'testcafe'
|
2018-04-14 19:08:43 +02:00
|
|
|
|
|
|
|
fixture`112-status-links.js`
|
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
|
|
|
test('External links, hashtags, and mentions have correct attributes', async t => {
|
2019-08-03 22:49:37 +02:00
|
|
|
const text = 'Why hello there @admin and @baz and @quux ' +
|
2018-04-14 19:08:43 +02:00
|
|
|
'and also #tag and #anotherTag and #yetAnotherTag ' +
|
|
|
|
'and also http://example.com and https://joinmastodon.org and ' +
|
|
|
|
'https://mastodon.social.'
|
|
|
|
|
2019-02-28 17:56:25 +01:00
|
|
|
const nthAnchor = n => $(`${getNthStatusSelector(1)} .status-content a`).nth(n)
|
2018-04-14 19:08:43 +02:00
|
|
|
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2018-08-30 06:42:57 +02:00
|
|
|
.typeText(composeInput, text, { paste: true })
|
2018-04-14 19:08:43 +02:00
|
|
|
.click(composeButton)
|
2019-02-28 17:56:25 +01:00
|
|
|
.expect(getNthStatus(1).innerText).contains('Why hello there', { timeout: 20000 })
|
2018-04-14 19:08:43 +02:00
|
|
|
.expect(nthAnchor(0).getAttribute('href')).eql('/accounts/1')
|
|
|
|
.expect(nthAnchor(0).hasAttribute('rel')).notOk()
|
|
|
|
.expect(nthAnchor(0).getAttribute('title')).eql('@admin')
|
|
|
|
.expect(nthAnchor(0).hasAttribute('target')).notOk()
|
|
|
|
.expect(nthAnchor(1).getAttribute('href')).eql('/accounts/5')
|
|
|
|
.expect(nthAnchor(1).hasAttribute('rel')).notOk()
|
|
|
|
.expect(nthAnchor(1).getAttribute('title')).eql('@baz')
|
|
|
|
.expect(nthAnchor(1).hasAttribute('target')).notOk()
|
|
|
|
.expect(nthAnchor(2).getAttribute('href')).eql('/accounts/3')
|
|
|
|
.expect(nthAnchor(2).hasAttribute('rel')).notOk()
|
|
|
|
.expect(nthAnchor(2).getAttribute('title')).eql('@quux')
|
|
|
|
.expect(nthAnchor(2).hasAttribute('target')).notOk()
|
|
|
|
.expect(nthAnchor(3).getAttribute('href')).eql('/tags/tag')
|
|
|
|
.expect(nthAnchor(3).hasAttribute('rel')).notOk()
|
|
|
|
.expect(nthAnchor(3).hasAttribute('target')).notOk()
|
2022-12-03 00:09:58 +01:00
|
|
|
.expect(nthAnchor(4).getAttribute('href')).eql('/tags/anothertag')
|
2018-04-14 19:08:43 +02:00
|
|
|
.expect(nthAnchor(4).hasAttribute('rel')).notOk()
|
|
|
|
.expect(nthAnchor(4).hasAttribute('target')).notOk()
|
2022-12-03 00:09:58 +01:00
|
|
|
.expect(nthAnchor(5).getAttribute('href')).eql('/tags/yetanothertag')
|
2018-04-14 19:08:43 +02:00
|
|
|
.expect(nthAnchor(5).hasAttribute('rel')).notOk()
|
|
|
|
.expect(nthAnchor(5).hasAttribute('target')).notOk()
|
|
|
|
.expect(nthAnchor(6).getAttribute('href')).eql('http://example.com')
|
2020-05-03 03:02:29 +02:00
|
|
|
.expect(nthAnchor(6).getAttribute('rel')).contains('nofollow noopener')
|
2018-04-14 19:08:43 +02:00
|
|
|
.expect(nthAnchor(6).getAttribute('title')).eql('http://example.com')
|
|
|
|
.expect(nthAnchor(6).getAttribute('target')).eql('_blank')
|
|
|
|
.expect(nthAnchor(7).getAttribute('href')).eql('https://joinmastodon.org')
|
2020-05-03 03:02:29 +02:00
|
|
|
.expect(nthAnchor(7).getAttribute('rel')).contains('nofollow noopener')
|
2018-04-14 19:08:43 +02:00
|
|
|
.expect(nthAnchor(7).getAttribute('title')).eql('https://joinmastodon.org')
|
|
|
|
.expect(nthAnchor(7).getAttribute('target')).eql('_blank')
|
|
|
|
.expect(nthAnchor(8).getAttribute('href')).eql('https://mastodon.social')
|
2020-05-03 03:02:29 +02:00
|
|
|
.expect(nthAnchor(8).getAttribute('rel')).contains('nofollow noopener')
|
2018-04-14 19:08:43 +02:00
|
|
|
.expect(nthAnchor(8).getAttribute('title')).eql('https://mastodon.social')
|
|
|
|
.expect(nthAnchor(8).getAttribute('target')).eql('_blank')
|
|
|
|
})
|