From a1a40ddc01decf82fb7f3ed9e7893d1de7a44c9c Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 16 Mar 2018 16:04:04 -0700 Subject: [PATCH] Add failing test for KapacitorRules renders both tables rows with unique label FORs --- .../components/KapacitorRules.test.tsx | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ui/test/kapacitor/components/KapacitorRules.test.tsx b/ui/test/kapacitor/components/KapacitorRules.test.tsx index fa06a2aef..6f344e077 100644 --- a/ui/test/kapacitor/components/KapacitorRules.test.tsx +++ b/ui/test/kapacitor/components/KapacitorRules.test.tsx @@ -72,5 +72,31 @@ describe('Kapacitor.Containers.KapacitorRules', () => { expect(containsAnyDuplicate(allCheckboxesIDs)).toEqual(false) }) + + it('renders each rule/task table row label with unique "for" attribute', () => { + const {wrapper} = setup() + + const kapacitorRulesTableRowsLabelFors = wrapper + .find('KapacitorRulesTable') + .dive() + .find('tbody') + .children() + .map(child => child.dive().find('label').props().htmlFor) + + const tasksTableLabelFors = wrapper + .find('TasksTable') + .dive() + .find('tbody') + .children() + .map(child => child.dive().find('label').props().htmlFor) + + const allCheckboxesLabelFors = kapacitorRulesTableRowsLabelFors.concat( + tasksTableLabelFors + ) + + const containsAnyDuplicate = arr => _.uniq(arr).length !== arr.length + + expect(containsAnyDuplicate(allCheckboxesLabelFors)).toEqual(false) + }) }) })