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: 1627 final cypress test class a seedlot registration #1674

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8fa4eb1
feat: add submission test
ngunner15 Oct 10, 2024
0a9994c
feat: create submission test
ngunner15 Oct 10, 2024
799a546
feat: add text
ngunner15 Oct 10, 2024
e85d407
fix: comment
ngunner15 Oct 10, 2024
0f7a252
feat: add title test
ngunner15 Oct 10, 2024
b6f501c
feat: add redirect test
ngunner15 Oct 10, 2024
2be2c0a
feat: update
ngunner15 Oct 10, 2024
c476442
feat: add buttons test
ngunner15 Oct 10, 2024
a6bf881
feat: add submit test
ngunner15 Oct 10, 2024
50ef134
fix: update
ngunner15 Oct 15, 2024
e46c742
feat: add comments
ngunner15 Oct 15, 2024
998c044
feat: update
ngunner15 Oct 15, 2024
df6183e
Merge branch 'main' into feat/1627-final-cypress-test-class-a-seedlot…
ngunner15 Oct 15, 2024
adb8c66
Merge branch 'main' into feat/1627-final-cypress-test-class-a-seedlot…
ngunner15 Oct 16, 2024
d9dcb57
feat: move submission click code from before each to it blocks
ngunner15 Oct 17, 2024
51769b9
feat: add step completion check
ngunner15 Oct 17, 2024
1222a9d
feat: change check code
ngunner15 Oct 17, 2024
914a360
Merge branch 'main' into feat/1627-final-cypress-test-class-a-seedlot…
ngunner15 Oct 18, 2024
a2f8a71
feat: add checkbox test
ngunner15 Oct 18, 2024
8370211
Merge branch 'main' into feat/1627-final-cypress-test-class-a-seedlot…
ngunner15 Oct 18, 2024
d913d33
Merge branch 'main' into feat/1627-final-cypress-test-class-a-seedlot…
ngunner15 Oct 22, 2024
2ff4928
Merge branch 'main' into feat/1627-final-cypress-test-class-a-seedlot…
ngunner15 Oct 22, 2024
6f71d84
feat: update test name
ngunner15 Oct 22, 2024
fd7b86d
fix remove save change code from checkbox block
ngunner15 Oct 22, 2024
923f43a
feat: add step 1 check again
ngunner15 Oct 22, 2024
6e67512
feat: move all tests in one it block
ngunner15 Oct 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frontend/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export default defineConfig({
'**/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'
'**/a-class-seedlot-reg-form-parent-tree-part-3.cy.ts',
'**/a-class-seedlot-reg-form-submission.cy.ts'
],
chromeWebSecurity: false,
retries: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('A Class Seedlot Registration form, Parent Tree and SMP part-1(Cone and
});

