Skip to content

Commit

Permalink
Refactor brand configurations schema and test coverage
Browse files Browse the repository at this point in the history
- Update brand_configurations.json schema to align with exported data structure
- Revise test cases to validate new JSON schema format
- Fix validation rules to handle modified data structure
  • Loading branch information
MalekKamel committed Oct 28, 2024
1 parent 1b778b6 commit 3e78f1f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions solara/lib/core/doctor/schema/brand_configurations.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"items": {
"type": "object",
"properties": {
"key": {
"filename": {
"type": "string"
},
"name": {
Expand All @@ -37,7 +37,7 @@
}
},
"required": [
"key",
"filename",
"name",
"content"
]
Expand Down
20 changes: 15 additions & 5 deletions solara/lib/spec/solara_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,29 +80,39 @@
end

it 'calls BrandOnboarder and switches to the new brand' do
expect(brand_onboarder_mock).to receive(:onboard)
expect(BrandOnboarder).to receive(:new).and_return(brand_onboarder_mock)
expect(brand_onboarder_mock).to receive(:onboard).with(brand_key, brand_name, clone_brand_key: nil)
expect(manager).to receive(:switch).with(brand_key, ignore_health_check: true)

manager.onboard(brand_key, brand_name)
end

it 'opens dashboard when open_dashboard is true' do
expect(BrandOnboarder).to receive(:new).with(brand_key, brand_name, clone_brand_key: nil).and_return(brand_onboarder_mock)
expect(brand_onboarder_mock).to receive(:onboard)
expect(BrandOnboarder).to receive(:new).and_return(brand_onboarder_mock)
expect(brand_onboarder_mock).to receive(:onboard).with(brand_key, brand_name, clone_brand_key: nil)
expect(manager).to receive(:switch).with(brand_key, ignore_health_check: true)
expect(manager).to receive(:dashboard).with(brand_key)

manager.onboard(brand_key, brand_name, open_dashboard: true)
end

it 'does not open dashboard when open_dashboard is false' do
expect(BrandOnboarder).to receive(:new).with(brand_key, brand_name, clone_brand_key: nil).and_return(brand_onboarder_mock)
expect(brand_onboarder_mock).to receive(:onboard)
expect(BrandOnboarder).to receive(:new).and_return(brand_onboarder_mock)
expect(brand_onboarder_mock).to receive(:onboard).with(brand_key, brand_name, clone_brand_key: nil)
expect(manager).to receive(:switch).with(brand_key, ignore_health_check: true)
expect(manager).not_to receive(:dashboard)

manager.onboard(brand_key, brand_name, open_dashboard: false)
end

it 'passes clone_brand_key when provided' do
clone_key = 'source_brand'
expect(BrandOnboarder).to receive(:new).and_return(brand_onboarder_mock)
expect(brand_onboarder_mock).to receive(:onboard).with(brand_key, brand_name, clone_brand_key: clone_key)
expect(manager).to receive(:switch).with(brand_key, ignore_health_check: true)

manager.onboard(brand_key, brand_name, clone_brand_key: clone_key)
end
end
end

Expand Down

0 comments on commit 3e78f1f

Please sign in to comment.