-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#234 | Better URL validation | Iframe board tests added (plus some refactor) #242
Changes from 2 commits
b5cfd27
e28548b
809094a
c3b216c
b774878
138a7f3
0ca26d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,11 @@ const dialogFields = { | |
component: TextInput, | ||
name: 'publicUrl', | ||
label: 'Public URL', | ||
validator: () => string().url(vm.INVALID_URL()) | ||
validator: () => | ||
string().matches( | ||
/^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/, | ||
{ message: vm.INVALID_URL(), excludeEmptyString: true } | ||
) | ||
Comment on lines
+79
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better URL Validation - port number possible |
||
}, | ||
WidgetTypeField: { | ||
component: DisplayValueSelect, | ||
|
@@ -210,13 +214,21 @@ const dialogFields = { | |
component: TextInput, | ||
name: 'url', | ||
label: 'URL', | ||
validator: () => string().url(vm.INVALID_URL()) | ||
validator: () => | ||
string().matches( | ||
/^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/, | ||
{ message: vm.INVALID_URL(), excludeEmptyString: true } | ||
) | ||
Comment on lines
+217
to
+221
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better URL Validation - port number possible |
||
}, | ||
IFrameURL: { | ||
component: TextInput, | ||
name: 'iframeUrl', | ||
label: 'URL', | ||
validator: () => string().url(vm.INVALID_URL()) | ||
validator: () => | ||
string().matches( | ||
/^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/, | ||
{ message: vm.INVALID_URL(), excludeEmptyString: true } | ||
) | ||
Comment on lines
+227
to
+231
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better URL Validation - port number possible |
||
}, | ||
IdString: { | ||
component: TextInput, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,9 @@ import { | |
dashboardNameGen, | ||
columnEdgeValues, | ||
switchIntervalEdgeValues, | ||
dashboardNames, | ||
dashboardTypes | ||
dashboardNames | ||
} from '../fixtures/Dashboard'; | ||
import { addWidgetsDashboard } from '../support/dashboard'; | ||
import { addIframeDashboard, addWidgetsDashboard } from '../support/dashboard'; | ||
|
||
describe('Basic Dashboard CRUD', () => { | ||
const newTitle = dashboardNameGen('Edit'); | ||
|
@@ -15,14 +14,24 @@ describe('Basic Dashboard CRUD', () => { | |
cy.login(); | ||
}); | ||
|
||
it('Logged user can add new dashboard', () => { | ||
it('Logged user can add new widgets dashboard', () => { | ||
addWidgetsDashboard(); | ||
}); | ||
|
||
it('Logged user can choose dashboard', () => { | ||
it('Logged user can choose widgets dashboard', () => { | ||
addWidgetsDashboard().canBeSelected(); | ||
}); | ||
|
||
it('Logged user can add new iframe dashboard', () => { | ||
addIframeDashboard(); | ||
}); | ||
|
||
it('Logged user can choose iframe dashboard', () => { | ||
addIframeDashboard() | ||
.canBeSelected() | ||
.assertIframeExists(); | ||
}); | ||
Comment on lines
+25
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added tests for Iframe widget |
||
|
||
it('Anonymous user can choose dashboard', () => { | ||
const board = addWidgetsDashboard(); | ||
cy.closeDrawer(); | ||
|
@@ -46,63 +55,61 @@ describe('Basic Dashboard CRUD', () => { | |
}); | ||
}); | ||
|
||
describe('Dashboard Frontend Validation', () => { | ||
describe('Dashboard Input Validation', () => { | ||
beforeEach(() => { | ||
cy.visit('/'); | ||
cy.login(); | ||
}); | ||
|
||
it(' For empty dashboard name is displayed and submit is impossible', () => { | ||
addWidgetsDashboard(' ', '4', '10', true).assertErrorMessageVisible( | ||
'This field is required' | ||
); | ||
it('Name input do not accept empty strings', () => { | ||
addWidgetsDashboard(' ') | ||
.expectConfigToBeInvalid() | ||
.assertErrorMessageVisible('This field is required'); | ||
}); | ||
|
||
dashboardNames.forEach(value => { | ||
it(` For too long dashboard name is displayed and submit is impossible. Length: ${value.length}`, () => { | ||
const board = addWidgetsDashboard( | ||
value, | ||
dashboardTypes.widgets, | ||
'8', | ||
'10', | ||
true | ||
); | ||
it(`Name input accepts strings not exceeding 50 characters. Current: ${value.length}`, () => { | ||
const board = addWidgetsDashboard(value); | ||
if (value.length > 50) { | ||
board.assertErrorMessageVisible( | ||
'Title length must be less or equal to 50.' | ||
); | ||
board | ||
.expectConfigToBeInvalid() | ||
.assertErrorMessageVisible( | ||
'Title length must be less or equal to 50.' | ||
); | ||
} else { | ||
board.assertErrorNotVisible(); | ||
board.expectConfigToBeValid(); | ||
} | ||
}); | ||
}); | ||
|
||
columnEdgeValues.forEach(value => { | ||
it(` For Columns input is displayed and submit is impossible for incorrect values. Edge value : ${value}`, () => { | ||
const board = addWidgetsDashboard(undefined, value, '10', true); | ||
if (value === '3') { | ||
board.assertErrorMessageVisible( | ||
'Columns number cannot be less than 4.' | ||
); | ||
} else if (value === '21') { | ||
board.assertErrorMessageVisible( | ||
'Columns number cannot be more than 20.' | ||
); | ||
it(`Columns input accepts only values from 4 to 20. Current: ${value}`, () => { | ||
const board = addWidgetsDashboard(undefined, value); | ||
if (value < 4) { | ||
board | ||
.expectConfigToBeInvalid() | ||
.assertErrorMessageVisible('Columns number cannot be less than 4.'); | ||
} else if (value > 20) { | ||
board | ||
.expectConfigToBeInvalid() | ||
.assertErrorMessageVisible('Columns number cannot be more than 20.'); | ||
} else { | ||
board.assertErrorNotVisible(); | ||
board.expectConfigToBeValid(); | ||
} | ||
}); | ||
}); | ||
|
||
switchIntervalEdgeValues.forEach(value => { | ||
it(` For Switch Interval input is displayed and submit is impossible for incorrect values. Edge value: ${value}`, () => { | ||
const board = addWidgetsDashboard(undefined, '8', value, true); | ||
if (value === '2') { | ||
board.assertErrorMessageVisible( | ||
'Switch interval number cannot be less than 3.' | ||
); | ||
it(`Switch interval input accepts only values grater than 2. Current: ${value}`, () => { | ||
const board = addWidgetsDashboard(undefined, undefined, value); | ||
if (value < 3) { | ||
board | ||
.expectConfigToBeInvalid() | ||
.assertErrorMessageVisible( | ||
'Switch interval number cannot be less than 3.' | ||
); | ||
} else { | ||
board.assertErrorNotVisible(); | ||
board.expectConfigToBeValid(); | ||
} | ||
}); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This link did not worked