Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 1807 backend tests cypress #1811

Merged
merged 10 commits into from
Jan 21, 2025
Merged
3 changes: 2 additions & 1 deletion frontend/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down Expand Up @@ -558,7 +557,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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-loop-func */
ngunner15 marked this conversation as resolved.
Show resolved Hide resolved
import prefix from '../../../src/styles/classPrefix';

describe('A Class Seedlot Registration form, Parent Tree Calculations Part 1', () => {
Expand Down Expand Up @@ -108,8 +109,7 @@ describe('A Class Seedlot Registration form, Parent Tree Calculations Part 1', (
.find('td:nth-child(2) input')
.invoke('val')
.then(($value: any) => {
totalConeCount = totalConeCount + Number($value);

totalConeCount += Number($value);
if (i === (totalParentTrees - 1)) {
// Check total cone counts
cy.get('#totalnumber\\ of\\ cone\\ count')
Expand All @@ -126,7 +126,7 @@ describe('A Class Seedlot Registration form, Parent Tree Calculations Part 1', (
.find('td:nth-child(3) input')
.invoke('val')
.then(($value) => {
totalPollenCount = totalPollenCount + Number($value);
totalPollenCount += Number($value);

if (i === (totalParentTrees - 1)) {
// Check total pollen counts
Expand All @@ -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
Expand Down Expand Up @@ -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));
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ 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');
// Do something if the input is empty
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')
Expand Down Expand Up @@ -79,15 +79,15 @@ 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');
// Do something if the input is empty
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')
Expand Down Expand Up @@ -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);

Expand All @@ -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');

Expand All @@ -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);

Expand Down Expand Up @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand All @@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down Expand Up @@ -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');
Expand All @@ -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');
Expand Down Expand Up @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand Down Expand Up @@ -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', '');

Expand All @@ -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');
Expand All @@ -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');

Expand Down
Loading
Loading