Skip to content

Commit

Permalink
Tester og div fix
Browse files Browse the repository at this point in the history
  • Loading branch information
betsytraran committed Apr 2, 2024
1 parent 4298314 commit f9b7d71
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 4 deletions.
54 changes: 54 additions & 0 deletions apps/dolly-frontend/src/main/js/cypress/e2e/TenorSoek.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { CypressSelector } from '../mocks/Selectors'
import {
responseFalse,
responseTrue,
tenorSoekOversiktMock,
tenorSoekTestdataMock,
} from '../mocks/BasicMocks'

describe('Tenor-søk testing', () => {
const tenorSoekOversikt = new RegExp(
/testnav-tenor-search-service\/api\/v1\/tenor\/testdata\/oversikt\?antall=10&side=0/,
)
const tenorSoekTestdata = new RegExp(
/testnav-tenor-search-service\/api\/v1\/tenor\/testdata\?kilde=FREG&type=AlleFelter/,
)
const dollyBackendFinnesTrue = new RegExp(/dolly-backend\/api\/v1\/ident\/finnes\/12345678912/)
const dollyBackendFinnesFalse = new RegExp(/dolly-backend\/api\/v1\/ident\/finnes\/98765432198/)

it('passes', () => {
cy.visit('')

cy.intercept({ method: 'POST', url: tenorSoekOversikt }, tenorSoekOversiktMock)
cy.intercept({ method: 'POST', url: tenorSoekTestdata }, tenorSoekTestdataMock)
cy.intercept({ method: 'GET', url: dollyBackendFinnesTrue }, responseTrue)
cy.intercept({ method: 'GET', url: dollyBackendFinnesFalse }, responseFalse)

// Naviger til Tenor-soek og gjoer et soek
cy.dollyGet(CypressSelector.BUTTON_HEADER_FINNPERSON).click()
cy.dollyGet(CypressSelector.BUTTON_HEADER_TENOR).click()
cy.get('h1').contains('Søk etter personer i Tenor').should('exist')
cy.dollyGet(CypressSelector.CHECKBOX_TENORSOEK).click()
cy.wait(1000)

// Velg person som ikke ligger i Dolly og start import av personen
cy.get('div').contains('TIGER ULV').click()
cy.get('h2').contains('TIGER ULV').should('exist')
cy.dollyGet(CypressSelector.BUTTON_IMPORTER_PERSONER).click()
cy.wait(500)
cy.get('h1').contains('Importer person').should('exist')
cy.dollyGet(CypressSelector.BUTTON_IMPORTER).click()
cy.wait(500)
cy.get('.bestillingsveileder').should('exist')
cy.dollyGet(CypressSelector.BUTTON_AVBRYT).click()
cy.wait(500)
cy.dollyGet(CypressSelector.BUTTON_BEKREFT).click()
cy.wait(1000)
cy.get('h1').contains('Søk etter personer i Tenor').should('exist')

// Naviger til foerste person som ligger i Dolly
cy.dollyGet(CypressSelector.BUTTON_VIS_I_GRUPPE).first().click()
cy.wait(500)
cy.get('h1').contains('Testytest').should('exist')
})
})
69 changes: 69 additions & 0 deletions apps/dolly-frontend/src/main/js/cypress/mocks/BasicMocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1882,3 +1882,72 @@ export const bestillingFragmentNavigerMock = {
bestillingNavigerTil: 1,
sidetall: 0,
}

export const tenorSoekOversiktMock = {
status: 'OK',
data: {
treff: 2,
rader: 2,
offset: 0,
nesteSide: null,
seed: 1111,
personer: [
{
id: '12345678912',
fornavn: 'TESTYTEST',
etternavn: 'CAFE',
tenorRelasjoner: ['Freg'],
},
{
id: '98765432198',
fornavn: 'TIGER',
etternavn: 'ULV',
tenorRelasjoner: ['Freg'],
},
],
},
query: 'legitimasjonsdokument:*',
error: null,
}

export const tenorSoekTestdataMock = {
status: 'OK',
data: {
treff: 2,
rader: 2,
offset: 0,
nesteSide: null,
seed: 1111,
dokumentListe: [
{
foedselsdato: '1992-06-04',
identifikator: ['12345678912'],
kjoenn: 'kvinne',
personstatus: 'midlertidig',
sivilstand: 'gift',
tenorMetadata: {
kildedata: '{}',
},
visningnavn: 'TESTYTEST CAFE',
},
{
foedselsdato: '1974-02-02',
identifikator: ['98765432198'],
kjoenn: 'kvinne',
personstatus: 'bosatt',
sivilstand: 'ugift',
tenorMetadata: {
kildedata: '{}',
},
visningnavn: 'TIGER ULV',
},
],
fasetter: {},
},
query: '',
error: null,
}

