From 5bbbc9174784f0a06cec7b221a18fabd07b4cf3a Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sun, 27 Nov 2022 10:02:34 -0800 Subject: [PATCH] test: add test --- tests/spec/010-focus.js | 18 +++++++++++++++++- tests/utils.js | 4 ++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/spec/010-focus.js b/tests/spec/010-focus.js index 78ea751f..c21d613c 100644 --- a/tests/spec/010-focus.js +++ b/tests/spec/010-focus.js @@ -14,7 +14,7 @@ import { getActiveElementTagName, getActiveElementClassList, getNthStatusSensitiveMediaButton, - getActiveElementAriaLabel, settingsNavButton, getActiveElementHref, communityNavButton + getActiveElementAriaLabel, settingsNavButton, getActiveElementHref, communityNavButton, getActiveElementId } from '../utils' import { loginAsFoobar } from '../roles' import { Selector as $ } from 'testcafe' @@ -73,6 +73,22 @@ test('timeline link preserves focus', async t => { .expect(getActiveElementInsideNthStatus()).eql('1') }) +test('timeline link preserves focus - reblogger avatar', async t => { + await loginAsFoobar(t) + await t + .expect(getNthStatus(1).exists).ok({ timeout: 20000 }) + + const avatar = `${getNthStatusSelector(1)} .status-header-avatar a` + const id = await $(avatar).getAttribute('id') + await t + .click($(avatar)) + .expect(getUrl()).contains('/accounts/') + .click(goBackButton) + .expect(getUrl()).eql('http://localhost:4002/') + .expect(getNthStatus(1).exists).ok() + .expect(getActiveElementId()).eql(id) +}) + test('notification timeline preserves focus', async t => { await loginAsFoobar(t) await t diff --git a/tests/utils.js b/tests/utils.js index 7b3050f3..de014857 100644 --- a/tests/utils.js +++ b/tests/utils.js @@ -169,6 +169,10 @@ export const getActiveElementInnerText = exec(() => (document.activeElement && document.activeElement.innerText) || '' ) +export const getActiveElementId = exec(() => + (document.activeElement && document.activeElement.id) || '' +) + export const getActiveElementRectTop = exec(() => ( (document.activeElement && document.activeElement.getBoundingClientRect().top) || -1 ))