2018-06-09 06:54:21 +02:00
|
|
|
import { getNthStatus, getNthStatusSelector, getUrl } from '../utils'
|
2018-05-26 22:51:41 +02:00
|
|
|
import { loginAsFoobar } from '../roles'
|
2018-03-05 00:31:31 +01:00
|
|
|
import { Selector as $ } from 'testcafe'
|
|
|
|
|
2018-03-07 06:32:51 +01:00
|
|
|
fixture`016-external-links.js`
|
2018-03-05 00:31:31 +01:00
|
|
|
.page`http://localhost:4002`
|
|
|
|
|
|
|
|
function getAnchor (nthStatus, nthAnchor) {
|
2019-02-28 17:56:25 +01:00
|
|
|
return $(`${getNthStatusSelector(1 + nthStatus)} .status-content a`).nth(nthAnchor)
|
2018-03-05 00:31:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function getAnchorInProfile (n) {
|
2018-06-09 06:54:21 +02:00
|
|
|
return $('.account-profile-note a').nth(n)
|
2018-03-05 00:31:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
test('converts external links in statuses', async t => {
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2019-02-28 17:56:25 +01:00
|
|
|
.hover(getNthStatus(1))
|
2018-03-05 00:31:31 +01:00
|
|
|
.navigateTo('/accounts/4')
|
|
|
|
.expect(getUrl()).contains('/accounts/4')
|
|
|
|
.expect(getAnchor(0, 0).getAttribute('href')).eql('/accounts/1')
|
|
|
|
.expect(getAnchor(0, 1).getAttribute('href')).eql('/accounts/3')
|
|
|
|
.expect(getAnchor(1, 0).getAttribute('href')).eql('https://joinmastodon.org')
|
|
|
|
.expect(getAnchor(1, 0).getAttribute('title')).eql('https://joinmastodon.org')
|
2020-05-03 03:02:29 +02:00
|
|
|
.expect(getAnchor(1, 0).getAttribute('rel')).contains('nofollow noopener')
|
2018-03-05 00:31:31 +01:00
|
|
|
.expect(getAnchor(1, 1).getAttribute('href')).eql('https://github.com/tootsuite/mastodon')
|
|
|
|
.expect(getAnchor(1, 1).getAttribute('title')).eql('https://github.com/tootsuite/mastodon')
|
2020-05-03 03:02:29 +02:00
|
|
|
.expect(getAnchor(1, 1).getAttribute('rel')).contains('nofollow noopener')
|
2018-03-05 00:31:31 +01:00
|
|
|
.expect(getAnchor(2, 0).getAttribute('href')).eql('/tags/kitten')
|
|
|
|
.expect(getAnchor(2, 1).getAttribute('href')).eql('/tags/kitties')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('converts external links in profiles', async t => {
|
2018-05-26 22:51:41 +02:00
|
|
|
await loginAsFoobar(t)
|
|
|
|
await t
|
2019-02-28 17:56:25 +01:00
|
|
|
.hover(getNthStatus(1))
|
2018-03-05 00:31:31 +01:00
|
|
|
.navigateTo('/accounts/4')
|
|
|
|
.expect(getUrl()).contains('/accounts/4')
|
2018-08-20 00:23:40 +02:00
|
|
|
.expect($('.account-profile-name').innerText).contains('External Lonk')
|
2018-03-05 00:31:31 +01:00
|
|
|
.expect($('.account-profile-name a').getAttribute('href')).eql('http://localhost:3000/@ExternalLinks')
|
2020-05-03 03:02:29 +02:00
|
|
|
.expect($('.account-profile-name a').getAttribute('rel')).contains('nofollow noopener')
|
2018-03-05 00:31:31 +01:00
|
|
|
.expect(getAnchorInProfile(0).getAttribute('href')).eql('https://joinmastodon.org')
|
2020-05-03 03:02:29 +02:00
|
|
|
.expect(getAnchorInProfile(0).getAttribute('rel')).contains('nofollow noopener')
|
2018-03-05 00:31:31 +01:00
|
|
|
.expect(getAnchorInProfile(1).getAttribute('href')).eql('http://localhost:3000/tags/cat')
|
|
|
|
.expect(getAnchorInProfile(2).getAttribute('href')).eql('http://localhost:3000/tags/mastocats')
|
|
|
|
.expect(getAnchorInProfile(3).getAttribute('href')).eql('http://localhost:3000/@quux')
|
|
|
|
})
|