Skip to content

Commit af8b9d2

Browse files
fix(frontend): #2336 fix mositure content cypress test
1 parent 043dc85 commit af8b9d2

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

frontend/cypress/e2e/smoke-test-05/41-moisture-content.cy.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ describe('Moisture Content Screen page', () => {
166166
.find('td:nth-last-child(1) svg')
167167
.click();
168168

169+
// Wait for the delete API to finish
170+
cy.wait('@deleteReplicate');
171+
169172
// Assert row count stabilizes
170173
cy.get('.activity-result-container tbody tr')
171174
.should('have.length', 3);
@@ -686,7 +689,7 @@ describe('Moisture Content Screen page', () => {
686689
});
687690

688691
it('Check Calculate average button functionality', () => {
689-
// Wait for table to have at least one row with content
692+
// Wait for the table to have at least one row
690693
cy.waitForTableData('.activity-result-container');
691694

692695
// Click the 'Calculate average' button
@@ -695,12 +698,16 @@ describe('Moisture Content Screen page', () => {
695698
.contains('Calculate average')
696699
.click();
697700

698-
// Wait for the mocked POST request and load fixture
699-
cy.wait('@postCalcAvg').then((interception) => {
700-
expect(interception.response!.statusCode).to.eq(200);
701+
// Wait for the POST request and assert the response
702+
cy.wait('@postCalcAvg').then(({ response }) => {
703+
// Make sure response exists
704+
if (!response) throw new Error('Intercepted response is undefined');
705+
706+
// Assert status code
707+
expect(response.statusCode).to.eq(200);
701708

702-
// Get the mocked average from the fixture
703-
const { body: { averageMc } } = interception.response!;
709+
// Destructure the mocked averageMc from the response body
710+
const { averageMc } = response.body;
704711

705712
// Assert the displayed average matches the mocked value
706713
cy.get('.activity-summary')
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
171.0
1+
{
2+
"averageMc": 171.0
3+
}

frontend/cypress/support/mockApiConsep.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@ export function mockMoistureContentApi() {
1717
{ method: 'POST', url: '**/api/moisture-content-cone/514330/calculate-average' },
1818
{ statusCode: 200, fixture: 'moisture-content-cal-avg.json' }
1919
).as('postCalcAvg');
20+
21+
cy.intercept(
22+
{ method: 'DELETE', url: '**/api/moisture-content-cone/514330/*' },
23+
{ statusCode: 200, fixture: 'seedlot-replicate-info.json' }
24+
).as('deleteReplicate');
2025
}

0 commit comments

Comments
 (0)