-
-
Notifications
You must be signed in to change notification settings - Fork 3k
timeslider: respect showAuthorshipColors and padFontFamily settings #7899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+164
−36
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/tests/frontend-new/specs/timeslider_author_colors.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| import {expect, test} from "@playwright/test"; | ||
| import {clearPadContent, goToNewPad, writeToPad} from "../helper/padHelper"; | ||
|
|
||
| test.describe('timeslider authorship colors', function () { | ||
| test.beforeEach(async ({context}) => { | ||
| await context.clearCookies(); | ||
| }); | ||
|
|
||
| test('respects showAuthorshipColors=false cookie from pad editor', async function ({page}) { | ||
| const padId = await goToNewPad(page); | ||
| await clearPadContent(page); | ||
| await writeToPad(page, 'Hello from author one'); | ||
|
|
||
| await page.context().addCookies([{ | ||
| name: 'prefsHttp', | ||
| value: encodeURIComponent(JSON.stringify({showAuthorshipColors: false})), | ||
| url: 'http://localhost:9001', | ||
| }]); | ||
|
|
||
| await page.goto(`http://localhost:9001/p/${padId}/timeslider?embed=1`); | ||
| await page.waitForSelector('#timeslider-wrapper', {state: 'visible'}); | ||
| await page.waitForTimeout(500); | ||
|
|
||
| await expect(page.locator('#innerdocbody')).not.toHaveClass(/authorColors/); | ||
| }); | ||
|
|
||
| test('shows author colors by default (cookie unset)', async function ({page}) { | ||
| const padId = await goToNewPad(page); | ||
| await clearPadContent(page); | ||
| await writeToPad(page, 'Hello from author one'); | ||
|
|
||
| await page.goto(`http://localhost:9001/p/${padId}/timeslider?embed=1`); | ||
| await page.waitForSelector('#timeslider-wrapper', {state: 'visible'}); | ||
| await page.waitForTimeout(500); | ||
|
|
||
| await expect(page.locator('#innerdocbody')).toHaveClass(/authorColors/); | ||
| }); | ||
|
|
||
| test('font type selector applies font-family to innerdocbody', async function ({page}) { | ||
| const padId = await goToNewPad(page); | ||
| await clearPadContent(page); | ||
| await writeToPad(page, 'Test content'); | ||
|
|
||
| await page.goto(`http://localhost:9001/p/${padId}/timeslider?embed=1`); | ||
| await page.waitForSelector('#timeslider-wrapper', {state: 'visible'}); | ||
| await page.waitForTimeout(500); | ||
|
|
||
| // Use evaluate() to trigger font change via jQuery, bypassing the | ||
| // nice-select UI and settings-popup open/close lifecycle. | ||
| await page.evaluate(() => { | ||
| const el = document.getElementById('viewfontmenu') as HTMLSelectElement; | ||
| if (el) { | ||
| el.value = 'RobotoMono'; | ||
| el.dispatchEvent(new Event('change', {bubbles: true})); | ||
| } | ||
| }); | ||
| await page.waitForTimeout(200); | ||
|
|
||
| const fontFamily = await page.locator('#innerdocbody').evaluate( | ||
| (el) => getComputedStyle(el).fontFamily); | ||
| expect(fontFamily).toContain('RobotoMono'); | ||
| }); | ||
|
|
||
| test('font-type selection persists and restores from cookie', async function ({page, context}) { | ||
| const padId = await goToNewPad(page); | ||
| await clearPadContent(page); | ||
| await writeToPad(page, 'Test content'); | ||
|
|
||
| // Set font cookie before loading timeslider | ||
| await context.addCookies([{ | ||
| name: 'prefsHttp', | ||
| value: encodeURIComponent(JSON.stringify({padFontFamily: 'Alegreya'})), | ||
| url: 'http://localhost:9001', | ||
| }]); | ||
|
|
||
| await page.goto(`http://localhost:9001/p/${padId}/timeslider?embed=1`); | ||
| await page.waitForSelector('#timeslider-wrapper', {state: 'visible'}); | ||
| await page.waitForTimeout(500); | ||
|
|
||
| const fontFamily = await page.locator('#innerdocbody').evaluate( | ||
| (el) => getComputedStyle(el).fontFamily); | ||
| expect(fontFamily).toContain('Alegreya'); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Double change event firing
🐞 Bug≡ CorrectnessThe nice-select option click handler triggers both trigger('change') and a native dispatchEvent('change'), so change handlers can run twice for one user action. This can duplicate side effects such as pad.setMyViewOption() → pad.applyOptionsChange() when selecting font/language/etc., and can also double-run the new addEventListener-based pad→timeslider bridge handlers.Agent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools