Skip to content

Commit 8ccf60b

Browse files
Fix inflection of OpenProject
1 parent 044996a commit 8ccf60b

4 files changed

Lines changed: 8 additions & 12 deletions

File tree

demo/config/initializers/lookbook_inflector_patch.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,12 @@ module Patches
3434
# Allow directory labels in lookbook to be inflected
3535
module LookbookTreeNodeInflector
3636
def label
37-
return name if name == "OpenProject"
37+
return "OpenProject" if %w[OpenProject open_project].include?(name.to_s)
3838

3939
super
4040
end
4141
end
4242
end
4343
end
4444

45-
# if Object.const_defined?(:Lookbook)
46-
# Lookbook::TreeNode.prepend OpenProject::Patches::LookbookTreeNodeInflector
47-
# end
45+
Lookbook::TreeNode.prepend OpenProject::Patches::LookbookTreeNodeInflector if Object.const_defined?(:Lookbook)

previews/primer/open_project/page_header_preview.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
module Primer
44
module OpenProject
5-
# @logical_path primer/OpenProject
65
# @component Primer::OpenProject::PageHeader
76
# @label Page Header
87
class PageHeaderPreview < ViewComponent::Preview

test/accessibility_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class AccessibilityTest < System::TestCase
1313

1414
scenarios.each do |scenario|
1515
define_method(:"test_#{scenario.lookup_path.parameterize(separator: "_")}") do
16-
visit "/rails/view_components/#{scenario.lookup_path.underscore}"
16+
visit "/rails/view_components/#{scenario.lookup_path}"
1717

1818
excludes = Primer::Accessibility.axe_rules_to_skip(
1919
component: preview.components.first&.component_class,

test/playwright/snapshots.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@ test.describe('generate snapshots', () => {
2929
for (const preview of previewsJson) {
3030
for (const example of preview.examples) {
3131
if (example.snapshot !== 'false') {
32-
const previewPath = example.preview_path.replace('OpenProject', 'open_project')
3332
if (example.snapshot === 'interactive') {
3433
for (const theme of themes) {
3534
test(`${example.preview_path}-${theme}`, async ({page}) => {
36-
await page.goto(`/rails/view_components/${previewPath}?theme=${theme}`)
35+
await page.goto(`/rails/view_components/${example.preview_path}?theme=${theme}`)
3736

3837
// Focus state
3938
await page.keyboard.press('Tab')
@@ -45,16 +44,16 @@ test.describe('generate snapshots', () => {
4544
await new Promise(resolve => setTimeout(resolve, 100))
4645

4746
const focusedScreenshot = await page.screenshot({animations: 'disabled'})
48-
expect(focusedScreenshot).toMatchSnapshot([previewPath, `${theme}.png`])
47+
expect(focusedScreenshot).toMatchSnapshot([example.preview_path, `${theme}.png`])
4948
})
5049
}
5150
}
5251

5352
test(example.preview_path, async ({page}) => {
54-
await page.goto(`/rails/view_components/${previewPath}?theme=all`)
53+
await page.goto(`/rails/view_components/${example.preview_path}?theme=all`)
5554

5655
const defaultScreenshot = await page.locator('#component-preview').screenshot({animations: 'disabled'})
57-
expect(defaultScreenshot).toMatchSnapshot([previewPath, 'default.png'])
56+
expect(defaultScreenshot).toMatchSnapshot([example.preview_path, 'default.png'])
5857

5958
// Focus state
6059
await page.keyboard.press('Tab')
@@ -63,7 +62,7 @@ test.describe('generate snapshots', () => {
6362
await new Promise(resolve => setTimeout(resolve, 100))
6463

6564
const focusedScreenshot = await page.locator('#component-preview').screenshot({animations: 'disabled'})
66-
expect(focusedScreenshot).toMatchSnapshot([previewPath, 'focused.png'])
65+
expect(focusedScreenshot).toMatchSnapshot([example.preview_path, 'focused.png'])
6766
})
6867
}
6968
}

0 commit comments

Comments
 (0)