Skip to content

Commit

Permalink
snippet-service playwright testing
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrikMatiasko committed Jul 1, 2024
1 parent 4aadc19 commit 5907a0e
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,5 @@ export const hasMockApi = (url: string) => {
export const getApiUrl = (url: string) => {
const parsedUrl = new URL(url)

return hasMockApi(parsedUrl.pathname) && parsedUrl.origin ? `${process.env.REACT_APP_MOCK_BASE_URL}${parsedUrl.pathname}` : url
return hasMockApi(parsedUrl.pathname) && parsedUrl.origin ? `${process.env.REACT_APP_MOCK_BASE_URL}${parsedUrl.pathname}${parsedUrl.search}` : url
}
1 change: 0 additions & 1 deletion src/common/hooks/use-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const getData = async (method, url, options) => {
const { telemetrySpan, telemetryWebTracer, ...restOptions } = options

if (telemetryWebTracer && telemetrySpan) {
console.log('TU')
const singleSpan = telemetryWebTracer.startSpan(telemetrySpan)

return context.with(
Expand Down
6 changes: 4 additions & 2 deletions src/common/hooks/use-version.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import FormSelect from '../../components/Atomic/FormSelect'
import { OptionType } from '../../components/Atomic/FormSelect/FormSelect.types'

type OptionsType = {
dataTestId?: string
i18n: { version: string; selectVersion: string }
refresh: () => void
versionData: any
}

export function useVersion(options: OptionsType) {
const { i18n, versionData, refresh } = options
const { dataTestId, i18n, versionData, refresh } = options

const [searchParams, setSearchParams] = useSearchParams()
const [version, setVersion] = useState('')
Expand All @@ -37,9 +38,10 @@ export function useVersion(options: OptionsType) {
}, [versionData, version])

const Selector = () => (
<FormGroup inline id='version' marginBottom={false}>
<FormGroup inline dataTestId={dataTestId} id='version' marginBottom={false}>
<FormLabel text={i18n.version} />
<FormSelect
dataTestId={dataTestId?.concat('-select')}
onChange={(options: OptionType) => {
const v = options.value
setSearchParams({ version: v as string })
Expand Down
8 changes: 7 additions & 1 deletion src/components/Atomic/FormGroup/FormGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const FormGroupCore: FC<Props> = (props) => {
const {
children,
className,
dataTestId,
error,
errorTooltip,
id,
Expand Down Expand Up @@ -92,7 +93,12 @@ export const FormGroupCore: FC<Props> = (props) => {
}

return (
<div className={className} css={[marginBottom && !inline && styles.formGroupMargin, fullSize && styles.inlineItemFullSize]} style={style}>
<div
className={className}
css={[marginBottom && !inline && styles.formGroupMargin, fullSize && styles.inlineItemFullSize]}
data-test-id={dataTestId}
style={style}
>
{getInputs()}
</div>
)
Expand Down
1 change: 1 addition & 0 deletions src/components/Atomic/FormGroup/FormGroup.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { CSSProperties, ReactNode } from 'react'
export type Props = {
children: ReactNode | ReactNode[]
className?: string
dataTestId?: string
error?: string | boolean
errorTooltip?: boolean
fullSize?: boolean
Expand Down
3 changes: 2 additions & 1 deletion src/components/Atomic/FormSelect/FormSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const FormSelect = forwardRef<any, Props>((props, ref) => {
className,
checkboxOptions,
creatable,
dataTestId,
defaultValue,
error,
disabled,
Expand Down Expand Up @@ -113,7 +114,7 @@ const FormSelect = forwardRef<any, Props>((props, ref) => {
const SelectContainer = <Option extends OptionType, IsMulti extends boolean, Group extends GroupBase<Option>>(
props: ContainerProps<Option, IsMulti, Group>
) => (
<components.SelectContainer {...props} css={[autoWidth ? styles.selectAutoWidthContainer : styles.selectContainer]}>
<components.SelectContainer {...props} css={[autoWidth ? styles.selectAutoWidthContainer : styles.selectContainer]} data-test-id={dataTestId}>
{props.children}
</components.SelectContainer>
)
Expand Down
1 change: 1 addition & 0 deletions src/components/Atomic/FormSelect/FormSelect.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type Props = {
checkboxOptions?: boolean
className?: string
creatable?: boolean
dataTestId?: string
defaultValue?: any
disabled?: boolean
error?: boolean
Expand Down
2 changes: 2 additions & 0 deletions src/components/Layout/LeftPanel/LeftPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const LeftPanelSubItems = (props: LeftPanelSubItemsType) => {
subItem.id === active && styles.subItemLinkActive,
(item.children?.length || 0) - 1 === key && styles.subItemLinkLast,
]}
data-test-id={subItem.dataTestId}
href={`${item.link}${subItem.link}`}
onClick={
subItem.disabled
Expand Down Expand Up @@ -171,6 +172,7 @@ const LeftPanelSubItems = (props: LeftPanelSubItemsType) => {
<li key={key}>
<a
css={[styles.subItemLink, subItem.id === active && styles.subItemLinkActive, subItem.disabled && styles.disabled]}
data-test-id={subItem.dataTestId}
href={`${item.link}${subItem.link}`}
onClick={
subItem.disabled
Expand Down

0 comments on commit 5907a0e

Please sign in to comment.