Skip to content

Commit

Permalink
Merge pull request #3545 from LiteFarmOrg/LF-4371a-Fix-Cypress-tests
Browse files Browse the repository at this point in the history
LF-4371a Fix Cypress tests
  • Loading branch information
SayakaOno authored Nov 25, 2024
2 parents da766c6 + 28e06d7 commit 8dade36
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
8 changes: 4 additions & 4 deletions packages/end-to-end/cypress/e2e/crops.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ describe('Crops', () => {
.should('exist')
.type('New Crop' + uniqueId);
// cy.contains(translation['INVITE_USER']['CHOOSE_ROLE'])
cy.get(Selectors.REACT_SELECT)
cy.getVisible(Selectors.REACT_SELECT)
.find('input')
.type(crops['CEREALS'] + '{enter}');

cy.get(Selectors.RADIO).first().check({ force: true });
cy.get(Selectors.CAN_BE_COVER_CROP).first().check({ force: true });

cy.get(Selectors.CROP_SUBMIT).should('exist').and('not.be.disabled').click();
cy.url().should('include', '/crop/new/add_crop_variety');
Expand Down Expand Up @@ -81,7 +81,7 @@ describe('Crops', () => {

// Add Management Plan
cy.contains(translation['CROP_DETAIL']['ADD_PLAN']).click();
cy.get(Selectors.RADIO).first().check();
cy.get(Selectors.PLANTING_METHOD_GROUND_PLANTED).first().check();
cy.get(Selectors.CROP_PLAN_SUBMIT).should('exist').and('not.be.disabled').click();
cy.get(Selectors.CROP_PLAN_TRANSPLANT_SUBMIT).should('exist').and('not.be.disabled').click();

Expand All @@ -102,7 +102,7 @@ describe('Crops', () => {
cy.get(Selectors.CROP_PLAN_LOCATION_SUBMIT).should('exist').and('not.be.disabled').click();

// Planning Method
cy.get(Selectors.RADIO).first().check();
cy.get(Selectors.PLANTING_METHOD_ROW).check();
cy.get(Selectors.PLANTING_METHOD_SUBMIT).should('exist').and('not.be.disabled').click();

// Row length
Expand Down
2 changes: 1 addition & 1 deletion packages/end-to-end/cypress/e2e/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe('Tasks', () => {
cy.get(Selectors.ADD_TASK_CROPS_CONTINUE).should('exist').and('not.be.disabled').click();

// Select type of work
cy.get(Selectors.REACT_SELECT).find('input').click({ force: true });
cy.getVisible(Selectors.REACT_SELECT).find('input').click({ force: true });
cy.contains(translation['ADD_TASK']['FIELD_WORK_VIEW']['TYPE']['PRUNING']).click({
force: true,
});
Expand Down
4 changes: 4 additions & 0 deletions packages/end-to-end/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ Cypress.Commands.add('waitUntilAnyVisible', (selector1, selector2, timeout = 100
return checkVisibility();
});

Cypress.Commands.add('getVisible', (selector, ...args) => {
return cy.get(selector, ...args).filter(':visible');
});

Cypress.Commands.add(
'loginOrCreateAccount',
(email, password, fullName, language, crop_menu_name, map_menu_name, fieldString) => {
Expand Down
3 changes: 3 additions & 0 deletions packages/end-to-end/cypress/support/selectorConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const INPUT_ERROR = '[data-cy=error]';
// crops.js
export const RADIO = '[type="radio"]';
export const REACT_SELECT = '[data-cy="react-select"]';
export const CAN_BE_COVER_CROP = '[name="can_be_cover_crop"]';
export const CROP_PLAN_LOCATION_SUBMIT = '[data-cy="cropPlan-locationSubmit"]';
export const CROP_PLAN_PLANT_DATE = '[data-cy="cropPlan-plantDate"]';
export const CROP_PLAN_PLANT_HARVEST = '[data-cy="cropPlan-plantHarvest"]';
Expand All @@ -76,6 +77,8 @@ export const CROP_PLAN_SEED_GERMINATION = '[data-cy="cropPlan-seedGermination"]'
export const CROP_PLAN_TRANSPLANT_SUBMIT = '[data-cy="cropPlan-transplantSubmit"]';
export const PLAN_GUIDANCE_SUBMIT = '[data-cy="planGuidance-submit"]';
export const PLANT_DATE_SUBMIT = '[data-cy="plantDate-submit"]';
export const PLANTING_METHOD_GROUND_PLANTED = '[data-cy="cropPlan-groundPlanted"]';
export const PLANTING_METHOD_ROW = 'input[data-cy="cropPlan-plantingMethod"][value="ROW_METHOD"]';
export const PLANTING_METHOD_SUBMIT = '[data-cy="plantingMethod-submit"]';
export const ROW_METHOD_LENGTH = '[data-cy="rowMethod-length"]';
export const ROW_METHOD_ROWS = '[data-cy="rowMethod-rows"]';
Expand Down

0 comments on commit 8dade36

Please sign in to comment.