Skip to content

Commit 1891ab3

Browse files
Copilotfregante
andauthored
Remove isRepo test exception (#247)
Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
1 parent f2cfcff commit 1891ab3

2 files changed

Lines changed: 40 additions & 11 deletions

File tree

‎index.test.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ for (const [detectName, detect] of Object.entries(pageDetect)) {
5454
});
5555
}
5656

57-
// Skip negatives for this one, it's too long
58-
if (detectName === 'isRepo') {
59-
continue;
60-
}
61-
6257
for (const url of allUrls) {
6358
if (!validURLs.includes(url)) {
6459
test(`${detectName} NO ${url}`, () => {

‎index.ts‎

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ function exists(selector: string): boolean {
3838
* ```
3939
*/
4040
async function waitFor(detection: () => boolean): Promise<boolean> {
41-
// eslint-disable-next-line no-await-in-loop -- We need to wait on each frame
4241
while (!detection() && document.readyState !== 'complete') {
4342
// eslint-disable-next-line no-await-in-loop
4443
await new Promise(resolve => {
@@ -457,11 +456,46 @@ export const isRepo = (url: URL | HTMLAnchorElement | Location = location): bool
457456
};
458457

459458
TEST: addTests('isRepo', [
460-
// Some of these are here simply as "gotchas" to other detections
461-
'https://github.com/sindresorhus/refined-github/blame/master/package.json',
462-
'https://github.com/sindresorhus/refined-github/issues/146',
463-
'https://github.com/sindresorhus/notifications/', // Gotcha for isNotifications
464-
'https://github.com/sindresorhus/refined-github/pull/148',
459+
'isActionRun', // Includes isActionJobRun URLs
460+
'isBranches',
461+
'isCompare', // Includes isQuickPR URLs
462+
'isDeletingFile',
463+
'isEditingFile',
464+
'isEditingRelease',
465+
'isFileFinder',
466+
'isForkingRepo',
467+
'isIssue',
468+
'isLabelList',
469+
'isMilestone',
470+
'isMilestoneList',
471+
'isNewAction',
472+
'isNewFile',
473+
'isNewIssue',
474+
'isNewRelease',
475+
'isPR', // Includes isPRConversation, isPRFiles (→isPRCommit), isPRCommitList
476+
'isPRConflicts',
477+
'isProjects',
478+
'isReleases',
479+
'isRepoPRList',
480+
'isRepoCommitList',
481+
'isRepoForksList',
482+
'isRepoGitObject', // Includes isRepoTree (→isRepoRoot→isRepoHome), isSingleFile (→isRenderedTextFile), isBlame
483+
'isRepoIssueList',
484+
'isRepoNetworkGraph',
485+
'isRepoSearch',
486+
'isRepoSettings', // Includes isRepoMainSettings
487+
'isRepoTaxonomyIssueOrPRList',
488+
'isRepoWiki', // Includes isNewWikiPage, isEditingWikiPage, isCompareWikiPage
489+
'isRepositoryActions',
490+
'isSingleCommit',
491+
'isSingleReleaseOrTag',
492+
'isTags',
493+
// Repo URLs from detections that also cover non-repo pages
494+
'https://github.com/sindresorhus/refined-github/projects/3', // From isProject
495+
'https://github.com/tophf/mpiv/discussions/50', // From isDiscussion
496+
'https://github.com/withastro/roadmap/discussions/new?category=proposal', // From isNewDiscussion
497+
'https://github.com/tophf/mpiv/discussions', // From isDiscussionList
498+
// These URLs are repos but don't match any specific detection
465499
'https://github.com/sindresorhus/refined-github/milestones/new', // Gotcha for isRepoTaxonomyIssueOrPRList
466500
'https://github.com/sindresorhus/refined-github/milestones/1/edit', // Gotcha for isRepoTaxonomyIssueOrPRList
467501
'https://github.com/sindresorhus/refined-github/issues/new/choose', // Gotcha for isRepoIssueList

0 commit comments

Comments
 (0)