From 8b66172c9288d1cf6bb1bc622daa2aa9e3420042 Mon Sep 17 00:00:00 2001 From: Nelson Kopliku Date: Thu, 26 Sep 2024 10:38:56 +0200 Subject: [PATCH] Add a refresh button to the Activity Log page (#3020) * Add a refresh button to the Activity Log page * Improve e2e tests * Adjust refresh button width --- .../pages/ActivityLogPage/ActivityLogPage.jsx | 13 +++++++++++- .../ActivityLogPage/ActivityLogPage.test.jsx | 8 +++++++ test/e2e/cypress/e2e/activity_log.cy.js | 21 ++++++++++++++++++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/assets/js/pages/ActivityLogPage/ActivityLogPage.jsx b/assets/js/pages/ActivityLogPage/ActivityLogPage.jsx index d9502d93ac..4a84872954 100644 --- a/assets/js/pages/ActivityLogPage/ActivityLogPage.jsx +++ b/assets/js/pages/ActivityLogPage/ActivityLogPage.jsx @@ -1,6 +1,7 @@ import React, { useState, useEffect } from 'react'; import { useSearchParams } from 'react-router-dom'; import { useSelector } from 'react-redux'; +import { EOS_REFRESH } from 'eos-icons-react'; import { map, pipe } from 'lodash/fp'; @@ -9,6 +10,7 @@ import { allowedActivities } from '@lib/model/activityLog'; import { getActivityLogUsers } from '@state/selectors/activityLog'; import { getUserProfile } from '@state/selectors/user'; +import Button from '@common/Button'; import PageHeader from '@common/PageHeader'; import ActivityLogOverview from '@common/ActivityLogOverview'; import ComposedFilter from '@common/ComposedFilter'; @@ -127,7 +129,7 @@ function ActivityLogPage() { Activity Log
-
+
+
{ expect(screen.getByText('No data available')).toBeVisible(); }); + it('should render filter actions', async () => { + const [StatefulActivityLogPage, _] = withDefaultState(); + await act(() => renderWithRouter(StatefulActivityLogPage)); + expect(screen.getByText('Apply')).toBeVisible(); + expect(screen.getByText('Reset')).toBeVisible(); + expect(screen.getByText('Refresh')).toBeVisible(); + }); + it.each` responseStatus | responseBody ${200} | ${{ dataz: [] }} diff --git a/test/e2e/cypress/e2e/activity_log.cy.js b/test/e2e/cypress/e2e/activity_log.cy.js index 40275a5f91..9fb2044a0a 100644 --- a/test/e2e/cypress/e2e/activity_log.cy.js +++ b/test/e2e/cypress/e2e/activity_log.cy.js @@ -5,7 +5,7 @@ const LAST = /^>>$/; context('Activity Log page', () => { before(() => { - cy.loadScenario('healthy-27-node-SAP-cluster'); + // cy.loadScenario('healthy-27-node-SAP-cluster'); }); describe('Navigation', () => { @@ -129,6 +129,25 @@ context('Activity Log page', () => { cy.wait('@data').its('response.statusCode').should('eq', 200); }); + + it('should refresh content based on currently applied filters', () => { + const apiUrl = + '/api/v1/activity_log?first=20&from_date=2024-08-14T10:21:00.000Z&to_date=2024-08-13T10:21:00.000Z&type[]=login_attempt&type[]=resource_tagging'; + const pageUrl = + '/activity_log?from_date=custom&from_date=2024-08-14T10%3A21%3A00.000Z&to_date=custom&to_date=2024-08-13T10%3A21%3A00.000Z&type=login_attempt&type=resource_tagging'; + + cy.intercept({ url: apiUrl }).as('initialDataLoad'); + + cy.visit(pageUrl); + + cy.wait('@initialDataLoad'); + + cy.intercept({ url: apiUrl }).as('refreshedDataLoad'); + cy.contains('Refresh').click(); + cy.wait('@refreshedDataLoad'); + + cy.url().should('eq', `${Cypress.config().baseUrl}${pageUrl}`); + }); }); describe('Pagination', () => {