このコミットが含まれているのは:
2026-10-29 21:38:38 +09:00
コミット 237331481f
11個のファイルの変更、56行の追加、26行の削除
+3 -1
ファイルの表示
@@ -29,7 +29,9 @@ RSpec.describe HistoryAccess do
admin = create(:user, :admin) admin = create(:user, :admin)
admin_metadata = described_class.set(user: admin) { described_class.authority } admin_metadata = described_class.set(user: admin) { described_class.authority }
TagVersion.create!(tag:, version_no: 1, event_type: 'discard', name: 'private', TagVersion.create!(tag:, version_no: 1, event_type: 'discard', name: 'private',
category: 'general', names: { ja: { name: 'private' } }, category: 'general',
names: { ja: { name: 'private', script_code: 'Jpan',
auto_generated: false, aliases: [] } },
aliases: '', parent_tag_ids: '', created_at: Time.utc(2024)) aliases: '', parent_tag_ids: '', created_at: Time.utc(2024))
described_class.set(user: nil) do described_class.set(user: nil) do
expect(described_class.authorised_artifact?(public_metadata)).to be(false) expect(described_class.authorised_artifact?(public_metadata)).to be(false)
+2 -2
ファイルの表示
@@ -16,13 +16,13 @@ RSpec.describe 'Counts table API', type: :request do
before do before do
TagVersion.create!(tag:, version_no: 1, event_type: 'create', name: 'alpha', TagVersion.create!(tag:, version_no: 1, event_type: 'create', name: 'alpha',
category: 'general', aliases: '', parent_tag_ids: '', category: 'general', aliases: '', parent_tag_ids: '',
names: { ja: { name: 'alpha', script_code: 'Jpan', aliases: [] } }, names: { ja: { name: 'alpha', script_code: 'Jpan', auto_generated: false, aliases: [] } },
created_at: Time.utc(2023)) created_at: Time.utc(2023))
NicoTagVersion.create!(external_tag: external, version_no: 1, NicoTagVersion.create!(external_tag: external, version_no: 1,
event_type: 'create', name: 'beta', linked_tags: '', created_at: Time.utc(2023)) event_type: 'create', name: 'beta', linked_tags: '', created_at: Time.utc(2023))
snapshots = [ snapshots = [
{ tag_id: tag.id, version_no: 1, name: 'alpha', category: 'general', sections: [] }, { tag_id: tag.id, version_no: 1, name: 'alpha', category: 'general', sections: [] },
{ external_tag_id: external.id, name: 'beta', sections: [] }] { external_tag_id: external.id }]
[1, 2, 3].each do |number| [1, 2, 3].each do |number|
PostVersion.create!(post: record, version_no: number, PostVersion.create!(post: record, version_no: number,
event_type: number == 1 ? 'create' : 'update', url: record.url, event_type: number == 1 ? 'create' : 'update', url: record.url,
+23 -1
ファイルの表示
@@ -21,7 +21,29 @@ RSpec.describe 'Post filter identity across locales', type: :request do
['nico:shared', 'union_alias', 'not:nico:shared'].each do |literal| ['nico:shared', 'union_alias', 'not:nico:shared'].each do |literal|
it "preserves the complete match set for #{ literal }" do it "preserves the complete match set for #{ literal }" do
get '/posts', params: { locale: 'ja', tags: literal } reference_params = { tag_refs: '' }
references.each_with_index do |reference, index|
%w[name tag_id external_tag_id negative missing].each do |field|
value = reference[field]
next if value.nil?
next if field == 'missing' && value == false
reference_params["tag_refs.#{index}.#{field}"] =
case value
when true
'1'
when false
'0'
else
value.to_s
end
end
end
get '/posts', params: {
locale: 'ain-Kana',
tags: references.map { _1.fetch('name') }.join(' ') }.merge(reference_params)
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
original_ids = json.fetch('posts').map { _1.fetch('id') } original_ids = json.fetch('posts').map { _1.fetch('id') }
expected = literal.start_with?('not:') ? [other_post.id] : expected = literal.start_with?('not:') ? [other_post.id] :
+2 -2
ファイルの表示
@@ -55,7 +55,7 @@ RSpec.describe 'Tag description Wiki compatibility', type: :request do
end end
it 'does not fall back to a revision absent from new history' do it 'does not fall back to a revision absent from new history' do
versions.first.destroy! TagDescriptionVersion.where(id: versions.first.id).delete_all
without_legacy_reads do without_legacy_reads do
get "/wiki/#{ description.id }", params: { version: versions.first.id } get "/wiki/#{ description.id }", params: { version: versions.first.id }
end end
@@ -190,7 +190,7 @@ RSpec.describe 'Tag description Wiki compatibility', type: :request do
describe 'index' do describe 'index' do
[nil, 'description_contract'].each do |title| [nil, 'description_contract'].each do |title|
it "returns new content once in #{ title ? 'filtered' : 'unfiltered' } index" do it "returns new content once in #{ title ? 'filtered' : 'unfiltered' } index" do
get '/wiki', params: { title: } get '/wiki', params: title.nil? ? { } : { title: title }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
rows = json.select { |row| row.fetch('id') == description.id } rows = json.select { |row| row.fetch('id') == description.id }
expect(rows.size).to eq(1) expect(rows.size).to eq(1)
+6 -1
ファイルの表示
@@ -12,11 +12,16 @@ RSpec.describe 'Counts export contracts' do
around do |example| around do |example|
Dir.mktmpdir('counts-export-spec') do |path| Dir.mktmpdir('counts-export-spec') do |path|
allow(CountsExportDownload).to receive(:directory).and_return(Pathname.new(path)) @counts_export_dir = Pathname.new(path)
HistoryAccess.set(user: nil) { example.run } HistoryAccess.set(user: nil) { example.run }
end end
end end
before do
allow(CountsExportDownload).to receive(:directory)
.and_return(@counts_export_dir)
end
context 'serialization after the authorised query' do context 'serialization after the authorised query' do
let(:rows) { [{ title: "=formula\n\"quoted\"" }, { title: 'second' }] } let(:rows) { [{ title: "=formula\n\"quoted\"" }, { title: 'second' }] }
let(:page) do let(:page) do
+2 -1
ファイルの表示
@@ -336,7 +336,8 @@ test ('counts SSR uses query/definitions, noindex and the common site title', as
for (const locale of ['ja', 'ain-Kana']) { for (const locale of ['ja', 'ain-Kana']) {
for (const resource of ['posts', 'tags']) { for (const resource of ['posts', 'tags']) {
const column = resource === 'posts' ? 'title' : (locale === 'ja' ? 'name_ja' : 'name_ain') const column = resource === 'posts' ? 'title' : (locale === 'ja' ? 'name_ja' : 'name_ain')
const query = `definition=history&mode=details&columns=resource_id+${column}&user_id=4` const query =
`definition=history&mode=details&columns=resource_id+${ column }&user_id=4&timezone=UTC`
const result = await renderPage (`/${locale}/counts/${resource}?${query}`, origin, apiURL) const result = await renderPage (`/${locale}/counts/${resource}?${query}`, origin, apiURL)
assert.equal (result.status, 200) assert.equal (result.status, 200)
assert.match (result.html, /SSR count/) assert.match (result.html, /SSR count/)
+2 -1
ファイルの表示
@@ -9,11 +9,12 @@ import { renderWithProviders } from '@/test/render'
import type { CountField } from '@/lib/counts' import type { CountField } from '@/lib/counts'
const renderTable = () => renderWithProviders (<CountsTableLayout> const renderTable = () => renderWithProviders (<CountsTableLayout>
<CountsSelectableTable family="details" columns={['resource_id', 'version_no']} <CountsSelectableTable family="details" columns={['resource_id', 'version_no']}
identity="stable" name={{ text: 'Grid', language: 'en' }}> identity="stable" name={{ text: 'Grid', language: 'en' }}>
<tbody> <tbody>
<tr><td><span>first</span> <span>cell</span></td><td>second</td></tr> <tr><td data-counts-copy="first cell"><span>first</span> <span>cell</span></td><td>second</td></tr>
<tr><td>third</td><td><input aria-label="editor" defaultValue="editable"/></td></tr> <tr><td>third</td><td><input aria-label="editor" defaultValue="editable"/></td></tr>
</tbody> </tbody>
</CountsSelectableTable> </CountsSelectableTable>
+2 -2
ファイルの表示
@@ -28,7 +28,7 @@ describe ('locale URL generation', () => {
'/tos', '/gekanator', '/more']) ('localises and redirects %s', pathname => { '/tos', '/gekanator', '/more']) ('localises and redirects %s', pathname => {
const location = { pathname, search: '?page=2&tag=a%23b', hash: '#section' } const location = { pathname, search: '?page=2&tag=a%23b', hash: '#section' }
expect (localiseTo (pathname, 'ain-Kana')).toBe (`/ain-Kana${ pathname }`) expect (localiseTo (pathname, 'ain-Kana')).toBe (`/ain-Kana${ pathname }`)
expect (legacyLocalePath (location)).toBe (`/ja${ pathname }${ location.search }#section`) expect (legacyLocalePath (location, () => true)).toBe (`/ja${ pathname }${ location.search }#section`)
expect (unlocalisedPath (`/ain-Kana${ pathname }`)).toBe (pathname) expect (unlocalisedPath (`/ain-Kana${ pathname }`)).toBe (pathname)
}) })
@@ -50,6 +50,6 @@ describe ('locale URL generation', () => {
it.each (['/en/posts', '/ain/posts', '/unknown', '/api/tags', '/assets/image.png']) ( it.each (['/en/posts', '/ain/posts', '/unknown', '/api/tags', '/assets/image.png']) (
'does not redirect invalid or non-page paths: %s', pathname => { 'does not redirect invalid or non-page paths: %s', pathname => {
expect (legacyLocalePath ({ pathname, search: '', hash: '' })).toBeNull () expect (legacyLocalePath ({ pathname, search: '', hash: '' }, () => false)).toBeNull ()
}) })
}) })
+4 -5
ファイルの表示
@@ -29,11 +29,10 @@ vi.mock ('@/components/PostEditForm', () => ({
default: () => <div>Post edit form</div>, default: () => <div>Post edit form</div>,
})) }))
vi.mock ('framer-motion', () => ({ vi.mock ('framer-motion', () => ({
motion: { useReducedMotion: () => false,
div: ({ children }: { children?: ReactNode }) => <div>{children}</div>, motion: {
main: ({ children }: { children?: ReactNode }) => <main>{children}</main>, div: ({ children }: { children?: ReactNode }) => <div>{children}</div>,
}, main: ({ children }: { children?: ReactNode }) => <main>{children}</main> } }))
}))
const renderPage = (user = buildUser ({ role: 'member' })) => const renderPage = (user = buildUser ({ role: 'member' })) =>
renderWithProviders ( renderWithProviders (
+5 -4
ファイルの表示
@@ -15,10 +15,11 @@ const api = vi.hoisted (() => ({
vi.mock ('@/lib/api', () => api) vi.mock ('@/lib/api', () => api)
vi.mock ('framer-motion', () => ({ vi.mock ('framer-motion', () => ({
AnimatePresence: ({ children }: { children?: ReactNode }) => <>{children}</>, AnimatePresence: ({ children }: { children?: ReactNode }) => <>{children}</>,
motion: { useReducedMotion: () => false,
div: ({ children }: { children?: ReactNode }) => <div>{children}</div>, motion: {
main: ({ children }: { children?: ReactNode }) => <main>{children}</main> } })) div: ({ children }: { children?: ReactNode }) => <div>{children}</div>,
main: ({ children }: { children?: ReactNode }) => <main>{children}</main> } }))
const metadata = (url: string, title: string) => ({ const metadata = (url: string, title: string) => ({
url, url,
+5 -6
ファイルの表示
@@ -65,12 +65,11 @@ vi.mock ('@/components/PostEditForm', () => ({
default: () => <div>Post edit form</div>, default: () => <div>Post edit form</div>,
})) }))
vi.mock ('framer-motion', () => ({ vi.mock ('framer-motion', () => ({
motion: { useReducedMotion: () => false,
aside: ({ children }: { children?: ReactNode }) => <aside>{children}</aside>, motion: {
div: ({ children }: { children?: ReactNode }) => <div>{children}</div>, aside: ({ children }: { children?: ReactNode }) => <aside>{children}</aside>,
main: ({ children }: { children?: ReactNode }) => <main>{children}</main>, div: ({ children }: { children?: ReactNode }) => <div>{children}</div>,
}, main: ({ children }: { children?: ReactNode }) => <main>{children}</main> } }))
}))
const currentPost = buildPost ({ const currentPost = buildPost ({
id: 10, id: 10,