From 4c9f4e37e4ace058f22b5dfda07cb3fbaebe3a3b Mon Sep 17 00:00:00 2001 From: monsieurswag Date: Tue, 14 May 2024 16:59:54 +0200 Subject: [PATCH] Adapt unit tests and functional tests to the library translation changes --- backend/app_tests/api/test_api_libraries.py | 12 +++++------ .../functional/detailed/libraries.test.ts | 20 +++++++++---------- frontend/tests/utils/page-content.ts | 16 +++++++-------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/backend/app_tests/api/test_api_libraries.py b/backend/app_tests/api/test_api_libraries.py index d83eb9041..df16ab0f3 100644 --- a/backend/app_tests/api/test_api_libraries.py +++ b/backend/app_tests/api/test_api_libraries.py @@ -66,10 +66,10 @@ def test_import_frameworks(self, test): ).json()["content"] lib_detail_response = json.loads(lib_detail_response)["framework"] - # Asserts that the library is not already imported + # Asserts that the library is not already loaded assert ( Framework.objects.all().count() == 0 - ), "libraries are already imported in the database" + ), "libraries are already loaded in the database" EndpointTestsQueries.Auth.get_object( test.client, "Frameworks", @@ -88,7 +88,7 @@ def test_import_frameworks(self, test): else 0 ), "Frameworks are not correctly imported in the database" - # Uses the API endpoint to assert that the library was properly imported + # Uses the API endpoint to assert that the library was properly loaded EndpointTestsQueries.Auth.get_object( test.client, "Frameworks", @@ -132,10 +132,10 @@ def test_import_risk_matrix(self, test): ).json()["content"] lib_detail_response = json.loads(lib_detail_response)["risk_matrix"][0] - # Asserts that the library is not already imported + # Asserts that the library is not already loaded assert ( RiskMatrix.objects.all().count() == 0 - ), "libraries are already imported in the database" + ), "libraries are already loaded in the database" EndpointTestsQueries.Auth.get_object( test.client, "Risk matrices", user_group=test.user_group ) @@ -152,7 +152,7 @@ def test_import_risk_matrix(self, test): else 0 ), "Risk matrices are not correctly imported in the database" - # Uses the API endpoint to assert that the library was properly imported + # Uses the API endpoint to assert that the library was properly loaded EndpointTestsQueries.Auth.get_object( test.client, "Risk matrices", diff --git a/frontend/tests/functional/detailed/libraries.test.ts b/frontend/tests/functional/detailed/libraries.test.ts index 38a620eef..dad419bce 100644 --- a/frontend/tests/functional/detailed/libraries.test.ts +++ b/frontend/tests/functional/detailed/libraries.test.ts @@ -1,7 +1,7 @@ import { test, expect } from '../../utils/test-utils.js'; test.describe.configure({ mode: 'serial' }); -test('every libraries can be imported', async ({ logedPage, librariesPage, page }) => { +test('every libraries can be loaded', async ({ logedPage, librariesPage, page }) => { test.slow(); await librariesPage.goto(); await librariesPage.hasUrl(); @@ -38,15 +38,15 @@ test('every libraries can be deleted', async ({ logedPage, librariesPage, page } await librariesPage.hasUrl(); await expect( - librariesPage.tab('Imported libraries'), - 'There is no imported libraries to delete' + librariesPage.tab('Loaded libraries'), + 'There is no loaded libraries to delete' ).toBeVisible(); if ( - (await librariesPage.tab('Imported libraries').isVisible()) && - (await librariesPage.tab('Imported libraries').getAttribute('aria-selected')) === 'false' + (await librariesPage.tab('Loaded libraries').isVisible()) && + (await librariesPage.tab('Loaded libraries').getAttribute('aria-selected')) === 'false' ) { - await librariesPage.tab('Imported libraries').click(); - expect(librariesPage.tab('Imported libraries').getAttribute('aria-selected')).toBeTruthy(); + await librariesPage.tab('Loaded libraries').click(); + expect(librariesPage.tab('Loaded libraries').getAttribute('aria-selected')).toBeTruthy(); } let previousRemainingLibrary = ''; @@ -54,7 +54,7 @@ test('every libraries can be deleted', async ({ logedPage, librariesPage, page } let count = 0; do { await page.reload(); // this is a workaround to try to fix the issue with delete button not being visible with dependencies in CI - if (await librariesPage.tab('Imported libraries').isVisible()) { + if (await librariesPage.tab('Loaded libraries').isVisible()) { previousRemainingLibrary = nextRemainingLibrary; nextRemainingLibrary = await page.locator('tbody tr td:nth-child(1)').nth(count)?.innerText(); expect( @@ -75,7 +75,7 @@ test('every libraries can be deleted', async ({ logedPage, librariesPage, page } timeout: 15000 } ); - if (await page.getByText(' You currently have no imported libraries.').isHidden()) { + if (await page.getByText(' You currently have no loaded libraries.').isHidden()) { await expect(librariesPage.getRow(nextRemainingLibrary)).not.toBeVisible(); } else { break; @@ -87,6 +87,6 @@ test('every libraries can be deleted', async ({ logedPage, librariesPage, page } } } while ( nextRemainingLibrary || - (await page.getByText(' You currently have no imported libraries.').isHidden()) + (await page.getByText(' You currently have no loaded libraries.').isHidden()) ); }); diff --git a/frontend/tests/utils/page-content.ts b/frontend/tests/utils/page-content.ts index f598cae8b..284b6f653 100644 --- a/frontend/tests/utils/page-content.ts +++ b/frontend/tests/utils/page-content.ts @@ -67,8 +67,8 @@ export class PageContent extends BasePage { async importLibrary(ref: string, urn?: string, language = 'English') { if ( - (await this.tab('Imported libraries').isVisible()) && - (await this.tab('Imported libraries').getAttribute('aria-selected')) === 'true' + (await this.tab('Loaded libraries').isVisible()) && + (await this.tab('Loaded libraries').getAttribute('aria-selected')) === 'true' ) { if (await this.getRow(ref).isHidden()) { await this.tab('Libraries store').click(); @@ -77,19 +77,19 @@ export class PageContent extends BasePage { return; } } - // If the library is not visible, it might have already been imported + // If the library is not visible, it might have already been loaded if (await this.getRow(ref).isHidden()) { - await this.tab('Imported libraries').click(); - expect(this.tab('Imported libraries').getAttribute('aria-selected')).toBeTruthy(); + await this.tab('Loaded libraries').click(); + expect(this.tab('Loaded libraries').getAttribute('aria-selected')).toBeTruthy(); expect(this.getRow(ref)).toBeVisible(); return; } await this.importItemButton(ref, language === 'any' ? undefined : language).click(); - await this.isToastVisible(`The library object has been successfully imported.+`, undefined, { + await this.isToastVisible(`The library has been successfully loaded.+`, undefined, { timeout: 15000 }); - await this.tab('Imported libraries').click(); - expect(this.tab('Imported libraries').getAttribute('aria-selected')).toBeTruthy(); + await this.tab('Loaded libraries').click(); + expect(this.tab('Loaded libraries').getAttribute('aria-selected')).toBeTruthy(); expect(this.getRow(ref)).toBeVisible(); }