Skip to content

Commit

Permalink
feat: merge 1454 branch's cypress code
Browse files Browse the repository at this point in the history
  • Loading branch information
ngunner15 committed Oct 4, 2024
1 parent 6ee8fa5 commit 147b3c4
Show file tree
Hide file tree
Showing 10 changed files with 586 additions and 41 deletions.
1 change: 1 addition & 0 deletions frontend/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default defineConfig({
'**/a-class-seedlot-reg-form-orchard.cy.ts',
'**/a-class-seedlot-reg-form-extraction.cy.ts',
'**/a-class-seedlot-reg-form-parent-tree-part-1.cy.ts',
'**/a-class-seedlot-reg-form-parent-tree-part-2.cy.ts',
'**/a-class-seedlot-reg-form-parent-tree-part-3.cy.ts'
],
chromeWebSecurity: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ describe('A Class Seedlot Registration form, Collection and Interim storage', ()

cy.get('#collection-location-code')
.should('have.value', locationCode);

// Save changes
cy.saveSeedlotRegFormProgress();
});

// Enter location code for linkage test
Expand Down Expand Up @@ -306,6 +309,12 @@ describe('A Class Seedlot Registration form, Collection and Interim storage', ()
});

it('[Collection] Checkbox input', () => {
// Change inputs
cy.get('#collection-step-default-checkbox')
.focus()
.check({ force: true })
.blur();

cy.get('#cone-collection-method-checkbox-1')
.focus()
.check({ force: true })
Expand All @@ -316,6 +325,9 @@ describe('A Class Seedlot Registration form, Collection and Interim storage', ()
.type('Test comment')
.blur();

// Save changes
cy.saveSeedlotRegFormProgress();

// Press next button
cy.get('.seedlot-registration-button-row')
.find('button.form-action-btn')
Expand Down Expand Up @@ -350,7 +362,7 @@ describe('A Class Seedlot Registration form, Collection and Interim storage', ()
.should('have.value', testPopupAcronym);

cy.get('#interim-location-code')
.should('have.value', '03');
.should('have.value', '01');

cy.get('#interim-use-collection-agency')
.should('be.checked');
Expand Down Expand Up @@ -450,6 +462,9 @@ describe('A Class Seedlot Registration form, Collection and Interim storage', ()

cy.get('#interim-location-code')
.should('have.value', locationCode);

// Save changes
cy.saveSeedlotRegFormProgress();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ describe('A Class Seedlot Registration form, Extraction and Storage', () => {

cy.get('#ext-location-code')
.should('have.value', locationCode);

// Save changes
cy.saveSeedlotRegFormProgress();
});
});

Expand Down Expand Up @@ -338,6 +341,9 @@ describe('A Class Seedlot Registration form, Extraction and Storage', () => {

cy.get('#str-location-code')
.should('have.value', locationCode);

// Save changes
cy.saveSeedlotRegFormProgress();
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import prefix from '../../../src/styles/classPrefix';
import { THIRTY_SECONDS } from '../../constants';
import { SeedlotRegFixtureType } from '../../definitions';
import { TYPE_DELAY } from '../../constants';

describe('A Class Seedlot Registration form, Orchard', () => {
let regFormData: {
Expand Down Expand Up @@ -57,24 +58,22 @@ describe('A Class Seedlot Registration form, Orchard', () => {
.eq(0)
.should('have.text', regFormData.orchard.subtitle);

cy.get('.seedlot-orchard-title-row')
cy.get('.seedlot-gamete-title-row')
.find('h2')
.eq(1)
.should('have.text', regFormData.orchard.gameteTitle);

cy.get('.seedlot-orchard-title-row')
cy.get('.seedlot-gamete-title-row')
.find('.subtitle-section')
.eq(1)
.should('have.text', regFormData.orchard.gameteSubtitle);

cy.get('.seedlot-orchard-title-row')
.find('h2')
.eq(2)
.eq(1)
.should('have.text', regFormData.orchard.pollenTitle);

cy.get('.seedlot-orchard-title-row')
.find('.subtitle-section')
.eq(2)
.eq(1)
.should('have.text', regFormData.orchard.pollenSubtitle);
});

Expand Down Expand Up @@ -364,6 +363,9 @@ describe('A Class Seedlot Registration form, Orchard', () => {
.contains('219 - VERNON - S - PRD')
.click();

// Save changes
cy.saveSeedlotRegFormProgress();

// Add additional orchard
cy.get('.seedlot-orchard-add-orchard')
.find('button')
Expand Down Expand Up @@ -556,62 +558,45 @@ 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);

// Check pollen breeding % error msg
cy.get('#orchard-breading-perc')
.clear()
.type('-1')
.type('-1', { delay: TYPE_DELAY })
.blur();

cy.get('#orchard-breading-perc-error-msg')
.should('have.text', regFormData.orchard.pollenError);

cy.get('#orchard-breading-perc')
.clear()
.type('101')
.type('101', { delay: TYPE_DELAY })
.blur();

cy.get('#orchard-breading-perc-error-msg')
.should('have.text', regFormData.orchard.pollenError);

cy.get('#orchard-breading-perc')
.clear()
.type('21.1576')
.type('21.1576', { delay: TYPE_DELAY })
.blur();

cy.get('#orchard-breading-perc-error-msg')
.should('have.text', regFormData.orchard.pollenError);

// Check '+' and '-' buttons for pollen breeding %
cy.get('#orchard-breading-perc')
.clear()
.type('5')
.type('5', { delay: TYPE_DELAY })
.blur();

cy.get('#orchard-breading-perc-helper-text')
.should('have.text', regFormData.orchard.pollenHelperText);

cy.get(`button.${prefix}--number__control-btn[title="Increment number"]`)
.click();

cy.get('#orchard-breading-perc')
.should('have.value', '15');

cy.get(`button.${prefix}--number__control-btn[title="Decrement number"]`)
.click();

cy.get('#orchard-breading-perc')
.should('have.value', '5');

// Save changes
cy.saveSeedlotRegFormProgress();
});

it('Step complete status', () => {
// Make sure value is loaded
cy.get('#orchard-breading-perc')
.should('have.value', '5');

// Press next button
cy.get('.seedlot-registration-button-row')
.find('button.form-action-btn')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ describe('A Class Seedlot Registration form, Ownership', () => {
.find('p')
.should('have.text', regFormData.ownership.subtitle);

// Check the checkbox if unchecked
cy.get('#default-owner-checkbox')
.then($checkbox => {
if ($checkbox.is(':not(:checked)')) {
cy.get('#default-owner-checkbox').check({ force: true });
// Save changes
cy.saveSeedlotRegFormProgress();
}
})
.should("be.checked");

cy.get(`.${prefix}--accordion__title`)
.find('.item-title-section')
.should('have.text', initialAccordionTitle);
Expand Down Expand Up @@ -207,10 +218,10 @@ describe('A Class Seedlot Registration form, Ownership', () => {

cy.get('#ownership-location-code-0')
.should('have.value', locationCode);
});

// Save changes
cy.saveSeedlotRegFormProgress();
// Save changes
cy.saveSeedlotRegFormProgress();
});
});

it('Owner portion %, reserved % and surplus % display default values', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,82 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and
});
});

it('Check primary and secondary orchard values', () => {
// Press next button
cy.get('.seedlot-registration-button-row')
.find('button.form-action-btn')
.contains('Back')
.click();

// Check primary orchard
cy.get('#primary-orchard-selection')
.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')
.click();

// Add additional orchard
cy.get('.seedlot-orchard-add-orchard')
.find('button')
.contains('Add additional orchard')
.click();

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')
.click();

// Save changes
cy.saveSeedlotRegFormProgress();
}
});

// Check secondary orchard
cy.get('#secondary-orchard-selection')
.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')
.click();

// Save changes
cy.saveSeedlotRegFormProgress();
}
});

