Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing text #13629

Merged
merged 5 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ describe('XSDUpload', () => {
});

it('does not allow uploading with invalid name', async () => {
window.alert = jest.fn();
const file = new File(['$-_123'], '$-_123.xsd', { type: 'text/xml' });
renderXsdUpload();

Expand All @@ -168,9 +169,10 @@ describe('XSDUpload', () => {

await user.upload(fileInput, file);

expect(await screen.findByRole('alert')).toHaveTextContent(
textMock('app_data_modelling.upload_xsd_invalid_error'),
expect(window.alert).toHaveBeenCalledWith(
textMock('app_data_modelling.upload_xsd_invalid_name_error'),
);
expect(window.alert).toHaveBeenCalledTimes(1);
});

it('shows a custom generic error message', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { ApplicationMetadata } from 'app-shared/types/ApplicationMetadata';
import { removeExtension } from 'app-shared/utils/filenameUtils';
import { useTranslation } from 'react-i18next';
import { toast } from 'react-toastify';

export const useValidateFileName = (appMetadata: ApplicationMetadata) => {
const { t } = useTranslation();
Expand All @@ -12,7 +11,7 @@ export const useValidateFileName = (appMetadata: ApplicationMetadata) => {
const nameFollowsRegexRules = Boolean(fileName.match(fileNameRegEx));

if (!nameFollowsRegexRules) {
toast.error(t('app_data_modelling.upload_xsd_invalid_error'));
alert(t('app_data_modelling.upload_xsd_invalid_name_error'));
return false;
}
return !Boolean(
Expand Down
1 change: 1 addition & 0 deletions frontend/language/src/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"app_data_modelling.landing_dialog_paragraph": "Velkommen til datamodellering! Her kan du laste opp en datamodell du har fra før, eller lage en ny modell du kan bruke i appen din.",
"app_data_modelling.landing_dialog_upload": "Last opp datamodell",
"app_data_modelling.upload_xsd": "Last opp",
"app_data_modelling.upload_xsd_invalid_name_error": "Filnavnet er ugyldig. Du kan bruke tall og store og små bokstaver fra det norske alfabetet, og understrek, punktum og bindestrek. Navnet må alltid starte med en bokstav.",
"app_data_modelling.uploading_xsd": "Laster opp XSD...",
"app_deployment.btn_deploy_new_version": "Publiser ny versjon",
"app_deployment.choose_version": "Velg den versjonen du vil publisere.",
Expand Down
Loading