このコミットが含まれているのは:
@@ -51,6 +51,21 @@ const postSimilarityQuestion = (
|
||||
})
|
||||
|
||||
|
||||
const sourceQuestion = (
|
||||
host: string,
|
||||
): GekanatorQuestion => ({
|
||||
id: `source:${ host }`,
|
||||
text: `${ host }?`,
|
||||
kind: 'source',
|
||||
condition: {
|
||||
type: 'source',
|
||||
host },
|
||||
source: 'default',
|
||||
priorityWeight: 1,
|
||||
test: candidate => new URL (candidate.url).hostname === host,
|
||||
})
|
||||
|
||||
|
||||
const answer = (
|
||||
question: GekanatorQuestion,
|
||||
value: GekanatorAnswerValue,
|
||||
@@ -64,7 +79,7 @@ const answer = (
|
||||
|
||||
|
||||
describe('candidatePostsFor', () => {
|
||||
it('lets recovered candidates ignore old answers but not later answers', () => {
|
||||
it('does not hard-filter semantic post_similarity answers', () => {
|
||||
const posts = [post (1), post (2), post (3)]
|
||||
const oldQuestion = postSimilarityQuestion ('old', {
|
||||
1: 'no',
|
||||
@@ -77,6 +92,29 @@ describe('candidatePostsFor', () => {
|
||||
3: 'yes',
|
||||
})
|
||||
|
||||
const candidates = candidatePostsFor ({
|
||||
posts,
|
||||
questions: [oldQuestion, laterQuestion],
|
||||
answers: [answer (oldQuestion, 'yes'), answer (laterQuestion, 'yes')],
|
||||
softenedQuestionIds: new Set (),
|
||||
rejectedPostIds: new Set (),
|
||||
recoveredCandidatePosts: new Map ([
|
||||
[1, 1],
|
||||
[3, 1],
|
||||
]) })
|
||||
|
||||
expect(candidates.map (candidate => candidate.id)).toEqual ([1, 2, 3])
|
||||
})
|
||||
|
||||
it('lets recovered candidates ignore old fact answers but not later fact answers', () => {
|
||||
const posts = [
|
||||
{ ...post (1), url: 'https://other.example/posts/1' },
|
||||
post (2),
|
||||
{ ...post (3), url: 'https://example.com/posts/3' },
|
||||
]
|
||||
const oldQuestion = sourceQuestion ('old.example.com')
|
||||
const laterQuestion = sourceQuestion ('example.com')
|
||||
|
||||
const candidates = candidatePostsFor ({
|
||||
posts,
|
||||
questions: [oldQuestion, laterQuestion],
|
||||
@@ -112,7 +150,7 @@ describe('candidatePostsFor', () => {
|
||||
|
||||
|
||||
describe('hardFilteredPostsForAnswer', () => {
|
||||
it('returns zero candidates without falling back to the original pool', () => {
|
||||
it('keeps the original pool for semantic post_similarity answers', () => {
|
||||
const posts = [post (1), post (2)]
|
||||
const question = postSimilarityQuestion ('question', {
|
||||
1: 'yes',
|
||||
@@ -123,7 +161,41 @@ describe('hardFilteredPostsForAnswer', () => {
|
||||
posts,
|
||||
question,
|
||||
answer: 'no',
|
||||
})).toEqual ([])
|
||||
})).toEqual (posts)
|
||||
})
|
||||
|
||||
it('hard-filters fact answers only for yes and no', () => {
|
||||
const posts = [
|
||||
{ ...post (1), url: 'https://example.com/posts/1' },
|
||||
{ ...post (2), url: 'https://other.example/posts/2' },
|
||||
]
|
||||
const question = sourceQuestion ('example.com')
|
||||
|
||||
expect(hardFilteredPostsForAnswer ({
|
||||
posts,
|
||||
question,
|
||||
answer: 'yes',
|
||||
}).map (candidate => candidate.id)).toEqual ([1])
|
||||
expect(hardFilteredPostsForAnswer ({
|
||||
posts,
|
||||
question,
|
||||
answer: 'no',
|
||||
}).map (candidate => candidate.id)).toEqual ([2])
|
||||
expect(hardFilteredPostsForAnswer ({
|
||||
posts,
|
||||
question,
|
||||
answer: 'partial',
|
||||
})).toEqual (posts)
|
||||
expect(hardFilteredPostsForAnswer ({
|
||||
posts,
|
||||
question,
|
||||
answer: 'probably_no',
|
||||
})).toEqual (posts)
|
||||
expect(hardFilteredPostsForAnswer ({
|
||||
posts,
|
||||
question,
|
||||
answer: 'unknown',
|
||||
})).toEqual (posts)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ export const hardFilteredPostsForAnswer = ({
|
||||
if (!(questionIsFactLikeForHardFiltering (question)))
|
||||
return posts
|
||||
|
||||
if (answer === 'unknown')
|
||||
if (!(answer === 'yes' || answer === 'no'))
|
||||
return posts
|
||||
|
||||
return posts.filter (post => {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { isQuestionHardFilteredAfterAnswers } from '@/lib/gekanatorQuestionFilters'
|
||||
@@ -49,6 +52,57 @@ const blocked = (
|
||||
isQuestionHardFilteredAfterAnswers (question (candidate), [answer (previous, value)])
|
||||
|
||||
|
||||
const gekanatorPageSource = readFileSync (
|
||||
resolve (process.cwd (), 'src/pages/GekanatorPage.tsx'),
|
||||
'utf8')
|
||||
|
||||
const gekanatorBackdropSource = gekanatorPageSource.slice (
|
||||
gekanatorPageSource.indexOf ('const GekanatorBackdrop'),
|
||||
gekanatorPageSource.indexOf ('const expectedAnswerFor'))
|
||||
|
||||
|
||||
describe('GekanatorBackdrop regression structure', () => {
|
||||
it('keeps displayedBackdropMode as the render-time source of truth', () => {
|
||||
expect(gekanatorBackdropSource).not.toContain ('isLeavingGuessBackdrop')
|
||||
expect(gekanatorBackdropSource).not.toContain ('renderBackdropMode')
|
||||
expect(gekanatorBackdropSource).not.toContain ('renderWinningRunCount')
|
||||
expect(gekanatorBackdropSource).not.toContain ('renderThumbnails')
|
||||
expect(gekanatorBackdropSource).not.toContain ('renderIsCrossfading')
|
||||
|
||||
expect(gekanatorBackdropSource).toContain (
|
||||
"const renderedSettings = settingsForMode (displayedBackdropMode)")
|
||||
expect(gekanatorBackdropSource).toContain (
|
||||
'scaleForMode (displayedBackdropMode, displayedWinningRunCount)')
|
||||
expect(gekanatorBackdropSource).toContain (
|
||||
"backdropMode === 'guess' || displayedBackdropMode === 'guess'")
|
||||
})
|
||||
|
||||
it('does not split guess into a separate renderer or force a remount', () => {
|
||||
expect(gekanatorBackdropSource).not.toContain ('renderStaticGuessBackdrop')
|
||||
expect(gekanatorBackdropSource).not.toContain ('guessZoomAnimationKey')
|
||||
expect(gekanatorBackdropSource).not.toContain ('shouldAnimateGuessZoomIn')
|
||||
expect(gekanatorBackdropSource).not.toContain ('previousBackdropModeRef')
|
||||
expect(gekanatorBackdropSource).not.toContain (
|
||||
'if (isGuessPresentation && guessThumbnail)')
|
||||
})
|
||||
|
||||
it('keeps tile keys independent from backdrop mode', () => {
|
||||
expect(gekanatorBackdropSource).toContain ('key={duplicate}')
|
||||
expect(gekanatorBackdropSource).toContain ('key={`${ duplicate }:${ index }`}')
|
||||
expect(gekanatorBackdropSource).not.toMatch (/key=\{`\$\{\s*mode/)
|
||||
expect(gekanatorBackdropSource).not.toMatch (/key=\{`\$\{\s*displayedBackdropMode/)
|
||||
})
|
||||
|
||||
it('keeps guess on the shared scale, x, and y animation path', () => {
|
||||
expect(gekanatorBackdropSource).toContain ('animate={{ scale: renderedScale')
|
||||
expect(gekanatorBackdropSource).toContain (
|
||||
"x: displayedBackdropMode === 'guess' ? guessFocusOffset.x : '0%'")
|
||||
expect(gekanatorBackdropSource).toContain (
|
||||
"y: displayedBackdropMode === 'guess' ? guessFocusOffset.y : '0%'")
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
describe('isQuestionHardFilteredAfterAnswers', () => {
|
||||
it('blocks only contradictory or redundant month questions after a yes answer', () => {
|
||||
const previous: GekanatorQuestionCondition = { type: 'original-month', month: 12 }
|
||||
|
||||
新しい課題から参照
ユーザをブロックする