diff --git a/src/intl/en-US.js b/src/intl/en-US.js index 7baed57b..448947df 100644 --- a/src/intl/en-US.js +++ b/src/intl/en-US.js @@ -678,5 +678,12 @@ export default { statusOptions: 'Status options', confirm: 'Confirm', closeDialog: 'Close dialog', - postPrivacy: 'Post privacy' + postPrivacy: 'Post privacy', + homeOnInstance: 'Home on {instance}', + statusesTimelineOnInstance: 'Statuses: {timeline} timeline on {instance}', + statusesHashtag: 'Statuses: #{hashtag} hashtag', + statusesThread: 'Statuses: thread', + statusesAccountTimeline: 'Statuses: account timeline', + statusesList: 'Statuses: list', + notificationsOnInstance: 'Notifications on {instance}' } diff --git a/src/routes/_components/DynamicHeading.html b/src/routes/_components/DynamicHeading.html new file mode 100644 index 00000000..5485b772 --- /dev/null +++ b/src/routes/_components/DynamicHeading.html @@ -0,0 +1,5 @@ +{#if level === 2} +

+{:else} +

+{/if} diff --git a/src/routes/_components/TimelineHomePage.html b/src/routes/_components/TimelineHomePage.html index b8efb221..ea13dc67 100644 --- a/src/routes/_components/TimelineHomePage.html +++ b/src/routes/_components/TimelineHomePage.html @@ -3,6 +3,7 @@ without a div wrapper due to sticky-positioned compose button. TODO: this is a bit hacky due to code duplication --> +

{headingLabel}

{#if hidePage} @@ -30,6 +31,7 @@ import { store } from '../_store/store.js' import LoadingPage from './LoadingPage.html' import LazyComposeBox from './compose/LazyComposeBox.html' + import { formatIntl } from '../_utils/formatIntl.js' export default { oncreate () { @@ -40,7 +42,8 @@ }, computed: { hidePage: ({ $timelineInitialized, $timelinePreinitialized }) => !$timelineInitialized && !$timelinePreinitialized, - hideTimeline: ({ $timelineInitialized }) => !$timelineInitialized + hideTimeline: ({ $timelineInitialized }) => !$timelineInitialized, + headingLabel: ({ $currentInstance }) => formatIntl('intl.homeOnInstance', { instance: $currentInstance }) }, store: () => store, components: { diff --git a/src/routes/_components/compose/ComposeBox.html b/src/routes/_components/compose/ComposeBox.html index 305ca4e7..c4ed8562 100644 --- a/src/routes/_components/compose/ComposeBox.html +++ b/src/routes/_components/compose/ComposeBox.html @@ -1,5 +1,5 @@ {#if realm === 'home'} -

{intl.composeStatus}

+

{intl.composeStatus}

{/if}
diff --git a/src/routes/_components/timeline/Timeline.html b/src/routes/_components/timeline/Timeline.html index 6cf1bf84..c0537aaa 100644 --- a/src/routes/_components/timeline/Timeline.html +++ b/src/routes/_components/timeline/Timeline.html @@ -1,4 +1,4 @@ -

{label}

+{label}
{#if components} @@ -26,6 +26,7 @@ diff --git a/src/routes/_pages/community/index.html b/src/routes/_pages/community/index.html index 31d3dd2d..14d1cc84 100644 --- a/src/routes/_pages/community/index.html +++ b/src/routes/_pages/community/index.html @@ -1,6 +1,6 @@ {#if $isUserLoggedIn} +

{intl.community}

- {intl.search}
diff --git a/tests/spec/042-headings.js b/tests/spec/042-headings.js new file mode 100644 index 00000000..6b6c7cf6 --- /dev/null +++ b/tests/spec/042-headings.js @@ -0,0 +1,52 @@ +import { + settingsNavButton, + notificationsNavButton, + localTimelineNavButton, + communityNavButton, + searchNavButton, + getNumElementsMatchingSelector, + getUrl, getNthStatus +} from '../utils' +import { loginAsFoobar } from '../roles' + +fixture`042-headings.js` + .page`http://localhost:4002` + +async function testHeadings (t, loggedIn) { + const navButtons = [ + { button: notificationsNavButton, url: 'notifications' }, + { button: localTimelineNavButton, url: 'local' }, + { button: communityNavButton, url: 'community' }, + { button: searchNavButton, url: 'search' }, + { button: settingsNavButton, url: 'settings' } + ] + + // home page + await t + .expect(getNumElementsMatchingSelector('h1')()).eql(1) + + if (loggedIn) { + // status page + await t + .click(getNthStatus(1)) + .expect(getUrl()).contains('status') + .expect(getNumElementsMatchingSelector('h1')()).eql(1) + } + + // non-home pages + for (const { button, url } of navButtons) { + await t + .click(button) + .expect(getUrl()).contains(url) + .expect(getNumElementsMatchingSelector('h1')()).eql(1) + } +} + +test('Only one

when not logged in', async t => { + await testHeadings(t, false) +}) + +test('Only one

when logged in', async t => { + await loginAsFoobar(t) + await testHeadings(t, true) +}) diff --git a/tests/utils.js b/tests/utils.js index 593ba305..888da0a3 100644 --- a/tests/utils.js +++ b/tests/utils.js @@ -570,6 +570,12 @@ export function getNthPinnedStatusFavoriteButton (n) { return $(`${getNthPinnedStatusSelector(n)} .status-toolbar button:nth-child(3)`) } +export const getNumElementsMatchingSelector = (selector) => (exec(() => { + return document.querySelectorAll(selector).length +}, { + dependencies: { selector } +})) + export async function validateTimeline (t, timeline) { const timeout = 30000 for (let i = 0; i < timeline.length; i++) {