mirror of
https://github.com/zen-browser/desktop.git
synced 2026-09-06 13:30:44 +00:00
gh-15234: Fixed issues live folders not loading (gh-15235)
This commit is contained in:
@@ -198,45 +198,36 @@ export class nsGithubLiveFolderProvider extends nsZenLiveFolderProvider {
|
||||
}
|
||||
|
||||
const document = new DOMParser().parseFromString(text, "text/html");
|
||||
const issues = document.querySelectorAll(
|
||||
"div[class^=IssueItem-module__defaultRepoContainer]"
|
||||
const links = document.querySelectorAll(
|
||||
'a[data-testid="issue-listitem-title-link"]'
|
||||
);
|
||||
const items = [];
|
||||
const activeRepos = new Set();
|
||||
|
||||
if (issues.length) {
|
||||
const authors = document.querySelectorAll(
|
||||
"a[class^=IssueItem-module__authorCreatedLink]"
|
||||
for (const link of links) {
|
||||
const issueUrl = new URL(link.getAttribute("href"), this.state.url);
|
||||
const pathMatch = issueUrl.pathname.match(
|
||||
/^\/([^/]+\/[^/]+)\/(?:issues|pull)\/([0-9]+)/
|
||||
);
|
||||
const titles = document.querySelectorAll(
|
||||
"div[class^=Title-module__container]"
|
||||
);
|
||||
const links = document.querySelectorAll(
|
||||
'[data-testid="issue-pr-title-link"]'
|
||||
);
|
||||
|
||||
for (let i = 0; i < issues.length; i++) {
|
||||
const [rawRepo, rawNumber] = issues[i].childNodes;
|
||||
const author = authors[i]?.textContent;
|
||||
const title = titles[i]?.textContent;
|
||||
const issueUrl = links[i]?.href;
|
||||
|
||||
const repo = rawRepo.textContent?.trim();
|
||||
if (repo) {
|
||||
activeRepos.add(repo);
|
||||
}
|
||||
|
||||
const numberMatch = rawNumber?.textContent?.match(/[0-9]+/);
|
||||
const number = numberMatch?.[0] ?? "";
|
||||
|
||||
items.push({
|
||||
title,
|
||||
subtitle: author,
|
||||
icon: "chrome://browser/content/zen-images/favicons/github.svg",
|
||||
url: "https://github.com" + issueUrl,
|
||||
id: `${repo}#${number}`,
|
||||
});
|
||||
if (!pathMatch) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const [, repo, number] = pathMatch;
|
||||
activeRepos.add(repo);
|
||||
|
||||
const author = link
|
||||
.closest("li")
|
||||
?.querySelector('[data-testid="author-filter-link"]')
|
||||
?.lastChild?.textContent.trim();
|
||||
|
||||
items.push({
|
||||
title: link.textContent.trim(),
|
||||
subtitle: author,
|
||||
icon: "chrome://browser/content/zen-images/favicons/github.svg",
|
||||
url: issueUrl.href,
|
||||
id: `${repo}#${number}`,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -130,18 +130,22 @@ add_task(async function test_html_parsing_logic() {
|
||||
const mockHtml = `
|
||||
<html>
|
||||
<body>
|
||||
<div>
|
||||
<div class="IssueItem-module__defaultRepoContainer"><span>mozilla/zen</span><span>#101</span></div>
|
||||
<a class="IssueItem-module__authorCreatedLink">UserA</a>
|
||||
<div class="Title-module__container">Fix the login bug</div>
|
||||
<a data-testid="issue-pr-title-link" href="/issues/101"></a>
|
||||
</div>
|
||||
<div>
|
||||
<div class="IssueItem-module__defaultRepoContainer"><span>mozilla/zen</span><span>#102</span></div>
|
||||
<a class="IssueItem-module__authorCreatedLink">UserB</a>
|
||||
<div class="Title-module__container">Add dark mode</div>
|
||||
<a data-testid="issue-pr-title-link" href="/pull/102"></a>
|
||||
</div>
|
||||
<ul>
|
||||
<li class="ListItem-module__listItem__wBJcm">
|
||||
<h4><a data-testid="issue-listitem-title-link" href="https://github.com/mozilla/zen/issues/101"><span><span>Fix the login bug</span></span></a></h4>
|
||||
<div class="Description-module__container__hpqJz">
|
||||
<span>zen-browser/desktop#101</span>
|
||||
<span> · <button data-testid="author-filter-link"><span class="prc-VisuallyHidden-VisuallyHidden-Q0qSB">Filter by author </span>UserA</button></span>
|
||||
</div>
|
||||
</li>
|
||||
<li class="ListItem-module__listItem__wBJcm">
|
||||
<h4><a data-testid="issue-listitem-title-link" href="https://github.com/mozilla/zen/pull/102"><span><span>Add dark mode</span></span></a></h4>
|
||||
<div class="Description-module__container__hpqJz">
|
||||
<span>zen-browser/desktop#102</span>
|
||||
<span> · <button data-testid="author-filter-link"><span class="prc-VisuallyHidden-VisuallyHidden-Q0qSB">Filter by author </span>UserB</button></span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
@@ -158,12 +162,15 @@ add_task(async function test_html_parsing_logic() {
|
||||
Assert.equal(items[0].title, "Fix the login bug");
|
||||
Assert.equal(items[0].subtitle, "UserA");
|
||||
Assert.equal(items[0].id, "mozilla/zen#101");
|
||||
Assert.equal(items[0].url, "https://github.com/issues/101");
|
||||
Assert.equal(
|
||||
items[0].url,
|
||||
"https://github.com/zen-browser/desktop/issues/101"
|
||||
);
|
||||
|
||||
Assert.equal(items[1].title, "Add dark mode");
|
||||
Assert.equal(items[1].subtitle, "UserB");
|
||||
Assert.equal(items[1].id, "mozilla/zen#102");
|
||||
Assert.equal(items[1].url, "https://github.com/pull/102");
|
||||
Assert.equal(items[1].url, "https://github.com/zen-browser/desktop/pull/102");
|
||||
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user