diff --git a/frontend/cypress.config.ts b/frontend/cypress.config.ts index 23b0bf613..83494e036 100644 --- a/frontend/cypress.config.ts +++ b/frontend/cypress.config.ts @@ -33,7 +33,8 @@ export default defineConfig({ '**/a-class-seedlot-reg-form-parent-tree-part-2.cy.ts', '**/a-class-seedlot-reg-form-parent-tree-part-3.cy.ts', '**/create-a-class-seedlot-fdi.cy.ts', - '**/a-class-seedlot-reg-form-parent-tree-calculations-part-1.cy.ts' + '**/a-class-seedlot-reg-form-parent-tree-calculations-part-1.cy.ts', + '**/api-tests.cy.ts' ], chromeWebSecurity: false, retries: { diff --git a/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-orchard.cy.ts b/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-orchard.cy.ts index b3deaff62..fc5270bc3 100644 --- a/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-orchard.cy.ts +++ b/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-orchard.cy.ts @@ -1,7 +1,6 @@ import prefix from '../../../src/styles/classPrefix'; -import { THIRTY_SECONDS } from '../../constants'; +import { THIRTY_SECONDS, TYPE_DELAY } from '../../constants'; import { SeedlotRegFixtureType } from '../../definitions'; -import { TYPE_DELAY } from '../../constants'; describe('A Class Seedlot Registration form, Orchard', () => { let regFormData: { @@ -325,7 +324,6 @@ describe('A Class Seedlot Registration form, Orchard', () => { .eq(i) .find('td:nth-child(1)') .invoke('text') - // eslint-disable-next-line no-loop-func .then(($number) => { parentTreeSet.add($number); }); @@ -409,7 +407,6 @@ describe('A Class Seedlot Registration form, Orchard', () => { .eq(i) .find('td:nth-child(1)') .invoke('text') - // eslint-disable-next-line no-loop-func .then(($number) => { unionParentTreeArray.push($number); if (i === lengthOfArray - 1) { @@ -558,7 +555,7 @@ describe('A Class Seedlot Registration form, Orchard', () => { cy.get('#orchard-is-regional') .should('be.checked'); - + cy.get('#orchard-breading-perc-helper-text') .should('have.text', regFormData.orchard.pollenHelperText); diff --git a/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-ownership.cy.ts b/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-ownership.cy.ts index 19c44eb66..ac512bfc8 100644 --- a/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-ownership.cy.ts +++ b/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-ownership.cy.ts @@ -68,14 +68,14 @@ describe('A Class Seedlot Registration form, Ownership', () => { // Check the checkbox if unchecked cy.get('#default-owner-checkbox') - .then($checkbox => { + .then(($checkbox) => { if ($checkbox.is(':not(:checked)')) { cy.get('#default-owner-checkbox').check({ force: true }); // Save changes cy.saveSeedlotRegFormProgress(); } }) - .should("be.checked"); + .should('be.checked'); cy.get(`.${prefix}--accordion__title`) .find('.item-title-section') diff --git a/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-parent-tree-calculations-part-1.cy.ts b/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-parent-tree-calculations-part-1.cy.ts index 6855579a0..c47cbb0f9 100644 --- a/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-parent-tree-calculations-part-1.cy.ts +++ b/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-parent-tree-calculations-part-1.cy.ts @@ -4,8 +4,8 @@ describe('A Class Seedlot Registration form, Parent Tree Calculations Part 1', ( let seedlotNum: string; const speciesKey = 'fdi'; let totalParentTrees: number = 0; - let totalConeCount: number = 0; - let totalPollenCount: number = 0; + const coneCount: number[] = [0]; + const pollenCount: number[] = [0]; let effectivePopulationSize: number = 0; let firstConeValue: number = 0; let firstPollenValue: number = 0; @@ -99,39 +99,39 @@ describe('A Class Seedlot Registration form, Parent Tree Calculations Part 1', ( totalParentTrees = row.length; cy.get('#totalnumber\\ of\\ parent\\ trees') .should('have.value', totalParentTrees); - // Get total cone counts for (let i = 0; i < totalParentTrees; i += 1) { + // Initialize total cone count + const localParentTreeTotal = totalParentTrees; cy.get('.parent-tree-step-table-container-col') .find('table tbody tr') .eq(i) .find('td:nth-child(2) input') .invoke('val') .then(($value: any) => { - totalConeCount = totalConeCount + Number($value); - - if (i === (totalParentTrees - 1)) { + coneCount[0] += Number($value); + if (i === (localParentTreeTotal - 1)) { // Check total cone counts cy.get('#totalnumber\\ of\\ cone\\ count') - .should('have.value', totalConeCount); + .should('have.value', coneCount[0]); } }); } - // Get total pollen counts for (let i = 0; i < totalParentTrees; i += 1) { + // Initialize total pollen count + const localParentTreeTotal = totalParentTrees; cy.get('.parent-tree-step-table-container-col') .find('table tbody tr') .eq(i) - .find('td:nth-child(3) input') + .find('td:nth-child(3) input') // Assuming pollen count is in the 3rd column .invoke('val') - .then(($value) => { - totalPollenCount = totalPollenCount + Number($value); - - if (i === (totalParentTrees - 1)) { + .then(($value: any) => { + pollenCount[0] += Number($value); + if (i === (localParentTreeTotal - 1)) { // Check total pollen counts cy.get('#totalnumber\\ of\\ pollen\\ count') - .should('have.value', totalPollenCount); + .should('have.value', pollenCount[0]); } }); } @@ -143,6 +143,7 @@ describe('A Class Seedlot Registration form, Parent Tree Calculations Part 1', ( .contains('Calculate metrics') .click(); + // eslint-disable-next-line cypress/no-unnecessary-waiting cy.wait(3000); // Store Ne value to a variable @@ -174,7 +175,7 @@ describe('A Class Seedlot Registration form, Parent Tree Calculations Part 1', ( // Check new total cone count cy.get('#totalnumber\\ of\\ cone\\ count') - .should('have.value', (totalConeCount - firstConeValue)); + .should('have.value', (coneCount[0] - firstConeValue)); }); cy.get('#8021-pollenCount-value-input') @@ -195,7 +196,7 @@ describe('A Class Seedlot Registration form, Parent Tree Calculations Part 1', ( // Check new total pollen count cy.get('#totalnumber\\ of\\ pollen\\ count') - .should('have.value', (totalPollenCount - firstPollenValue)); + .should('have.value', (pollenCount[0] - firstPollenValue)); }); // Click 'Calculate metrics' button again @@ -204,12 +205,13 @@ describe('A Class Seedlot Registration form, Parent Tree Calculations Part 1', ( .contains('Calculate metrics') .click(); + // eslint-disable-next-line cypress/no-unnecessary-waiting cy.wait(3000); // Check Ne value after clearing first parent tree row cy.get('#effectivepopulation\\ size\\ \\(ne\\)') .invoke('val') - .then($value => { + .then(($value) => { expect(Number($value)).to.be.lessThan(Number(effectivePopulationSize)); }); }); diff --git a/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-parent-tree-part-1.cy.ts b/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-parent-tree-part-1.cy.ts index a8ec97a73..7286cdd93 100644 --- a/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-parent-tree-part-1.cy.ts +++ b/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-parent-tree-part-1.cy.ts @@ -43,7 +43,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and // Check primary orchard cy.get('#primary-orchard-selection') - .then($input => { + .then(($input) => { const value = $input.val(); if (value === '') { cy.log('Primary input is empty'); @@ -51,7 +51,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and cy.get('#primary-orchard-selection') .siblings(`button.${prefix}--list-box__menu-icon[title="Open"]`) .click(); - + cy.get(`.${prefix}--list-box--expanded`) .find('ul li') .contains('219 - VERNON - S - PRD') @@ -79,7 +79,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and // Check secondary orchard cy.get('#secondary-orchard-selection') - .then($input => { + .then(($input) => { const value = $input.val(); if (value === '') { cy.log('Secondary input is empty'); @@ -87,7 +87,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and cy.get('#secondary-orchard-selection') .siblings(`button.${prefix}--list-box__menu-icon[title="Open"]`) .click(); - + cy.get(`.${prefix}--list-box--expanded`) .find('ul li') .contains('222 - VERNON - S - PRD') @@ -220,7 +220,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and .clear() .type('0.00000000001') .blur(); - + cy.get('@errorDialog') .should('have.text', regFormData.parentTree.coneErrorMsg); @@ -229,7 +229,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and .clear() .type('1') .blur(); - + cy.get(`.${prefix}--actionable-notification--error`) .should('not.exist'); @@ -249,16 +249,16 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and .clear() .type('10000000001') .blur(); - + cy.get('@errorDialog') .should('have.text', regFormData.parentTree.pollenErrorMsg); - + // Check error message for Pollen count value > 10 decimal places cy.get('#212-pollenCount-value-input') .clear() .type('0.00000000001') .blur(); - + cy.get('@errorDialog') .should('have.text', regFormData.parentTree.pollenErrorMsg); @@ -300,7 +300,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and .eq(0) .find('button') .as('clickShowHideBtn') - .click({force: true}); + .click({ force: true }); cy.get('ul.parent-tree-table-toggle-menu') .find('li') @@ -318,7 +318,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and // Click 'Comandra blister rust (DSC)' checkbox cy.get('@clickShowHideBtn') - .click({force: true}); + .click({ force: true }); cy.get('ul.parent-tree-table-toggle-menu') .find('li') @@ -334,7 +334,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and // Click 'Western gall rust (DSG)' checkbox cy.get('@clickShowHideBtn') - .click({force: true}); + .click({ force: true }); cy.get('ul.parent-tree-table-toggle-menu') .find('li') @@ -350,7 +350,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and // Click 'Volume growth (GVO)' checkbox cy.get('@clickShowHideBtn') - .click({force: true}); + .click({ force: true }); cy.get('ul.parent-tree-table-toggle-menu') .find('li') @@ -392,7 +392,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and .click(); cy.readFile(`${Cypress.config('downloadsFolder')}/Seedlot_composition_template.csv`); - + // Enter values in Cone count and Pollen count columns of the table cy.get('#212-coneCount-value-input') .clear() @@ -492,14 +492,14 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and // Check file upload functionality cy.get('button.upload-button') - .click({force: true}); + .click({ force: true }); cy.get(`.${prefix}--modal-container[aria-label="Seedlot registration"]`) .should('be.visible'); cy.get(`.${prefix}--file`) .find(`input.${prefix}--file-input`) - .selectFile('cypress/fixtures/Seedlot_composition_template.csv', {force: true}); + .selectFile('cypress/fixtures/Seedlot_composition_template.csv', { force: true }); cy.get('button') .contains('Import file and continue') @@ -552,7 +552,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and cy.get(`table.${prefix}--data-table tbody`) .find('tr') .then(($row) => { - expect($row.length).equal(parseInt(dropdownNumber)); + expect($row.length).equal(parseInt(dropdownNumber, 10)); }); // Page number dropdown @@ -572,7 +572,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and cy.get(`.${prefix}--pagination__control-buttons`) .find(`button.${prefix}--pagination__button--forward`) .click(); - + cy.get(`.${prefix}--pagination__right`) .find(`select.${prefix}--select-input`) .should('have.value', '2'); diff --git a/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-parent-tree-part-2.cy.ts b/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-parent-tree-part-2.cy.ts index 23bdc851e..b5a18afcc 100644 --- a/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-parent-tree-part-2.cy.ts +++ b/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-parent-tree-part-2.cy.ts @@ -1,5 +1,4 @@ import prefix from '../../../src/styles/classPrefix'; -import { THIRTY_SECONDS } from '../../constants'; describe('A Class Seedlot Registration form, Parent Tree and SMP part-2(SMP success on parent)', () => { let regFormData: { @@ -55,7 +54,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-2(SMP succ .should('not.be.checked'); cy.get('#smp-default-vals-checkbox') - .check({ force: true}); + .check({ force: true }); cy.get('.smp-default-input-row') .should('be.visible'); @@ -66,7 +65,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-2(SMP succ cy.get('#parentTreeNumber', { timeout: 10000 }); cy.get('#smp-default-vals-checkbox') - .check({force: true}); + .check({ force: true }); cy.get('.smp-default-input-row') .should('be.visible'); @@ -230,7 +229,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-2(SMP succ .eq(0) .find('button') .as('clickShowHideBtn') - .click({force: true}); + .click({ force: true }); cy.get('ul.parent-tree-table-toggle-menu') .find('li') @@ -248,7 +247,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-2(SMP succ // Click 'Comandra blister rust (DSC)' checkbox cy.get('@clickShowHideBtn') - .click({force: true}); + .click({ force: true }); cy.get('ul.parent-tree-table-toggle-menu') .find('li') @@ -264,7 +263,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-2(SMP succ // Click 'Western gall rust (DSG)' checkbox cy.get('@clickShowHideBtn') - .click({force: true}); + .click({ force: true }); cy.get('ul.parent-tree-table-toggle-menu') .find('li') @@ -280,7 +279,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-2(SMP succ // Click 'Volume growth (GVO)' checkbox cy.get('@clickShowHideBtn') - .click({force: true}); + .click({ force: true }); cy.get('ul.parent-tree-table-toggle-menu') .find('li') @@ -362,7 +361,8 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-2(SMP succ .contains('Clean table data') .click(); - // Check values in 'SMP success on parent (%)' and 'Non-orchard pollen contam. (%)' columns of the table + // Check values in 'SMP success on parent (%)' + // and 'Non-orchard pollen contam. (%)' columns of the table cy.get('#212-smpSuccessPerc-value-input') .should('have.value', ''); @@ -377,7 +377,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-2(SMP succ // Check upload button functionality cy.get('button.upload-button') - .click({force: true}); + .click({ force: true }); cy.get(`.${prefix}--modal-container[aria-label="Seedlot registration"]`) .should('be.visible'); @@ -391,20 +391,21 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-2(SMP succ // Check file upload functionality cy.get('button.upload-button') - .click({force: true}); + .click({ force: true }); cy.get(`.${prefix}--modal-container[aria-label="Seedlot registration"]`) .should('be.visible'); cy.get(`.${prefix}--file`) .find(`input.${prefix}--file-input`) - .selectFile('cypress/fixtures/Seedlot_composition_template_02.csv', {force: true}); + .selectFile('cypress/fixtures/Seedlot_composition_template_02.csv', { force: true }); cy.get('button') .contains('Import file and continue') .click(); - // Compare values in 'SMP success on parent (%)' and 'Non-orchard pollen contam. (%)' columns of the table with the csv file + // Compare values in 'SMP success on parent (%)' + // and 'Non-orchard pollen contam. (%)' columns of the table with the csv file cy.get('#212-smpSuccessPerc-value-input') .should('have.value', '1'); diff --git a/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-parent-tree-part-3.cy.ts b/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-parent-tree-part-3.cy.ts index 6391dcab5..e1f1f0be4 100644 --- a/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-parent-tree-part-3.cy.ts +++ b/frontend/cypress/e2e/smoke-test/a-class-seedlot-reg-form-parent-tree-part-3.cy.ts @@ -54,14 +54,14 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat .eq(0) .find('button') .as('clickAddRowBtn') - .click({force: true}); + .click({ force: true }); // Check total number of rows cy.get(`.${prefix}--pagination__items-count`) .should('include.text', '21 items'); cy.get('@clickAddRowBtn') - .click({force: true}); + .click({ force: true }); // Check total number of rows cy.get(`.${prefix}--pagination__items-count`) @@ -70,7 +70,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat // Check delete button functionality cy.get('#7-action-btn-del') .find('button') - .click({ force: true}); + .click({ force: true }); // Check total number of rows cy.get(`.${prefix}--pagination__items-count`) @@ -86,7 +86,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat .eq(1) .find('button') .as('clickShowHideBtn') - .click({force: true}); + .click({ force: true }); cy.get('ul.parent-tree-table-toggle-menu') .find('li') @@ -96,7 +96,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat cy.get('.parent-tree-step-table-container') .find('h4') .as('closeShowHideDropdown') - .click({force: true}); + .click({ force: true }); cy.get('thead.table-header') .find('#dfs') @@ -104,7 +104,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat // Click 'Comandra blister rust (DSC)' checkbox cy.get('@clickShowHideBtn') - .click({force: true}); + .click({ force: true }); cy.get('ul.parent-tree-table-toggle-menu') .find('li') @@ -112,7 +112,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat .click(); cy.get('@closeShowHideDropdown') - .click({force: true}); + .click({ force: true }); cy.get('thead.table-header') .find('#dsc') @@ -120,7 +120,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat // Click 'Western gall rust (DSG)' checkbox cy.get('@clickShowHideBtn') - .click({force: true}); + .click({ force: true }); cy.get('ul.parent-tree-table-toggle-menu') .find('li') @@ -128,7 +128,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat .click(); cy.get('@closeShowHideDropdown') - .click({force: true}); + .click({ force: true }); cy.get('thead.table-header') .find('#dsg') @@ -136,7 +136,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat // Click 'Volume growth (GVO)' checkbox cy.get('@clickShowHideBtn') - .click({force: true}); + .click({ force: true }); cy.get('ul.parent-tree-table-toggle-menu') .find('li') @@ -144,7 +144,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat .click(); cy.get('@closeShowHideDropdown') - .click({force: true}); + .click({ force: true }); cy.get('thead.table-header') .find('#gvo') @@ -152,15 +152,15 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat // Click 'Weighted DFS' checkbox cy.get('@clickShowHideBtn') - .click({force: true}); - + .click({ force: true }); + cy.get('ul.parent-tree-table-toggle-menu') .find('li') .contains('Weighted DFS') .click(); cy.get('@closeShowHideDropdown') - .click({force: true}); + .click({ force: true }); cy.get('thead.table-header') .find('#w_dfs') @@ -168,15 +168,15 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat // Click 'Weighted DSC' checkbox cy.get('@clickShowHideBtn') - .click({force: true}); - + .click({ force: true }); + cy.get('ul.parent-tree-table-toggle-menu') .find('li') .contains('Weighted DSC') .click(); cy.get('@closeShowHideDropdown') - .click({force: true}); + .click({ force: true }); cy.get('thead.table-header') .find('#w_dsc') @@ -184,15 +184,15 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat // Click 'Weighted DSG' checkbox cy.get('@clickShowHideBtn') - .click({force: true}); - + .click({ force: true }); + cy.get('ul.parent-tree-table-toggle-menu') .find('li') .contains('Weighted DSG') .click(); cy.get('@closeShowHideDropdown') - .click({force: true}); + .click({ force: true }); cy.get('thead.table-header') .find('#w_dsg') @@ -200,15 +200,15 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat // Click 'Weighted GVO' checkbox cy.get('@clickShowHideBtn') - .click({force: true}); - + .click({ force: true }); + cy.get('ul.parent-tree-table-toggle-menu') .find('li') .contains('Weighted GVO') .click(); cy.get('@closeShowHideDropdown') - .click({force: true}); + .click({ force: true }); cy.get('thead.table-header') .find('#w_gvo') @@ -235,7 +235,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat // Click 'Clean table data' option cy.get('@clickMoreOptionsBtn') - .click({force: true}); + .click({ force: true }); cy.get('ul.parent-tree-table-option-menu') .find('li') @@ -257,10 +257,10 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat // Check 'X' button of 'Clean table data' dialog box cy.get('@clickMoreOptionsBtn') - .click({force: true}); + .click({ force: true }); cy.get('@clickCleanTableBtn') - .click({force: true}); + .click({ force: true }); cy.get(`.${prefix}--modal-container[aria-label="Clean table data"]`) .find('button') @@ -272,17 +272,18 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat // Check 'Clean table data' button of 'Clean table data' dialog box cy.get('@clickMoreOptionsBtn') - .click({force: true}); + .click({ force: true }); cy.get('@clickCleanTableBtn') - .click({force: true}); + .click({ force: true }); cy.get(`.${prefix}--modal-container[aria-label="Clean table data"]`) .find('button') .contains('Clean table data') .click(); - // Check values in 'SMP success on parent (%)' and 'Non-orchard pollen contam. (%)' columns of the table + // Check values in 'SMP success on parent (%)' + // and 'Non-orchard pollen contam. (%)' columns of the table cy.get('#0-volume-value-input') .should('have.value', ''); @@ -291,7 +292,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat // Check upload button functionality cy.get('button.upload-button') - .click({force: true}); + .click({ force: true }); cy.get(`.${prefix}--modal-container[aria-label="Seedlot registration"]`) .should('be.visible'); @@ -305,14 +306,14 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat // Check file upload functionality cy.get('button.upload-button') - .click({force: true}); + .click({ force: true }); cy.get(`.${prefix}--modal-container[aria-label="Seedlot registration"]`) .should('be.visible'); cy.get(`.${prefix}--file`) .find(`input.${prefix}--file-input`) - .selectFile('cypress/fixtures/Seedlot_composition_template_03.csv', {force: true}); + .selectFile('cypress/fixtures/Seedlot_composition_template_03.csv', { force: true }); cy.get('button') .contains('Import file and continue') @@ -343,12 +344,12 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat cy.get(`.${prefix}--toolbar-content > span`) .eq(2) .find('button') - .click({force: true}); + .click({ force: true }); cy.get('ul.parent-tree-table-option-menu') .find('li') .contains('Clean table data') - .click({force: true}); + .click({ force: true }); cy.get(`.${prefix}--modal-container[aria-label="Clean table data"]`) .find('button') @@ -448,7 +449,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat cy.get('.parent-tree-step-table-container') .find('h4') .as('waitClick') - .click({force: true}); + .click({ force: true }); // Check proportion value cy.get('#0-proportion-value') @@ -479,7 +480,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-3(Calculat .blur(); cy.get('@waitClick') - .click({force: true}); + .click({ force: true }); cy.get('#0-proportion-value') .should('have.text', '0.2500'); diff --git a/frontend/cypress/e2e/smoke-test/api-tests.cy.ts b/frontend/cypress/e2e/smoke-test/api-tests.cy.ts new file mode 100644 index 000000000..5b33e31cd --- /dev/null +++ b/frontend/cypress/e2e/smoke-test/api-tests.cy.ts @@ -0,0 +1,39 @@ +import { SeedlotRegFixtureType } from '../../definitions'; + +describe('Applicant and seedlot information page', () => { + let seedlotNumber: string; + let fixtureData: SeedlotRegFixtureType; + + beforeEach(() => { + cy.fixture('aclass-seedlot').then((fData) => { + fixtureData = fData; + cy.task('getData', fData.fdi.species).then((sNumber) => { + seedlotNumber = sNumber as string; + }); + }); + + cy.login(); + }); + + it('GET /api/seedlots to fetch seedlot details', () => { + const regData = fixtureData.fdi; + cy.intercept('GET', `/api/seedlots/${seedlotNumber}`).as('getSeedlot'); + + cy.visit(`/seedlots/details/${seedlotNumber}`); + cy.wait('@getSeedlot').then((interception) => { + // Check that the request method is GET + expect(interception.response?.statusCode).to.eq(200); + + // Check the response body + const responseBody = interception.response?.body.seedlot; + expect(responseBody).to.have.property('applicantLocationCode', regData.agencyNumber); + }); + }); + + it('404 test', () => { + // Visit a non-existent URL + cy.visit('/dashboard1', { failOnStatusCode: false }).then(() => { + cy.get('h1').should('contain', 'Page not found'); + }); + }); +}); diff --git a/frontend/cypress/e2e/smoke-test/create-a-class-seedlot-fdi.cy.ts b/frontend/cypress/e2e/smoke-test/create-a-class-seedlot-fdi.cy.ts index f55b5ce94..9f3e8f4b4 100644 --- a/frontend/cypress/e2e/smoke-test/create-a-class-seedlot-fdi.cy.ts +++ b/frontend/cypress/e2e/smoke-test/create-a-class-seedlot-fdi.cy.ts @@ -1,4 +1,4 @@ -import { TYPE_DELAY } from 'cypress/constants'; +import { TYPE_DELAY } from '../../constants'; import prefix from '../../../src/styles/classPrefix'; import { SeedlotRegFixtureType } from '../../definitions'; @@ -15,6 +15,9 @@ describe('Create FDI Seedlot', () => { it('Register fdi seedlot', () => { const regData = fixtureData.fdi; + // Intercept the POST request + cy.intercept('POST', '/api/seedlots').as('postSeedlot'); + // Enter the applicant agency number cy.get('#agency-number-input') .clear() @@ -62,5 +65,15 @@ describe('Create FDI Seedlot', () => { cy.task('setData', [regData.species, seedlotNumber]); }); cy.log('A-Class seedlot created with species', regData.species); + + // Wait for the intercepted request and verify its response + cy.wait('@postSeedlot').then((interception) => { + // Check that the request method is POST + expect(interception.response?.statusCode).to.eq(201); + + // Check the request body + const requestBody = interception.request.body; + expect(requestBody).to.have.property('applicantEmailAddress', regData.email); + }); }); });