Skip to content

Commit

Permalink
Merge pull request #1209 from DFE-Digital/cypress_decision
Browse files Browse the repository at this point in the history
Cypress decision
  • Loading branch information
FahadDarw authored Oct 18, 2024
2 parents 7322cba + 8c3e92a commit 35e46c7
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,44 @@ describe('Decisions Tests', () => {

Logger.log("Capture the projectId dynamically from the URL");
cy.url().then((url) => {
projectId = url.match(/task-list\/(\d+)/)[1];
projectId = url.match(/task-list\/(\d+)/)[1];
Logger.log(`Project ID: ${projectId}`);
}).then(() => {
Logger.log("Click on record a decision menubar button");
decisionPage.clickRecordDecisionMenu();

Logger.log("Click on record a decision button");
decisionPage.clickRecordDecision();


Logger.log("Check error and add necessary details to record the decision");
decisionPage.checkErrorAndAddDetails('15', '10', '2024', 'Paul Lockwood');

Logger.log("Click on record a decision menubar button");
decisionPage.clickRecordDecisionMenu();

Logger.log("Click on record a decision button");
decisionPage.clickRecordDecisionWithoutError();

Logger.log("Record the decision with the necessary details");
decisionPage.makeDecision("approved")
decisionPage.makeDecision("deferred")
.decsionMaker("grade6")
.selectNoConditions()
.selectReasonWhyDeferred()
.enterDecisionMakerName('Fahad Darwish')
.enterDecisionDate('12', '12', '2023')
.verifyDecisionDetails('Approved', 'Grade 6', 'Fahad Darwish', 'No', '12 December 2023');
.verifyDecisionDetails('Deferred', 'Grade 6', 'Fahad Darwish', '12 December 2023');

Logger.log("Verify that decision was recorded successfully then change the decision details, verify the changes");
decisionPage.changeDecisionDetails();

Logger.log("Change the current decision to DAO (Directive Academy Order) revoked and verify the changes");
decisionPage.changeDecisionDAODetails();


Logger.log("Change the current decision to Approved, verify the changes then check if the project is readonly");
decisionPage.changeDecisionApproved();

Logger.log("Check if this project is readonly after adding a decision");
decisionPage.clickToGoBackandCheckReadOnly();

Logger.log("Delete the project and verify that it was deleted successfully - Project ID: " + projectId);
decisionPage.deleteProject(projectId);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ describe('Sponsored conversion journey', { tags: ['@dev', '@stage'] }, () => {
// Complete
ConversionDetails.markComplete();
cy.confirmContinueBtn().click();

projectTaskList.getConversionDetailsStatus().should('contain.text', testData.completedText);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Logger } from "../support/logger";

export class DecisionPage {


Expand Down Expand Up @@ -39,10 +41,54 @@ export class DecisionPage {
}

clickRecordDecision() {
cy.get('[data-test="record_decision_error_btn"]').click();
return this;
}

clickRecordDecisionWithoutError() {
cy.get('[data-cy="record_decision_btn"]').click();
return this;
}


checkErrorAndAddDetails(day, month, year, userName) {

cy.get('#errorSummary').should('be.visible');
cy.get('#error-summary-title').should('contain', 'There is a problem');
cy.get('[data-cy="error-summary"]')
.find('a')
.should('have.length', 2)
.eq(0)
.should('contain', 'You must enter an advisory board date before you can record a decision.')
.and('be.visible');
cy.get('[data-cy="error-summary"]')
.find('a')
.eq(1)
.should('contain', 'You must enter the name of the person who worked on this project before you can record a decision.')
.and('be.visible');
cy.contains('a', 'You must enter an advisory board date before you can record a decision').click();
cy.get('#head-teacher-board-date-day').type(day);
cy.get('#head-teacher-board-date-month').type(month);
cy.get('#head-teacher-board-date-year').type(year);
cy.get('[data-cy="select-common-submitbutton"]').click();

cy.get('[data-cy="record_decision_menu"] > .moj-sub-navigation__link').click();


cy.get('[data-test="record_decision_error_btn"]').click();
cy.contains('a', 'You must enter the name of the person who worked on this project before you can record a decision.').click();
cy.get('#delivery-officer').type(userName);
cy.get('.autocomplete__option').first().click();
cy.get('[data-cy="continue-Btn"]').click();


cy.get('#notification-message').should('include.text', 'Project is assigned');
cy.get('#main-content > :nth-child(2) > :nth-child(2)').should('include.text', userName);

return this;
}


makeDecision(decision) {
cy.get(`#${decision}-radio`).click();
cy.get('#submit-btn').click();
Expand All @@ -67,6 +113,13 @@ export class DecisionPage {
return this;
}

selectReasonWhyDeferred() {
cy.get('#additionalinformationneeded-checkbox').click();
cy.get('#additionalinformationneeded-txtarea').type('Fahads Cypress Reason is Additional Information Needed');
cy.get('#submit-btn').click();
return this;
}

enterDecisionDate(day, month, year) {
cy.get('#decision-date-day').type(day);
cy.get('#decision-date-month').type(month);
Expand All @@ -83,26 +136,40 @@ export class DecisionPage {
return this;
}

verifyDecisionDetails(decision, grade, name, conditions, date) {
cy.get('#decision').should('contain', decision);
verifyDecisionDetails(decision, grade, name, date) {
Logger.log(`Decision: ${decision}, Name: ${name}, Date: ${date}`);
cy.log(`Decision: ${decision}, Name: ${name}, Date: ${date}`);
cy.get('#decision')
.invoke('text')
.then((text) => {
expect(text.trim()).to.contain(decision);
});
cy.get('#decision-made-by').eq(0).should('contain', grade);
cy.get('#decision-maker-name').should('contain', name);
cy.get('#condition-set').should('contain', conditions);
cy.get('#decision-date').should('contain', date);
cy.get('#submit-btn').click();
return this;
}

verifyDecisionDetailsBeforeChanging(decision, name, conditions, date) {
cy.get('#decision').should('contain', decision);
verifyDecisionDetailsBeforeChanging(decision, name, date) {
Logger.log(`Decision: ${decision}, Name: ${name}, Date: ${date}`);
cy.log(`Decision: ${decision}, Name: ${name}, Date: ${date}`);
cy.get('#decision')
.invoke('text')
.then((text) => {
expect(text.trim().toLowerCase()).to.contain(decision.toLowerCase().trim());
});
cy.get('#decision-maker-name').should('contain', name);
cy.get('#condition-set').should('contain', conditions);
cy.get('#decision-date').should('contain', date);
return this;
}

verifyDecisionDetailsAfterChanging(decision, name, date) {
cy.get('#decision').should('contain', decision);
cy.get('#decision')
.invoke('text')
.then((text) => {
expect(text.trim().toLowerCase()).to.contain(decision.toLowerCase().trim());
});
cy.get('#decision-made-by').should('contain', name);
console.log('Date:', date);
cy.get('#decision-date').should('contain', date);
Expand All @@ -111,7 +178,7 @@ export class DecisionPage {

changeDecisionDetails() {
cy.get('[data-cy="record_decision_menu"]').click();
this.verifyDecisionDetailsBeforeChanging('Approved', 'Fahad Darwish', 'No', '12 December 2023');
this.verifyDecisionDetailsBeforeChanging('DEFERRED', 'Fahad Darwish', '12 December 2023');
cy.get('#record-decision-link').click();
cy.get('#declined-radio').click();
cy.get('#submit-btn').click();
Expand All @@ -121,7 +188,6 @@ export class DecisionPage {
cy.get('#declined-reasons-finance').click();
cy.get('#reason-finance').type('Fahads Cypress Reason is Finance');
cy.get('#submit-btn').click();
//decision maker name will stay as name Fahad Darwish then click continue
cy.get('#submit-btn').click();

//change the date to 12th November 2023
Expand Down Expand Up @@ -155,13 +221,65 @@ export class DecisionPage {
cy.get('#submit-btn').click();
cy.get('#submit-btn').click();
this.verifyDecisionDetailsAfterChanging('DAO', 'Minister', '12 November 2023');
cy.get('#submit-btn').click();
return this;
}


changeDecisionApproved() {
cy.get('[data-cy="record_decision_menu"]').click();
cy.get('#record-decision-link').click();
cy.get('#approved-radio').click();
cy.get('#submit-btn').click();
cy.get('#minister-radio').click();
cy.get('#submit-btn').click();
cy.get('#no-radio').click();
cy.get('#submit-btn').click();
cy.get('#decision-maker-name').clear().type('Fahad Darwish');
cy.get('#submit-btn').click();
cy.get('#decision-date-day').clear();
cy.get('#decision-date-day').type('12');
cy.get('#decision-date-month').clear();
cy.get('#decision-date-month').type('11');
cy.get('#decision-date-year').clear();
cy.get('#decision-date-year').type('2023');
cy.get('#submit-btn').click();
this.verifyDecisionDetailsAfterChanging('Approved', 'Minister', '12 November 2023');
cy.get('#submit-btn').click();
cy.get('[data-cy="decision-recorded-confirmation"]')
.should('be.visible');
cy.get('[data-cy="decision-recorded-confirmation"]').should('contain', 'Decision recorded');
cy.get('[data-cy="approved-body"]').should('contain', 'Manchester Academy')
.and('contain', 'Approved');

cy.get('[data-cy="open-in-compelete-btn"]')
.should('be.visible');
return this;
}
deleteProject(projectId) {
cy.callAcademisationApi("DELETE", `/conversion-project/${projectId}/Delete`).then((response) => {
expect(response.status).to.eq(200);
});
}

clickToGoBackandCheckReadOnly() {
cy.get('[data-cy="select-backlink"]').click();
cy.get('[data-cy="record_decision_menu"]').click();
cy.get('[data-cy="approved-message_banner"]')
.should('be.visible')
.and('contain', 'This project was approved');

return this;
}



goBackToTaskList() {
cy.get('[data-cy="back-link"]').click();
return this;
}


}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class ProjectTaskList extends BasePage {
ofstedLink: 'a[href*="/school-performance-ofsted-information"]',
keyStageLink: (keyStageNumber) => `a[href*="/key-stage-${keyStageNumber}-performance-tables"]`,
createNewConversionButton: '[data-cy="create_new_conversion_btn"]',
recordDecisionButton: '[data-cy="record_decision_btn"]',
recordDecisionButton: '[data-cy="record_decision_error_btn"]',
schoolName: '[data-cy="school-name"]',
urn: '[data-cy="urn"]',
urnId: '.govuk-caption-xl',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</select>

<div class="govuk-button-group govuk-!-margin-top-5">
<button class="govuk-button" data-module="govuk-button">
<button class="govuk-button" data-module="govuk-button" data-cy="continue-Btn">
Continue
</button>
<input type="hidden" name="UnassignDeliveryOfficer" id="UnassignDeliveryOfficer" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
}
else
{
<strong class="govuk-tag @decisionClass" id="decision">@decisionName</strong>
<strong class="govuk-tag @decisionClass" data-cy="decision_name" id="decision">@decisionName</strong>
}

</dd>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</select>

<div class="govuk-button-group govuk-!-margin-top-5">
<button class="govuk-button" data-module="govuk-button">
<button class="govuk-button" data-module="govuk-button" data-cy="continue-Btn">
Continue
</button>
<input type="hidden" name="UnassignDeliveryOfficer" id="UnassignDeliveryOfficer"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</select>

<div class="govuk-button-group govuk-!-margin-top-5">
<button class="govuk-button" data-module="govuk-button">
<button class="govuk-button" data-module="govuk-button" data-cy="continue-Btn">
Continue
</button>
<input type="hidden" name="UnassignDeliveryOfficer" id="UnassignDeliveryOfficer"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</select>

<div class="govuk-button-group govuk-!-margin-top-5">
<button class="govuk-button" data-module="govuk-button">
<button class="govuk-button" data-module="govuk-button" data-cy="continue-Btn">
Continue
</button>
<input type="hidden" name="UnassignDeliveryOfficer" id="UnassignDeliveryOfficer"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</div>
@if (Model.IsReadOnly)
{
<div class="govuk-grid-column-two-thirds">
<div class="govuk-grid-column-two-thirds" data-cy="approved-message_banner">
<div class="govuk-notification-banner" role="region" aria-labelledby="govuk-notification-banner-title" data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h2 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
}

<div class="govuk-panel govuk-panel--confirmation">
<h1 class="govuk-panel__title">
<h1 class="govuk-panel__title" data-cy="decision-recorded-confirmation">
Decision recorded
</h1>
<div class="govuk-panel__body">
<div class="govuk-panel__body" data-cy="approved-body">
@Model.SchoolName<br><strong>Approved @(Model.Decision.ApprovedConditionsSet.HasValue && Model.Decision.ApprovedConditionsSet.Value ? "with conditions" : string.Empty)</strong>
</div>
</div>
Expand All @@ -44,7 +44,7 @@
<li>links to SharePoint folders</li>
<li>external contact details</li>
</ul>
<a href="@Configuration["ApplicationLinks:CompleteHandoverProjectListLink"]" role="button" draggable="false" class="govuk-button govuk-button--start" data-module="govuk-button">
<a href="@Configuration["ApplicationLinks:CompleteHandoverProjectListLink"]" role="button" draggable="false" class="govuk-button govuk-button--start" data-module="govuk-button" data-cy="open-in-compelete-btn">
Open project in compelete
<svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewBox="0 0 33 40" aria-hidden="true" focusable="false">
<path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

@section BeforeMain
{
<govuk-back-link link-item="@Links.TaskList.Index"/>
<govuk-back-link link-item="@Links.TaskList.Index" data-cy="back-link" />
}

<div class="govuk-grid-row">
Expand Down

0 comments on commit 35e46c7

Please sign in to comment.