Skip to content

Commit

Permalink
preheat error log is not displayed (#375)
Browse files Browse the repository at this point in the history
Signed-off-by: zhaoxinxin <[email protected]>
  • Loading branch information
Liam-Zhao committed Jun 11, 2024
1 parent 5acff46 commit c3c0e40
Show file tree
Hide file tree
Showing 24 changed files with 454 additions and 385 deletions.
48 changes: 24 additions & 24 deletions cypress/e2e/developer/tokens/tokens.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,35 +83,35 @@ describe('Tokens', () => {
},
);

cy.get('#tokens-list').should('not.exist');
cy.get('.MuiPaper-root').should('be.visible').and('have.text', `You don't have any tokens.`);
});

describe('should handle API error response', () => {
beforeEach(() => {
cy.intercept(
{
method: 'GET',
url: '/api/v1/personal-access-tokens?page=1&per_page=10000000',
},
(req) => {
req.reply({
forceNetworkError: true,
});
},
);
});
it('should handle API error response', () => {
cy.intercept(
{
method: 'GET',
url: '/api/v1/personal-access-tokens?page=1&per_page=10000000',
},
(req) => {
req.reply({
forceNetworkError: true,
});
},
);

it('show error message', () => {
// Show error message.
cy.get('.MuiAlert-message').should('be.visible').and('have.text', 'Failed to fetch');
cy.get('.MuiAlert-action > .MuiButtonBase-root').click();
});
// Show error message.
cy.get('.MuiAlert-message').should('be.visible').and('have.text', 'Failed to fetch');
cy.get('.MuiAlert-action > .MuiButtonBase-root').click();

it('there should be a message indicating that there is not tokens', () => {
cy.get('#tokens-list').should('not.exist');
cy.get('.MuiPaper-root').should('be.visible').and('have.text', `You don't have any tokens.`);
});
// Close error message.
cy.get('.MuiAlert-action > .MuiButtonBase-root').click();
cy.get('.MuiAlert-message').should('not.exist');

// No tokens list exists.
cy.get('#tokens-list').should('not.exist');

// Show You don't have any preheat tokens.
cy.get('.MuiPaper-root').should('be.visible').and('have.text', `You don't have any tokens.`);
});

describe('pagination', () => {
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/job/preheats/create-preheat.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('Create preheat', () => {
// Displays successfully added preheat task.
cy.get('#list-12 > .css-1mlhis1').should('exist').find('#PENDING-12').should('exist');
cy.get('#list-12 > .css-1mlhis1 > .css-ux5pj > .css-mu8687 > .MuiTypography-body1').should('have.text', 12);
cy.get('#list-12 > .css-1mlhis1 > .css-18467a > .MuiChip-root').should('contain', '2023-04-23 08:29:18');
cy.get('#list-12 > .css-1mlhis1 > .css-18467a > .MuiChip-root').should('have.text', '2023-04-23 16:29:18');
cy.get('#list-12 > .css-1mlhis1 > .css-ux5pj > .css-mu8687 > .MuiTypography-body2').should(
'have.text',
'create preheat',
Expand Down Expand Up @@ -194,7 +194,7 @@ describe('Create preheat', () => {
// Displays successfully added preheat task.
cy.get('#list-12 > .css-1mlhis1').should('exist').find('#PENDING-12').should('exist');
cy.get('#list-12 > .css-1mlhis1 > .css-ux5pj > .css-mu8687 > .MuiTypography-body1').should('have.text', 12);
cy.get('#list-12 > .css-1mlhis1 > .css-18467a > .MuiChip-root').should('contain', '2023-04-23 08:29:18');
cy.get('#list-12 > .css-1mlhis1 > .css-18467a > .MuiChip-root').should('have.text', '2023-04-23 16:29:18');
cy.get('#list-12 > .css-1mlhis1 > .css-ux5pj > .css-mu8687 > .MuiTypography-body2').should(
'have.text',
'create preheat',
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/job/preheats/preheat.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('Preheat', () => {
cy.get('.show_schedulerClustersID__iQd1s').should('have.text', 1);

// Show preheat Created At.
cy.get(':nth-child(10) > .MuiChip-root').should('have.text', '2023-12-13 11:58:53');
cy.get(':nth-child(10) > .MuiChip-root').should('have.text', '2023-12-13 19:58:53');

// Click the show error log button.
cy.get('#status > .MuiButtonBase-root').click();
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/job/preheats/preheats.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('Preheats', () => {
// The preheating status is displayed as PENDING.
cy.get('#list-11 > .css-1mlhis1').should('exist').find('#PENDING-11').should('exist');
cy.get('#list-11 > .css-1mlhis1 > .css-ux5pj > .css-mu8687 > .MuiTypography-body1').should('have.text', 11);
cy.get('#list-11 > .css-1mlhis1 > .css-18467a > .MuiChip-root').should('contain', '2023-03-23 08:29:18');
cy.get('#list-11 > .css-1mlhis1 > .css-18467a > .MuiChip-root').should('have.text', '2023-03-23 16:29:18');
cy.get('#list-11 > .css-1mlhis1 > .css-ux5pj > .css-mu8687 > .MuiTypography-body2').should(
'have.text',
'This is a preheat task with status pending',
Expand Down
5 changes: 2 additions & 3 deletions cypress/e2e/schedulers/schedulers.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('Schedulers', () => {

cy.signin();
cy.visit('clusters/1');
cy.viewport(1440, 1080);
cy.viewport(1440, 2080);
});

describe('when data is loaded', () => {
Expand Down Expand Up @@ -201,8 +201,7 @@ describe('Schedulers', () => {
cy.get('#scheduler-pagination > .MuiPagination-ul .Mui-selected').should('have.text', '2');

// Show scheduler information.
cy.get('#scheduler-table-body > :nth-child(1) > :nth-child(2)')
.scrollIntoView()
cy.get('#scheduler-table > .MuiTableBody-root > :nth-child(1) > :nth-child(2) > .MuiTypography-root')
.should('be.visible')
.and('contain', 'scheduler-11');

Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/seed-peers/seed-peer.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,13 @@ describe('Seed peer', () => {

describe('when no data is loaded', () => {
beforeEach(() => {
cy.intercept({ method: 'GET', url: '/api/v1/seed-peers/10' }, (req) => {
cy.intercept({ method: 'GET', url: '/api/v1/seed-peers/9' }, (req) => {
req.reply({
statusCode: 200,
body: [],
});
});
cy.visit('/clusters/1/seed-peers/9');
});

it('unable to display breadcrumb', () => {
Expand Down
7 changes: 1 addition & 6 deletions cypress/e2e/seed-peers/seed-peers.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Seed peers', () => {
);

cy.visit('clusters/1');
cy.viewport(1440, 1080);
cy.viewport(1440, 2080);
});

describe('when data is loaded', () => {
Expand All @@ -64,7 +64,6 @@ describe('Seed peers', () => {
it('can display seed peers table', () => {
// Show hostname.
cy.get('#seed-peer-table-body > :nth-child(1) > :nth-child(2)')
.scrollIntoView()
.should('be.visible')
.and('contain', 'seed-peer-10');

Expand Down Expand Up @@ -121,7 +120,6 @@ describe('Seed peers', () => {

it('there should be a message indicating that there is no seed peer', () => {
cy.get('#seed-peer-table-body > .MuiTableRow-root > .MuiTableCell-root')
.scrollIntoView()
.should('be.visible')
.and('contain', `You don't have seed peer cluster.`);
});
Expand Down Expand Up @@ -159,7 +157,6 @@ describe('Seed peers', () => {

it('there should be a message indicating that there is no seed peer', () => {
cy.get('#seed-peer-table-body > .MuiTableRow-root > .MuiTableCell-root')
.scrollIntoView()
.should('be.visible')
.and('contain', `You don't have seed peer cluster.`);
});
Expand Down Expand Up @@ -468,7 +465,6 @@ describe('Seed peers', () => {
cy.guestSignin();

cy.get('#seed-peer-table-body > :nth-child(1) > :nth-child(2)')
.scrollIntoView()
.should('be.visible')
.and('contain', 'seed-peer-10');

Expand All @@ -494,7 +490,6 @@ describe('Seed peers', () => {

it('should handle API error response', () => {
cy.get('#seed-peer-table-body > :nth-child(1) > :nth-child(2)')
.scrollIntoView()
.should('be.visible')
.and('contain', 'seed-peer-10');

Expand Down
18 changes: 18 additions & 0 deletions cypress/fixtures/job/preheats/failure-preheat.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
"CreatedAt": "2023-12-13T11:58:53.535716295Z",
"GroupUUID": "group_f60c3730-b718-45c7-98a5-014052c1c02a",
"JobStates": [
{
"CreatedAt": "2023-12-13T11:58:53.535716295Z",
"Error": "",
"Results": null,
"State": "STARTED",
"TTL": 0,
"TaskName": "preheat",
"TaskUUID": "task_8cd497e9-4748-45c3-acc4-db32aebe44ed3"
},
{
"CreatedAt": "2023-12-13T11:58:53.535716295Z",
"Error": "rpc error: code = Aborted desc = source response 401/401 Unauthorized is not valid",
Expand All @@ -32,6 +41,15 @@
"TTL": 0,
"TaskName": "preheat",
"TaskUUID": "task_8cd497e9-4748-45c3-acc4-db32aebe44ed3"
},
{
"CreatedAt": "2023-12-13T11:58:53.535716295Z",
"Error": "",
"Results": [],
"State": "SUCCESS",
"TTL": 0,
"TaskName": "preheat",
"TaskUUID": "task_8cd497e9-4748-45c3-acc4-db32aebe44ed3"
}
],
"State": "FAILURE"
Expand Down
6 changes: 0 additions & 6 deletions src/components/clusters/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ import { getCluster, updateCluster, getClusterResponse } from '../../lib/api';
import CancelIcon from '@mui/icons-material/Cancel';
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
import { useNavigate, useParams } from 'react-router-dom';
import LoadingBackdrop from '../loading-backdrop';

export default function EditCluster() {
const [successMessage, setSuccessMessage] = useState(false);
const [errorMessage, setErrorMessage] = useState(false);
const [errorMessageText, setErrorMessageText] = useState('');
const [pageLoding, setPageLoding] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [bioError, setBioError] = useState(false);
const [seedPeerLoadLimitError, setSeedPeerLoadLimitError] = useState(false);
Expand Down Expand Up @@ -86,18 +84,15 @@ export default function EditCluster() {
useEffect(() => {
(async function () {
try {
setPageLoding(true);
setIsLoading(true);

if (typeof params.id === 'string') {
const cluster = await getCluster(params.id);
setCluster(cluster);
setPageLoding(false);
setIsLoading(false);
}
} catch (error) {
if (error instanceof Error) {
setPageLoding(false);
setIsLoading(false);
setErrorMessage(true);
setErrorMessageText(error.message);
Expand Down Expand Up @@ -643,7 +638,6 @@ export default function EditCluster() {

return (
<Grid>
<LoadingBackdrop open={pageLoding} />
<Snackbar
open={successMessage}
autoHideDuration={3000}
Expand Down
6 changes: 0 additions & 6 deletions src/components/clusters/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import MoreTimeIcon from '@mui/icons-material/MoreTime';
import ArrowCircleRightIcon from '@mui/icons-material/ArrowCircleRight';
import { useNavigate } from 'react-router-dom';
import { DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE } from '../../lib/constants';
import LoadingBackdrop from '../loading-backdrop';

const theme = createTheme({
breakpoints: {
Expand All @@ -59,7 +58,6 @@ const theme = createTheme({
export default function Clusters() {
const [errorMessage, setErrorMessage] = useState(false);
const [errorMessageText, setErrorMessageText] = useState('');
const [pageLoding, setPageLoding] = useState(false);
const [isLoading, setIsLoading] = useState(true);
const [clusterIsLoading, setClusterIsLoading] = useState(true);
const [clusterPage, setClusterPage] = useState(1);
Expand All @@ -77,7 +75,6 @@ export default function Clusters() {
useEffect(() => {
(async function () {
try {
setPageLoding(true);
setIsLoading(true);
setClusterIsLoading(true);
setClusterPage(page);
Expand All @@ -92,14 +89,12 @@ export default function Clusters() {
setScheduler(scheduler);
setSeedPeer(seedPeer);
setClusterCount(cluster);
setPageLoding(false);
setIsLoading(false);
setClusterIsLoading(false);
} catch (error) {
if (error instanceof Error) {
setErrorMessage(true);
setErrorMessageText(error.message);
setPageLoding(false);
setIsLoading(false);
}
}
Expand Down Expand Up @@ -179,7 +174,6 @@ export default function Clusters() {

return (
<Box flex="1">
<LoadingBackdrop open={pageLoding} />
<Snackbar
open={errorMessage}
autoHideDuration={3000}
Expand Down
Loading

0 comments on commit c3c0e40

Please sign in to comment.