// Press next button
cy.get('.seedlot-registration-button-row')
.find('button.form-action-btn')
.contains('Next')
.click();

cy.get('#parentTreeNumber').scrollIntoView();

// Save changes
cy.saveSeedlotRegFormProgress();
});

it('Page title and subtitles', () => {
cy.get('.title-row')
.find('h2')
Expand Down Expand Up @@ -115,7 +191,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and

// Wait for the table to load
cy.wait('@parentTreesUnderVegCode', { timeout: THIRTY_SECONDS }).its('response.statusCode').should('equal', 200);
cy.get('#parentTreeNumber');
cy.get('#parentTreeNumber').scrollIntoView();

// Check error message for negative Cone count
cy.get('#212-coneCount-value-input')
Expand Down Expand Up @@ -217,7 +293,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and

// Wait for the table to load
cy.wait('@parentTreesUnderVegCode', { timeout: THIRTY_SECONDS }).its('response.statusCode').should('equal', 200);
cy.get('#parentTreeNumber');
cy.get('#parentTreeNumber').scrollIntoView();

// Click 'Dothistroma needle blight (DFS)' checkbox
cy.get(`.${prefix}--toolbar-content > span`)
Expand Down Expand Up @@ -301,7 +377,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and

// Wait for the table to load
cy.wait('@parentTreesUnderVegCode', { timeout: THIRTY_SECONDS }).its('response.statusCode').should('equal', 200);
cy.get('#parentTreeNumber');
cy.get('#parentTreeNumber').scrollIntoView();

// Check Download file option
cy.get(`.${prefix}--toolbar-content > span`)
Expand Down Expand Up @@ -368,7 +444,8 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and
.click();

cy.get(`.${prefix}--modal-container[aria-label="Clean table data"]`)
.find('button[aria-label="close"]')
.find('button')
.contains('Cancel')
.click();

cy.get(`.${prefix}--modal-container[aria-label="Clean table data"]`)
Expand Down Expand Up @@ -456,6 +533,8 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and
cy.wait('@parentTreesUnderVegCode', { timeout: THIRTY_SECONDS }).its('response.statusCode').should('equal', 200);
cy.get('#parentTreeNumber');

cy.get(`.${prefix}--pagination`).scrollIntoView();

const dropdownNumber = '20';
// Number of item dropdown
cy.get(`.${prefix}--pagination__left`)
Expand Down Expand Up @@ -518,6 +597,8 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and
cy.wait('@parentTreesUnderVegCode', { timeout: THIRTY_SECONDS }).its('response.statusCode').should('equal', 200);
cy.get('#parentTreeNumber');

cy.get('.info-sections-row').scrollIntoView();

// Check info sections not visible in DOM
cy.get('.info-section-sub-title')
.should('not.exist');
Expand Down
Loading

0 comments on commit 147b3c4

Please sign in to comment.