Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AAfghahi committed May 11, 2022
1 parent b69390e commit 18e51d9
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('Dashboard edit action', () => {
.click()
.then(() => {
// assert that modal edit window has closed
cy.get('.ant-modal-body').should('not.be.visible');
cy.get('.ant-modal-body').should('not.exist');

// assert title has been updated
cy.get('.editable-title input').should('have.value', dashboardTitle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('Header Report Dropdown', () => {
expect(screen.getByText('Delete email report')).toBeInTheDocument();
});

it('opens an edit modal', () => {
it('opens an edit modal', async () => {
const mockedProps = createProps();
act(() => {
setup(mockedProps, stateWithUserAndReport);
Expand All @@ -142,7 +142,8 @@ describe('Header Report Dropdown', () => {
userEvent.click(emailReportModalButton);
const editModal = screen.getByText('Edit email report');
userEvent.click(editModal);
expect(screen.getByText('Edit Email Report')).toBeInTheDocument();
const textBoxes = await screen.findAllByText('Edit email report');
expect(textBoxes).toHaveLength(2);
});

it('opens a delete modal', () => {
Expand All @@ -164,7 +165,7 @@ describe('Header Report Dropdown', () => {
});
const emailReportModalButton = screen.getByRole('button');
userEvent.click(emailReportModalButton);
expect(screen.getByText('New Email Report')).toBeInTheDocument();
expect(screen.getByText('Schedule a new email report')).toBeInTheDocument();
});

it('renders Manage Email Reports Menu if textMenu is set to true and there is a report', () => {
Expand Down
7 changes: 5 additions & 2 deletions superset-frontend/src/components/ReportModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ import { CronError } from 'src/components/CronPicker';
import { RadioChangeEvent } from 'src/components';
import withToasts from 'src/components/MessageToasts/withToasts';
import { ChartState } from 'src/explore/types';
import { ReportCreationMethod, ReportType } from 'src/reports/types';
import { ReportObject, NOTIFICATION_FORMATS } from 'src/views/CRUD/alert/types';
import {
ReportCreationMethod,
ReportObject,
NOTIFICATION_FORMATS,
} from 'src/reports/types';
import { reportSelector } from 'src/views/CRUD/hooks';
import { CreationMethod } from './HeaderReportDropdown';
import {
Expand Down
9 changes: 5 additions & 4 deletions superset-frontend/src/reports/reducers/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ export default function reportsReducer(state = {}, action) {
[ADD_REPORT]() {
const { result, id } = action.json;
const report = { ...result, id };
const reportId = report.dashboard || report.chart;
const reportTypeId = report.dashboard || report.chart;
// this is the id of either the chart or the dashboard associated with the report.

return {
...state,
[report.creation_method]: {
...state[report.creation_method],
[reportId]: report,
[reportTypeId]: report,
},
};
},
Expand All @@ -67,13 +68,13 @@ export default function reportsReducer(state = {}, action) {
...action.json.result,
id: action.json.id,
};
const reportId = report.dashboard || report.chart;
const reportTypeId = report.dashboard || report.chart;

return {
...state,
[report.creation_method]: {
...state[report.creation_method],
[reportId]: report,
[reportTypeId]: report,
},
};
},
Expand Down
29 changes: 29 additions & 0 deletions superset-frontend/src/reports/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,32 @@ export enum ReportType {
DASHBOARDS = 'dashboards',
CHARTS = 'charts',
}

export enum NOTIFICATION_FORMATS {
TEXT = 'TEXT',
PNG = 'PNG',
CSV = 'CSV',
}
export interface ReportObject {
id?: number;
active: boolean;
crontab: string;
dashboard?: number;
chart?: number;
description?: string;
log_retention: number;
name: string;
owners: number[];
recipients: [
{ recipient_config_json: { target: string }; type: ReportRecipientType },
];
report_format: string;
timezone: string;
type: ReportScheduleType;
validator_config_json: {} | null;
validator_type: string;
working_timeout: number;
creation_method: string;
force_screenshot: boolean;
error?: string;
}
31 changes: 1 addition & 30 deletions superset-frontend/src/views/CRUD/alert/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import Owner from 'src/types/Owner';
import { ReportRecipientType, ReportScheduleType } from 'src/reports/types';
import { NOTIFICATION_FORMATS } from 'src/reports/types';

type user = {
id: number;
Expand Down Expand Up @@ -94,35 +94,6 @@ export type AlertObject = {
error?: string;
};

export enum NOTIFICATION_FORMATS {
TEXT = 'TEXT',
PNG = 'PNG',
CSV = 'CSV',
}
export interface ReportObject {
id?: number;
active: boolean;
crontab: string;
dashboard?: number;
chart?: number;
description?: string;
log_retention: number;
name: string;
owners: number[];
recipients: [
{ recipient_config_json: { target: string }; type: ReportRecipientType },
];
report_format: string;
timezone: string;
type: ReportScheduleType;
validator_config_json: {} | null;
validator_type: string;
working_timeout: number;
creation_method: string;
force_screenshot: boolean;
error?: string;
}

export type LogObject = {
end_dttm: string;
error_message: string;
Expand Down

0 comments on commit 18e51d9

Please sign in to comment.