зеркало из https://github.com/mozilla/treeherder.git
Bug 1609059 - Remove My alerts in detailed Alerts view
This commit is contained in:
Родитель
85bcc50cd4
Коммит
13a6788c0d
|
@ -19,7 +19,7 @@ import repos from '../mock/repositories';
|
|||
|
||||
const testUser = {
|
||||
username: 'mozilla-ldap/test_user@mozilla.com',
|
||||
is_superuser: false,
|
||||
isLoggedIn: true,
|
||||
isStaff: true,
|
||||
email: 'test_user@mozilla.com',
|
||||
};
|
||||
|
@ -227,8 +227,16 @@ const mockUpdateAlertSummary = (alertSummaryId, params) => ({
|
|||
failureStatus: null,
|
||||
});
|
||||
|
||||
const alertsViewControls = () =>
|
||||
render(
|
||||
const alertsViewControls = ({
|
||||
isListingAlertSummaries = null,
|
||||
user: userMock = null,
|
||||
alertDropdowns: alertDropdownMock = null,
|
||||
} = {}) => {
|
||||
const user = userMock !== null ? userMock : testUser;
|
||||
const alertDropdowns =
|
||||
alertDropdownMock !== null ? alertDropdownMock : testAlertDropdowns;
|
||||
|
||||
return render(
|
||||
<AlertsViewControls
|
||||
validated={{
|
||||
hideDwnToInv: undefined,
|
||||
|
@ -236,13 +244,14 @@ const alertsViewControls = () =>
|
|||
filter: undefined,
|
||||
updateParams: () => {},
|
||||
}}
|
||||
dropdownOptions={testAlertDropdowns}
|
||||
isListingAlertSummaries={isListingAlertSummaries}
|
||||
dropdownOptions={alertDropdowns}
|
||||
alertSummaries={testAlertSummaries}
|
||||
issueTrackers={testIssueTrackers}
|
||||
optionCollectionMap={optionCollectionMap}
|
||||
fetchAlertSummaries={() => {}}
|
||||
updateViewState={() => {}}
|
||||
user={testUser}
|
||||
user={user}
|
||||
modifyAlert={(alert, params) => mockModifyAlert.update(alert, params)}
|
||||
updateAlertSummary={() =>
|
||||
Promise.resolve({ failureStatus: false, data: 'alert summary data' })
|
||||
|
@ -254,6 +263,7 @@ const alertsViewControls = () =>
|
|||
}}
|
||||
/>,
|
||||
);
|
||||
};
|
||||
|
||||
const modifyAlertSpy = jest.spyOn(mockModifyAlert, 'update');
|
||||
|
||||
|
@ -557,5 +567,40 @@ test('Alerts retriggered by the backfill bot have a title', async () => {
|
|||
expect(titles).toHaveLength(1);
|
||||
});
|
||||
|
||||
describe('"My alerts" checkbox\'s display behaviors', () => {
|
||||
// By default, user is logged in &
|
||||
// status & framework dropdowns are available
|
||||
|
||||
test('Not displayed in Alerts view (detailed mode)', async () => {
|
||||
const { queryByText } = alertsViewControls({
|
||||
isListingAlertSummaries: false,
|
||||
}); // as Django detailed view mode
|
||||
|
||||
expect(queryByText('My alerts')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('Not displayed in Alerts view (detailed mode), even when param is missing', async () => {
|
||||
const { queryByText } = alertsViewControls({ alertDropdowns: [] });
|
||||
|
||||
expect(queryByText('My alerts')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('Displayed in Alerts view (list mode)', async () => {
|
||||
const { getByText } = alertsViewControls({ isListingAlertSummaries: true }); // as Django detailed view mode
|
||||
|
||||
const myAlertsCheckbox = await waitForElement(() => getByText('My alerts'));
|
||||
expect(myAlertsCheckbox).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('Not displayed if user is not logged in', async () => {
|
||||
const { queryByText } = alertsViewControls({
|
||||
isListingAlertSummaries: false,
|
||||
user: { isLoggedIn: false },
|
||||
});
|
||||
|
||||
expect(queryByText('My alerts')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
// TODO should write tests for alert summary dropdown menu actions performed in StatusDropdown
|
||||
// (adding notes or marking as 'fixed', etc)
|
||||
|
|
|
@ -9,6 +9,17 @@ import AlertTable from './AlertTable';
|
|||
export default class AlertsViewControls extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
let { isListingAlertSummaries } = props;
|
||||
if (
|
||||
isListingAlertSummaries === null ||
|
||||
isListingAlertSummaries === undefined
|
||||
) {
|
||||
isListingAlertSummaries =
|
||||
// no dropdown options were provided
|
||||
props.dropdownOptions !== null && props.dropdownOptions.length > 0;
|
||||
}
|
||||
|
||||
this.validated = this.props.validated;
|
||||
this.state = {
|
||||
hideImprovements: convertParams(this.validated, 'hideImprovements'),
|
||||
|
@ -17,6 +28,7 @@ export default class AlertsViewControls extends React.Component {
|
|||
this.validated,
|
||||
'hideAssignedToOthers',
|
||||
),
|
||||
isListingAlertSummaries,
|
||||
filterText: '',
|
||||
};
|
||||
}
|
||||
|
@ -62,6 +74,7 @@ export default class AlertsViewControls extends React.Component {
|
|||
hideImprovements,
|
||||
hideDownstream,
|
||||
hideAssignedToOthers,
|
||||
isListingAlertSummaries,
|
||||
} = this.state;
|
||||
|
||||
const alertFilters = [
|
||||
|
@ -77,7 +90,7 @@ export default class AlertsViewControls extends React.Component {
|
|||
},
|
||||
];
|
||||
|
||||
if (user.isLoggedIn) {
|
||||
if (user.isLoggedIn && isListingAlertSummaries) {
|
||||
alertFilters.push({
|
||||
text: 'My alerts',
|
||||
state: hideAssignedToOthers,
|
||||
|
@ -114,6 +127,7 @@ AlertsViewControls.propTypes = {
|
|||
validated: PropTypes.shape({
|
||||
updateParams: PropTypes.func,
|
||||
}).isRequired,
|
||||
isListingAlertSummaries: PropTypes.bool,
|
||||
dropdownOptions: PropTypes.arrayOf(PropTypes.shape({})),
|
||||
fetchAlertSummaries: PropTypes.func.isRequired,
|
||||
alertSummaries: PropTypes.arrayOf(PropTypes.shape({})),
|
||||
|
@ -121,6 +135,7 @@ AlertsViewControls.propTypes = {
|
|||
};
|
||||
|
||||
AlertsViewControls.defaultProps = {
|
||||
isListingAlertSummaries: null,
|
||||
dropdownOptions: null,
|
||||
alertSummaries: [],
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче