Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Mnes 468 create an automatic testing strategy #91

Merged
merged 63 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
73966fd
Update README.md (#14) (#15)
NilsXitaso Jun 27, 2024
a8a3f91
Merge pull request #61 from mnestix/dev
Xmilofranke Aug 13, 2024
af44c2a
feat(qr-scanner): implement scanner feature in dashboard and compare …
JonathanXITASO Aug 22, 2024
7530194
Mnes 1186 add sqlite db (#69)
GailMelanie Aug 26, 2024
f652e81
Merge remote-tracking branch 'refs/remotes/origin/feat(qr-scanner)' i…
NilsXitaso Aug 27, 2024
8314c3d
Mnes 1187 repositories form (#74)
GailMelanie Aug 29, 2024
1edd24b
feat(mutiple repositories): Add search logic for multiple repositorie…
NilsXitaso Sep 2, 2024
741b0c0
Mnes 1203 refactor idsettings (#77)
GailMelanie Sep 2, 2024
dbe25be
docs(Submodel Registry): Add submodel registry description (#63)
pawel-baran-se Aug 19, 2024
dfc7922
fix(Asset redirect): fix asset redirect (#65)
pawel-baran-se Aug 19, 2024
4732056
fix(github-runner): The github runner will use and push the correct d…
JonathanXITASO Aug 19, 2024
dbb327d
fix(versioning): fix version number not displaying when authenticatio…
Xmilofranke Aug 19, 2024
93cd96c
feat(keycloak): setup keycloak azure instance (#59)
pawel-baran-se Aug 19, 2024
17e6753
chore(basyx): version bump (#67)
NilsXitaso Aug 21, 2024
7377f88
refactor(submodel repository): create separate env variable for submo…
Xmilofranke Aug 27, 2024
e366270
feat(handover documentation): add support for handover documentation …
Xmilofranke Aug 30, 2024
c2cc1f6
feat(qr scanner): Implement QR scanner in dashboard and compare view …
JonathanXITASO Aug 30, 2024
be6af21
test strategy: aas search moved to server and made testable
Sep 6, 2024
59975c6
test strategy: added jest
Sep 6, 2024
634906b
refactor(SubmodelOverviewCard): improve search performance (#79)
Xmilofranke Sep 9, 2024
18d9387
Merge remote-tracking branch 'origin/feat(repositry-settings)' into M…
Sep 9, 2024
3b43420
test strategy: extracted interfaces for all the dependencies of the s…
Sep 9, 2024
1207edb
test strategy: first test
Sep 9, 2024
76be42a
Mnes 1189 discovery list for multiple identical aas ids (#80)
FranzXitaso Sep 9, 2024
827f34e
test strategy: happy paths for searchServer
Sep 9, 2024
14aa17b
test strategy: transform dependencies of searchServer into nullables-…
Sep 10, 2024
3185a4e
Mnes 1209 create UI for submodel repositories (#81)
pawel-baran-se Sep 10, 2024
4d48958
test strategy: searchServer advances on testing the edge cases
Sep 11, 2024
a1e0228
Merge remote-tracking branch 'origin/dev' into MNES-468-create-an-aut…
Sep 11, 2024
42c7bd7
Merge remote-tracking branch 'origin/feat(repositry-settings)' into M…
Sep 11, 2024
46615bc
test strategy: WIP
Sep 11, 2024
049d6df
MNES-468: refactored multiple data source actions
pawel-baran-se Sep 11, 2024
a35aaf1
MNES-468: build fixed
pawel-baran-se Sep 11, 2024
34e4c5a
MNES-468: Changes by frederik
pawel-baran-se Sep 11, 2024
dd5e7e8
MNES-468: searchClient.ts removed
pawel-baran-se Sep 11, 2024
a208200
Merge branch 'refs/heads/dev' into feat(repositry-settings)
Xmilofranke Sep 11, 2024
75c4a1b
remove accidental comment from merge
Xmilofranke Sep 11, 2024
020ec48
remove duplicated qr scanner section in translation files
Xmilofranke Sep 11, 2024
41e2fc0
test strategy: fully covered AasSearcher with multiple repositories
Sep 12, 2024
d9f1154
test strategy: attempt to make calls from the server instead of the c…
Sep 12, 2024
137b83d
test strategy: attempt to make calls from the server instead of the c…
Sep 12, 2024
0f95458
test strategy: attempt to make calls from the server instead of the c…
Sep 12, 2024
c064602
MNES-468: e2e test update
pawel-baran-se Sep 12, 2024
a1ed401
MNES-468: e2e test update
pawel-baran-se Sep 13, 2024
f1cd1e9
MNES-468: e2e test update, increased timeout
pawel-baran-se Sep 13, 2024
a287e92
MNES-468: e2e test update, increased global timeout
pawel-baran-se Sep 13, 2024
b04de78
test strategy: are failing tests timeout problem?
Sep 13, 2024
b4b5734
test strategy: fixed pipeline
Sep 16, 2024
348dcb5
test strategy: fixed pipeline finally really
Sep 16, 2024
6ac87fc
Merge remote-tracking branch 'origin/feat(repositry-settings)' into M…
Sep 16, 2024
593256b
test strategy: updated lock file
Sep 16, 2024
5869b12
Merge remote-tracking branch 'origin/dev' into MNES-468-create-an-aut…
Sep 16, 2024
847b651
updated compose.yml
Sep 16, 2024
b4820e5
Update cypress/e2e/compareViewTest.spec.js
fleanegan Sep 18, 2024
2000320
Update src/lib/services/searchUtilActions/AasSearcher.ts
fleanegan Sep 18, 2024
d312122
Update src/lib/services/searchUtilActions/AasSearcher.ts
fleanegan Sep 18, 2024
d79d4b4
Update src/lib/services/searchUtilActions/AasSearcher.ts
fleanegan Sep 18, 2024
d16be54
test strategy: apply to review comments
Sep 18, 2024
df7541f
test strategy: restore time outs
Sep 18, 2024
dd7fbf1
test strategy: replied to remaining comments of review
Sep 18, 2024
9fcd947
test strategy: fixed build
Sep 18, 2024
da26de6
test strategy: refactor
Sep 18, 2024
a1b2aab
test strategy: responded to hidden comments
Sep 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ module.exports = {
'object-curly-spacing': [1, 'always'],
'formatjs/no-id': 1,
'react-hooks/exhaustive-deps': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
},
],
},
settings: {
react: {
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ cypress-artifacts
.env
/cypress/videos/
/cypress/screenshots/
/cypress/results/*
/prisma/mnestix-database.db
/cypress/results/*
28 changes: 14 additions & 14 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ networks:
mnestix-network:
driver: bridge
name: mnestix-network

volumes:
mnestix-database:

services:
mnestix-browser:
container_name: mnestix-browser
image: mnestix/mnestix-browser:latest
profiles: ["", "frontend", "tests"]
profiles: [ "", "frontend", "tests" ]
build:
dockerfile: Dockerfile
target: production
ports:
- '3000:3000'
environment:
REGISTRY_API_URL: 'https://localhost:8083/' # 'https://registry.dpp40-2-v2.industrialdigitaltwin.org/'
SUBMODEL_REGISTRY_API_URL: 'http://localhost:8084'
DISCOVERY_API_URL: 'http://localhost:5064/discovery'
AAS_REPO_API_URL: 'http://localhost:5064/repo'
SUBMODEL_REPO_API_URL: 'http://localhost:5064/repo'
MNESTIX_BACKEND_API_URL: 'http://localhost:5064'
REGISTRY_API_URL: 'https://aas-registry:8083/' # 'https://registry.dpp40-2-v2.industrialdigitaltwin.org/'
SUBMODEL_REGISTRY_API_URL: 'http://submodel-registry:8084'
DISCOVERY_API_URL: 'http://mnestix-api:5064/discovery'
AAS_REPO_API_URL: 'http://mnestix-api:5064/repo'
SUBMODEL_REPO_API_URL: 'http://mnestix-api:5064/repo'
MNESTIX_BACKEND_API_URL: 'http://mnestix-api:5064'
AAS_LIST_FEATURE_FLAG: "true"
COMPARISON_FEATURE_FLAG: "true"
AUTHENTICATION_FEATURE_FLAG: "false"
Expand All @@ -39,7 +39,7 @@ services:
mnestix-api:
image: mnestix/mnestix-api:1.2.0
container_name: mnestix-api
profiles: ["", "backend", "tests"]
profiles: [ "", "backend", "tests" ]
ports:
- '5064:5064'
environment:
Expand Down Expand Up @@ -79,7 +79,7 @@ services:
mongodb:
image: mongo:5
container_name: mongodb
profiles: ["", "basyx", "tests"]
profiles: [ "", "basyx", "tests" ]
environment:
MONGO_INITDB_ROOT_USERNAME: mongoAdmin
MONGO_INITDB_ROOT_PASSWORD: mongoPassword
Expand All @@ -100,7 +100,7 @@ services:
aas-environment:
image: eclipsebasyx/aas-environment:2.0.0-milestone-03.1
container_name: aas-environment
profiles: ["", "basyx", "tests"]
profiles: [ "", "basyx", "tests" ]
depends_on:
- mongodb
environment:
Expand Down Expand Up @@ -132,7 +132,7 @@ services:
aas-discovery:
image: eclipsebasyx/aas-discovery:2.0.0-milestone-03.1
container_name: aas-discovery
profiles: ["", "basyx", "tests"]
profiles: [ "", "basyx", "tests" ]
depends_on:
- mongodb
environment:
Expand Down Expand Up @@ -160,7 +160,7 @@ services:
aas-registry:
image: eclipsebasyx/aas-registry-log-mongodb:2.0.0-milestone-03.1
container_name: aas-registry
profiles: ["", "basyx"]
profiles: [ "", "basyx" ]
ports:
- '8083:8080'
depends_on:
Expand All @@ -180,7 +180,7 @@ services:
submodel-registry:
image: eclipsebasyx/submodel-registry-log-mongodb:2.0.0-milestone-03.1
container_name: submodel-registry
profiles: ["", "basyx"]
profiles: [ "", "basyx" ]
ports:
- '8084:8080'
depends_on:
Expand Down
5 changes: 5 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { defineConfig } from 'cypress';

export default defineConfig({
defaultCommandTimeout: 150000, // 150
pageLoadTimeout: 600000, // 600
requestTimeout: 150000, // 150
responseTimeout: 200000, // 200
fleanegan marked this conversation as resolved.
Show resolved Hide resolved
video: true,
videoCompression: true,
retries: 2,
Expand All @@ -13,6 +17,7 @@ export default defineConfig({
baseUrl: 'http://localhost:3000/',
excludeSpecPattern: '**/ignoredTestFiles/*.js',
specPattern: 'cypress/e2e/**/*.spec.{js,jsx,ts,tsx}',
experimentalRunAllSpecs: true,
},
env: {
AAS_REPO_API_URL: 'http://localhost:5064/repo',
Expand Down
7 changes: 6 additions & 1 deletion cypress/e2e/compareViewTest.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ describe('Test compare feature view', function () {

it('In the viewer detail page clicking Compare redirects to compare feature and loads first data to compare', function () {
cy.getByTestId('detail-compare-button').click();
cy.getByTestId('compare-Data-0').click();
cy.url().should('contain', '/compare');
cy.getByTestId('compare-aas-0').should('be.visible');
cy.getByTestId('compare-Data-0').click();
cy.getByTestId('compare-Record').eq(0).should('be.visible');
});

it('In the compare view clicks on the add another AAS and adds correct data to compare', function () {
cy.getByTestId('detail-compare-button').click();
cy.getByTestId('compare-aas-0').should('be.visible');
// open popup dialog and insert second aas to compare
cy.getByTestId('add-aas-to-compare-button').click();
cy.getByTestId('compare-aas-aad-dialog').should('be.visible');
Expand All @@ -49,6 +50,7 @@ describe('Test compare feature view', function () {

it('In the compare view three aas are added with correct data and no possibility to add more aas', function () {
cy.getByTestId('detail-compare-button').click();
cy.getByTestId('compare-aas-0').should('be.visible');
// open popup dialog and insert second aas to compare
cy.getByTestId('add-aas-to-compare-button').click();
cy.get('@IDInput').click().type(compareAAS[1].assetInformation.globalAssetId);
Expand All @@ -74,6 +76,7 @@ describe('Test compare feature view', function () {

it('In the compare view check if different values are being marked when different', function () {
cy.getByTestId('detail-compare-button').click();
cy.getByTestId('compare-aas-0').should('be.visible');
// open popup dialog and insert second aas to compare
cy.getByTestId('add-aas-to-compare-button').click();
cy.get('@IDInput').click().type(compareAAS[1].assetInformation.globalAssetId);
Expand Down Expand Up @@ -104,11 +107,13 @@ describe('Test compare feature view', function () {
cy.get('@IDInput').click().type(compareAAS[0].id);
cy.getByTestId('aasId-submit-button').click();
cy.getByTestId('detail-compare-button').click();
cy.getByTestId('compare-aas-0').should('be.visible');
// //insert mock data
for (let i = 1; i < 3; i++) {
cy.getByTestId('add-aas-to-compare-button').click();
cy.get('@IDInput').click().type(compareAAS[i].assetInformation.globalAssetId);
cy.getByTestId('aasId-submit-button').click();
cy.getByTestId(`compare-aas-${i}`).should('be.visible');
}
});

Expand Down
5 changes: 2 additions & 3 deletions cypress/e2e/dnsRedirectTest.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import testAas from '../fixtures/testAAS.json';

const testAasId = testAas.aasId;
const testAssetId = testAas.assetId;

Expand All @@ -7,9 +8,7 @@ describe('Test the DNS Redirect', function () {
cy.postTestAas();
});
it('Visits the "/asset/URLEncodedAssetID" page and gets redirected to the corresponding viewer page', function () {
cy.intercept({ method: 'GET', url: `${Cypress.env('AAS_DISCOVERY_API_URL')}/lookup/shells*` }).as(
'redirectedViewer',
);
cy.intercept({ method: 'POST', url: `/en/viewer/*` }).as('redirectedViewer');
let encodedUrl = encodeURIComponent(testAssetId);

cy.visit('/asset?assetId=' + encodedUrl);
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/listAasPageComparisonTest.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ describe('Test that the list works together with the comparison view (Resolution
before(function () {
cy.postCompareMockData();

cy.setResolution(resolutions[0]);
cy.visit('/list');
cy.setResolution(resolutions[0]);
Comment on lines 7 to +8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why switch? for me the resolution is part of the setup and shoud be set first

});
it('should redirect to the comparison page and display the submodel data correctly', function () {
cy.get('[data-testid="list-row-https://i40.xitaso.com/aas/testElement_1"]')
Expand All @@ -14,13 +14,13 @@ describe('Test that the list works together with the comparison view (Resolution
cy.get('[data-testid="list-row-https://i40.xitaso.com/aas/testElement_2"]')
.findByTestId('list-checkbox')
.click();

cy.getByTestId('compare-button').click();
cy.wait(100);
cy.url().should('contain', '/compare');
cy.wait(60000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove debug wait

cy.getByTestId('compare-aas-0').should('be.visible');
cy.getByTestId('compare-aas-1').should('be.visible');

// assert that second aas is displayed correctly
cy.getByTestId('compare-aas-1').should('be.visible');
cy.getByTestId('compare-Data-0').click();
cy.getByTestId('compare-value-1').eq(1).contains('TEST_DATA2');
cy.getByTestId('compare-value-0').eq(10).should('be.empty');
Expand Down
2 changes: 0 additions & 2 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ Cypress.Commands.add('setResolution', (res) => {

Cypress.Commands.add('visitViewer', (aasId) => {
cy.visit('/viewer/' + btoa(aasId).replace(/=+$/g, ''));
cy.intercept('GET', '**/submodels/*').as('getSubmodels');
cy.wait('@getSubmodels');
});

Cypress.Commands.add('getByTestId', (dataTestId) => {
Expand Down
10 changes: 10 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export {};
module.exports = {
moduleDirectories: ['node_modules', 'src'],
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/__tests__/**/*.ts', '**/?(*.)+(spec|test).ts'],
};
1 change: 1 addition & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom'
13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@eslint/js": "^9.2.0",
"@next/eslint-plugin-next": "^14.2.3",
"@swc/core": "^1.7.23",
"@swc/jest": "^0.2.36",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/flat": "^5.0.5",
"@types/jest": "^29.5.12",
"@types/lodash": "^4.17.0",
"@types/node": "^22.4.2",
"@types/node": "^22.5.4",
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"@typescript-eslint/eslint-plugin": "^7.7.1",
Expand All @@ -24,9 +30,14 @@
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"globals": "^15.1.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lodash": "^4.17.21",
"prettier": "^3.2.5",
"prisma": "^5.18.0",
"ts-jest": "^29.2.5",
"ts-mockito": "^2.6.1",
"ts-node": "^10.9.2",
"typescript-eslint": "^7.8.0"
},
"dependencies": {
Expand Down
6 changes: 2 additions & 4 deletions src/app/[locale]/_components/DashboardInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@ import { messages } from 'lib/i18n/localization';
import { FormattedMessage } from 'react-intl';
import { ManualAasInput } from 'app/[locale]/_components/ManualAasInput';
import { QrScanner } from 'app/[locale]/_components/QrScanner';
import { handleSearchForAas } from 'lib/searchUtilActions/searchClient';
import { useRouter } from 'next/navigation';
import { useAasState, useRegistryAasState } from 'components/contexts/CurrentAasContext';
import { LocalizedError } from 'lib/util/LocalizedError';
import { useApis } from 'components/azureAuthentication/ApiProvider';
import { performFullAasSearch } from 'lib/services/searchUtilActions/searchActions';

export const DashboardInput = () => {
const [, setAas] = useAasState();
const [, setRegistryAasData] = useRegistryAasState();
const navigate = useRouter();
const { repositoryClient } = useApis();

const browseAasUrl = async (val: string) => {
try {
const aasSearch = await handleSearchForAas(val, repositoryClient);
const aasSearch = await performFullAasSearch(val);

if (aasSearch.aas) {
setAas(aasSearch.aas);
Expand Down
8 changes: 3 additions & 5 deletions src/app/[locale]/compare/_components/CompareView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { useEffect, useState } from 'react';
import { useNotificationSpawner } from 'lib/hooks/UseNotificationSpawner';
import { useSearchParams } from 'next/navigation';
import { showError } from 'lib/util/ErrorHandlerUtil';
import { AasSearchResult, handleSearchForAas } from 'lib/searchUtilActions/searchClient';
import { LocalizedError } from 'lib/util/LocalizedError';
import { useApis } from 'components/azureAuthentication/ApiProvider';
import { performFullAasSearch } from 'lib/services/searchUtilActions/searchActions';
import { AasSearchResult } from 'lib/services/searchUtilActions/AasSearcher';

export function CompareView() {
const { compareAas, addSeveralAas, deleteAas, addAas } = useCompareAasContext();
Expand All @@ -25,8 +25,6 @@ export function CompareView() {
});
const [addModalOpen, setAddModalOpen] = useState(false);

const { repositoryClient } = useApis();

useEffect(() => {
async function _fetchAas() {
try {
Expand Down Expand Up @@ -61,7 +59,7 @@ export function CompareView() {
const handleAddAas = async (aasId: string) => {
let aasSearch: AasSearchResult;
try {
aasSearch = await handleSearchForAas(aasId, repositoryClient);
aasSearch = await performFullAasSearch(aasId);
} catch (e) {
throw new LocalizedError(messages.mnestix.aasUrlNotFound);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useNotificationSpawner } from 'lib/hooks/UseNotificationSpawner';
import {
getConnectionDataAction,
upsertConnectionDataAction,
} from 'app/[locale]/settings/_components/mnestix-connections/MnestixConnectionServerActions';
} from 'lib/services/MultipleRepositorySearch/MnestixConnectionServerActions';
import { useForm } from 'react-hook-form';
import { useEnv } from 'app/env/provider';
import { SettingsCardHeader } from 'app/[locale]/settings/_components/SettingsCardHeader';
Expand Down
Loading