Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit 7297616

Browse files
authored
chore: add users roles pages tests automation (#373)
1 parent ca1bbc8 commit 7297616

File tree

15 files changed

+323
-38
lines changed

15 files changed

+323
-38
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
1111
"start": "vite preview --host --port 3002",
1212
"tsCheck": "tsc --noEmit",
13-
"pq": "pretty-quick"
13+
"pq": "pretty-quick",
14+
"test": "playwright test",
15+
"test-ui": "playwright test --ui"
1416
},
1517
"dependencies": {
1618
"@apache-arrow/ts": "^14.0.2",

src/components/Button/IconButton.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import classes from './Button.module.css';
55
type IconButtonProps = {
66
onClick?: () => void;
77
renderIcon: () => ReactNode;
8+
data_id?: string;
89
icon?: ReactNode;
910
active?: boolean;
1011
tooltipLabel?: string;
@@ -17,6 +18,7 @@ const IconButton: FC<IconButtonProps> = (props) => {
1718
return (
1819
<Tooltip label={tooltipLabel}>
1920
<ActionIcon
21+
data-testId={props.data_id}
2022
size={props.size ? props.size : 'xl'}
2123
className={`${classes.iconBtn} ${props.active && classes.iconBtnActive}`}
2224
onClick={props.onClick && props.onClick}>
@@ -27,6 +29,7 @@ const IconButton: FC<IconButtonProps> = (props) => {
2729
} else {
2830
return (
2931
<ActionIcon
32+
data-testId={props.data_id}
3033
size={props.size ? props.size : 'xl'}
3134
className={`${classes.iconBtn} ${props.active && classes.iconBtnActive}`}
3235
onClick={props.onClick && props.onClick}>

src/hooks/useGetStreamMetadata.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export type MetaData = {
1515

1616
// until dedicated endpoint been provided - fetch one by one
1717
export const useGetStreamMetadata = () => {
18-
const [isLoading, setLoading] = useState<Boolean>(true);
19-
const [error, setError] = useState<Boolean>(false);
18+
const [isLoading, setLoading] = useState<boolean>(true);
19+
const [error, setError] = useState<boolean>(false);
2020
const [metaData, setMetadata] = useState<MetaData | null>(null);
2121
const [userRoles] = useAppStore((store) => store.userRoles);
2222

src/pages/AccessManagement/PrivilegeTR.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ const PrivilegeTR: FC<PrivilegeTRProps> = (props) => {
274274
<Button
275275
variant="default"
276276
className={classes.actionBtn}
277-
aria-label="Delete user"
277+
aria-label="Delete Role"
278278
onClick={() => {
279279
openDeleteRole();
280280
}}>

src/pages/AccessManagement/Roles.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,13 @@ const Roles: FC = () => {
167167
return (
168168
<Box className={classes.container}>
169169
<Stack className={classes.header} gap={0}>
170-
<Text style={{ fontWeight: 600 }}>Roles</Text>
170+
<Text component="h2" style={{ fontWeight: 600 }}>
171+
Roles
172+
</Text>
171173
<Stack style={{ flexDirection: 'row' }} gap={0}>
172174
<Button
173175
className={classes.createUserBtn}
176+
data-testId="create-role-button"
174177
rightSection={<IconUserPlus size={px('1rem')} stroke={1.5} />}
175178
onClick={() => {
176179
setModalOpen(true);
@@ -187,7 +190,7 @@ const Roles: FC = () => {
187190
Set Default OIDC Role{' '}
188191
</Button>
189192
)}
190-
<IconButton renderIcon={renderDocsIcon} onClick={navigateToDocs} tooltipLabel="Docs" />
193+
<IconButton renderIcon={renderDocsIcon} onClick={navigateToDocs} tooltipLabel="Docs" data_id="roles-docs" />
191194
</Stack>
192195
</Stack>
193196
<ScrollArea className={classes.tableContainer} type="always">
@@ -207,6 +210,7 @@ const Roles: FC = () => {
207210
onClose={handleDefaultRoleModalClose}
208211
title="Set default oidc role"
209212
centered
213+
styles={{ title: { fontWeight: 500 } }}
210214
className={classes.modalStyle}>
211215
<Stack>
212216
<Select
@@ -310,12 +314,18 @@ const Roles: FC = () => {
310314
<Button
311315
variant="filled"
312316
color="gray"
317+
data-testId="create-role-modal-button"
313318
className={classes.modalActionBtn}
314319
disabled={createVaildtion()}
315320
onClick={handleCreateRole}>
316321
Create
317322
</Button>
318-
<Button onClick={handleClose} variant="outline" color="gray" className={classes.modalCancelBtn}>
323+
<Button
324+
onClick={handleClose}
325+
variant="outline"
326+
color="gray"
327+
data-testId="cancel-role-modal-button"
328+
className={classes.modalCancelBtn}>
319329
Cancel
320330
</Button>
321331
</Group>

src/pages/Dashboards/CreateTileForm.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,14 +527,14 @@ const sanitizeFormValues = (form: TileFormType, type: 'create' | 'update'): Edit
527527
};
528528

529529
const defaultVizOpts = {
530-
visualization_type: 'donut-chart' as 'donut-chart',
530+
visualization_type: 'donut-chart' as const,
531531
size: 'sm',
532532
color_config: [],
533533
tick_config: [],
534534
circular_chart_config: {},
535535
graph_config: { x_key: '', y_keys: [] },
536-
orientation: 'horizontal' as 'horizontal',
537-
graph_type: 'default' as 'default',
536+
orientation: 'horizontal' as const,
537+
graph_type: 'default' as const,
538538
};
539539

540540
const defaultFormOpts = {

src/pages/Dashboards/assets/templates.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const pmetaConfig = {
1212
query: 'select MAX(parseable_events_ingested), address from pmeta GROUP BY address LIMIT 100',
1313
order: 1,
1414
visualization: {
15-
visualization_type: 'donut-chart' as 'donut-chart',
15+
visualization_type: 'donut-chart' as const,
1616
circular_chart_config: {
1717
name_key: 'address',
1818
value_key: 'MAX(pmeta.parseable_events_ingested)',
@@ -30,7 +30,7 @@ const pmetaConfig = {
3030
"select a.time,SUM(a.current_events) as current_events, SUM(a.lifetime_events) as lifetime_events, SUM(a.deleted_events) as deleted_events from (select MAX(parseable_events_ingested) as current_events, MAX(parseable_lifetime_events_ingested) as lifetime_events, MAX(parseable_deleted_events_ingested) as deleted_events, DATE_BIN('10 minutes', p_timestamp, NOW()) AS time from pmeta where address='http://parseable-ing-8yvv-0.parseable-ingestor-headless.demo.svc.cluster.local:8000/' group by time order by time) a GROUP BY a.time ORDER BY a.time LIMIT 100",
3131
order: 2,
3232
visualization: {
33-
visualization_type: 'bar-chart' as 'bar-chart',
33+
visualization_type: 'bar-chart' as const,
3434
circular_chart_config: null,
3535
graph_config: {
3636
x_key: 'time',
@@ -67,7 +67,7 @@ const pmetaConfig = {
6767
query: 'SELECT MAX(process_resident_memory_bytes) as memory_usage, address FROM pmeta GROUP BY address LIMIT 100',
6868
order: 3,
6969
visualization: {
70-
visualization_type: 'pie-chart' as 'pie-chart',
70+
visualization_type: 'pie-chart' as const,
7171
circular_chart_config: {
7272
name_key: 'address',
7373
value_key: 'memory_usage',
@@ -85,7 +85,7 @@ const pmetaConfig = {
8585
"select a.time, SUM(a.current_events_size) as current_events_size, SUM(a.lifetime_events_size) as lifetime_events_size, SUM(a.deleted_events_size) as deleted_events_size from (select MAX(parseable_events_ingested_size) as current_events_size, MAX(parseable_lifetime_events_ingested_size) as lifetime_events_size, MAX(parseable_deleted_events_ingested_size) as deleted_events_size, DATE_BIN('10 minutes', p_timestamp, NOW()) AS time from pmeta where address='http://parseable-ing-8yvv-0.parseable-ingestor-headless.demo.svc.cluster.local:8000/' group by time order by time) a GROUP BY a.time ORDER BY a.time LIMIT 100",
8686
order: 4,
8787
visualization: {
88-
visualization_type: 'bar-chart' as 'bar-chart',
88+
visualization_type: 'bar-chart' as const,
8989
circular_chart_config: null,
9090
graph_config: {
9191
x_key: 'time',
@@ -135,7 +135,7 @@ const pmetaConfig = {
135135
"SELECT MAX(parseable_events_ingested_size) as current_events_size, MAX(parseable_storage_size_data) as current_data_size FROM pmeta where address='http://ec2-3-15-172-147.us-east-2.compute.amazonaws.com:443/' LIMIT 100",
136136
order: 5,
137137
visualization: {
138-
visualization_type: 'table' as 'table',
138+
visualization_type: 'table' as const,
139139
circular_chart_config: null,
140140
graph_config: null,
141141
size: 'sm',
@@ -159,7 +159,7 @@ const pmetaConfig = {
159159
"select DATE_BIN('10 minutes', p_timestamp, NOW()) AS time, MAX(process_resident_memory_bytes) as process_resident_memory_bytes from pmeta where address='http://parseable-ing-8yvv-0.parseable-ingestor-headless.demo.svc.cluster.local:8000/' group by time order by time LIMIT 100",
160160
order: 6,
161161
visualization: {
162-
visualization_type: 'bar-chart' as 'bar-chart',
162+
visualization_type: 'bar-chart' as const,
163163
circular_chart_config: null,
164164
graph_config: {
165165
x_key: 'time',

src/pages/Stream/Views/Explore/StaticLogTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ const Table = (props: { primaryHeaderHeight: number }) => {
120120
overflow: 'hidden',
121121
textOverflow: 'ellipsis',
122122
display: 'table-cell',
123-
...(!_.includes(wrapDisabledColumns, columnName) ? { whiteSpace: 'nowrap' as 'nowrap' } : {}),
123+
...(!_.includes(wrapDisabledColumns, columnName) ? { whiteSpace: 'nowrap' as const } : {}),
124124
},
125125
};
126126
},

src/pages/Stream/Views/Manage/Alerts.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import ErrorView from './ErrorView';
2222
import RestrictedView from '@/components/Misc/RestrictedView';
2323

2424
const defaultColumnTypeConfig = { column: '', operator: '=', value: '', repeats: 1, ignoreCase: false };
25-
const defaultColumnTypeRule = { type: 'column' as 'column', config: defaultColumnTypeConfig };
25+
const defaultColumnTypeRule = { type: 'column' as const, config: defaultColumnTypeConfig };
2626
const { transformAlerts } = streamStoreReducers;
2727

2828
const stringOperators = [
@@ -574,7 +574,7 @@ const AlertsModal = (props: {
574574
);
575575
};
576576

577-
const Header = (props: { selectAlert: selectAlert; isLoading: boolean, showCreateBtn: boolean }) => {
577+
const Header = (props: { selectAlert: selectAlert; isLoading: boolean; showCreateBtn: boolean }) => {
578578
return (
579579
<Stack className={classes.headerContainer} style={{ minHeight: '3rem', maxHeight: '3rem' }}>
580580
<Text className={classes.title}>Alerts</Text>

src/pages/Stream/providers/LogsProvider.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ const getDefaultTimeRange = (duration: FixedDuration = DEFAULT_FIXED_DURATIONS)
135135
return {
136136
startTime: startTime.toDate(),
137137
endTime: now.toDate(),
138-
type: 'fixed' as 'fixed',
138+
type: 'fixed' as const,
139139
label,
140140
interval: milliseconds,
141141
shiftInterval: 1,
@@ -152,7 +152,7 @@ const defaultQuickFilters = {
152152
};
153153

154154
const defaultLiveTailConfig = {
155-
liveTailStatus: '' as '',
155+
liveTailStatus: '' as const,
156156
liveTailSchemaData: [],
157157
liveTailSearchValue: '',
158158
liveTailSearchField: '',
@@ -298,7 +298,7 @@ type LogsStoreReducers = {
298298
};
299299

300300
const defaultSortKey = 'p_timestamp';
301-
const defaultSortOrder = 'desc' as 'desc';
301+
const defaultSortOrder = 'desc' as const;
302302

303303
const initialState: LogsStore = {
304304
timeRange: getDefaultTimeRange(),
@@ -464,7 +464,7 @@ const setCustQuerySearchState = (store: LogsStore, query: string, viewMode: stri
464464
isQuerySearchActive: true,
465465
custSearchQuery: query,
466466
viewMode,
467-
activeMode: viewMode === 'filters' ? ('filters' as 'filters') : ('sql' as 'sql'),
467+
activeMode: viewMode === 'filters' ? ('filters' as const) : ('sql' as const),
468468
},
469469
...getCleanStoreForRefetch(store),
470470
timeRange,
@@ -757,7 +757,7 @@ const applyCustomQuery = (
757757
endTime: endTime.toDate(),
758758
label,
759759
interval,
760-
type: 'custom' as 'custom', // always
760+
type: 'custom' as const, // always
761761
},
762762
};
763763
}
@@ -810,7 +810,7 @@ const setAndSortData = (store: LogsStore, sortKey: string, sortOrder: 'asc' | 'd
810810
};
811811
};
812812

813-
const setAndFilterData = (store: LogsStore, filterKey: string, filterValues: string[], remove: boolean = false) => {
813+
const setAndFilterData = (store: LogsStore, filterKey: string, filterValues: string[], remove = false) => {
814814
const { data, tableOpts } = store;
815815
const { sortKey, sortOrder, filters } = tableOpts;
816816
const updatedFilters = remove ? _.omit(filters, filterKey) : { ...filters, [filterKey]: filterValues };
@@ -903,7 +903,7 @@ const setRetention = (_store: LogsStore, retention: { duration?: string; descrip
903903
retention: {
904904
duration: durationInNumber,
905905
description: retention.description || '',
906-
action: 'delete' as 'delete',
906+
action: 'delete' as const,
907907
},
908908
};
909909
};
@@ -941,8 +941,7 @@ const onToggleView = (store: LogsStore, viewMode: 'json' | 'table') => {
941941
};
942942

943943
const toggleConfigViewType = (store: LogsStore) => {
944-
const configViewType =
945-
store.tableOpts.configViewType === 'schema' ? ('columns' as 'columns') : ('schema' as 'schema');
944+
const configViewType: 'columns' | 'schema' = store.tableOpts.configViewType === 'schema' ? 'columns' : 'schema';
946945

947946
return {
948947
tableOpts: {

0 commit comments

Comments
 (0)