Files
modeling-app/src/components/UpdaterRestartModal.test.tsx
Pierre Jacquier b13c1339aa Custom updater modal (#1738)
* WIP: Custom updater modal
Fixes #1663

* First working example with data

* Clean up, moved code to index.tsx

* Clean up

* Nicer dialog

* Add relaunch dialog (macOS)

* max-height in case of a long text

* Clean up

* Add component tests and fix name consistency

* Update styling, re-add md parser

* Clean up

* Quick typo

* Clean up

* Rebase on tauri v2

* Clean up

* Add updater permissions

* Remove dialog from config

* Fix restart after install
2024-04-17 10:30:23 -04:00

41 lines
1.2 KiB
TypeScript

import { fireEvent, render, screen } from '@testing-library/react'
import { vi } from 'vitest'
import { UpdaterRestartModal } from './UpdaterRestartModal'
describe('UpdaterRestartModal tests', () => {
test('Renders the modal', () => {
const callback = vi.fn()
const data = {
version: '1.2.3',
}
render(
<UpdaterRestartModal
isOpen={true}
onReject={() => {}}
onResolve={callback}
instanceId=""
open={false}
close={(res) => {}}
version={data.version}
/>
)
expect(screen.getByTestId('update-restart-version')).toHaveTextContent(
data.version
)
const updateButton = screen.getByTestId('update-restrart-button-update')
expect(updateButton).toBeEnabled()
fireEvent.click(updateButton)
expect(callback.mock.calls).toHaveLength(1)
expect(callback.mock.lastCall[0]).toEqual({ wantRestart: true })
const cancelButton = screen.getByTestId('update-restrart-button-cancel')
expect(cancelButton).toBeEnabled()
fireEvent.click(cancelButton)
expect(callback.mock.calls).toHaveLength(2)
expect(callback.mock.lastCall[0]).toEqual({ wantRestart: false })
})
})