Skip to content

Commit

Permalink
fix: preheat page switching state to initiate multiple requests (#392)
Browse files Browse the repository at this point in the history
Signed-off-by: zhaoxinxin <[email protected]>
  • Loading branch information
Liam-Zhao authored Sep 12, 2024
1 parent 402e683 commit feda25f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions cypress/e2e/job/preheats/create-preheat.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Create preheat', () => {
cy.intercept(
{
method: 'GET',
url: '/api/v1/jobs?page=1&per_page=10',
url: '/api/v1/jobs?page=1&per_page=10&type=preheat',
},
(req) => {
req.reply((res: any) => {
Expand Down Expand Up @@ -77,7 +77,7 @@ describe('Create preheat', () => {
cy.intercept(
{
method: 'GET',
url: '/api/v1/jobs?page=1&per_page=10',
url: '/api/v1/jobs?page=1&per_page=10&type=preheat',
},
(req) => {
req.reply((res: any) => {
Expand Down Expand Up @@ -171,7 +171,7 @@ describe('Create preheat', () => {
cy.intercept(
{
method: 'GET',
url: '/api/v1/jobs?page=1&per_page=10',
url: '/api/v1/jobs?page=1&per_page=10&type=preheat',
},
(req) => {
req.reply((res: any) => {
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 @@ -12,7 +12,7 @@ describe('Preheat', () => {
cy.intercept(
{
method: 'GET',
url: '/api/v1/jobs?page=1&per_page=10',
url: '/api/v1/jobs?page=1&per_page=10&type=preheat',
},
(req) => {
req.reply((res: any) => {
Expand Down
18 changes: 9 additions & 9 deletions cypress/e2e/job/preheats/preheats.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('Preheats', () => {
cy.intercept(
{
method: 'GET',
url: '/api/v1/jobs?page=1&per_page=10',
url: '/api/v1/jobs?page=1&per_page=10&type=preheat',
},
(req) => {
req.reply((res: any) => {
Expand All @@ -28,7 +28,7 @@ describe('Preheats', () => {
cy.intercept(
{
method: 'GET',
url: '/api/v1/jobs?page=2&per_page=10',
url: '/api/v1/jobs?page=2&per_page=10&type=preheat',
},
(req) => {
req.reply((res: any) => {
Expand All @@ -52,7 +52,7 @@ describe('Preheats', () => {
cy.intercept(
{
method: 'GET',
url: '/api/v1/jobs?page=1&per_page=10',
url: '/api/v1/jobs?page=1&per_page=10&type=preheat',
},
(req) => {
req.reply((res: any) => {
Expand Down Expand Up @@ -115,7 +115,7 @@ describe('Preheats', () => {
cy.intercept(
{
method: 'GET',
url: '/api/v1/jobs?page=1&per_page=10&state=SUCCESS',
url: '/api/v1/jobs?page=1&per_page=10&state=SUCCESS&type=preheat',
},
(req) => {
req.reply((res: any) => {
Expand All @@ -141,7 +141,7 @@ describe('Preheats', () => {
cy.intercept(
{
method: 'GET',
url: '/api/v1/jobs?page=1&per_page=10&state=FAILURE',
url: '/api/v1/jobs?page=1&per_page=10&state=FAILURE&type=preheat',
},
(req) => {
req.reply((res: any) => {
Expand All @@ -167,7 +167,7 @@ describe('Preheats', () => {
cy.intercept(
{
method: 'GET',
url: '/api/v1/jobs?page=1&per_page=10&state=PENDING',
url: '/api/v1/jobs?page=1&per_page=10&state=PENDING&type=preheat',
},
(req) => {
req.reply((res: any) => {
Expand Down Expand Up @@ -199,7 +199,7 @@ describe('Preheats', () => {
cy.intercept(
{
method: 'GET',
url: '/api/v1/jobs?page=1&per_page=10&state=PENDING',
url: '/api/v1/jobs?page=1&per_page=10&state=PENDING&type=preheat',
},
(req) => {
req.reply({
Expand All @@ -220,7 +220,7 @@ describe('Preheats', () => {
cy.intercept(
{
method: 'GET',
url: '/api/v1/jobs?page=1&per_page=10',
url: '/api/v1/jobs?page=1&per_page=10&type=preheat',
},
(req) => {
req.reply((res: any) => {
Expand All @@ -245,7 +245,7 @@ describe('Preheats', () => {
cy.intercept(
{
method: 'GET',
url: '/api/v1/jobs?page=1&per_page=10',
url: '/api/v1/jobs?page=1&per_page=10&type=preheat',
},
(req) => {
req.reply({
Expand Down
3 changes: 1 addition & 2 deletions src/components/job/preheats/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ export default function Preheats() {

const changeStatus = (event: any) => {
setStatus(event.target.value);
setShouldPoll(true);
setPreheatPage(1);
navigate(`/jobs/preheats`);
};

const handleClose = (_event: any, reason?: string) => {
Expand Down
11 changes: 6 additions & 5 deletions src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,10 @@ interface updateSchedulerFeatruesRequset {
features: Array<string>;
}

export async function updateSchedulerFeatrues(id: string,request: updateSchedulerFeatruesRequset,): Promise<getSchedulerResponse> {
export async function updateSchedulerFeatrues(
id: string,
request: updateSchedulerFeatruesRequset,
): Promise<getSchedulerResponse> {
const url = new URL(`/api/v1/schedulers/${id}`, API_URL);
const response = await patch(url, request);
return await response.json();
Expand Down Expand Up @@ -712,10 +715,8 @@ interface getJobsResponse {
total_page?: number;
}

export async function getJobs(params?: getJobsParams): Promise<getJobsResponse> {
const url = params
? new URL(`/api/v1/jobs?${queryString.stringify(params)}`, API_URL)
: new URL('/api/v1/jobs', API_URL);
export async function getJobs(params: getJobsParams): Promise<getJobsResponse> {
const url = new URL(`/api/v1/jobs?${queryString.stringify(params)}&type=preheat`, API_URL);

const response = await get(url);
const data = await response.json();
Expand Down

0 comments on commit feda25f

Please sign in to comment.