Skip to content

Commit

Permalink
Switch to (@gsa/testing) testing module.
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h-abdelsalam committed May 13, 2024
1 parent 62d27fd commit 349acd0
Show file tree
Hide file tree
Showing 13 changed files with 220 additions and 211 deletions.
1 change: 1 addition & 0 deletions src/gmp/commands/__tests__/auditreport.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {describe, test, expect} from '@gsa/testing';
import {createHttp, createEntityResponse} from 'gmp/commands/testing';
import {AuditReportCommand} from 'gmp/commands/auditreports';

Expand Down
1 change: 1 addition & 0 deletions src/gmp/commands/__tests__/auditreports.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {describe, test, expect} from '@gsa/testing';
import {ALL_FILTER} from 'gmp/models/filter';

import {
Expand Down
41 changes: 21 additions & 20 deletions src/web/components/powerfilter/__tests__/compliancelevelsgroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {describe, test, expect, testing} from '@gsa/testing';
import {render, fireEvent} from 'web/utils/testing';

import ComplianceLevelsFilterGroup from 'web/components/powerfilter/compliancelevelsgroup';
Expand All @@ -24,8 +25,8 @@ import Filter from 'gmp/models/filter';
describe('ComplianceLevelsFilterGroup audit reports tests', () => {
test('should call change handler', () => {
const filter = Filter.fromString('report_compliance_levels=');
const handleChange = vi.fn();
const handleRemove = vi.fn();
const handleChange = testing.fn();
const handleRemove = testing.fn();
const {element} = render(
<ComplianceLevelsFilterGroup
filter={filter}
Expand All @@ -43,8 +44,8 @@ describe('ComplianceLevelsFilterGroup audit reports tests', () => {

test('should check checkbox', () => {
const filter = Filter.fromString('report_compliance_levels=yn');
const handleChange = vi.fn();
const handleRemove = vi.fn();
const handleChange = testing.fn();
const handleRemove = testing.fn();
const {element} = render(
<ComplianceLevelsFilterGroup
filter={filter}
Expand All @@ -62,8 +63,8 @@ describe('ComplianceLevelsFilterGroup audit reports tests', () => {
test('should uncheck checkbox', () => {
const filter1 = Filter.fromString('report_compliance_levels=yni');
const filter2 = Filter.fromString('report_compliance_levels=yn');
const handleChange = vi.fn();
const handleRemove = vi.fn();
const handleChange = testing.fn();
const handleRemove = testing.fn();
const {element, rerender} = render(
<ComplianceLevelsFilterGroup
filter={filter1}
Expand Down Expand Up @@ -93,8 +94,8 @@ describe('ComplianceLevelsFilterGroup audit reports tests', () => {

test('should be unchecked by default', () => {
const filter = Filter.fromString();
const handleChange = vi.fn();
const handleRemove = vi.fn();
const handleChange = testing.fn();
const handleRemove = testing.fn();
const {element} = render(
<ComplianceLevelsFilterGroup
filter={filter}
Expand All @@ -113,8 +114,8 @@ describe('ComplianceLevelsFilterGroup audit reports tests', () => {

test('should call remove handler', () => {
const filter = Filter.fromString('report_compliance_levels=y');
const handleChange = vi.fn();
const handleRemove = vi.fn();
const handleChange = testing.fn();
const handleRemove = testing.fn();
const {element} = render(
<ComplianceLevelsFilterGroup
filter={filter}
Expand All @@ -135,8 +136,8 @@ describe('ComplianceLevelsFilterGroup audit reports tests', () => {
describe('ComplianceLevelsFilterGroup audit results tests', () => {
test('should call change handler', () => {
const filter = Filter.fromString('compliance_levels=');
const handleChange = vi.fn();
const handleRemove = vi.fn();
const handleChange = testing.fn();
const handleRemove = testing.fn();
const {element} = render(
<ComplianceLevelsFilterGroup
filter={filter}
Expand All @@ -155,8 +156,8 @@ describe('ComplianceLevelsFilterGroup audit results tests', () => {

test('should check checkbox', () => {
const filter = Filter.fromString('compliance_levels=yn');
const handleChange = vi.fn();
const handleRemove = vi.fn();
const handleChange = testing.fn();
const handleRemove = testing.fn();
const {element} = render(
<ComplianceLevelsFilterGroup
filter={filter}
Expand All @@ -175,8 +176,8 @@ describe('ComplianceLevelsFilterGroup audit results tests', () => {
test('should uncheck checkbox', () => {
const filter1 = Filter.fromString('compliance_levels=yni');
const filter2 = Filter.fromString('compliance_levels=yn');
const handleChange = vi.fn();
const handleRemove = vi.fn();
const handleChange = testing.fn();
const handleRemove = testing.fn();
const {element, rerender} = render(
<ComplianceLevelsFilterGroup
filter={filter1}
Expand Down Expand Up @@ -208,8 +209,8 @@ describe('ComplianceLevelsFilterGroup audit results tests', () => {

test('should be unchecked by default', () => {
const filter = Filter.fromString();
const handleChange = vi.fn();
const handleRemove = vi.fn();
const handleChange = testing.fn();
const handleRemove = testing.fn();
const {element} = render(
<ComplianceLevelsFilterGroup
filter={filter}
Expand All @@ -229,8 +230,8 @@ describe('ComplianceLevelsFilterGroup audit results tests', () => {

test('should call remove handler', () => {
const filter = Filter.fromString('compliance_levels=y');
const handleChange = vi.fn();
const handleRemove = vi.fn();
const handleChange = testing.fn();
const handleRemove = testing.fn();
const {element} = render(
<ComplianceLevelsFilterGroup
filter={filter}
Expand Down
89 changes: 45 additions & 44 deletions src/web/pages/reports/__tests__/auditdeltadetailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {describe, test, expect, testing} from '@gsa/testing';
import React from 'react';

import Capabilities from 'gmp/capabilities/capabilities';
Expand Down Expand Up @@ -46,37 +47,37 @@ const caps = new Capabilities(['everything']);

const manualUrl = 'test/';

const currentSettings = vi.fn().mockResolvedValue({
const currentSettings = testing.fn().mockResolvedValue({
foo: 'bar',
});

const getReportComposerDefaults = vi.fn().mockResolvedValue({
const getReportComposerDefaults = testing.fn().mockResolvedValue({
foo: 'bar',
});

describe('Audit Detla Report Details Content tests', () => {
test('should render Audit Delta Report Details Content', () => {
const onActivateTab = vi.fn();
const onAddToAssetsClick = vi.fn();
const onError = vi.fn();
const onFilterAddLogLevelClick = vi.fn();
const onFilterDecreaseMinQoDClick = vi.fn();
const onFilterChanged = vi.fn();
const onFilterCreated = vi.fn();
const onFilterEditClick = vi.fn();
const onFilterRemoveSeverityClick = vi.fn();
const onFilterResetClick = vi.fn();
const onFilterRemoveClick = vi.fn();
const onInteraction = vi.fn();
const onRemoveFromAssetsClick = vi.fn();
const onReportDownloadClick = vi.fn();
const showError = vi.fn();
const showErrorMessage = vi.fn();
const showSuccessMessage = vi.fn();
const onSortChange = vi.fn();
const onTagSuccess = vi.fn();
const onTargetEditClick = vi.fn();
const onTlsCertificateDownloadClick = vi.fn();
const onActivateTab = testing.fn();
const onAddToAssetsClick = testing.fn();
const onError = testing.fn();
const onFilterAddLogLevelClick = testing.fn();
const onFilterDecreaseMinQoDClick = testing.fn();
const onFilterChanged = testing.fn();
const onFilterCreated = testing.fn();
const onFilterEditClick = testing.fn();
const onFilterRemoveSeverityClick = testing.fn();
const onFilterResetClick = testing.fn();
const onFilterRemoveClick = testing.fn();
const onInteraction = testing.fn();
const onRemoveFromAssetsClick = testing.fn();
const onReportDownloadClick = testing.fn();
const showError = testing.fn();
const showErrorMessage = testing.fn();
const showSuccessMessage = testing.fn();
const onSortChange = testing.fn();
const onTagSuccess = testing.fn();
const onTargetEditClick = testing.fn();
const onTlsCertificateDownloadClick = testing.fn();

const sorting = {
errors: {sortField: 'error', sortReverse: true},
Expand Down Expand Up @@ -227,27 +228,27 @@ describe('Audit Detla Report Details Content tests', () => {
});

test('should render results tab', () => {
const onActivateTab = vi.fn();
const onAddToAssetsClick = vi.fn();
const onError = vi.fn();
const onFilterAddLogLevelClick = vi.fn();
const onFilterDecreaseMinQoDClick = vi.fn();
const onFilterChanged = vi.fn();
const onFilterCreated = vi.fn();
const onFilterEditClick = vi.fn();
const onFilterRemoveSeverityClick = vi.fn();
const onFilterResetClick = vi.fn();
const onFilterRemoveClick = vi.fn();
const onInteraction = vi.fn();
const onRemoveFromAssetsClick = vi.fn();
const onReportDownloadClick = vi.fn();
const showError = vi.fn();
const showErrorMessage = vi.fn();
const showSuccessMessage = vi.fn();
const onSortChange = vi.fn();
const onTagSuccess = vi.fn();
const onTargetEditClick = vi.fn();
const onTlsCertificateDownloadClick = vi.fn();
const onActivateTab = testing.fn();
const onAddToAssetsClick = testing.fn();
const onError = testing.fn();
const onFilterAddLogLevelClick = testing.fn();
const onFilterDecreaseMinQoDClick = testing.fn();
const onFilterChanged = testing.fn();
const onFilterCreated = testing.fn();
const onFilterEditClick = testing.fn();
const onFilterRemoveSeverityClick = testing.fn();
const onFilterResetClick = testing.fn();
const onFilterRemoveClick = testing.fn();
const onInteraction = testing.fn();
const onRemoveFromAssetsClick = testing.fn();
const onReportDownloadClick = testing.fn();
const showError = testing.fn();
const showErrorMessage = testing.fn();
const showSuccessMessage = testing.fn();
const onSortChange = testing.fn();
const onTagSuccess = testing.fn();
const onTargetEditClick = testing.fn();
const onTlsCertificateDownloadClick = testing.fn();

const sorting = {
apps: {sortField: 'severity', sortReverse: true},
Expand Down
89 changes: 45 additions & 44 deletions src/web/pages/reports/__tests__/auditdetailscontent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {describe, test, expect, testing} from '@gsa/testing';
import React from 'react';

import Capabilities from 'gmp/capabilities/capabilities';
Expand Down Expand Up @@ -50,37 +51,37 @@ const caps = new Capabilities(['everything']);

const manualUrl = 'test/';

const currentSettings = vi.fn().mockResolvedValue({
const currentSettings = testing.fn().mockResolvedValue({
foo: 'bar',
});

const getReportComposerDefaults = vi.fn().mockResolvedValue({
const getReportComposerDefaults = testing.fn().mockResolvedValue({
foo: 'bar',
});

describe('Audit Report Details Content tests', () => {
test('should render Audit Report Details Content', () => {
const onActivateTab = vi.fn();
const onAddToAssetsClick = vi.fn();
const onError = vi.fn();
const onFilterAddLogLevelClick = vi.fn();
const onFilterDecreaseMinQoDClick = vi.fn();
const onFilterChanged = vi.fn();
const onFilterCreated = vi.fn();
const onFilterEditClick = vi.fn();
const onFilterRemoveSeverityClick = vi.fn();
const onFilterResetClick = vi.fn();
const onFilterRemoveClick = vi.fn();
const onInteraction = vi.fn();
const onRemoveFromAssetsClick = vi.fn();
const onReportDownloadClick = vi.fn();
const showError = vi.fn();
const showErrorMessage = vi.fn();
const showSuccessMessage = vi.fn();
const onSortChange = vi.fn();
const onTagSuccess = vi.fn();
const onTargetEditClick = vi.fn();
const onTlsCertificateDownloadClick = vi.fn();
const onActivateTab = testing.fn();
const onAddToAssetsClick = testing.fn();
const onError = testing.fn();
const onFilterAddLogLevelClick = testing.fn();
const onFilterDecreaseMinQoDClick = testing.fn();
const onFilterChanged = testing.fn();
const onFilterCreated = testing.fn();
const onFilterEditClick = testing.fn();
const onFilterRemoveSeverityClick = testing.fn();
const onFilterResetClick = testing.fn();
const onFilterRemoveClick = testing.fn();
const onInteraction = testing.fn();
const onRemoveFromAssetsClick = testing.fn();
const onReportDownloadClick = testing.fn();
const showError = testing.fn();
const showErrorMessage = testing.fn();
const showSuccessMessage = testing.fn();
const onSortChange = testing.fn();
const onTagSuccess = testing.fn();
const onTargetEditClick = testing.fn();
const onTlsCertificateDownloadClick = testing.fn();

const sorting = {
errors: {sortField: 'error', sortReverse: true},
Expand Down Expand Up @@ -226,27 +227,27 @@ describe('Audit Report Details Content tests', () => {
});

test('should render audit threshold panel', () => {
const onActivateTab = vi.fn();
const onAddToAssetsClick = vi.fn();
const onError = vi.fn();
const onFilterAddLogLevelClick = vi.fn();
const onFilterDecreaseMinQoDClick = vi.fn();
const onFilterChanged = vi.fn();
const onFilterCreated = vi.fn();
const onFilterEditClick = vi.fn();
const onFilterRemoveSeverityClick = vi.fn();
const onFilterResetClick = vi.fn();
const onFilterRemoveClick = vi.fn();
const onInteraction = vi.fn();
const onRemoveFromAssetsClick = vi.fn();
const onReportDownloadClick = vi.fn();
const showError = vi.fn();
const showErrorMessage = vi.fn();
const showSuccessMessage = vi.fn();
const onSortChange = vi.fn();
const onTagSuccess = vi.fn();
const onTargetEditClick = vi.fn();
const onTlsCertificateDownloadClick = vi.fn();
const onActivateTab = testing.fn();
const onAddToAssetsClick = testing.fn();
const onError = testing.fn();
const onFilterAddLogLevelClick = testing.fn();
const onFilterDecreaseMinQoDClick = testing.fn();
const onFilterChanged = testing.fn();
const onFilterCreated = testing.fn();
const onFilterEditClick = testing.fn();
const onFilterRemoveSeverityClick = testing.fn();
const onFilterResetClick = testing.fn();
const onFilterRemoveClick = testing.fn();
const onInteraction = testing.fn();
const onRemoveFromAssetsClick = testing.fn();
const onReportDownloadClick = testing.fn();
const showError = testing.fn();
const showErrorMessage = testing.fn();
const showSuccessMessage = testing.fn();
const onSortChange = testing.fn();
const onTagSuccess = testing.fn();
const onTargetEditClick = testing.fn();
const onTlsCertificateDownloadClick = testing.fn();

const sorting = {
errors: {sortField: 'error', sortReverse: true},
Expand Down
7 changes: 4 additions & 3 deletions src/web/pages/reports/__tests__/auditfilterdialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {describe, test, expect, testing} from '@gsa/testing';
import React from 'react';

import Capabilities from 'gmp/capabilities/capabilities';
Expand All @@ -34,9 +35,9 @@ const manualUrl = 'test/';

describe('Filter Dialog for Audit report', () => {
test('should render filter with compliance level group', () => {
const onFilterChanged = vi.fn();
const onFilterCreated = vi.fn();
const onCloseClick = vi.fn();
const onFilterChanged = testing.fn();
const onFilterCreated = testing.fn();
const onCloseClick = testing.fn();

const filter = Filter.fromString(
'apply_overrides=0 levels=hmlg rows=100 min_qod=70 first=1 sort=compliant',
Expand Down
Loading

0 comments on commit 349acd0

Please sign in to comment.