it('Check primary and secondary orchard values', () => {
// Press next button
// Press back button
cy.get('.seedlot-registration-button-row')
.find('button.form-action-btn')
.contains('Back')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,380 @@
import prefix from '../../../src/styles/classPrefix';
import { SeedlotRegFixtureType } from '../../definitions';

describe('A Class Seedlot Registration form submission', () => {
let regFormData: {
submission: {
title: string;
subtitle: string;
checkboxText: string;
successTitle: string;
successSubtitle: string;
}
};

let seedlotNum: string;
const speciesKey = 'pli';
let seedlotData: SeedlotRegFixtureType;
const fundingSource = 'FTM - Forests for Tomorrow MOF Admin';
const F2GameticValue = 'F2 - Measured Cone Volume';
const M3GameticValue = 'M3 - Pollen Volume Estimate by 100% Survey';

beforeEach(() => {
// Login
cy.login();
cy.fixture('aclass-reg-form').then((fData) => {
regFormData = fData;
});

cy.fixture('aclass-seedlot').then((fData) => {
seedlotData = fData;
cy.task('getData', fData[speciesKey].species).then((sNumber) => {
seedlotNum = sNumber as string;
const url = `/seedlots/a-class-registration/${seedlotNum}/?step=6`;
cy.visit(url);
cy.url().should('contains', url);
});
});
});

it('Check step completion', () => {
// Step 1 check
cy.get('ul.spar-seedlot-reg-progress-bar > li')
.eq(0)
.find(`.${prefix}--assistive-text`)
.then($element => {
const elementText = $element.text();
if (elementText === 'Incomplete') {
const url = `/seedlots/a-class-registration/${seedlotNum}/?step=1`;
cy.log('Step 1 incomplete');
cy.visit(url);

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

// Enter Collection start date
cy.get('#collection-start-date')
.clear()
.type('2024-05-11')
.blur();

// Enter Collection end date
cy.get('#collection-end-date')
.clear()
.type('2024-05-21')
.blur();

// Save changes
cy.saveSeedlotRegFormProgress();
} else {
cy.log('Step 1 complete');
}
});

// Step 2 check
cy.get('ul.spar-seedlot-reg-progress-bar > li')
.eq(1)
.find(`.${prefix}--assistive-text`)
.then($element => {
const elementText = $element.text();
if (elementText === 'Incomplete') {
const url = `/seedlots/a-class-registration/${seedlotNum}/?step=2`;
cy.log('Step 2 incomplete');
cy.visit(url);

// 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 });
}
})
.should("be.checked");

// Expand the funding source combo box
cy.get('#ownership-funding-source-0')
.should('have.value', '')
.click();

cy.get(`.${prefix}--list-box__menu-item__option`)
.contains(fundingSource)
.scrollIntoView()
.click();

cy.get('#ownership-funding-source-0')
.should('have.value', fundingSource);

// Save changes
cy.saveSeedlotRegFormProgress();
} else {
cy.log('Step 2 complete');
}
});

// Step 3 check
cy.get('ul.spar-seedlot-reg-progress-bar > li')
.eq(2)
.find(`.${prefix}--assistive-text`)
.then($element => {
const elementText = $element.text();
if (elementText === 'Incomplete') {
const url = `/seedlots/a-class-registration/${seedlotNum}/?step=3`;
cy.log('Step 3 incomplete');
cy.visit(url);

// Check the checkbox if unchecked
cy.get('#interim-use-collection-agency')
.then($checkbox => {
if ($checkbox.is(':not(:checked)')) {
cy.get('#interim-use-collection-agency').check({ force: true });
}
})
.should("be.checked");

// Enter Interim start date
cy.get('#start-date-input')
.clear()
.type('2024-05-11')
.blur();

// Enter Interim end date
cy.get('#end-date-input')
.clear()
.type('2024-05-21')
.blur();

// Save changes
cy.saveSeedlotRegFormProgress();
} else {
cy.log('Step 3 complete');
}
});

// Step 4 check
cy.get('ul.spar-seedlot-reg-progress-bar > li')
.eq(3)
.find(`.${prefix}--assistive-text`)
.then($element => {
const elementText = $element.text();
if (elementText === 'Incomplete') {
const url = `/seedlots/a-class-registration/${seedlotNum}/?step=4`;
cy.log('Step 4 incomplete');
cy.visit(url);

// Select primary orchard
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();

// Select female gametic contribution methodology
cy.get('#orchard-female-gametic')
.siblings()
.click();

cy.get(`.${prefix}--list-box--expanded`)
.find('ul li')
.contains(F2GameticValue)
.click();

cy.get('#orchard-female-gametic')
.should('have.value', F2GameticValue);

// Select male gametic contribution methodology
cy.get('#orchard-male-gametic')
.siblings()
.click();

cy.get(`.${prefix}--list-box--expanded`)
.find('ul li')
.contains(M3GameticValue)
.click();

cy.get('#orchard-male-gametic')
.should('have.value', M3GameticValue);

// Save changes
cy.saveSeedlotRegFormProgress();
} else {
cy.log('Step 4 complete');
}
});

// Step 5 check
cy.get('ul.spar-seedlot-reg-progress-bar > li')
.eq(4)
.find(`.${prefix}--assistive-text`)
.then($element => {
const elementText = $element.text();
if (elementText === 'Incomplete') {
const url = `/seedlots/a-class-registration/${seedlotNum}/?step=5`;
cy.log('Step 5 incomplete');
cy.visit(url);

// Wait for the table to load
cy.get('#parentTreeNumber', { timeout: 10000 });

// Enter cone count
cy.get('#223-coneCount-value-input')
.clear()
.type('1')
.blur();

// Enter pollen count
cy.get('#223-pollenCount-value-input')
.clear()
.type('1')
.blur();

// Save changes
cy.saveSeedlotRegFormProgress();
} else {
cy.log('Step 5 complete');
}
});

// Step 1 check again
cy.get('ul.spar-seedlot-reg-progress-bar > li')
.eq(0)
.find(`.${prefix}--assistive-text`)
.then($element => {
const elementText = $element.text();
if (elementText === 'Incomplete') {
const url = `/seedlots/a-class-registration/${seedlotNum}/?step=1`;
cy.log('Step 1 incomplete');
cy.visit(url);

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

// Title and subtitle test
// Press submission button
const extractionUrl = `/seedlots/a-class-registration/${seedlotNum}/?step=6`;
cy.visit(extractionUrl);
cy.get('.seedlot-registration-button-row')
.find('button.submit-modal-btn')
.contains('Submit Registration')
.as('submitRegBtn')
.click();

cy.get(`.${prefix}--modal-container[aria-label="Seedlot registration"]`)
.should('be.visible');

cy.get(`.${prefix}--modal-container[aria-label="Seedlot registration"]`)
.find(`h3.${prefix}--modal-header__heading`)
.should('have.text', regFormData.submission.title);

cy.get(`.${prefix}--modal-container[aria-label="Seedlot registration"]`)
.find(`.${prefix}--modal-content`)
.children('p')
.should('have.text', regFormData.submission.subtitle);

cy.get(`.${prefix}--modal-container[aria-label="Seedlot registration"]`)
.find(`span.${prefix}--checkbox-label-text`)
.should('have.text', regFormData.submission.checkboxText);

// Redirect test
const redirectUrl = `/seedlots/a-class-registration/${seedlotNum}/?step=1`;
cy.get(`a.${prefix}--link`)
.contains('Click here to go back to the first step.')
.click();

cy.url().should('contains', redirectUrl);

// Check button test
cy.visit(extractionUrl);
// Press submission button
cy.get('@submitRegBtn')
.click();

cy.get(`.${prefix}--modal-container[aria-label="Seedlot registration"]`)
.find(`button.${prefix}--btn--secondary`)
.contains('Cancel')
.as('cancelButton')
.click();

cy.get(`.${prefix}--modal-container[aria-label="Seedlot registration"]`)
.should('not.be.visible');

// Press submission button
cy.get('@submitRegBtn')
.click();

cy.get(`.${prefix}--modal-container[aria-label="Seedlot registration"]`)
.should('be.visible');

// Check default checkbox behaviour
cy.get('#declaration-modal-checkbox')
.should('not.be.checked');

cy.get(`.${prefix}--modal-container[aria-label="Seedlot registration"]`)
.find(`button.${prefix}--btn--primary`)
.contains('Submit seedlot')
.as('submitButton')
.should('be.disabled');

// Check the checkbox
cy.get('#declaration-modal-checkbox')
.check({ force: true });

cy.get('@submitButton')
.should('not.be.disabled');

cy.get('@cancelButton')
.click();

const submissionUrl = `/seedlots/details/${seedlotNum}?isSubmitSuccess=true`;

// Press submission button
cy.get('@submitRegBtn')
.click();

// Check the checkbox
cy.get('#declaration-modal-checkbox')
.check({ force: true });

// Click submit seedlot button
cy.get('@submitButton')
.click();

cy.url().should('contains', submissionUrl);

cy.get('.seedlot-submitted-notification')
.should('be.visible');

cy.get('.seedlot-submitted-notification')
.find(`.${prefix}--inline-notification__title`)
.should('have.text', regFormData.submission.successTitle);

cy.get('.seedlot-submitted-notification')
.find(`.${prefix}--inline-notification__subtitle`)
.should('have.text', regFormData.submission.successSubtitle);

cy.contains('p.seedlot-summary-info-label', 'Status')
.next()
.children('span')
.should('have.text', 'Submitted');
});
});
Loading
Loading