MERL-1004: fixed missing edit button in the Faust toolbar when previewing a post#1556
Conversation
Co-authored-by: Joe Fusco <josephfusco@users.noreply.github.com> Co-authored-by: Blake Wilson <blake@blake.id>
🦋 Changeset detectedLatest commit: 9ecee4e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📦 Next.js Bundle Analysis for @faustwp/getting-started-exampleThis analysis was generated by the Next.js Bundle Analysis action. 🤖
|
| Page | Size (compressed) |
|---|---|
global |
242.63 KB (🟡 +36 B) |
Details
The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.
Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis
If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!
Co-authored-by: Blake Wilson <blake.wilson@wpengine.com>
|
This is working well for me in Chrome. Noted internally that it does not work in Safari, but seems to be related to existing auth/cookie issue in Safari, and not a blocker for merge here. Would be nice to have some tests to confirm the Edit node appears as expected to avoid regressions. |
Co-authored-by: John Parris <john.parris@wpengine.com>
|
For the tests that are failing, this seems due to our introduction of Do a wildcard import of import * as nextRouter from 'next/router';Then in the Toolbar tests that are failing, mock the const useRouterSpy = jest.spyOn(nextRouter, 'useRouter').mockReturnValue({
query: {},
} as any as nextRouter.NextRouter);For example: test('renders the toolbar if user preference is true', async () => {
expect.assertions(1);
mockIsAuthenticated = true;
const mockUseQuery = {
data: {
viewer: {
shouldShowFaustToolbar: true,
},
},
} as any as QueryResult<unknown, unknown>;
const useQuerySpy = jest
.spyOn(apollo, 'useQuery')
.mockReturnValue(mockUseQuery);
const useRouterSpy = jest.spyOn(nextRouter, 'useRouter').mockReturnValue({
query: {},
} as any as nextRouter.NextRouter);
const dom = render(<Toolbar />);
const navElement = await waitFor(() =>
queryByAttribute('id', dom.container, 'wpadminbar'),
);
expect(navElement).toBeInTheDocument();
});+1 to @mindctrl's point about adding another test to avoid regressions. We could mock certain values from the const useRouterSpy = jest.spyOn(nextRouter, 'useRouter').mockReturnValue({
query: {
p: '123',
typeName: 'Post'
},
} as any as nextRouter.NextRouter); |
Thank you John! Still working on getting the tests to pass here for the packages on Node.js 16 and 18- the logic has changed a bit with this implementation. 👍 |
… of https://github.com/wpengine/faustjs into MERL-1004-edit-button-in-toolbar-added-to-preview-node
|
Hi @blakewilson and @mindctrl ! Thank you so much for reviewing this for me! My test packages for Node.js 16 and 18 failed upon adding our regression tests for the Edit Post Node in previews. I've confirmed that they're passing locally, but in our GitHub actions the test is receiving one assertion call instead of two, and expects 3 items but receives 4. I've dug around but can't seem to find an explanation for the discrepancy. Maybe something is unexpected about the way GitHub is handling expect.assertions(number) in this scenario? I've also rerun the failed checks, no change. |
It might be that the assertions fail because of the missing https://github.com/wpengine/faustjs/actions/runs/6041182270/job/16393924705?pr=1556#step:6:513 |
blakewilson
left a comment
There was a problem hiding this comment.
Nice work @TeresaGobble! Thanks for adding regression tests as well.
Tasks
Description
This PR addresses the missing edit button in the Faust toolbar when previewing a post.
Ticket: https://wpengine.atlassian.net/jira/software/c/projects/MERL/boards/1007?modal=detail&selectedIssue=MERL-1004
Closes #1515
Testing
Before testing:
Enable the experimental toolbar in your test site- see Customizing the Toolbar - Faust.js™ for instructions.
Enable public route redirects in WordPress:
wp-admin → settings → faust → Enable public route redirects ✅
Testing:

Start your test site after switching to this branch.
go to
wp-adminand create a new post. Add content, and then click on the laptop icon on the upper righthand side of the editor. Go toPreview in new tab.Note the edit button present in the Faust toolbar.