export const responseTrue = { body: true }

export const responseFalse = { body: false }
7 changes: 7 additions & 0 deletions apps/dolly-frontend/src/main/js/cypress/mocks/Selectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export enum CypressSelector {
INPUT_MINSIDE_SOEK_MAL = 'input-minside-mal',
INPUT_DOLLY_SOEK = 'input-dolly-soek',
INPUT_TESTNORGE_FNR = 'input-testnorge-fnr',
INPUT_TENORSOEK_FNR = 'input-tenorsoek-fnr',
INPUT_NAVN = 'input-navn',
INPUT_NY_GRUPPE_NAVN = 'input-ny-gruppe-navn',
INPUT_NY_GRUPPE_HENSIKT = 'input-ny-gruppe-hensikt',
Expand Down Expand Up @@ -44,6 +45,8 @@ export enum CypressSelector {
BUTTON_FJERN_ALLE = 'button-fjern-alle',
BUTTON_VIDERE = 'button-videre',
BUTTON_TILBAKE = 'button-tilbake',
BUTTON_AVBRYT = 'button-avbryt',
BUTTON_BEKREFT = 'button-bekreft',
BUTTON_FLYTT_PERSONER = 'button-flytt-personer',
BUTTON_FLYTT_PERSONER_AVBRYT = 'button-flytt-personer-avbryt',
BUTTON_VARSLING_LUKK = 'button-varsling-lukk',
Expand All @@ -55,13 +58,15 @@ export enum CypressSelector {
BUTTON_HEADER_FINNPERSON = 'button-header-finnperson',
BUTTON_HEADER_DOLLYSOEK = 'button-header-dollysoek',
BUTTON_HEADER_TESTNORGE = 'button-header-testnorge',
BUTTON_HEADER_TENOR = 'button-header-tenor',
BUTTON_HEADER_ENDRINGSMELDING = 'button-header-endringsmelding',
BUTTON_PROFIL = 'button-minside',
BUTTON_PROFIL_MINSIDE = 'button-profil-minside',
BUTTON_SEND_FORBEDRINGSOENSKE = 'button-send-forbedringsoenske',
BUTTON_FULLFOER_BESTILLING = 'button-fullfoer-bestilling',
BUTTON_AVBRYT_BESTILLING = 'button-avbryt-bestilling',
BUTTON_IMPORTER_PERSONER = 'button-importer-personer',
BUTTON_IMPORTER = 'button-importer',
BUTTON_MINSIDE_ENDRE_MALNAVN = 'button-minside-endre-malnavn',
BUTTON_MINSIDE_LAGRE_MALNAVN = 'button-minside-lagre-malnavn',
BUTTON_LUKK_BESTILLING_RESULTAT = 'button-lukk-bestilling-resultat',
Expand All @@ -82,10 +87,12 @@ export enum CypressSelector {
BUTTON_GJENOPPRETT_GRUPPE = 'button-gjenopprett-gruppe',
BUTTON_REDIGER_GRUPPE = 'button-rediger-gruppe',
BUTTON_TIDLIGEREBESTILLINGER_NAVIGER = 'button-tidligerebestillinger-naviger',
BUTTON_PERSON_TENORSOEK = 'button-person-tenorsoek',
SELECT_PERSON_SEARCH = 'select-person-search',
SELECT_TAGS = 'select-tags',
HOVER_MILJOE = 'hover-miljoe',
CHECKBOX_FORBEDRING_ANONYM = 'checkbox-forbedring-anonym',
CHECKBOX_TENORSOEK = 'checkbox-tenorsoek',
ERROR_MESSAGE_NAVIGERING = 'error-message-navigering',
EXPANDABLE_PERSONINFORMASJON = 'expandable-personinformasjon',
CONTAINER_VALGTE_PERSONER = 'container-valgte-personer',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const FinnPersonDropdown = () => {
Søk i Test-Norge
</Dropdown.Menu.List.Item>
<Dropdown.Menu.List.Item
data-cy={CypressSelector.BUTTON_HEADER_TESTNORGE}
data-cy={CypressSelector.BUTTON_HEADER_TENOR}
onClick={() => navigate('/tenor')}
style={{ color: '#212529' }}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import DollyModal from '@/components/ui/modal/DollyModal'
import Icon from '@/components/ui/icon/Icon'

import './AvbrytModal.less'
import { CypressSelector } from '../../../../../cypress/mocks/Selectors'

type Props = {
action: Function
Expand All @@ -16,7 +17,7 @@ export const AvbrytButton = ({ action, children }: Props) => {

return (
<React.Fragment>
<NavButton variant={'danger'} onClick={openModal}>
<NavButton data-cy={CypressSelector.BUTTON_AVBRYT} variant={'danger'} onClick={openModal}>
Avbryt
</NavButton>
<DollyModal isOpen={modalIsOpen} closeModal={closeModal} width="fit-content" overflow="auto">
Expand All @@ -31,6 +32,7 @@ export const AvbrytButton = ({ action, children }: Props) => {
Nei
</NavButton>
<NavButton
data-cy={CypressSelector.BUTTON_BEKREFT}
onClick={() => {
closeModal()
return action()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import DollyModal from '@/components/ui/modal/DollyModal'
import { top } from '@popperjs/core'
import { Hjelpetekst } from '@/components/hjelpetekst/Hjelpetekst'
import styled from 'styled-components'
import { CypressSelector } from '../../../../cypress/mocks/Selectors'

const CheckboxWrapper = styled.div`
display: flex;
Expand Down Expand Up @@ -91,6 +92,7 @@ export const ImporterValgtePersoner = ({ identer, isMultiple }) => {
</Button>
) : (
<Button
data-cy={CypressSelector.BUTTON_IMPORTER_PERSONER}
variant="tertiary"
size="xsmall"
icon={<EnterIcon />}
Expand Down Expand Up @@ -121,7 +123,9 @@ export const ImporterValgtePersoner = ({ identer, isMultiple }) => {
)}
<MalValg setValgtMal={setValgtMal} />
<div className="dollymodal_buttons dollymodal_buttons--center">
<Button onClick={() => handleClick()}>Importer</Button>
<Button data-cy={CypressSelector.BUTTON_IMPORTER} onClick={() => handleClick()}>
Importer
</Button>
<Button variant="secondary" onClick={closeModal}>
Avbryt
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export const PersonVisning = ({ person, ident, loading, error }) => {
return null
}

const personData = person.data?.dokumentListe?.[0]
const personData = person.data?.dokumentListe?.find((dokument) =>
dokument.identifikator?.includes(ident),
)

return (
<PersonVisningWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Loading from '@/components/ui/loading/Loading'
import styled from 'styled-components'
import { ListeValg } from '@/pages/tenorSoek/resultatVisning/ListeValg'
import { ImporterValgtePersoner } from '@/pages/tenorSoek/resultatVisning/ImporterValgtePersoner'
import { CypressSelector } from '../../../../cypress/mocks/Selectors'

const PersonNavn = styled.h3`
word-break: break-word;
Expand Down Expand Up @@ -73,6 +74,7 @@ export const TreffListe = ({ response, personListe, loading, error }: any) => {
return (
<Box
key={person?.id}
data-cy={CypressSelector.BUTTON_PERSON_TENORSOEK}
padding="2"
background={
person?.id === valgtPerson?.id ? 'surface-alt-3-moderate' : 'surface-alt-3-subtle'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createOptions } from '@/pages/tenorSoek/utils'
import { SelectOptionsManager as Options } from '@/service/SelectOptions'
import { FormDatepicker } from '@/components/ui/form/inputs/datepicker/Datepicker'
import { FormCheckbox } from '@/components/ui/form/inputs/checbox/Checkbox'
import { CypressSelector } from '../../../../cypress/mocks/Selectors'

export const FolkeregisteretIdentifikasjonStatus = ({ handleChange, handleChangeList }: any) => {
const { domain: identifikatorTypeOptions } = useTenorDomain('IdentifikatorType')
Expand All @@ -23,6 +24,7 @@ export const FolkeregisteretIdentifikasjonStatus = ({ handleChange, handleChange
<SoekKategori>
<FormTextInput
name="identifikator"
data-cy={CypressSelector.INPUT_TENORSOEK_FNR}
label="Fødselsnummer / D-nummer"
onBlur={(val: SyntheticEvent) => handleChange(val?.target?.value || null, 'identifikator')}
visHvisAvhuket={false}
Expand Down Expand Up @@ -109,6 +111,7 @@ export const FolkeregisteretIdentifikasjonStatus = ({ handleChange, handleChange
</div>
<FormCheckbox
name="harLegitimasjonsdokument"
data-cy={CypressSelector.CHECKBOX_TENORSOEK}
label="Har legitimasjonsdokument"
onChange={(val: SyntheticEvent) =>
handleChange(val?.target?.checked || undefined, 'harLegitimasjonsdokument')
Expand Down

0 comments on commit f9b7d71

Please sign in to comment.