forked from rancher/dashboard
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automation: Loki Outputs URL can accept invalid input (rancher#9042)
* Add prefix in management settings test description * Add dictionary term * Add url validation test for Banzai cloud * Test presence of placeholder for Loki URL input * Prevent issues with optional values * Prevent issues with missing imported statics * Hide warnings from unit tests on CI * Correct issues with replaceAll unsupported on Safari
- Loading branch information
Showing
7 changed files
with
68 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
"cSpell.words": [ | ||
"apiserver", | ||
"autoscroll", | ||
"banzaicloud", | ||
"cacerts", | ||
"chainable", | ||
"Codecov", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
shell/edit/logging.banzaicloud.io.output/__tests__/logging.banzaicloud.io.output.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { mount } from '@vue/test-utils'; | ||
import Banzai from '@shell/edit/logging.banzaicloud.io.output/index.vue'; | ||
|
||
describe('view: logging.banzaicloud.io.output', () => { | ||
it.each([ | ||
['http://localhost:3100', []], | ||
['not a proper URL', ['logging.loki.urlInvalid']], | ||
])('should validate Loki URL on save', (url, expectation) => { | ||
const wrapper = mount(Banzai, { | ||
data: () => ({ selectedProvider: 'loki' }), | ||
propsData: { | ||
value: { | ||
save: jest.fn(), | ||
spec: { loki: { url } } | ||
} | ||
}, | ||
mocks: { | ||
$store: { | ||
getters: { | ||
currentStore: () => 'current_store', | ||
'management/schemaFor': jest.fn(), | ||
'current_store/all': jest.fn(), | ||
'current_store/schemaFor': jest.fn(), | ||
'cluster/all': jest.fn(), | ||
'type-map/isSpoofed': jest.fn(), | ||
'i18n/t': jest.fn().mockImplementation((key: string) => key), | ||
namespaces: () => ({}), | ||
} | ||
}, | ||
$route: { | ||
name: 'whatever', | ||
query: { AS: '' } | ||
}, | ||
$router: { replace: jest.fn() }, | ||
} | ||
}); | ||
const fakeDone = jest.fn(); | ||
|
||
(wrapper.vm as any).saveSettings(fakeDone); | ||
|
||
expect((wrapper.vm as any).errors).toStrictEqual(expectation); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
shell/edit/logging.banzaicloud.io.output/providers/__tests__/loki.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { shallowMount } from '@vue/test-utils'; | ||
import Loki from '@shell/edit/logging.banzaicloud.io.output/providers/loki.vue'; | ||
|
||
describe('component: Loki', () => { | ||
it('should display URL placeholder', () => { | ||
const wrapper = shallowMount(Loki, { propsData: { mode: 'edit', namespace: 'whatever' } }); | ||
const url = 'https://127.0.0.1:8000'; | ||
|
||
const placeholder = wrapper.find('[data-testid="loki-url"]').attributes('placeholder'); | ||
|
||
expect(placeholder).toBe(url); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters