Fakultas Ilmu Komputer UI

Commit 662d5fd3 authored by Nurul Srianda Putri's avatar Nurul Srianda Putri
Browse files

[RED] add test lanjut button changes page after form submitted

parent 4830af1d
Pipeline #72117 failed with stages
in 4 minutes and 48 seconds
import {screen, fireEvent} from '@testing-library/react'
import {
screen,
fireEvent,
waitForElementToBeRemoved,
} from '@testing-library/react'
import FormIUMK from './formiumk'
import {testRender, makeTestStore, fixtureSet} from '../testUtils'
import userEvent from '@testing-library/user-event'
test('renders Navbar Element', () => {
const store = makeTestStore(fixtureSet)
testRender(<FormIUMK />, {store})
})
test('renders lanjut button changes form page', () => {
test('renders lanjut button changes form page', async () => {
const store = makeTestStore()
testRender(<FormIUMK />, {store})
expect(screen.getByTestId('form-iumk-1')).toBeInTheDocument()
const lanjutButton = screen.getByTestId('lanjut-button')
userEvent.type(screen.getByTestId('form-1-nama-field'), 'pt ABC')
userEvent.click(screen.getByTestId('form-1-status-pt'))
userEvent.type(
screen.getByTestId('form-1-alamat-field'),
'Jl. TB Simatupang No. 5 Ragunan, Pasar Minggu Jakarta 12550',
)
userEvent.type(
screen.getByTestId('form-1-barang-jasa-field'),
'Travel Agency',
)
expect(screen.getByTestId('form-1-nama-field')).toHaveValue('pt ABC')
expect(screen.getByTestId('form-1-status-pt')).toBeChecked()
expect(screen.getByTestId('form-1-alamat-field')).toHaveValue(
'Jl. TB Simatupang No. 5 Ragunan, Pasar Minggu Jakarta 12550',
)
expect(screen.getByTestId('form-1-barang-jasa-field')).toHaveValue(
'Travel Agency',
)
let lanjutButton = screen.getByTestId('lanjut-button')
fireEvent.click(lanjutButton)
expect(screen.getByTestId('form-iumk-2')).toBeInTheDocument()
await waitForElementToBeRemoved(() => screen.getByTestId('form-1-nama-field'))
const formIumk2 = screen.getByTestId('form-iumk-2')
expect(formIumk2).toBeInTheDocument()
lanjutButton = screen.getByTestId('lanjut-button')
fireEvent.click(lanjutButton)
await waitForElementToBeRemoved(() =>
screen.getByTestId('form-iumk-2-kode-kbli'),
)
expect(screen.getByTestId('form-iumk-3')).toBeInTheDocument()
})
test('renders submit button at page 3', () => {
test('renders submit button at page 3', async () => {
const store = makeTestStore()
testRender(<FormIUMK />, {store})
expect(screen.getByTestId('form-iumk-1')).toBeInTheDocument()
userEvent.type(screen.getByTestId('form-1-nama-field'), 'pt ABC')
userEvent.click(screen.getByTestId('form-1-status-pt'))
userEvent.type(
screen.getByTestId('form-1-alamat-field'),
'Jl. TB Simatupang No. 5 Ragunan, Pasar Minggu Jakarta 12550',
)
userEvent.type(
screen.getByTestId('form-1-barang-jasa-field'),
'Travel Agency',
)
const lanjutButton = screen.getByTestId('lanjut-button')
let lanjutButton = screen.getByTestId('lanjut-button')
fireEvent.click(lanjutButton)
await waitForElementToBeRemoved(() => screen.getByTestId('form-1-nama-field'))
const formIumk2 = screen.getByTestId('form-iumk-2')
expect(formIumk2).toBeInTheDocument()
lanjutButton = screen.getByTestId('lanjut-button')
fireEvent.click(lanjutButton)
await waitForElementToBeRemoved(() =>
screen.getByTestId('form-iumk-2-kode-kbli'),
)
expect(screen.getByTestId('form-iumk-3')).toBeInTheDocument()
expect(screen.getByTestId('submit-button')).toBeInTheDocument()
})
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment