Skip to content
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

#7378: Fix page editor detection #7391

Merged
merged 3 commits into from
Jan 22, 2024

Conversation

fregante
Copy link
Contributor

@fregante fregante commented Jan 21, 2024

Note

This PR's base branch is #7378

What does this PR do?

See issues in:

Checklist

@fregante fregante added the bug Something isn't working label Jan 21, 2024
@fregante fregante requested a review from twschiller January 21, 2024 09:07
@fregante fregante changed the base branch from main to feature/7377-uipath-local January 21, 2024 09:37
@@ -68,8 +68,8 @@ async function safelyRunBrick(
}

// This must follow the tab existence checks or else it returns false even if the tab simply doesn't exist
if (!(await canAccessTab(tabId))) {
throw new BusinessError("PixieBrix doesn't have access to the tab");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated bugfix, but should be straightforward

isDevToolsPage() ||
// Check for the page editor pagePath in the location pathname
location.pathname === "/pageEditor.html"
) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've been bitten by this before

@@ -52,7 +52,7 @@ const startWatching = once(async () => {
});

export default function useCurrentUrl(): string {
expectContext("devTools");
expectContext("pageEditor");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pageEditor: isPageEditor,
contentScript: isContentScript,
sidebar: isBrowserSidebar,
} as const;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out we were making a mistake here. Due to the Map type, all the contexts were specified and allowed by TypeScript, but then fail at runtime.

Copy link
Contributor Author

@fregante fregante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Duplicate)

Copy link

codecov bot commented Jan 21, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (c2a7420) 72.43% compared to head (65ec246) 72.43%.

Files Patch % Lines
src/utils/expectContext.ts 60.00% 2 Missing ⚠️
src/pageEditor/hooks/useCurrentUrl.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                    Coverage Diff                     @@
##           feature/7377-uipath-local    #7391   +/-   ##
==========================================================
  Coverage                      72.43%   72.43%           
==========================================================
  Files                           1207     1207           
  Lines                          37535    37535           
  Branches                        7053     7051    -2     
==========================================================
+ Hits                           27187    27188    +1     
+ Misses                         10348    10347    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@twschiller
Copy link
Contributor

Marking @BLoe as primary reviewer

@@ -57,14 +57,6 @@ describe("useCurrentOrigin", () => {
expect(result.current).toBe("chrome-extension://abcxyz/");
});

test("if devtools page, should return devtools origin", async () => {
setContext("devToolsPage");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The page editor test is below. We have no React code running on devtools_page

Copy link

No loom links were found in the first post. Please add one there if you'd like to it to appear on Slack.

Do not edit this comment manually.

@fregante fregante merged commit 3b04a07 into feature/7377-uipath-local Jan 22, 2024
17 checks passed
@fregante fregante deleted the F/bug/stop-using-isDevToolsPage branch January 22, 2024 02:19
@grahamlangford grahamlangford added this to the 1.8.8 milestone Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

4 participants