forked from opendatahub-io/odh-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'cypress-RHOAIENG-15766' of https://github.com/antowaddl…
…e/odh-dashboard into cypress-RHOAIENG-15766
- Loading branch information
Showing
17 changed files
with
94 additions
and
152 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
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
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
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
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
28 changes: 28 additions & 0 deletions
28
frontend/src/concepts/pipelines/content/createRun/contentSections/__tests__/utils.spec.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,28 @@ | ||
import { extractNumberAndTimeUnit } from '~/concepts/pipelines/content/createRun/contentSections/utils'; | ||
|
||
describe('extractNumberAndTimeUnit', () => { | ||
test('splits valid numeric and unit parts', () => { | ||
expect(extractNumberAndTimeUnit('1555Days')).toEqual([1555, 'Days']); | ||
expect(extractNumberAndTimeUnit('1.23e+21Week')).toEqual([1.23e21, 'Week']); | ||
expect(extractNumberAndTimeUnit('1.2342342342342342e+32Week')).toEqual([ | ||
1.2342342342342342e32, | ||
'Week', | ||
]); | ||
}); | ||
|
||
test('handles missing numeric part', () => { | ||
expect(extractNumberAndTimeUnit('Day')).toEqual([1, 'Day']); | ||
expect(extractNumberAndTimeUnit('Minute')).toEqual([1, 'Minute']); | ||
}); | ||
|
||
test('handles edge cases', () => { | ||
expect(extractNumberAndTimeUnit('')).toEqual([1, '']); | ||
expect(extractNumberAndTimeUnit('InfinityYear')).toEqual([1, 'InfinityYear']); | ||
expect(extractNumberAndTimeUnit('-InfinityWeek')).toEqual([1, '-InfinityWeek']); | ||
}); | ||
|
||
test('trims whitespace', () => { | ||
expect(extractNumberAndTimeUnit(' 123Day ')).toEqual([123, 'Day']); | ||
expect(extractNumberAndTimeUnit(' Day ')).toEqual([1, 'Day']); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
frontend/src/concepts/pipelines/content/createRun/contentSections/utils.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,18 @@ | ||
/** | ||
* Splits a string into a numeric part and a unit part | ||
* @param value The input string to be split. | ||
* @returns [numberPart, unitPart] | ||
*/ | ||
export const extractNumberAndTimeUnit = (value: string): [number, string] => { | ||
const trimmedValue = value.trim(); | ||
|
||
const match = trimmedValue.match(/^([+-]?\d+(\.\d+)?([eE][+-]?\d+)?)([a-zA-Z]*)$/); | ||
if (match) { | ||
const numericPart = parseFloat(match[1]); | ||
const unitPart = match[4] || ''; | ||
return [numericPart, unitPart]; | ||
} | ||
|
||
// The required minimum numeric value is set to 1 | ||
return [1, trimmedValue]; | ||
}; |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -219,3 +219,9 @@ rules: | |
- delete | ||
resources: | ||
- accounts | ||
- verbs: | ||
- get | ||
apiGroups: | ||
- '' | ||
resources: | ||
- endpoints |