|
| 1 | +import { TYPE_DELAY } from '../../constants'; |
| 2 | +import { mockMoistureContentApi } from '../../support/mockApiConsep'; |
| 3 | +import { MoistureContentType, SeedlotReplicateInfoType } from '../../definitions'; |
| 4 | + |
| 5 | +describe('Moisture Content Screen page', () => { |
| 6 | + let mcData: MoistureContentType; |
| 7 | + let seedlotData: SeedlotReplicateInfoType; |
| 8 | + beforeEach(() => { |
| 9 | + cy.fixture('moisture-content').then((jsonData) => { |
| 10 | + mcData = jsonData; |
| 11 | + }); |
| 12 | + cy.fixture('seedlot-replicate-info').then((jsonData) => { |
| 13 | + seedlotData = jsonData; |
| 14 | + }); |
| 15 | + mockMoistureContentApi(); |
| 16 | + cy.login(); |
| 17 | + cy.visit('/consep/manual-moisture-content/514330'); |
| 18 | + cy.url().should('contains', '/consep/manual-moisture-content/514330'); |
| 19 | + }); |
| 20 | + |
| 21 | + it('should load and display manual moisture content page correctly', () => { |
| 22 | + // Check if the page title is displayed correctly |
| 23 | + cy.get('.consep-moisture-content-title') |
| 24 | + .find('h1') |
| 25 | + .contains(mcData.mc.title); |
| 26 | + |
| 27 | + // Check if the table title is displayed correctly |
| 28 | + cy.get('.activity-result-actions-title') |
| 29 | + .find('h3') |
| 30 | + .contains(mcData.table.title); |
| 31 | + }); |
| 32 | + |
| 33 | + it('should display breadcrumbs correctly', () => { |
| 34 | + cy.get('.consep-moisture-content-breadcrumb') |
| 35 | + .find('li') |
| 36 | + .should('have.length', 3) |
| 37 | + .and('contain', 'CONSEP') |
| 38 | + .and('contain', 'Testing activities search') |
| 39 | + .and('contain', 'Testing list'); |
| 40 | + }); |
| 41 | + |
| 42 | + it('should display Activity summary section correctly', () => { |
| 43 | + cy.get('.activity-summary') |
| 44 | + .find('.activity-summary-info-value') |
| 45 | + .eq(0) |
| 46 | + .should('have.text', seedlotData.activityType); |
| 47 | + |
| 48 | + cy.get('.activity-summary') |
| 49 | + .find('.activity-summary-info-value') |
| 50 | + .eq(1) |
| 51 | + .should('have.text', seedlotData.seedlotNumber); |
| 52 | + |
| 53 | + cy.get('.activity-summary') |
| 54 | + .find('.activity-summary-info-value') |
| 55 | + .eq(2) |
| 56 | + .should('have.text', seedlotData.requestId); |
| 57 | + |
| 58 | + cy.get('.activity-summary') |
| 59 | + .find('.activity-summary-info-value') |
| 60 | + .eq(3) |
| 61 | + .should('have.text', `${seedlotData.vegetationCode} | ${seedlotData.geneticClassCode}`); |
| 62 | + |
| 63 | + cy.get('.activity-summary') |
| 64 | + .find('.activity-summary-info-value') |
| 65 | + .eq(4) |
| 66 | + .should('have.text', seedlotData.moisturePct); |
| 67 | + }); |
| 68 | + |
| 69 | + it('should check comment box', () => { |
| 70 | + // Check if the comment input exists |
| 71 | + cy.get('#moisture-content-comments').should('be.visible'); |
| 72 | + |
| 73 | + // Type a comment |
| 74 | + cy.get('#moisture-content-comments') |
| 75 | + .clear() |
| 76 | + .type(mcData.mc.testComment, { delay: TYPE_DELAY }) |
| 77 | + .blur() |
| 78 | + .should('have.value', mcData.mc.testComment); |
| 79 | + }); |
| 80 | +}); |
0 commit comments