diff --git a/backend/src/Designer/Controllers/AppDevelopmentController.cs b/backend/src/Designer/Controllers/AppDevelopmentController.cs index 3c3b46ea47f..a184d14d02a 100644 --- a/backend/src/Designer/Controllers/AppDevelopmentController.cs +++ b/backend/src/Designer/Controllers/AppDevelopmentController.cs @@ -271,15 +271,17 @@ public async Task GetAppMetadataDataModelIds(string org, string a /// Unique identifier of the organisation responsible for the app. /// Application identifier which is unique within an organisation. /// Name of current layoutSet in ux-editor that edited layout belongs to + /// Name of data model to fetch /// An that observes if operation is cancelled. /// The model as JSON [HttpGet] [UseSystemTextJson] [Route("model-metadata")] - public async Task GetModelMetadata(string org, string app, [FromQuery] string layoutSetName, CancellationToken cancellationToken) + public async Task GetModelMetadata(string org, string app, [FromQuery] string layoutSetName, [FromQuery] string dataModelName, CancellationToken cancellationToken) { string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext); - ModelMetadata modelMetadata = await _appDevelopmentService.GetModelMetadata(AltinnRepoEditingContext.FromOrgRepoDeveloper(org, app, developer), layoutSetName, cancellationToken); + ModelMetadata modelMetadata = await _appDevelopmentService.GetModelMetadata(AltinnRepoEditingContext.FromOrgRepoDeveloper(org, app, developer), layoutSetName, dataModelName, cancellationToken); + return Ok(modelMetadata); } diff --git a/backend/src/Designer/Services/Implementation/AppDevelopmentService.cs b/backend/src/Designer/Services/Implementation/AppDevelopmentService.cs index 9f262203e00..92d9920413f 100644 --- a/backend/src/Designer/Services/Implementation/AppDevelopmentService.cs +++ b/backend/src/Designer/Services/Implementation/AppDevelopmentService.cs @@ -12,11 +12,9 @@ using Altinn.Studio.Designer.Infrastructure.GitRepository; using Altinn.Studio.Designer.Models; using Altinn.Studio.Designer.Services.Interfaces; -using JetBrains.Annotations; using Microsoft.AspNetCore.Http; using NuGet.Versioning; using LayoutSets = Altinn.Studio.Designer.Models.LayoutSets; -using PlatformStorageModels = Altinn.Platform.Storage.Interface.Models; namespace Altinn.Studio.Designer.Services.Implementation { @@ -190,39 +188,45 @@ public async Task> GetAppMetadataModelIds(AltinnRepoEditingC } /// - public async Task GetModelMetadata(AltinnRepoEditingContext altinnRepoEditingContext, - string layoutSetName, CancellationToken cancellationToken = default) + public async Task GetModelMetadata(AltinnRepoEditingContext altinnRepoEditingContext, string layoutSetName, string dataModelName, CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - AltinnAppGitRepository altinnAppGitRepository = - _altinnGitRepositoryFactory.GetAltinnAppGitRepository(altinnRepoEditingContext.Org, - altinnRepoEditingContext.Repo, altinnRepoEditingContext.Developer); - ApplicationMetadata applicationMetadata = - await altinnAppGitRepository.GetApplicationMetadata(cancellationToken); - // get task_id since we might not maintain dataType ref in layout-sets-file - string taskId = await GetTaskIdBasedOnLayoutSet(altinnRepoEditingContext, layoutSetName, cancellationToken); - string modelName = GetModelName(applicationMetadata, taskId); + string modelPath; + ModelMetadata modelMetadata; + + if (dataModelName is not null) + { + modelPath = $"App/models/{dataModelName}.schema.json"; + modelMetadata = await _schemaModelService.GenerateModelMetadataFromJsonSchema(altinnRepoEditingContext, modelPath, cancellationToken); + return modelMetadata; + } + + string modelName = await GetModelName(altinnRepoEditingContext, layoutSetName, cancellationToken); + if (string.IsNullOrEmpty(modelName)) { return new ModelMetadata(); } - string modelPath = $"App/models/{modelName}.schema.json"; - ModelMetadata modelMetadata = await _schemaModelService.GenerateModelMetadataFromJsonSchema(altinnRepoEditingContext, modelPath, cancellationToken); + + modelPath = $"App/models/{modelName}.schema.json"; + modelMetadata = await _schemaModelService.GenerateModelMetadataFromJsonSchema(altinnRepoEditingContext, modelPath, cancellationToken); return modelMetadata; } - private string GetModelName(ApplicationMetadata applicationMetadata, [CanBeNull] string taskId) + private async Task GetModelName(AltinnRepoEditingContext altinnRepoEditingContext, string layoutSetName, CancellationToken cancellationToken = default) { - // fallback to first model if no task_id is provided (no layout sets) - if (taskId == null) + if (string.IsNullOrEmpty(layoutSetName)) { + // Fallback to first model in app metadata if no layout set is provided + AltinnAppGitRepository altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(altinnRepoEditingContext.Org, altinnRepoEditingContext.Repo, altinnRepoEditingContext.Developer); + ApplicationMetadata applicationMetadata = await altinnAppGitRepository.GetApplicationMetadata(cancellationToken); return applicationMetadata.DataTypes.FirstOrDefault(data => data.AppLogic != null && !string.IsNullOrEmpty(data.AppLogic.ClassRef) && !string.IsNullOrEmpty(data.TaskId))?.Id ?? string.Empty; } - PlatformStorageModels.DataType data = applicationMetadata.DataTypes - .FirstOrDefault(data => data.AppLogic != null && DoesDataTaskMatchTaskId(data, taskId) && !string.IsNullOrEmpty(data.AppLogic.ClassRef)); + LayoutSets layoutSets = await GetLayoutSets(altinnRepoEditingContext, cancellationToken); + var foundLayoutSet = layoutSets.Sets.Find(set => set.Id == layoutSetName); - return data?.Id ?? string.Empty; + return foundLayoutSet.DataType; } private IEnumerable GetAppMetadataModelIds(ApplicationMetadata applicationMetadata, bool onlyUnReferenced) @@ -240,23 +244,6 @@ private IEnumerable GetAppMetadataModelIds(ApplicationMetadata applicati return appMetaDataDataTypes.Select(datatype => datatype.Id); } - private bool DoesDataTaskMatchTaskId(PlatformStorageModels.DataType data, [CanBeNull] string taskId) - { - return string.IsNullOrEmpty(taskId) || data.TaskId == taskId; - } - - private async Task GetTaskIdBasedOnLayoutSet(AltinnRepoEditingContext altinnRepoEditingContext, string layoutSetName, CancellationToken cancellationToken = default) - { - if (string.IsNullOrEmpty(layoutSetName)) - { - // App without layout sets --> no need for task_id, we just retrieve the first occurence of a dataType with a classRef - return null; - } - LayoutSets layoutSets = await GetLayoutSets(altinnRepoEditingContext, cancellationToken); - - return layoutSets?.Sets?.Find(set => set.Id == layoutSetName)?.Tasks[0]; - } - /// public async Task GetLayoutSets(AltinnRepoEditingContext altinnRepoEditingContext, CancellationToken cancellationToken = default) diff --git a/backend/src/Designer/Services/Interfaces/IAppDevelopmentService.cs b/backend/src/Designer/Services/Interfaces/IAppDevelopmentService.cs index a5683a5043c..42556e4eaa3 100644 --- a/backend/src/Designer/Services/Interfaces/IAppDevelopmentService.cs +++ b/backend/src/Designer/Services/Interfaces/IAppDevelopmentService.cs @@ -92,10 +92,11 @@ public Task> GetAppMetadataModelIds( /// /// An . /// Name of layoutSet to fetch corresponding model metadata for + /// Name of data model to fetch /// An that observes if operation is cancelled. /// The model metadata for a given layout set. public Task GetModelMetadata( - AltinnRepoEditingContext altinnRepoEditingContext, [CanBeNull] string layoutSetName, + AltinnRepoEditingContext altinnRepoEditingContext, [CanBeNull] string layoutSetName, [CanBeNull] string dataModelName, CancellationToken cancellationToken = default); /// diff --git a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetModelMetadataTests.cs b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetModelMetadataTests.cs index 32d6972096b..f39caac9664 100644 --- a/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetModelMetadataTests.cs +++ b/backend/tests/Designer.Tests/Controllers/AppDevelopmentController/GetModelMetadataTests.cs @@ -20,39 +20,57 @@ public GetModelMetadataTests(WebApplicationFactory factory) : base(fact } [Theory] - [InlineData("ttd", "app-with-layoutsets", "testUser", "layoutSet1", "TestData/Model/Metadata/datamodel.json")] - [InlineData("ttd", "app-without-layoutsets", "testUser", null, "TestData/Model/Metadata/datamodel.json")] - public async Task GetModelMetadata_Should_Return_ModelMetadata(string org, string app, string developer, string layoutSetName, string expectedModelMetadataPath) + [InlineData("ttd", "app-with-layoutsets", "testUser", "layoutSet1", null)] + [InlineData("ttd", "app-without-layoutsets", "testUser", null, null)] + public async Task GetModelMetadata_Should_Return_ModelMetadata_Based_On_LayoutSet_When_DataModelName_Is_Undefined(string org, string app, string developer, string layoutSetName, string dataModelName) { - string targetRepository = TestDataHelper.GenerateTestRepoName(); - await CopyRepositoryForTest(org, app, developer, targetRepository); - - string expectedModelMetadata = await AddModelMetadataToRepo(TestRepoPath, expectedModelMetadataPath); - - string url = $"{VersionPrefix(org, targetRepository)}/model-metadata?layoutSetName={layoutSetName}"; + // Arrange + (string url, string expectedModelMetadata) = await ArrangeGetModelMetadataTest(org, app, developer, layoutSetName, dataModelName); using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); + // Act using var response = await HttpClient.SendAsync(httpRequestMessage); + string responseContent = await response.Content.ReadAsStringAsync(); + + // Assert response.StatusCode.Should().Be(HttpStatusCode.OK); + responseContent.Should().Be(expectedModelMetadata); + JsonUtils.DeepEquals(expectedModelMetadata, responseContent).Should().BeTrue(); + } + [Theory] + [InlineData("ttd", "app-with-layoutsets", "testUser", "layoutSet1", "datamodel")] + [InlineData("ttd", "app-without-layoutsets", "testUser", null, "datamodel")] + public async Task GetModelMetadata_Should_Return_ModelMetadata_When_DataModelName_Is_Specified(string org, string app, string developer, string layoutSetName, string dataModelName) + { + // Arrange + (string url, string expectedModelMetadata) = await ArrangeGetModelMetadataTest(org, app, developer, layoutSetName, dataModelName); + using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); + + // Act + using var response = await HttpClient.SendAsync(httpRequestMessage); string responseContent = await response.Content.ReadAsStringAsync(); + // Assert + response.StatusCode.Should().Be(HttpStatusCode.OK); responseContent.Should().Be(expectedModelMetadata); JsonUtils.DeepEquals(expectedModelMetadata, responseContent).Should().BeTrue(); } [Theory] - [InlineData("ttd", "app-with-layoutsets", "testUser", "layoutSet3")] - [InlineData("ttd", "app-without-layoutsets-mismatch-modelname", "testUser", null)] - public async Task GetModelMetadata_Should_Return_404_When_No_Corresponding_Datamodel_Exists(string org, string app, string developer, string layoutSetName) + [InlineData("ttd", "app-with-layoutsets", "testUser", "layoutSet3", null)] + [InlineData("ttd", "app-without-layoutsets-mismatch-modelname", "testUser", null, null)] + [InlineData("ttd", "app-with-layoutsets", "testUser", null, "non-existing-dataModelName")] + public async Task GetModelMetadata_Should_Return_404_When_No_Corresponding_Datamodel_Exists(string org, string app, string developer, string layoutSetName, string dataModelName) { - string targetRepository = TestDataHelper.GenerateTestRepoName(); - await CopyRepositoryForTest(org, app, developer, targetRepository); - - string url = $"{VersionPrefix(org, targetRepository)}/model-metadata?layoutSetName={layoutSetName}"; + // Arrange + (string url, _) = await ArrangeGetModelMetadataTest(org, app, developer, layoutSetName, dataModelName); using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url); + // Act using var response = await HttpClient.SendAsync(httpRequestMessage); + + // Assert response.StatusCode.Should().Be(HttpStatusCode.NotFound); } @@ -63,5 +81,18 @@ private async Task AddModelMetadataToRepo(string createdFolderPath, stri await File.WriteAllTextAsync(filePath, modelMetadata); return modelMetadata; } + + private async Task<(string url, string expectedModelMetadata)> ArrangeGetModelMetadataTest(string org, string app, string developer, string layoutSetName, string dataModelName) + { + string targetRepository = TestDataHelper.GenerateTestRepoName(); + await CopyRepositoryForTest(org, app, developer, targetRepository); + + const string expectedModelMetadataPath = "TestData/Model/Metadata/datamodel.json"; + string expectedModelMetadata = await AddModelMetadataToRepo(TestRepoPath, expectedModelMetadataPath); + + string url = $"{VersionPrefix(org, targetRepository)}/model-metadata?layoutSetName={layoutSetName}&dataModelName={dataModelName}"; + + return (url, expectedModelMetadata); + } } } diff --git a/frontend/app-preview/src/components/AppPreviewSubMenu.test.tsx b/frontend/app-preview/src/components/AppPreviewSubMenu.test.tsx index 90ea1e9eb63..7455a3e0471 100644 --- a/frontend/app-preview/src/components/AppPreviewSubMenu.test.tsx +++ b/frontend/app-preview/src/components/AppPreviewSubMenu.test.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { queryClientMock } from 'app-shared/mocks/queryClientMock'; import { renderWithProviders } from '@altinn/ux-editor/testing/mocks'; -import { layoutSet1NameMock, layoutSetsMock } from '@altinn/ux-editor/testing/layoutMock'; +import { layoutSet1NameMock, layoutSetsMock } from '@altinn/ux-editor/testing/layoutSetsMock'; import type { AppPreviewSubMenuProps } from './AppPreviewSubMenu'; import { AppPreviewSubMenu } from './AppPreviewSubMenu'; import type { LayoutSets } from 'app-shared/types/api/LayoutSetsResponse'; diff --git a/frontend/packages/shared/src/api/paths.js b/frontend/packages/shared/src/api/paths.js index 49ae403859f..3ed4187aa7f 100644 --- a/frontend/packages/shared/src/api/paths.js +++ b/frontend/packages/shared/src/api/paths.js @@ -32,7 +32,7 @@ export const widgetSettingsPath = (org, app) => `${basePath}/${org}/${app}/app-d export const optionListIdsPath = (org, app) => `${basePath}/${org}/${app}/app-development/option-list-ids`; // Get export const ruleConfigPath = (org, app, layoutSetName) => `${basePath}/${org}/${app}/app-development/rule-config?${s({ layoutSetName })}`; // Get, Post export const appMetadataModelIdsPath = (org, app, onlyUnReferenced) => `${basePath}/${org}/${app}/app-development/model-ids?${s({ onlyUnReferenced })}`; // Get -export const datamodelMetadataPath = (org, app, layoutSetName) => `${basePath}/${org}/${app}/app-development/model-metadata?${s({ layoutSetName })}`; // Get +export const datamodelMetadataPath = (org, app, layoutSetName, dataModelName) => `${basePath}/${org}/${app}/app-development/model-metadata?${s({ layoutSetName })}&${s({ dataModelName })}`; // Get export const layoutNamesPath = (org, app) => `${basePath}/${org}/${app}/app-development/layout-names`; // Get export const layoutSetsPath = (org, app) => `${basePath}/${org}/${app}/app-development/layout-sets`; // Get export const layoutSetPath = (org, app, layoutSetIdToUpdate) => `${basePath}/${org}/${app}/app-development/layout-set/${layoutSetIdToUpdate}`; // Put, Delete diff --git a/frontend/packages/shared/src/api/queries.ts b/frontend/packages/shared/src/api/queries.ts index 2f7fe759143..d877b66c193 100644 --- a/frontend/packages/shared/src/api/queries.ts +++ b/frontend/packages/shared/src/api/queries.ts @@ -79,7 +79,7 @@ export const getAppReleases = (owner: string, app: string) => get get(appVersionPath(org, app)); export const getBranchStatus = (owner: string, app: string, branch: string) => get(branchStatusPath(owner, app, branch)); export const getDatamodel = (owner: string, app: string, modelPath: string) => get(datamodelPath(owner, app, modelPath)); -export const getDatamodelMetadata = (owner: string, app: string, layoutSetName: string) => get(datamodelMetadataPath(owner, app, layoutSetName)); +export const getDatamodelMetadata = (owner: string, app: string, layoutSetName: string, dataModelName: string) => get(datamodelMetadataPath(owner, app, layoutSetName, dataModelName)); export const getDatamodelsJson = (owner: string, app: string) => get(datamodelsPath(owner, app)); export const getDatamodelsXsd = (owner: string, app: string) => get(datamodelsXsdPath(owner, app)); export const getDeployPermissions = (owner: string, app: string) => get(deployPermissionsPath(owner, app)); diff --git a/frontend/packages/ux-editor-v3/src/App.test.tsx b/frontend/packages/ux-editor-v3/src/App.test.tsx index 705da158b65..4b16a3968e0 100644 --- a/frontend/packages/ux-editor-v3/src/App.test.tsx +++ b/frontend/packages/ux-editor-v3/src/App.test.tsx @@ -8,7 +8,7 @@ import type { ServicesContextProps } from 'app-shared/contexts/ServicesContext'; import { appStateMock } from './testing/stateMocks'; import type { AppContextProps } from './AppContext'; import ruleHandlerMock from './testing/ruleHandlerMock'; -import { layoutSetsMock } from './testing/layoutMock'; +import { layoutSetsMock } from './testing/layoutSetsMock'; const { selectedLayoutSet } = appStateMock.formDesigner.layout; diff --git a/frontend/packages/ux-editor-v3/src/App.tsx b/frontend/packages/ux-editor-v3/src/App.tsx index 11a0ebd7e72..fc045b26527 100644 --- a/frontend/packages/ux-editor-v3/src/App.tsx +++ b/frontend/packages/ux-editor-v3/src/App.tsx @@ -27,7 +27,7 @@ export function App() { const { data: layoutSets, isSuccess: areLayoutSetsFetched } = useLayoutSetsQuery(org, app); const { isSuccess: areWidgetsFetched, isError: widgetFetchedError } = useWidgetsQuery(org, app); const { isSuccess: isDatamodelFetched, isError: dataModelFetchedError } = - useDatamodelMetadataQuery(org, app, selectedLayoutSet); + useDatamodelMetadataQuery(org, app, selectedLayoutSet, undefined); const { isSuccess: areTextResourcesFetched } = useTextResourcesQuery(org, app); useEffect(() => { diff --git a/frontend/packages/ux-editor-v3/src/components/Elements/LayoutSetsContainer.test.tsx b/frontend/packages/ux-editor-v3/src/components/Elements/LayoutSetsContainer.test.tsx index 897d1ba1b81..320fa9de26a 100644 --- a/frontend/packages/ux-editor-v3/src/components/Elements/LayoutSetsContainer.test.tsx +++ b/frontend/packages/ux-editor-v3/src/components/Elements/LayoutSetsContainer.test.tsx @@ -4,7 +4,11 @@ import userEvent from '@testing-library/user-event'; import { LayoutSetsContainer } from './LayoutSetsContainer'; import { queryClientMock } from 'app-shared/mocks/queryClientMock'; import { renderWithMockStore } from '../../testing/mocks'; -import { layoutSet1NameMock, layoutSet2NameMock, layoutSetsMock } from '../../testing/layoutMock'; +import { + layoutSet1NameMock, + layoutSet2NameMock, + layoutSetsMock, +} from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import type { AppContextProps } from '../../AppContext'; import { appStateMock } from '../../testing/stateMocks'; import { QueryKey } from 'app-shared/types/QueryKey'; diff --git a/frontend/packages/ux-editor-v3/src/components/config/EditFormComponent.test.tsx b/frontend/packages/ux-editor-v3/src/components/config/EditFormComponent.test.tsx index 0ccaa9c37b4..1a9d21f1840 100644 --- a/frontend/packages/ux-editor-v3/src/components/config/EditFormComponent.test.tsx +++ b/frontend/packages/ux-editor-v3/src/components/config/EditFormComponent.test.tsx @@ -9,7 +9,7 @@ import { mockUseTranslation } from '@studio/testing/mocks/i18nMock'; import { ComponentTypeV3 } from 'app-shared/types/ComponentTypeV3'; import { useDatamodelMetadataQuery } from '../../hooks/queries/useDatamodelMetadataQuery'; import type { DatamodelMetadataResponse } from 'app-shared/types/api'; -import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { dataModelNameMock, layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import { app, org } from '@studio/testing/testids'; const user = userEvent.setup(); @@ -226,7 +226,8 @@ const waitForData = async () => { const dataModelMetadataResult = renderHookWithMockStore( {}, { getDatamodelMetadata }, - )(() => useDatamodelMetadataQuery(org, app, layoutSet1NameMock)).renderHookResult.result; + )(() => useDatamodelMetadataQuery(org, app, layoutSet1NameMock, dataModelNameMock)) + .renderHookResult.result; await waitFor(() => expect(dataModelMetadataResult.current.isSuccess).toBe(true)); await waitFor(() => expect(layoutSchemaResult.current[0].isSuccess).toBe(true)); }; diff --git a/frontend/packages/ux-editor-v3/src/components/config/EditFormContainer.test.tsx b/frontend/packages/ux-editor-v3/src/components/config/EditFormContainer.test.tsx index 61a0246318b..c1181c0b1d1 100644 --- a/frontend/packages/ux-editor-v3/src/components/config/EditFormContainer.test.tsx +++ b/frontend/packages/ux-editor-v3/src/components/config/EditFormContainer.test.tsx @@ -15,8 +15,8 @@ import { container1IdMock, externalLayoutsMock, layoutMock, - layoutSet1NameMock, -} from '../../testing/layoutMock'; +} from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import { textMock } from '@studio/testing/mocks/i18nMock'; import type { FormLayoutsResponseV3 } from 'app-shared/types/api'; import type { ILayoutSettings } from 'app-shared/types/global'; diff --git a/frontend/packages/ux-editor-v3/src/components/config/EditFormContainer.tsx b/frontend/packages/ux-editor-v3/src/components/config/EditFormContainer.tsx index 6ac25b0d67f..9c28a3f4efa 100644 --- a/frontend/packages/ux-editor-v3/src/components/config/EditFormContainer.tsx +++ b/frontend/packages/ux-editor-v3/src/components/config/EditFormContainer.tsx @@ -46,7 +46,7 @@ export const EditFormContainer = ({ const { selectedLayoutSet } = useAppContext(); const { data: formLayouts } = useFormLayoutsQuery(org, app, selectedLayoutSet); - const { data: dataModel } = useDatamodelMetadataQuery(org, app, selectedLayoutSet); + const { data: dataModel } = useDatamodelMetadataQuery(org, app, selectedLayoutSet, undefined); const { components, containers } = useSelectedFormLayout(); const textResources: ITextResource[] = useTextResourcesSelector( textResourcesByLanguageSelector(DEFAULT_LANGUAGE), diff --git a/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionContent.test.tsx b/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionContent.test.tsx index bee3e86329e..80a4a94c771 100644 --- a/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionContent.test.tsx +++ b/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionContent.test.tsx @@ -8,7 +8,8 @@ import { import type { ServicesContextProps } from 'app-shared/contexts/ServicesContext'; import { renderWithMockStore } from '../../../../testing/mocks'; import type { IFormLayouts } from '../../../../types/global'; -import { layout1NameMock, layoutMock, layoutSet1NameMock } from '../../../../testing/layoutMock'; +import { layout1NameMock, layoutMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import type { ExpressionContentProps } from './ExpressionContent'; import { ExpressionContent } from './ExpressionContent'; import { textMock } from '@studio/testing/mocks/i18nMock'; diff --git a/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/ExpressionEditMode.test.tsx b/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/ExpressionEditMode.test.tsx index 8a058e363d8..6692196ea85 100644 --- a/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/ExpressionEditMode.test.tsx +++ b/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/ExpressionEditMode.test.tsx @@ -11,7 +11,8 @@ import { import type { ServicesContextProps } from 'app-shared/contexts/ServicesContext'; import { renderWithMockStore } from '../../../../../testing/mocks'; import type { IFormLayouts } from '../../../../../types/global'; -import { layout1NameMock, layoutMock, layoutSet1NameMock } from '../../../../../testing/layoutMock'; +import { layout1NameMock, layoutMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import { textMock } from '@studio/testing/mocks/i18nMock'; import { createQueryClientMock } from 'app-shared/mocks/queryClientMock'; import { QueryKey } from 'app-shared/types/QueryKey'; diff --git a/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/DataSourceValue.tsx b/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/DataSourceValue.tsx index fd9657d9bb5..27977f5a334 100644 --- a/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/DataSourceValue.tsx +++ b/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/DataSourceValue.tsx @@ -34,7 +34,7 @@ export const DataSourceValue = ({ const { org, app } = useStudioUrlParams(); const { selectedLayoutSet } = useAppContext(); // TODO: Show spinner when isLoading - const datamodelQuery = useDatamodelMetadataQuery(org, app, selectedLayoutSet); + const datamodelQuery = useDatamodelMetadataQuery(org, app, selectedLayoutSet, undefined); const { data: formLayoutsData } = useFormLayoutsQuery(org, app, selectedLayoutSet); const t = useText(); diff --git a/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/SimpleExpression.test.tsx b/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/SimpleExpression.test.tsx index 92f73c9822b..0a977ad109d 100644 --- a/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/SimpleExpression.test.tsx +++ b/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/SimpleExpression.test.tsx @@ -9,11 +9,8 @@ import { textMock } from '@studio/testing/mocks/i18nMock'; import { createQueryClientMock } from 'app-shared/mocks/queryClientMock'; import { QueryKey } from 'app-shared/types/QueryKey'; import type { IFormLayouts } from '../../../../../../types/global'; -import { - layout1NameMock, - layoutMock, - layoutSet1NameMock, -} from '../../../../../../testing/layoutMock'; +import { layout1NameMock, layoutMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import { app, org } from '@studio/testing/testids'; const layoutSetName = layoutSet1NameMock; diff --git a/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/SubExpressionContent.test.tsx b/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/SubExpressionContent.test.tsx index d083dcf1686..0029b6688ee 100644 --- a/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/SubExpressionContent.test.tsx +++ b/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/SubExpressionContent.test.tsx @@ -14,11 +14,8 @@ import { renderWithMockStore } from '../../../../../../testing/mocks'; import { textMock } from '@studio/testing/mocks/i18nMock'; import { createQueryClientMock } from 'app-shared/mocks/queryClientMock'; import { QueryKey } from 'app-shared/types/QueryKey'; -import { - layout1NameMock, - layoutMock, - layoutSet1NameMock, -} from '../../../../../../testing/layoutMock'; +import { layout1NameMock, layoutMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import type { IFormLayouts } from '../../../../../../types/global'; import { DataSource } from '../../../../../../types/Expressions'; import { app, org } from '@studio/testing/testids'; diff --git a/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionPreview/ExpressionPreview.test.tsx b/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionPreview/ExpressionPreview.test.tsx index dfc5a4e2ee9..d56e2a37a89 100644 --- a/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionPreview/ExpressionPreview.test.tsx +++ b/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionPreview/ExpressionPreview.test.tsx @@ -9,7 +9,8 @@ import { import type { ServicesContextProps } from 'app-shared/contexts/ServicesContext'; import { renderWithMockStore } from '../../../../../testing/mocks'; import type { IFormLayouts } from '../../../../../types/global'; -import { layout1NameMock, layoutMock, layoutSet1NameMock } from '../../../../../testing/layoutMock'; +import { layout1NameMock, layoutMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import { textMock } from '@studio/testing/mocks/i18nMock'; import { createQueryClientMock } from 'app-shared/mocks/queryClientMock'; import { QueryKey } from 'app-shared/types/QueryKey'; diff --git a/frontend/packages/ux-editor-v3/src/components/config/Expressions/Expressions.test.tsx b/frontend/packages/ux-editor-v3/src/components/config/Expressions/Expressions.test.tsx index e48a2b40170..f23c2272037 100644 --- a/frontend/packages/ux-editor-v3/src/components/config/Expressions/Expressions.test.tsx +++ b/frontend/packages/ux-editor-v3/src/components/config/Expressions/Expressions.test.tsx @@ -5,7 +5,8 @@ import type { ServicesContextProps } from 'app-shared/contexts/ServicesContext'; import { renderWithMockStore } from '../../../testing/mocks'; import { formItemContextProviderMock } from '../../../testing/formItemContextMocks'; import type { IFormLayouts } from '../../../types/global'; -import { layout1NameMock, layoutMock, layoutSet1NameMock } from '../../../testing/layoutMock'; +import { layout1NameMock, layoutMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import { textMock } from '@studio/testing/mocks/i18nMock'; import { createQueryClientMock } from 'app-shared/mocks/queryClientMock'; import { QueryKey } from 'app-shared/types/QueryKey'; diff --git a/frontend/packages/ux-editor-v3/src/components/config/SelectDataModelComponent.test.tsx b/frontend/packages/ux-editor-v3/src/components/config/SelectDataModelComponent.test.tsx index 1c937b2ba14..f1a38551a84 100644 --- a/frontend/packages/ux-editor-v3/src/components/config/SelectDataModelComponent.test.tsx +++ b/frontend/packages/ux-editor-v3/src/components/config/SelectDataModelComponent.test.tsx @@ -9,7 +9,7 @@ import { textMock } from '@studio/testing/mocks/i18nMock'; import { useDatamodelMetadataQuery } from '../../hooks/queries/useDatamodelMetadataQuery'; import userEvent from '@testing-library/user-event'; import type { DatamodelMetadataResponse } from 'app-shared/types/api'; -import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { dataModelNameMock, layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import { app, org } from '@studio/testing/testids'; const getDatamodelMetadata = () => @@ -55,13 +55,14 @@ const getDatamodelMetadata = () => const user = userEvent.setup(); const waitForData = async () => { - const datamodelMetadatResult = renderHookWithMockStore( + const datamodelMetadataResult = renderHookWithMockStore( {}, { getDatamodelMetadata, }, - )(() => useDatamodelMetadataQuery(org, app, layoutSet1NameMock)).renderHookResult.result; - await waitFor(() => expect(datamodelMetadatResult.current.isSuccess).toBe(true)); + )(() => useDatamodelMetadataQuery(org, app, layoutSet1NameMock, dataModelNameMock)) + .renderHookResult.result; + await waitFor(() => expect(datamodelMetadataResult.current.isSuccess).toBe(true)); }; const render = async ({ dataModelBindings = {}, handleComponentChange = jest.fn() } = {}) => { diff --git a/frontend/packages/ux-editor-v3/src/components/config/SelectDataModelComponent.tsx b/frontend/packages/ux-editor-v3/src/components/config/SelectDataModelComponent.tsx index 78944462fb7..063b2856f35 100644 --- a/frontend/packages/ux-editor-v3/src/components/config/SelectDataModelComponent.tsx +++ b/frontend/packages/ux-editor-v3/src/components/config/SelectDataModelComponent.tsx @@ -32,7 +32,7 @@ export const SelectDataModelComponent = ({ }: ISelectDataModelProps) => { const { org, app } = useStudioUrlParams(); const { selectedLayoutSet } = useAppContext(); - const { data } = useDatamodelMetadataQuery(org, app, selectedLayoutSet); + const { data } = useDatamodelMetadataQuery(org, app, selectedLayoutSet, undefined); const [dataModelElementNames, setDataModelElementNames] = React.useState([]); useEffect(() => { diff --git a/frontend/packages/ux-editor-v3/src/components/config/componentSpecificContent/Panel/PanelComponent.test.tsx b/frontend/packages/ux-editor-v3/src/components/config/componentSpecificContent/Panel/PanelComponent.test.tsx index 5a6ead97b7a..b8f5d1b2995 100644 --- a/frontend/packages/ux-editor-v3/src/components/config/componentSpecificContent/Panel/PanelComponent.test.tsx +++ b/frontend/packages/ux-editor-v3/src/components/config/componentSpecificContent/Panel/PanelComponent.test.tsx @@ -15,7 +15,7 @@ import { useFormLayoutSettingsQuery } from '../../../../hooks/queries/useFormLay import { textMock } from '@studio/testing/mocks/i18nMock'; import { FormPanelVariant } from 'app-shared/types/FormPanelVariant'; import { app, org } from '@studio/testing/testids'; -import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; // Test data: const selectedLayoutSet = layoutSet1NameMock; diff --git a/frontend/packages/ux-editor-v3/src/components/config/editModal/EditDataModelBindings.tsx b/frontend/packages/ux-editor-v3/src/components/config/editModal/EditDataModelBindings.tsx index 5bb9f97d77f..667bd91da3a 100644 --- a/frontend/packages/ux-editor-v3/src/components/config/editModal/EditDataModelBindings.tsx +++ b/frontend/packages/ux-editor-v3/src/components/config/editModal/EditDataModelBindings.tsx @@ -30,7 +30,7 @@ export const EditDataModelBindings = ({ }: EditDataModelBindingsProps) => { const { org, app } = useStudioUrlParams(); const { selectedLayoutSet } = useAppContext(); - const { data } = useDatamodelMetadataQuery(org, app, selectedLayoutSet); + const { data } = useDatamodelMetadataQuery(org, app, selectedLayoutSet, undefined); const t = useText(); const handleDataModelChange = (selectedDataModelElement: string, key = 'simpleBinding') => { diff --git a/frontend/packages/ux-editor-v3/src/containers/DesignView/DesignView.test.tsx b/frontend/packages/ux-editor-v3/src/containers/DesignView/DesignView.test.tsx index 229102a36a7..6a7b5b4e178 100644 --- a/frontend/packages/ux-editor-v3/src/containers/DesignView/DesignView.test.tsx +++ b/frontend/packages/ux-editor-v3/src/containers/DesignView/DesignView.test.tsx @@ -15,8 +15,8 @@ import { externalLayoutsMock, layout1NameMock, layout2NameMock, - layoutSet1NameMock, -} from '../../testing/layoutMock'; +} from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import { convertExternalLayoutsToInternalFormat } from '../../utils/formLayoutsUtils'; import { app, org } from '@studio/testing/testids'; diff --git a/frontend/packages/ux-editor-v3/src/containers/DesignView/PageAccordion/NavigationMenu/NavigationMenu.test.tsx b/frontend/packages/ux-editor-v3/src/containers/DesignView/PageAccordion/NavigationMenu/NavigationMenu.test.tsx index ce7ef9e9fa7..c52bb226e1b 100644 --- a/frontend/packages/ux-editor-v3/src/containers/DesignView/PageAccordion/NavigationMenu/NavigationMenu.test.tsx +++ b/frontend/packages/ux-editor-v3/src/containers/DesignView/PageAccordion/NavigationMenu/NavigationMenu.test.tsx @@ -12,11 +12,8 @@ import { } from '../../../../testing/mocks'; import { useFormLayoutSettingsQuery } from '../../../../hooks/queries/useFormLayoutSettingsQuery'; import { app, org } from '@studio/testing/testids'; -import { - layout1NameMock, - layout2NameMock, - layoutSet1NameMock, -} from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layout1NameMock, layout2NameMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; const mockPageName1: string = layout1NameMock; const mockSelectedLayoutSet = layoutSet1NameMock; diff --git a/frontend/packages/ux-editor-v3/src/containers/DesignView/PageAccordion/PageAccordion.test.tsx b/frontend/packages/ux-editor-v3/src/containers/DesignView/PageAccordion/PageAccordion.test.tsx index 479701e8ae8..8c7098b856a 100644 --- a/frontend/packages/ux-editor-v3/src/containers/DesignView/PageAccordion/PageAccordion.test.tsx +++ b/frontend/packages/ux-editor-v3/src/containers/DesignView/PageAccordion/PageAccordion.test.tsx @@ -11,7 +11,8 @@ import { renderHookWithMockStore, renderWithMockStore, } from '../../../testing/mocks'; -import { layout1NameMock, layout2NameMock, layoutSet1NameMock } from '../../../testing/layoutMock'; +import { layout1NameMock, layout2NameMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import { app, org } from '@studio/testing/testids'; const mockPageName1: string = layout1NameMock; diff --git a/frontend/packages/ux-editor-v3/src/containers/DesignView/ReceiptContent/ReceiptContent.test.tsx b/frontend/packages/ux-editor-v3/src/containers/DesignView/ReceiptContent/ReceiptContent.test.tsx index e9eb4eef986..bf440026f55 100644 --- a/frontend/packages/ux-editor-v3/src/containers/DesignView/ReceiptContent/ReceiptContent.test.tsx +++ b/frontend/packages/ux-editor-v3/src/containers/DesignView/ReceiptContent/ReceiptContent.test.tsx @@ -10,8 +10,8 @@ import { component2Mock, layout1NameMock, layout2NameMock, - layoutSet1NameMock, -} from '../../../testing/layoutMock'; +} from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import type { IInternalLayout } from '../../../types/global'; import { formLayoutSettingsMock, diff --git a/frontend/packages/ux-editor-v3/src/containers/FormDesigner.test.tsx b/frontend/packages/ux-editor-v3/src/containers/FormDesigner.test.tsx index 38498e5d2ba..dad4a718019 100644 --- a/frontend/packages/ux-editor-v3/src/containers/FormDesigner.test.tsx +++ b/frontend/packages/ux-editor-v3/src/containers/FormDesigner.test.tsx @@ -10,7 +10,7 @@ import { textMock } from '@studio/testing/mocks/i18nMock'; import { useWidgetsQuery } from '../hooks/queries/useWidgetsQuery'; import ruleHandlerMock from '../testing/ruleHandlerMock'; import { app, org } from '@studio/testing/testids'; -import { layoutSet1NameMock } from '../testing/layoutMock'; +import { layoutSet1NameMock } from '../testing/layoutSetsMock'; const render = () => { const queries = { diff --git a/frontend/packages/ux-editor-v3/src/hooks/mutations/useAddFormContainerMutation.test.ts b/frontend/packages/ux-editor-v3/src/hooks/mutations/useAddFormContainerMutation.test.ts index 489b541785f..a098b198c3a 100644 --- a/frontend/packages/ux-editor-v3/src/hooks/mutations/useAddFormContainerMutation.test.ts +++ b/frontend/packages/ux-editor-v3/src/hooks/mutations/useAddFormContainerMutation.test.ts @@ -6,7 +6,8 @@ import type { AddFormContainerMutationArgs } from './useAddFormContainerMutation import { useAddFormContainerMutation } from './useAddFormContainerMutation'; import type { FormContainer } from '../../types/FormContainer'; import { ComponentTypeV3 } from 'app-shared/types/ComponentTypeV3'; -import { layout1NameMock, layoutSet1NameMock } from '../../testing/layoutMock'; +import { layout1NameMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import { app, org } from '@studio/testing/testids'; // Test data: diff --git a/frontend/packages/ux-editor-v3/src/hooks/mutations/useAddItemToLayoutMutation.test.ts b/frontend/packages/ux-editor-v3/src/hooks/mutations/useAddItemToLayoutMutation.test.ts index 18fd15b5ec5..b8fcd0eb772 100644 --- a/frontend/packages/ux-editor-v3/src/hooks/mutations/useAddItemToLayoutMutation.test.ts +++ b/frontend/packages/ux-editor-v3/src/hooks/mutations/useAddItemToLayoutMutation.test.ts @@ -8,12 +8,12 @@ import { useAddItemToLayoutMutation } from './useAddItemToLayoutMutation'; import { ComponentTypeV3 } from 'app-shared/types/ComponentTypeV3'; import type { ApplicationAttachmentMetadata } from 'app-shared/types/ApplicationAttachmentMetadata'; import type { IAppState } from '../../types/global'; +import { externalLayoutsMock } from '@altinn/ux-editor-v3/testing/layoutMock'; import { - externalLayoutsMock, layoutSet1NameMock, layoutSet2NameMock, layoutSetsMock, -} from '../../testing/layoutMock'; +} from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import { QueryKey } from 'app-shared/types/QueryKey'; import { convertExternalLayoutsToInternalFormat } from '../../utils/formLayoutsUtils'; import { app, org } from '@studio/testing/testids'; diff --git a/frontend/packages/ux-editor-v3/src/hooks/mutations/useAddLayoutMutation.test.ts b/frontend/packages/ux-editor-v3/src/hooks/mutations/useAddLayoutMutation.test.ts index c3b9f291c2a..b3b6fe5ff98 100644 --- a/frontend/packages/ux-editor-v3/src/hooks/mutations/useAddLayoutMutation.test.ts +++ b/frontend/packages/ux-editor-v3/src/hooks/mutations/useAddLayoutMutation.test.ts @@ -6,7 +6,8 @@ import { useFormLayoutsQuery } from '../queries/useFormLayoutsQuery'; import { waitFor } from '@testing-library/react'; import { useFormLayoutSettingsQuery } from '../queries/useFormLayoutSettingsQuery'; import { ComponentTypeV3 } from 'app-shared/types/ComponentTypeV3'; -import { externalLayoutsMock, layoutSet1NameMock } from '../../testing/layoutMock'; +import { externalLayoutsMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import type { FormLayoutsResponseV3 } from 'app-shared/types/api'; import type { ILayoutSettings } from 'app-shared/types/global'; import { app, org } from '@studio/testing/testids'; diff --git a/frontend/packages/ux-editor-v3/src/hooks/mutations/useAddWidgetMutation.test.ts b/frontend/packages/ux-editor-v3/src/hooks/mutations/useAddWidgetMutation.test.ts index 2f9d8389544..047f0f1eeb0 100644 --- a/frontend/packages/ux-editor-v3/src/hooks/mutations/useAddWidgetMutation.test.ts +++ b/frontend/packages/ux-editor-v3/src/hooks/mutations/useAddWidgetMutation.test.ts @@ -9,7 +9,7 @@ import { ComponentTypeV3 } from 'app-shared/types/ComponentTypeV3'; import type { ITextResource } from 'app-shared/types/global'; import { useTextResourcesQuery } from 'app-shared/hooks/queries/useTextResourcesQuery'; import { app, org } from '@studio/testing/testids'; -import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; // Test data: const selectedLayoutSet = layoutSet1NameMock; diff --git a/frontend/packages/ux-editor-v3/src/hooks/mutations/useDeleteFormComponentMutation.test.ts b/frontend/packages/ux-editor-v3/src/hooks/mutations/useDeleteFormComponentMutation.test.ts index f225f47a4b6..ee0d1c1994d 100644 --- a/frontend/packages/ux-editor-v3/src/hooks/mutations/useDeleteFormComponentMutation.test.ts +++ b/frontend/packages/ux-editor-v3/src/hooks/mutations/useDeleteFormComponentMutation.test.ts @@ -3,7 +3,8 @@ import { renderHookWithMockStore } from '../../testing/mocks'; import { waitFor } from '@testing-library/react'; import { useDeleteFormComponentMutation } from './useDeleteFormComponentMutation'; import { useFormLayoutsQuery } from '../queries/useFormLayoutsQuery'; -import { component2IdMock, layout1NameMock, layoutSet1NameMock } from '../../testing/layoutMock'; +import { component2IdMock, layout1NameMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import { app, org } from '@studio/testing/testids'; // Test data: diff --git a/frontend/packages/ux-editor-v3/src/hooks/mutations/useDeleteFormContainerMutation.test.ts b/frontend/packages/ux-editor-v3/src/hooks/mutations/useDeleteFormContainerMutation.test.ts index c1d9abfaa5c..a3ca0dc4ae0 100644 --- a/frontend/packages/ux-editor-v3/src/hooks/mutations/useDeleteFormContainerMutation.test.ts +++ b/frontend/packages/ux-editor-v3/src/hooks/mutations/useDeleteFormContainerMutation.test.ts @@ -7,8 +7,8 @@ import { container1IdMock, externalLayoutsMock, layout1NameMock, - layoutSet1NameMock, -} from '../../testing/layoutMock'; +} from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import type { FormLayoutsResponseV3 } from 'app-shared/types/api'; import { app, org } from '@studio/testing/testids'; diff --git a/frontend/packages/ux-editor-v3/src/hooks/mutations/useDeleteLayoutMutation.test.ts b/frontend/packages/ux-editor-v3/src/hooks/mutations/useDeleteLayoutMutation.test.ts index 162d42bccac..7fd7d06bc59 100644 --- a/frontend/packages/ux-editor-v3/src/hooks/mutations/useDeleteLayoutMutation.test.ts +++ b/frontend/packages/ux-editor-v3/src/hooks/mutations/useDeleteLayoutMutation.test.ts @@ -2,7 +2,8 @@ import { queriesMock } from 'app-shared/mocks/queriesMock'; import { queryClientMock } from 'app-shared/mocks/queryClientMock'; import { formLayoutSettingsMock, renderHookWithMockStore } from '../../testing/mocks'; import { useDeleteLayoutMutation } from './useDeleteLayoutMutation'; -import { externalLayoutsMock, layout2NameMock, layoutSet1NameMock } from '../../testing/layoutMock'; +import { externalLayoutsMock, layout2NameMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import { QueryKey } from 'app-shared/types/QueryKey'; import { convertExternalLayoutsToInternalFormat } from '../../utils/formLayoutsUtils'; import { app, org } from '@studio/testing/testids'; diff --git a/frontend/packages/ux-editor-v3/src/hooks/mutations/useFormLayoutMutation.test.tsx b/frontend/packages/ux-editor-v3/src/hooks/mutations/useFormLayoutMutation.test.tsx index 87816f2f610..a46f0eca0ab 100644 --- a/frontend/packages/ux-editor-v3/src/hooks/mutations/useFormLayoutMutation.test.tsx +++ b/frontend/packages/ux-editor-v3/src/hooks/mutations/useFormLayoutMutation.test.tsx @@ -4,7 +4,8 @@ import { renderHookWithMockStore } from '../../testing/mocks'; import { useFormLayoutMutation } from './useFormLayoutMutation'; import type { IInternalLayout } from '../../types/global'; import { ComponentTypeV3 } from 'app-shared/types/ComponentTypeV3'; -import { baseContainerIdMock, layout1NameMock, layoutSet1NameMock } from '../../testing/layoutMock'; +import { baseContainerIdMock, layout1NameMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import type { AppContextProps } from '../../AppContext'; import type { RefObject } from 'react'; import { createRef } from 'react'; diff --git a/frontend/packages/ux-editor-v3/src/hooks/mutations/useFormLayoutSettingsMutation.test.ts b/frontend/packages/ux-editor-v3/src/hooks/mutations/useFormLayoutSettingsMutation.test.ts index 84407e29796..1434e9893bf 100644 --- a/frontend/packages/ux-editor-v3/src/hooks/mutations/useFormLayoutSettingsMutation.test.ts +++ b/frontend/packages/ux-editor-v3/src/hooks/mutations/useFormLayoutSettingsMutation.test.ts @@ -3,7 +3,7 @@ import { formLayoutSettingsMock, renderHookWithMockStore } from '../../testing/m import { useFormLayoutSettingsMutation } from './useFormLayoutSettingsMutation'; import { waitFor } from '@testing-library/react'; import { app, org } from '@studio/testing/testids'; -import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; // Test data: const selectedLayoutSet = layoutSet1NameMock; diff --git a/frontend/packages/ux-editor-v3/src/hooks/mutations/useRuleConfigMutation.test.ts b/frontend/packages/ux-editor-v3/src/hooks/mutations/useRuleConfigMutation.test.ts index 50afa62312f..7e526023987 100644 --- a/frontend/packages/ux-editor-v3/src/hooks/mutations/useRuleConfigMutation.test.ts +++ b/frontend/packages/ux-editor-v3/src/hooks/mutations/useRuleConfigMutation.test.ts @@ -3,7 +3,7 @@ import { renderHookWithMockStore } from '../../testing/mocks'; import { useRuleConfigMutation } from './useRuleConfigMutation'; import type { RuleConfig } from 'app-shared/types/RuleConfig'; import { app, org } from '@studio/testing/testids'; -import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; // Test data: const selectedLayoutSet = layoutSet1NameMock; diff --git a/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateFormComponentMutation.test.ts b/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateFormComponentMutation.test.ts index f267fb300bd..5008630b419 100644 --- a/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateFormComponentMutation.test.ts +++ b/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateFormComponentMutation.test.ts @@ -8,8 +8,8 @@ import { component1IdMock, externalLayoutsMock, layout1NameMock, - layoutSet1NameMock, -} from '../../testing/layoutMock'; +} from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import type { FormCheckboxesComponent, FormComponent, diff --git a/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateFormComponentOrderMutation.test.ts b/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateFormComponentOrderMutation.test.ts index e9e9aacaa8a..90b40adff2d 100644 --- a/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateFormComponentOrderMutation.test.ts +++ b/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateFormComponentOrderMutation.test.ts @@ -11,8 +11,8 @@ import { externalLayoutsMock, layout1NameMock, layoutMock, - layoutSet1NameMock, -} from '../../testing/layoutMock'; +} from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import type { FormLayoutsResponseV3 } from 'app-shared/types/api'; import { app, org } from '@studio/testing/testids'; diff --git a/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateFormContainerMutation.test.ts b/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateFormContainerMutation.test.ts index b5bbc9bb930..2fc65272eb2 100644 --- a/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateFormContainerMutation.test.ts +++ b/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateFormContainerMutation.test.ts @@ -11,8 +11,8 @@ import { externalLayoutsMock, layout1Mock, layout1NameMock, - layoutSet1NameMock, -} from '../../testing/layoutMock'; +} from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import { ruleConfig as ruleConfigMock } from '../../testing/ruleConfigMock'; import type { FormLayoutsResponseV3 } from 'app-shared/types/api'; import type { RuleConfig } from 'app-shared/types/RuleConfig'; diff --git a/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateLayoutNameMutation.test.ts b/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateLayoutNameMutation.test.ts index 10cc8250617..fb686e111ab 100644 --- a/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateLayoutNameMutation.test.ts +++ b/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateLayoutNameMutation.test.ts @@ -5,7 +5,8 @@ import { useFormLayoutSettingsQuery } from '../queries/useFormLayoutSettingsQuer import { waitFor } from '@testing-library/react'; import type { UpdateLayoutNameMutationArgs } from './useUpdateLayoutNameMutation'; import { useUpdateLayoutNameMutation } from './useUpdateLayoutNameMutation'; -import { layout1NameMock, layoutSet1NameMock } from '../../testing/layoutMock'; +import { layout1NameMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import { app, org } from '@studio/testing/testids'; // Test data: diff --git a/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateLayoutOrderMutation.test.ts b/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateLayoutOrderMutation.test.ts index 9bb302a522c..480009e53bb 100644 --- a/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateLayoutOrderMutation.test.ts +++ b/frontend/packages/ux-editor-v3/src/hooks/mutations/useUpdateLayoutOrderMutation.test.ts @@ -4,7 +4,8 @@ import { useFormLayoutSettingsQuery } from '../queries/useFormLayoutSettingsQuer import { waitFor } from '@testing-library/react'; import type { UpdateLayoutOrderMutationArgs } from './useUpdateLayoutOrderMutation'; import { useUpdateLayoutOrderMutation } from './useUpdateLayoutOrderMutation'; -import { layout1NameMock, layout2NameMock, layoutSet1NameMock } from '../../testing/layoutMock'; +import { layout1NameMock, layout2NameMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; import { app, org } from '@studio/testing/testids'; // Test data: diff --git a/frontend/packages/ux-editor-v3/src/hooks/queries/useDatamodelMetadataQuery.ts b/frontend/packages/ux-editor-v3/src/hooks/queries/useDatamodelMetadataQuery.ts index 19f11f81ed1..937768c3c8b 100644 --- a/frontend/packages/ux-editor-v3/src/hooks/queries/useDatamodelMetadataQuery.ts +++ b/frontend/packages/ux-editor-v3/src/hooks/queries/useDatamodelMetadataQuery.ts @@ -8,12 +8,13 @@ export const useDatamodelMetadataQuery = ( org: string, app: string, layoutSetName: string, + dataModelName: string, ): UseQueryResult => { const { getDatamodelMetadata } = useServicesContext(); return useQuery({ - queryKey: [QueryKey.DatamodelMetadata, org, app, layoutSetName], + queryKey: [QueryKey.DatamodelMetadata, org, app, layoutSetName, dataModelName], queryFn: () => - getDatamodelMetadata(org, app, layoutSetName).then((res) => { + getDatamodelMetadata(org, app, layoutSetName, dataModelName).then((res) => { const dataModelFields: DatamodelFieldElement[] = []; Object.keys(res.elements).forEach((dataModelField) => { if (dataModelField) { diff --git a/frontend/packages/ux-editor-v3/src/hooks/queries/useRuleModelQuery.test.ts b/frontend/packages/ux-editor-v3/src/hooks/queries/useRuleModelQuery.test.ts index 6774c4e3397..3d2336205b5 100644 --- a/frontend/packages/ux-editor-v3/src/hooks/queries/useRuleModelQuery.test.ts +++ b/frontend/packages/ux-editor-v3/src/hooks/queries/useRuleModelQuery.test.ts @@ -26,7 +26,7 @@ import ruleHandlerMock, { import { createQueryClientMock } from 'app-shared/mocks/queryClientMock'; import type { ServicesContextProps } from 'app-shared/contexts/ServicesContext'; import { app, org } from '@studio/testing/testids'; -import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor-v3/testing/layoutSetsMock'; // Test data: const selectedLayoutSet = layoutSet1NameMock; diff --git a/frontend/packages/ux-editor-v3/src/hooks/useFormLayoutsSelector.test.ts b/frontend/packages/ux-editor-v3/src/hooks/useFormLayoutsSelector.test.ts index 4cec5a46e42..683a9074394 100644 --- a/frontend/packages/ux-editor-v3/src/hooks/useFormLayoutsSelector.test.ts +++ b/frontend/packages/ux-editor-v3/src/hooks/useFormLayoutsSelector.test.ts @@ -6,12 +6,8 @@ import { } from './useFormLayoutsSelector'; import { renderHookWithMockStore } from '../testing/mocks'; import { useFormLayoutsQuery } from './queries/useFormLayoutsQuery'; -import { - externalLayoutsMock, - layoutMock, - layout1NameMock, - layoutSet1NameMock, -} from '../testing/layoutMock'; +import { externalLayoutsMock, layoutMock, layout1NameMock } from '../testing/layoutMock'; +import { layoutSet1NameMock } from '../testing/layoutSetsMock'; import { waitFor } from '@testing-library/react'; import { convertExternalLayoutsToInternalFormat } from '../utils/formLayoutsUtils'; import type { IFormLayouts, IInternalLayout, IInternalLayoutWithName } from '../types/global'; diff --git a/frontend/packages/ux-editor-v3/src/testing/appContextMock.ts b/frontend/packages/ux-editor-v3/src/testing/appContextMock.ts index d855c60b85c..f6bc2ea625e 100644 --- a/frontend/packages/ux-editor-v3/src/testing/appContextMock.ts +++ b/frontend/packages/ux-editor-v3/src/testing/appContextMock.ts @@ -1,6 +1,6 @@ import type { AppContextProps } from '../AppContext'; import type { RefObject } from 'react'; -import { layoutSet1NameMock } from './layoutMock'; +import { layoutSet1NameMock } from './layoutSetsMock'; const previewIframeRefMock: RefObject = { current: null, diff --git a/frontend/packages/ux-editor-v3/src/testing/layoutMock.ts b/frontend/packages/ux-editor-v3/src/testing/layoutMock.ts index bcb76ee9286..3e58616d53e 100644 --- a/frontend/packages/ux-editor-v3/src/testing/layoutMock.ts +++ b/frontend/packages/ux-editor-v3/src/testing/layoutMock.ts @@ -1,7 +1,6 @@ import { BASE_CONTAINER_ID } from 'app-shared/constants'; import { ComponentTypeV3 } from 'app-shared/types/ComponentTypeV3'; import type { IInternalLayout } from '../types/global'; -import type { LayoutSets } from 'app-shared/types/api/LayoutSetsResponse'; import type { KeyValuePairs } from 'app-shared/types/KeyValuePairs'; import type { FormComponent } from '../types/FormComponent'; import type { @@ -11,9 +10,6 @@ import type { export const layout1NameMock = 'Side1'; export const layout2NameMock = 'Side2'; -export const layoutSet1NameMock = 'test-layout-set'; -export const layoutSet2NameMock = 'test-layout-set-2'; - export const baseContainerIdMock = BASE_CONTAINER_ID; export const component1IdMock = 'Component-1'; export const component1TypeMock = ComponentTypeV3.Input; @@ -102,18 +98,3 @@ export const externalLayoutsMock: FormLayoutsResponseV3 = { [layout1NameMock]: layout1Mock, [layout2NameMock]: layout2Mock, }; - -export const layoutSetsMock: LayoutSets = { - sets: [ - { - id: layoutSet1NameMock, - dataType: 'datamodel', - tasks: ['Task_1'], - }, - { - id: layoutSet2NameMock, - dataType: 'datamodel-2', - tasks: ['Task_2'], - }, - ], -}; diff --git a/frontend/packages/ux-editor-v3/src/testing/layoutSetsMock.ts b/frontend/packages/ux-editor-v3/src/testing/layoutSetsMock.ts new file mode 100644 index 00000000000..1c89c23adae --- /dev/null +++ b/frontend/packages/ux-editor-v3/src/testing/layoutSetsMock.ts @@ -0,0 +1,20 @@ +import type { LayoutSets } from 'app-shared/types/api/LayoutSetsResponse'; + +export const dataModelNameMock = 'test-data-model'; +export const layoutSet1NameMock = 'test-layout-set'; +export const layoutSet2NameMock = 'test-layout-set-2'; + +export const layoutSetsMock: LayoutSets = { + sets: [ + { + id: layoutSet1NameMock, + dataType: 'datamodel', + tasks: ['Task_1'], + }, + { + id: layoutSet2NameMock, + dataType: 'datamodel-2', + tasks: ['Task_2'], + }, + ], +}; diff --git a/frontend/packages/ux-editor-v3/src/testing/stateMocks.ts b/frontend/packages/ux-editor-v3/src/testing/stateMocks.ts index 285997a5a99..d089e23b7d5 100644 --- a/frontend/packages/ux-editor-v3/src/testing/stateMocks.ts +++ b/frontend/packages/ux-editor-v3/src/testing/stateMocks.ts @@ -1,7 +1,8 @@ import type { ITextResourcesState } from '../features/appData/textResources/textResourcesSlice'; import type { IAppDataState } from '../features/appData/appDataReducers'; import type { IFormDesignerState } from '../features/formDesigner/formDesignerReducer'; -import { layout1NameMock, layoutSet1NameMock } from './layoutMock'; +import { layout1NameMock } from './layoutMock'; +import { layoutSet1NameMock } from './layoutSetsMock'; import type { IAppState } from '../types/global'; export const textResourcesMock: ITextResourcesState = { diff --git a/frontend/packages/ux-editor/src/App.test.tsx b/frontend/packages/ux-editor/src/App.test.tsx index 420a8942498..3e5deccddf7 100644 --- a/frontend/packages/ux-editor/src/App.test.tsx +++ b/frontend/packages/ux-editor/src/App.test.tsx @@ -7,7 +7,7 @@ import { typedLocalStorage } from 'app-shared/utils/webStorage'; import type { ServicesContextProps } from 'app-shared/contexts/ServicesContext'; import type { AppContextProps } from './AppContext'; import ruleHandlerMock from './testing/ruleHandlerMock'; -import { layoutSetsMock } from './testing/layoutMock'; +import { layoutSetsMock } from './testing/layoutSetsMock'; import { createQueryClientMock } from 'app-shared/mocks/queryClientMock'; const mockQueries: Partial = { diff --git a/frontend/packages/ux-editor/src/App.tsx b/frontend/packages/ux-editor/src/App.tsx index 464fdd941bc..033a322de39 100644 --- a/frontend/packages/ux-editor/src/App.tsx +++ b/frontend/packages/ux-editor/src/App.tsx @@ -21,7 +21,7 @@ export function App() { const { selectedFormLayoutSetName } = useAppContext(); const { isSuccess: areWidgetsFetched, isError: widgetFetchedError } = useWidgetsQuery(org, app); const { isSuccess: isDatamodelFetched, isError: dataModelFetchedError } = - useDatamodelMetadataQuery(org, app, selectedFormLayoutSetName); + useDatamodelMetadataQuery(org, app, selectedFormLayoutSetName, undefined); const { isSuccess: areTextResourcesFetched } = useTextResourcesQuery(org, app); const componentIsReady = areWidgetsFetched && isDatamodelFetched && areTextResourcesFetched; diff --git a/frontend/packages/ux-editor/src/AppContext.test.tsx b/frontend/packages/ux-editor/src/AppContext.test.tsx index 9f5c45c245f..5e4468e08a9 100644 --- a/frontend/packages/ux-editor/src/AppContext.test.tsx +++ b/frontend/packages/ux-editor/src/AppContext.test.tsx @@ -10,7 +10,8 @@ import { MemoryRouter } from 'react-router-dom'; import { QueryKey } from 'app-shared/types/QueryKey'; import { useAppContext } from './hooks'; import type { QueryClient } from '@tanstack/react-query'; -import { layout1NameMock, layoutSet1NameMock } from './testing/layoutMock'; +import { layout1NameMock } from './testing/layoutMock'; +import { layoutSet1NameMock } from './testing/layoutSetsMock'; import { app, org } from '@studio/testing/testids'; const mockSelectedFormLayoutSetName = layoutSet1NameMock; diff --git a/frontend/packages/ux-editor/src/components/Elements/LayoutSetsContainer.test.tsx b/frontend/packages/ux-editor/src/components/Elements/LayoutSetsContainer.test.tsx index 892c197ce46..8e9c1a0b880 100644 --- a/frontend/packages/ux-editor/src/components/Elements/LayoutSetsContainer.test.tsx +++ b/frontend/packages/ux-editor/src/components/Elements/LayoutSetsContainer.test.tsx @@ -4,7 +4,11 @@ import userEvent from '@testing-library/user-event'; import { LayoutSetsContainer } from './LayoutSetsContainer'; import { queryClientMock } from 'app-shared/mocks/queryClientMock'; import { renderWithProviders } from '../../testing/mocks'; -import { layoutSet1NameMock, layoutSet2NameMock, layoutSetsMock } from '../../testing/layoutMock'; +import { + layoutSet1NameMock, + layoutSet2NameMock, + layoutSetsMock, +} from '../../testing/layoutSetsMock'; import { QueryKey } from 'app-shared/types/QueryKey'; import { appContextMock } from '../../testing/appContextMock'; import { app, org } from '@studio/testing/testids'; diff --git a/frontend/packages/ux-editor/src/components/Properties/DataModelBindings.test.tsx b/frontend/packages/ux-editor/src/components/Properties/DataModelBindings.test.tsx index 429aabe629f..f7b5b2a17f9 100644 --- a/frontend/packages/ux-editor/src/components/Properties/DataModelBindings.test.tsx +++ b/frontend/packages/ux-editor/src/components/Properties/DataModelBindings.test.tsx @@ -12,12 +12,8 @@ import { componentSchemaMocks } from '../../testing/componentSchemaMocks'; import { ComponentType } from 'app-shared/types/ComponentType'; import type { FormItem } from '../../types/FormItem'; import { componentMocks } from '../../testing/componentMocks'; -import { - component3IdMock, - component3Mock, - layoutMock, - layoutSet1NameMock, -} from '../../testing/layoutMock'; +import { component3IdMock, component3Mock, layoutMock } from '@altinn/ux-editor/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutSetsMock'; import { app, org } from '@studio/testing/testids'; const user = userEvent.setup(); diff --git a/frontend/packages/ux-editor/src/components/Properties/PageConfigPanel/EditPageId.test.tsx b/frontend/packages/ux-editor/src/components/Properties/PageConfigPanel/EditPageId.test.tsx index d3236a2869b..27acbfde78a 100644 --- a/frontend/packages/ux-editor/src/components/Properties/PageConfigPanel/EditPageId.test.tsx +++ b/frontend/packages/ux-editor/src/components/Properties/PageConfigPanel/EditPageId.test.tsx @@ -12,8 +12,8 @@ import { externalLayoutsMock, layout1NameMock, layout2NameMock, - layoutSet1NameMock, -} from '../../../testing/layoutMock'; +} from '@altinn/ux-editor/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutSetsMock'; import { app, org } from '@studio/testing/testids'; // Test data diff --git a/frontend/packages/ux-editor/src/components/Properties/PageConfigPanel/HiddenExpressionOnLayout.test.tsx b/frontend/packages/ux-editor/src/components/Properties/PageConfigPanel/HiddenExpressionOnLayout.test.tsx index 5f0c96e51ea..4eeb08f5cd8 100644 --- a/frontend/packages/ux-editor/src/components/Properties/PageConfigPanel/HiddenExpressionOnLayout.test.tsx +++ b/frontend/packages/ux-editor/src/components/Properties/PageConfigPanel/HiddenExpressionOnLayout.test.tsx @@ -6,7 +6,8 @@ import { QueryKey } from 'app-shared/types/QueryKey'; import { queryClientMock } from 'app-shared/mocks/queryClientMock'; import { HiddenExpressionOnLayout } from './HiddenExpressionOnLayout'; import type { IFormLayouts } from '../../../types/global'; -import { layout1NameMock, layoutMock, layoutSet1NameMock } from '../../../testing/layoutMock'; +import { layout1NameMock, layoutMock } from '@altinn/ux-editor/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutSetsMock'; import { textMock } from '@studio/testing/mocks/i18nMock'; import type { BooleanExpression } from '@studio/components'; import { GeneralRelationOperator } from '@studio/components'; @@ -15,6 +16,7 @@ import { app, org } from '@studio/testing/testids'; // Test data const layoutSet = layoutSet1NameMock; +const dataModelName = undefined; const defaultLayouts: IFormLayouts = { [layout1NameMock]: layoutMock, @@ -116,6 +118,9 @@ describe('HiddenExpressionOnLayout', () => { const renderHiddenExpressionOnLayout = (layouts = defaultLayouts) => { queryClientMock.setQueryData([QueryKey.FormLayouts, org, app, layoutSet], layouts); - queryClientMock.setQueryData([QueryKey.DatamodelMetadata, org, app, layoutSet], []); + queryClientMock.setQueryData( + [QueryKey.DatamodelMetadata, org, app, layoutSet, dataModelName], + [], + ); return renderWithProviders(); }; diff --git a/frontend/packages/ux-editor/src/components/Properties/PageConfigPanel/PageConfigPanel.test.tsx b/frontend/packages/ux-editor/src/components/Properties/PageConfigPanel/PageConfigPanel.test.tsx index 330308c39fe..3047bf491b9 100644 --- a/frontend/packages/ux-editor/src/components/Properties/PageConfigPanel/PageConfigPanel.test.tsx +++ b/frontend/packages/ux-editor/src/components/Properties/PageConfigPanel/PageConfigPanel.test.tsx @@ -8,12 +8,14 @@ import type { ITextResources } from 'app-shared/types/global'; import { DEFAULT_LANGUAGE, DEFAULT_SELECTED_LAYOUT_NAME } from 'app-shared/constants'; import { textMock } from '@studio/testing/mocks/i18nMock'; import type { IFormLayouts } from '../../../types/global'; -import { layout1NameMock, layoutMock, layoutSet1NameMock } from '../../../testing/layoutMock'; +import { layout1NameMock, layoutMock } from '@altinn/ux-editor/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutSetsMock'; import { app, org } from '@studio/testing/testids'; // Test data const layoutSet = layoutSet1NameMock; const duplicatedLayout = 'duplicatedLayout'; +const dataModelName = undefined; const defaultTexts: ITextResources = { [DEFAULT_LANGUAGE]: [ @@ -93,7 +95,10 @@ const renderPageConfigPanel = ( ) => { queryClientMock.setQueryData([QueryKey.TextResources, org, app], textResources); queryClientMock.setQueryData([QueryKey.FormLayouts, org, app, layoutSet], layouts); - queryClientMock.setQueryData([QueryKey.DatamodelMetadata, org, app, layoutSet], []); + queryClientMock.setQueryData( + [QueryKey.DatamodelMetadata, org, app, layoutSet, dataModelName], + [], + ); return renderWithProviders(, { appContextProps: { selectedFormLayoutName: selectedLayoutName }, diff --git a/frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/EditComponentIdRow/EditComponentIdRow.test.tsx b/frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/EditComponentIdRow/EditComponentIdRow.test.tsx index d31a76b78d1..720c11d8cc9 100644 --- a/frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/EditComponentIdRow/EditComponentIdRow.test.tsx +++ b/frontend/packages/ux-editor/src/components/Properties/PropertiesHeader/EditComponentIdRow/EditComponentIdRow.test.tsx @@ -8,7 +8,8 @@ import { textMock } from '@studio/testing/mocks/i18nMock'; import { queryClientMock } from 'app-shared/mocks/queryClientMock'; import type { IFormLayouts } from '../../../../types/global'; import { QueryKey } from 'app-shared/types/QueryKey'; -import { layout1NameMock, layoutMock, layoutSet1NameMock } from '../../../../testing/layoutMock'; +import { layout1NameMock, layoutMock } from '@altinn/ux-editor/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutSetsMock'; import { app, org } from '@studio/testing/testids'; const layoutSetName = layoutSet1NameMock; diff --git a/frontend/packages/ux-editor/src/components/config/EditFormComponent.test.tsx b/frontend/packages/ux-editor/src/components/config/EditFormComponent.test.tsx index 54be5fdb114..7600a267937 100644 --- a/frontend/packages/ux-editor/src/components/config/EditFormComponent.test.tsx +++ b/frontend/packages/ux-editor/src/components/config/EditFormComponent.test.tsx @@ -9,7 +9,7 @@ import { ComponentType } from 'app-shared/types/ComponentType'; import { useDatamodelMetadataQuery } from '../../hooks/queries/useDatamodelMetadataQuery'; import type { DatamodelMetadataResponse } from 'app-shared/types/api'; import { componentMocks } from '../../testing/componentMocks'; -import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutMock'; +import { dataModelNameMock, layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutSetsMock'; import { app, org } from '@studio/testing/testids'; // Test data: @@ -100,7 +100,7 @@ const waitForData = async () => { const layoutSchemaResult = renderHookWithProviders(() => useLayoutSchemaQuery()).result; await waitFor(() => expect(layoutSchemaResult.current[0].isSuccess).toBe(true)); const dataModelMetadataResult = renderHookWithProviders( - () => useDatamodelMetadataQuery(org, app, layoutSet1NameMock), + () => useDatamodelMetadataQuery(org, app, layoutSet1NameMock, dataModelNameMock), { queries: { getDatamodelMetadata } }, ).result; await waitFor(() => expect(dataModelMetadataResult.current.isSuccess).toBe(true)); diff --git a/frontend/packages/ux-editor/src/components/config/ExpressionContent/ExpressionContent.test.tsx b/frontend/packages/ux-editor/src/components/config/ExpressionContent/ExpressionContent.test.tsx index fa627e2cb2c..e2c71b4bfae 100644 --- a/frontend/packages/ux-editor/src/components/config/ExpressionContent/ExpressionContent.test.tsx +++ b/frontend/packages/ux-editor/src/components/config/ExpressionContent/ExpressionContent.test.tsx @@ -3,7 +3,8 @@ import { screen } from '@testing-library/react'; import { parsableLogicalExpression } from '../../../testing/expressionMocks'; import { renderWithProviders } from '../../../testing/mocks'; import type { IFormLayouts } from '../../../types/global'; -import { layout1NameMock, layoutMock, layoutSet1NameMock } from '../../../testing/layoutMock'; +import { layout1NameMock, layoutMock } from '@altinn/ux-editor/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutSetsMock'; import type { ExpressionContentProps } from './ExpressionContent'; import { ExpressionContent } from './ExpressionContent'; import { createQueryClientMock } from 'app-shared/mocks/queryClientMock'; @@ -19,6 +20,7 @@ const layoutSetName = layoutSet1NameMock; const layouts: IFormLayouts = { [layout1NameMock]: layoutMock, }; +const dataModelName = undefined; const heading = 'Test'; const defaultProps: ExpressionContentProps = { expression: null, @@ -69,7 +71,10 @@ const renderExpressionContent = (props: Partial = {}) => const queryClient = createQueryClientMock(); queryClient.setQueryData([QueryKey.FormLayouts, org, app, layoutSetName], layouts); - queryClient.setQueryData([QueryKey.DatamodelMetadata, org, app, layoutSetName], []); + queryClient.setQueryData( + [QueryKey.DatamodelMetadata, org, app, layoutSetName, dataModelName], + [], + ); return renderWithProviders(, { appContextProps, diff --git a/frontend/packages/ux-editor/src/components/config/ExpressionContent/ExpressionContent.tsx b/frontend/packages/ux-editor/src/components/config/ExpressionContent/ExpressionContent.tsx index 050f4604014..c01e6e1c9c4 100644 --- a/frontend/packages/ux-editor/src/components/config/ExpressionContent/ExpressionContent.tsx +++ b/frontend/packages/ux-editor/src/components/config/ExpressionContent/ExpressionContent.tsx @@ -32,6 +32,7 @@ export const ExpressionContent = ({ org, app, selectedFormLayoutSetName, + undefined, ); const dataLookupOptions: Partial = useMemo( () => ({ diff --git a/frontend/packages/ux-editor/src/components/config/Expressions/Expressions.test.tsx b/frontend/packages/ux-editor/src/components/config/Expressions/Expressions.test.tsx index 454004cd6db..d28047958dd 100644 --- a/frontend/packages/ux-editor/src/components/config/Expressions/Expressions.test.tsx +++ b/frontend/packages/ux-editor/src/components/config/Expressions/Expressions.test.tsx @@ -3,7 +3,8 @@ import { screen, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { renderWithProviders } from '../../../testing/mocks'; import type { IFormLayouts } from '../../../types/global'; -import { layout1NameMock, layoutMock, layoutSet1NameMock } from '../../../testing/layoutMock'; +import { layout1NameMock, layoutMock } from '@altinn/ux-editor/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutSetsMock'; import { textMock } from '@studio/testing/mocks/i18nMock'; import { createQueryClientMock } from 'app-shared/mocks/queryClientMock'; import { QueryKey } from 'app-shared/types/QueryKey'; @@ -23,6 +24,7 @@ const layoutSetName = layoutSet1NameMock; const layouts: IFormLayouts = { [layout1NameMock]: layoutMock, }; +const dataModelName = undefined; const componentWithExpression: FormComponent = { id: 'some-id', type: ComponentType.Input, @@ -55,7 +57,7 @@ describe('Expressions', () => { screen.getByRole('button', { name: textMock('right_menu.expressions_add') }); }); - it('renders the expression and the button for adding an expression when th hidden field on the component has an expression', () => { + it('renders the expression and the button for adding an expression when the hidden field on the component has an expression', () => { renderExpressions(); const expressionName = textMock('right_menu.expressions_property_preview_hidden'); screen.getByRole('group', { name: expressionName }); @@ -174,7 +176,10 @@ const renderExpressions = (formItemContext: Partial = {}) => { const queryClient = createQueryClientMock(); queryClient.setQueryData([QueryKey.FormLayouts, org, app, layoutSetName], layouts); - queryClient.setQueryData([QueryKey.DatamodelMetadata, org, app, layoutSetName], []); + queryClient.setQueryData( + [QueryKey.DatamodelMetadata, org, app, layoutSetName, dataModelName], + [], + ); return renderWithProviders( diff --git a/frontend/packages/ux-editor/src/components/config/SelectDataModelComponent.test.tsx b/frontend/packages/ux-editor/src/components/config/SelectDataModelComponent.test.tsx index cd2f501d8e1..8f780e3a22f 100644 --- a/frontend/packages/ux-editor/src/components/config/SelectDataModelComponent.test.tsx +++ b/frontend/packages/ux-editor/src/components/config/SelectDataModelComponent.test.tsx @@ -9,7 +9,9 @@ import { getDataModelFieldsFilter } from '../../utils/datamodel'; import { queryClientMock } from 'app-shared/mocks/queryClientMock'; import { QueryKey } from 'app-shared/types/QueryKey'; import { app, org } from '@studio/testing/testids'; -import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutSetsMock'; + +const dataModelName = undefined; const datamodelMetadataMock = [ { @@ -69,7 +71,7 @@ const render = async ({ handleComponentChange = jest.fn(), } = {}) => { queryClientMock.setQueryData( - [QueryKey.DatamodelMetadata, org, app, layoutSet1NameMock], + [QueryKey.DatamodelMetadata, org, app, layoutSet1NameMock, dataModelName], dataModelMetadata, ); renderWithProviders( diff --git a/frontend/packages/ux-editor/src/components/config/SelectDataModelComponent.tsx b/frontend/packages/ux-editor/src/components/config/SelectDataModelComponent.tsx index 111a5cdfaf1..225cda70e40 100644 --- a/frontend/packages/ux-editor/src/components/config/SelectDataModelComponent.tsx +++ b/frontend/packages/ux-editor/src/components/config/SelectDataModelComponent.tsx @@ -33,7 +33,7 @@ export const SelectDataModelComponent = ({ }: ISelectDataModelProps) => { const { org, app } = useStudioUrlParams(); const { selectedFormLayoutSetName } = useAppContext(); - const { data } = useDatamodelMetadataQuery(org, app, selectedFormLayoutSetName); + const { data } = useDatamodelMetadataQuery(org, app, selectedFormLayoutSetName, undefined); const [dataModelElementNames, setDataModelElementNames] = React.useState([]); useEffect(() => { diff --git a/frontend/packages/ux-editor/src/components/config/componentSpecificContent/Panel/PanelComponent.test.tsx b/frontend/packages/ux-editor/src/components/config/componentSpecificContent/Panel/PanelComponent.test.tsx index 65e3953fc42..b1f6a748aa8 100644 --- a/frontend/packages/ux-editor/src/components/config/componentSpecificContent/Panel/PanelComponent.test.tsx +++ b/frontend/packages/ux-editor/src/components/config/componentSpecificContent/Panel/PanelComponent.test.tsx @@ -15,7 +15,7 @@ import { useFormLayoutSettingsQuery } from '../../../../hooks/queries/useFormLay import { textMock } from '@studio/testing/mocks/i18nMock'; import { FormPanelVariant } from 'app-shared/types/FormPanelVariant'; import { app, org } from '@studio/testing/testids'; -import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutSetsMock'; // Test data: const selectedLayoutSet = layoutSet1NameMock; diff --git a/frontend/packages/ux-editor/src/components/config/componentSpecificContent/RepeatingGroup/RepeatingGroupComponent.test.tsx b/frontend/packages/ux-editor/src/components/config/componentSpecificContent/RepeatingGroup/RepeatingGroupComponent.test.tsx index cdb91e9b4ce..af178bd3658 100644 --- a/frontend/packages/ux-editor/src/components/config/componentSpecificContent/RepeatingGroup/RepeatingGroupComponent.test.tsx +++ b/frontend/packages/ux-editor/src/components/config/componentSpecificContent/RepeatingGroup/RepeatingGroupComponent.test.tsx @@ -9,8 +9,8 @@ import { container2IdMock, layout1NameMock, layoutMock, - layoutSet1NameMock, -} from '../../../../testing/layoutMock'; +} from '@altinn/ux-editor/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutSetsMock'; import { QueryKey } from 'app-shared/types/QueryKey'; import { queryClientMock } from 'app-shared/mocks/queryClientMock'; import type { IFormLayouts } from '../../../../types/global'; diff --git a/frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBindings/EditDataModelBindings.test.tsx b/frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBindings/EditDataModelBindings.test.tsx index 1a4fbdf736d..03e89d8cd23 100644 --- a/frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBindings/EditDataModelBindings.test.tsx +++ b/frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBindings/EditDataModelBindings.test.tsx @@ -11,7 +11,9 @@ import { QueryKey } from 'app-shared/types/QueryKey'; import { componentMocks } from '../../../../testing/componentMocks'; import type { FormItem } from '../../../../types/FormItem'; import { app, org } from '@studio/testing/testids'; -import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutSetsMock'; + +const dataModelName = undefined; const datamodelMetadata: DatamodelMetadataResponse = { elements: { @@ -305,7 +307,7 @@ describe('EditDataModelBindings', () => { const dataBindingNameMock = 'element'; const maxCountMock = 2; queryClientMock.setQueryData( - [QueryKey.DatamodelMetadata, org, app, layoutSet1NameMock], + [QueryKey.DatamodelMetadata, org, app, layoutSet1NameMock, dataModelName], [{ dataBindingName: dataBindingNameMock, maxOccurs: maxCountMock }], ); render({ diff --git a/frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBindings/EditDataModelBindings.tsx b/frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBindings/EditDataModelBindings.tsx index 1f8127fdc26..ba3c6f76750 100644 --- a/frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBindings/EditDataModelBindings.tsx +++ b/frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBindings/EditDataModelBindings.tsx @@ -35,7 +35,7 @@ export const EditDataModelBindings = ({ }: EditDataModelBindingsProps) => { const { org, app } = useStudioUrlParams(); const { selectedFormLayoutSetName } = useAppContext(); - const { data } = useDatamodelMetadataQuery(org, app, selectedFormLayoutSetName); + const { data } = useDatamodelMetadataQuery(org, app, selectedFormLayoutSetName, undefined); const { t } = useTranslation(); const [dataModelSelectVisible, setDataModelSelectVisible] = useState(false); diff --git a/frontend/packages/ux-editor/src/containers/DesignView/DesignView.test.tsx b/frontend/packages/ux-editor/src/containers/DesignView/DesignView.test.tsx index 01881072eb6..3bde49dd736 100644 --- a/frontend/packages/ux-editor/src/containers/DesignView/DesignView.test.tsx +++ b/frontend/packages/ux-editor/src/containers/DesignView/DesignView.test.tsx @@ -15,8 +15,8 @@ import { externalLayoutsMock, layout1NameMock, layout2NameMock, - layoutSet1NameMock, -} from '../../testing/layoutMock'; +} from '@altinn/ux-editor/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutSetsMock'; import { convertExternalLayoutsToInternalFormat } from '../../utils/formLayoutsUtils'; import { appContextMock } from '../../testing/appContextMock'; import { app, org } from '@studio/testing/testids'; diff --git a/frontend/packages/ux-editor/src/containers/DesignView/FormTree/FormItem/FormItemTitle/FormItemTitle.test.tsx b/frontend/packages/ux-editor/src/containers/DesignView/FormTree/FormItem/FormItemTitle/FormItemTitle.test.tsx index 35f83b76252..3ec41d1f671 100644 --- a/frontend/packages/ux-editor/src/containers/DesignView/FormTree/FormItem/FormItemTitle/FormItemTitle.test.tsx +++ b/frontend/packages/ux-editor/src/containers/DesignView/FormTree/FormItem/FormItemTitle/FormItemTitle.test.tsx @@ -12,7 +12,8 @@ import { FormItemContext } from '../../../../FormItemContext'; import { formItemContextProviderMock } from '../../../../../testing/formItemContextMocks'; import { queriesMock } from 'app-shared/mocks/queriesMock'; import { app, org } from '@studio/testing/testids'; -import { layout1NameMock, layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutMock'; +import { layout1NameMock } from '@altinn/ux-editor/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutSetsMock'; const mockHandleDiscard = jest.fn(); diff --git a/frontend/packages/ux-editor/src/containers/DesignView/PageAccordion/NavigationMenu/NavigationMenu.test.tsx b/frontend/packages/ux-editor/src/containers/DesignView/PageAccordion/NavigationMenu/NavigationMenu.test.tsx index 2607532871a..da18997e689 100644 --- a/frontend/packages/ux-editor/src/containers/DesignView/PageAccordion/NavigationMenu/NavigationMenu.test.tsx +++ b/frontend/packages/ux-editor/src/containers/DesignView/PageAccordion/NavigationMenu/NavigationMenu.test.tsx @@ -11,11 +11,8 @@ import { renderWithProviders, } from '../../../../testing/mocks'; import { useFormLayoutSettingsQuery } from '../../../../hooks/queries/useFormLayoutSettingsQuery'; -import { - layout1NameMock, - layout2NameMock, - layoutSet1NameMock, -} from '../../../../testing/layoutMock'; +import { layout1NameMock, layout2NameMock } from '@altinn/ux-editor/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutSetsMock'; import { app, org } from '@studio/testing/testids'; const mockPageName1: string = layout1NameMock; diff --git a/frontend/packages/ux-editor/src/containers/DesignView/PageAccordion/PageAccordion.test.tsx b/frontend/packages/ux-editor/src/containers/DesignView/PageAccordion/PageAccordion.test.tsx index 8ab020d47b2..b3a5523b195 100644 --- a/frontend/packages/ux-editor/src/containers/DesignView/PageAccordion/PageAccordion.test.tsx +++ b/frontend/packages/ux-editor/src/containers/DesignView/PageAccordion/PageAccordion.test.tsx @@ -11,7 +11,8 @@ import { renderHookWithProviders, renderWithProviders, } from '../../../testing/mocks'; -import { layout1NameMock, layoutSet1NameMock } from '../../../testing/layoutMock'; +import { layout1NameMock } from '@altinn/ux-editor/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutSetsMock'; import { queriesMock } from 'app-shared/mocks/queriesMock'; import { appContextMock } from '../../../testing/appContextMock'; import { app, org } from '@studio/testing/testids'; diff --git a/frontend/packages/ux-editor/src/containers/DesignView/ReceiptContent/ReceiptContent.test.tsx b/frontend/packages/ux-editor/src/containers/DesignView/ReceiptContent/ReceiptContent.test.tsx index 3c37127130a..6d005ba4ccf 100644 --- a/frontend/packages/ux-editor/src/containers/DesignView/ReceiptContent/ReceiptContent.test.tsx +++ b/frontend/packages/ux-editor/src/containers/DesignView/ReceiptContent/ReceiptContent.test.tsx @@ -10,8 +10,8 @@ import { component2Mock, layout1NameMock, layout2NameMock, - layoutSet1NameMock, -} from '../../../testing/layoutMock'; +} from '@altinn/ux-editor/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutSetsMock'; import type { IInternalLayout } from '../../../types/global'; import { formLayoutSettingsMock, diff --git a/frontend/packages/ux-editor/src/containers/FormDesigner.test.tsx b/frontend/packages/ux-editor/src/containers/FormDesigner.test.tsx index c6127405726..5ad2c098b64 100644 --- a/frontend/packages/ux-editor/src/containers/FormDesigner.test.tsx +++ b/frontend/packages/ux-editor/src/containers/FormDesigner.test.tsx @@ -24,6 +24,7 @@ import { app, org } from '@studio/testing/testids'; const defaultTexts: ITextResources = { [DEFAULT_LANGUAGE]: [], }; +const dataModelName = undefined; const render = () => { const queryClient = createQueryClientMock(); @@ -35,7 +36,10 @@ const render = () => { getRuleModel: jest.fn().mockImplementation(() => Promise.resolve(ruleHandlerMock)), getInstanceIdForPreview: jest.fn().mockImplementation(() => Promise.resolve('test')), }; - queryClient.setQueryData([QueryKey.DatamodelMetadata, org, app, 'test-layout-set'], []); + queryClient.setQueryData( + [QueryKey.DatamodelMetadata, org, app, 'test-layout-set', dataModelName], + [], + ); queryClient.setQueryData([QueryKey.TextResources, org, app], defaultTexts); return renderWithProviders( => { const { getDatamodelMetadata } = useServicesContext(); return useQuery({ - queryKey: [QueryKey.DatamodelMetadata, org, app, layoutSetName], + queryKey: [QueryKey.DatamodelMetadata, org, app, layoutSetName, dataModelName], queryFn: () => - getDatamodelMetadata(org, app, layoutSetName).then((res) => { + getDatamodelMetadata(org, app, layoutSetName, dataModelName).then((res) => { const dataModelFields: DatamodelFieldElement[] = []; // Hack because we don't know if the response is upper or lower cased. Should be reverted once diff --git a/frontend/packages/ux-editor/src/hooks/queries/useRuleModelQuery.test.ts b/frontend/packages/ux-editor/src/hooks/queries/useRuleModelQuery.test.ts index 7a7d6597b13..3d459f27f26 100644 --- a/frontend/packages/ux-editor/src/hooks/queries/useRuleModelQuery.test.ts +++ b/frontend/packages/ux-editor/src/hooks/queries/useRuleModelQuery.test.ts @@ -26,7 +26,7 @@ import ruleHandlerMock, { import { createQueryClientMock } from 'app-shared/mocks/queryClientMock'; import type { ServicesContextProps } from 'app-shared/contexts/ServicesContext'; import { app, org } from '@studio/testing/testids'; -import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutMock'; +import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutSetsMock'; // Test data: const selectedLayoutSet = layoutSet1NameMock; diff --git a/frontend/packages/ux-editor/src/hooks/useFormLayout.test.ts b/frontend/packages/ux-editor/src/hooks/useFormLayout.test.ts index 5654a9bda17..150160e853d 100644 --- a/frontend/packages/ux-editor/src/hooks/useFormLayout.test.ts +++ b/frontend/packages/ux-editor/src/hooks/useFormLayout.test.ts @@ -1,12 +1,8 @@ import { useFormLayout } from './'; import { renderHookWithProviders } from '../testing/mocks'; import { useFormLayoutsQuery } from './queries/useFormLayoutsQuery'; -import { - externalLayoutsMock, - layout1NameMock, - layoutMock, - layoutSet1NameMock, -} from '../testing/layoutMock'; +import { externalLayoutsMock, layout1NameMock, layoutMock } from '../testing/layoutMock'; +import { layoutSet1NameMock } from '../testing/layoutSetsMock'; import { waitFor } from '@testing-library/react'; import { app, org } from '@studio/testing/testids'; diff --git a/frontend/packages/ux-editor/src/hooks/useFormLayouts.test.ts b/frontend/packages/ux-editor/src/hooks/useFormLayouts.test.ts index 7269a1ec413..4c75e7dc1d6 100644 --- a/frontend/packages/ux-editor/src/hooks/useFormLayouts.test.ts +++ b/frontend/packages/ux-editor/src/hooks/useFormLayouts.test.ts @@ -1,7 +1,8 @@ import { useFormLayouts } from './'; import { renderHookWithProviders } from '../testing/mocks'; import { useFormLayoutsQuery } from './queries/useFormLayoutsQuery'; -import { externalLayoutsMock, layoutSet1NameMock } from '../testing/layoutMock'; +import { externalLayoutsMock } from '../testing/layoutMock'; +import { layoutSet1NameMock } from '../testing/layoutSetsMock'; import { waitFor } from '@testing-library/react'; import { convertExternalLayoutsToInternalFormat } from '../utils/formLayoutsUtils'; import { app, org } from '@studio/testing/testids'; diff --git a/frontend/packages/ux-editor/src/hooks/useSelectedFormLayout.test.ts b/frontend/packages/ux-editor/src/hooks/useSelectedFormLayout.test.ts index 4e11afee9f5..7c7b366ea07 100644 --- a/frontend/packages/ux-editor/src/hooks/useSelectedFormLayout.test.ts +++ b/frontend/packages/ux-editor/src/hooks/useSelectedFormLayout.test.ts @@ -1,9 +1,10 @@ import { useSelectedFormLayout } from './'; import { renderHookWithProviders } from '../testing/mocks'; import { useFormLayoutsQuery } from './queries/useFormLayoutsQuery'; -import { externalLayoutsMock, layoutMock, layoutSet1NameMock } from '../testing/layoutMock'; +import { externalLayoutsMock, layoutMock } from '../testing/layoutMock'; import { waitFor } from '@testing-library/react'; import { app, org } from '@studio/testing/testids'; +import { layoutSet1NameMock } from '@altinn/ux-editor/testing/layoutSetsMock'; // Test data: const selectedLayoutSet = layoutSet1NameMock; diff --git a/frontend/packages/ux-editor/src/hooks/useSelectedFormLayoutName.test.tsx b/frontend/packages/ux-editor/src/hooks/useSelectedFormLayoutName.test.tsx index 93d245a1dc0..3a9cf526307 100644 --- a/frontend/packages/ux-editor/src/hooks/useSelectedFormLayoutName.test.tsx +++ b/frontend/packages/ux-editor/src/hooks/useSelectedFormLayoutName.test.tsx @@ -1,7 +1,8 @@ import type { ReactNode } from 'react'; import React from 'react'; import { useSelectedFormLayoutName } from './'; -import { layout1NameMock, layoutSet1NameMock } from '../testing/layoutMock'; +import { layout1NameMock } from '../testing/layoutMock'; +import { layoutSet1NameMock } from '../testing/layoutSetsMock'; import { renderHook } from '@testing-library/react'; import type { ServicesContextProps } from 'app-shared/contexts/ServicesContext'; import { ServicesContextProvider } from 'app-shared/contexts/ServicesContext'; diff --git a/frontend/packages/ux-editor/src/hooks/useSelectedFormLayoutSetName.test.tsx b/frontend/packages/ux-editor/src/hooks/useSelectedFormLayoutSetName.test.tsx index 62e1c4727e2..04f832f735f 100644 --- a/frontend/packages/ux-editor/src/hooks/useSelectedFormLayoutSetName.test.tsx +++ b/frontend/packages/ux-editor/src/hooks/useSelectedFormLayoutSetName.test.tsx @@ -1,7 +1,7 @@ import type { ReactNode } from 'react'; import React from 'react'; import { useSelectedFormLayoutSetName } from './'; -import { layoutSet1NameMock, layoutSetsMock } from '../testing/layoutMock'; +import { layoutSet1NameMock, layoutSetsMock } from '../testing/layoutSetsMock'; import { renderHook, waitFor } from '@testing-library/react'; import type { ServicesContextProps } from 'app-shared/contexts/ServicesContext'; import { ServicesContextProvider } from 'app-shared/contexts/ServicesContext'; diff --git a/frontend/packages/ux-editor/src/hooks/useSelectedFormLayoutWithName.test.ts b/frontend/packages/ux-editor/src/hooks/useSelectedFormLayoutWithName.test.ts index 83e274318ce..fcac9abf3b2 100644 --- a/frontend/packages/ux-editor/src/hooks/useSelectedFormLayoutWithName.test.ts +++ b/frontend/packages/ux-editor/src/hooks/useSelectedFormLayoutWithName.test.ts @@ -1,12 +1,8 @@ import { useSelectedFormLayoutWithName } from './'; import { renderHookWithProviders } from '../testing/mocks'; import { useFormLayoutsQuery } from './queries/useFormLayoutsQuery'; -import { - externalLayoutsMock, - layoutMock, - layout1NameMock, - layoutSet1NameMock, -} from '../testing/layoutMock'; +import { externalLayoutsMock, layoutMock, layout1NameMock } from '../testing/layoutMock'; +import { layoutSet1NameMock } from '../testing/layoutSetsMock'; import { waitFor } from '@testing-library/react'; import { app, org } from '@studio/testing/testids'; diff --git a/frontend/packages/ux-editor/src/hooks/useSelectedTaskId.test.tsx b/frontend/packages/ux-editor/src/hooks/useSelectedTaskId.test.tsx index d764b5f455e..1d2607a2971 100644 --- a/frontend/packages/ux-editor/src/hooks/useSelectedTaskId.test.tsx +++ b/frontend/packages/ux-editor/src/hooks/useSelectedTaskId.test.tsx @@ -1,7 +1,8 @@ import type { ReactNode } from 'react'; import React from 'react'; import { useSelectedTaskId } from './'; -import { layout1NameMock, layoutSet1NameMock } from '../testing/layoutMock'; +import { layout1NameMock } from '../testing/layoutMock'; +import { layoutSet1NameMock } from '../testing/layoutSetsMock'; import { renderHook } from '@testing-library/react'; import type { ServicesContextProps } from 'app-shared/contexts/ServicesContext'; import { ServicesContextProvider } from 'app-shared/contexts/ServicesContext'; diff --git a/frontend/packages/ux-editor/src/testing/appContextMock.ts b/frontend/packages/ux-editor/src/testing/appContextMock.ts index 3e305702615..918b4d3fa69 100644 --- a/frontend/packages/ux-editor/src/testing/appContextMock.ts +++ b/frontend/packages/ux-editor/src/testing/appContextMock.ts @@ -1,6 +1,7 @@ import type { AppContextProps } from '../AppContext'; import type { RefObject } from 'react'; -import { layout1NameMock, layoutSet1NameMock } from './layoutMock'; +import { layoutSet1NameMock } from './layoutSetsMock'; +import { layout1NameMock } from './layoutMock'; const previewIframeRefMock: RefObject = { current: null, diff --git a/frontend/packages/ux-editor/src/testing/layoutMock.ts b/frontend/packages/ux-editor/src/testing/layoutMock.ts index 12ce0f02758..59944d43e50 100644 --- a/frontend/packages/ux-editor/src/testing/layoutMock.ts +++ b/frontend/packages/ux-editor/src/testing/layoutMock.ts @@ -1,7 +1,6 @@ import { BASE_CONTAINER_ID } from 'app-shared/constants'; import { ComponentType } from 'app-shared/types/ComponentType'; import type { IInternalLayout } from '../types/global'; -import type { LayoutSets } from 'app-shared/types/api/LayoutSetsResponse'; import type { KeyValuePairs } from 'app-shared/types/KeyValuePairs'; import type { FormComponent } from '../types/FormComponent'; import type { @@ -11,9 +10,6 @@ import type { export const layout1NameMock = 'Side1'; export const layout2NameMock = 'Side2'; -export const layoutSet1NameMock = 'test-layout-set'; -export const layoutSet2NameMock = 'test-layout-set-2'; - export const baseContainerIdMock = BASE_CONTAINER_ID; export const component1IdMock = 'Component-1'; export const component1TypeMock = ComponentType.Input; @@ -161,18 +157,3 @@ export const externalLayoutsMock: FormLayoutsResponse = { [layout1NameMock]: layout1Mock, [layout2NameMock]: layout2Mock, }; - -export const layoutSetsMock: LayoutSets = { - sets: [ - { - id: layoutSet1NameMock, - dataType: 'datamodel', - tasks: ['Task_1'], - }, - { - id: layoutSet2NameMock, - dataType: 'datamodel-2', - tasks: ['Task_2'], - }, - ], -}; diff --git a/frontend/packages/ux-editor/src/testing/layoutSetsMock.ts b/frontend/packages/ux-editor/src/testing/layoutSetsMock.ts new file mode 100644 index 00000000000..1c89c23adae --- /dev/null +++ b/frontend/packages/ux-editor/src/testing/layoutSetsMock.ts @@ -0,0 +1,20 @@ +import type { LayoutSets } from 'app-shared/types/api/LayoutSetsResponse'; + +export const dataModelNameMock = 'test-data-model'; +export const layoutSet1NameMock = 'test-layout-set'; +export const layoutSet2NameMock = 'test-layout-set-2'; + +export const layoutSetsMock: LayoutSets = { + sets: [ + { + id: layoutSet1NameMock, + dataType: 'datamodel', + tasks: ['Task_1'], + }, + { + id: layoutSet2NameMock, + dataType: 'datamodel-2', + tasks: ['Task_2'], + }, + ], +};