-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
190 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { TaFixture } from '../test/fixture/timedAutomatonFixture'; | ||
import { TEST_BASE_URL } from './helper/endToEndTestConstants'; | ||
import { test } from './helper/testOptions'; | ||
import { expect } from '@playwright/test'; | ||
|
||
test.describe('For resetting the TA', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto(TEST_BASE_URL); | ||
}); | ||
|
||
test('the initial page should contain an enabled button for resetting', async ({ page }) => { | ||
await expect(page.getByTestId('button-open-reset')).toBeVisible(); | ||
await expect(page.getByTestId('button-open-reset')).toBeEnabled(); | ||
}); | ||
|
||
test('the reset button should reset the TA to its original state', async ({ page, taUiHelper }) => { | ||
// given | ||
const initialTa = await taUiHelper.readTaFromUi(); | ||
const otherTa = TaFixture.withTwoLocationsAndTwoSwitches(); | ||
await taUiHelper.setTimedAutomatonTo(otherTa); | ||
|
||
// when | ||
await page.getByTestId('button-open-reset').click(); | ||
await page.getByTestId('button-confirm-ta-reset').click(); | ||
|
||
// then | ||
const taAfterReset = await taUiHelper.readTaFromUi(); | ||
expect(taAfterReset, 'TA after reset should be the same as the initial TA').toEqual(initialTa); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { useTranslation } from 'react-i18next'; | ||
import { useButtonUtils } from '../utils/buttonUtils'; | ||
import { | ||
Button, | ||
Dialog, | ||
DialogActions, | ||
DialogContent, | ||
DialogContentText, | ||
DialogTitle, | ||
IconButton, | ||
} from '@mui/material'; | ||
import CloseIcon from '@mui/icons-material/Close'; | ||
|
||
interface ResetDialogProps { | ||
open: boolean; | ||
handleClose: () => void; | ||
handleReset: () => void; | ||
} | ||
|
||
export const ResetDialog: React.FC<ResetDialogProps> = (props) => { | ||
const { open, handleClose, handleReset } = props; | ||
const { t } = useTranslation(); | ||
const { executeOnKeyboardClick } = useButtonUtils(); | ||
|
||
const confirmReset = () => { | ||
handleClose(); | ||
handleReset(); | ||
}; | ||
|
||
return ( | ||
<Dialog open={open} onClose={handleClose}> | ||
<DialogTitle> | ||
{t('resetDialog.title')} | ||
<IconButton | ||
onMouseDown={handleClose} | ||
onKeyDown={(e) => executeOnKeyboardClick(e.key, handleClose)} | ||
sx={{ position: 'absolute', right: 8, top: 8, color: (theme) => theme.palette.grey[500] }} | ||
> | ||
<CloseIcon /> | ||
</IconButton> | ||
</DialogTitle> | ||
<DialogContent> | ||
<DialogContentText>{t('resetDialog.contentText')}</DialogContentText> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button | ||
onMouseDown={handleClose} | ||
onKeyDown={(e) => executeOnKeyboardClick(e.key, handleClose)} | ||
variant="contained" | ||
color="primary" | ||
> | ||
{t('resetDialog.button.cancel')} | ||
</Button> | ||
<Button | ||
onMouseDown={confirmReset} | ||
onKeyDown={(e) => executeOnKeyboardClick(e.key, confirmReset)} | ||
variant="contained" | ||
color="error" | ||
data-testid="button-confirm-ta-reset" | ||
> | ||
{t('resetDialog.button.reset')} | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters