Skip to content

Commit

Permalink
Merge pull request #906 from DFE-Digital/137749-cypress-sponsored-pat…
Browse files Browse the repository at this point in the history
…h-school-overview

137749 Cypress - sponsored path - school overview
  • Loading branch information
nwarms authored Sep 22, 2023
2 parents 02641f9 + bb46c1b commit 8dda945
Show file tree
Hide file tree
Showing 7 changed files with 291 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"cypress/globals": true
},
"extends": [
"plugin:cypress/recommended"
"plugin:cypress/recommended",
"eslint:recommended"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,73 @@
import projectList from "../../pages/projectList";
import projectTaskList from "../../pages/projectTaskList";
import projectAssignment from "../../pages/projectAssignment";
import schoolOverview from "../../pages/schoolOverview";

const projectName = 'Sponsored Cypress Project';
const deliveryOfficer = 'Richika Dogra';

const testData = {
projectName: 'Sponsored Cypress Project',
deliveryOfficer: 'Richika Dogra',
assignedOfficerMessage: 'Project is assigned',
pan: '98765',
pfiDescription: 'PFI Description',
distance: '15',
distanceDecription: 'Distance description',
mp: 'Important Politician, Indepentent',
}

describe('Sponsored conversion', { tags: ['@dev', '@stage'] }, () => {
beforeEach(() => {
cy.callAcademisationApi('POST', `cypress-data/add-sponsored-project.cy`, "{}")
.then(() => {
projectList.selectProject(projectName)
projectList.selectProject(testData.projectName)
});
})

it('TC01: Sponsored conversion journey ', () => {
// -----------------------
// Assign Delivery Officer
// -----------------------

projectTaskList.selectAssignProject();
projectAssignment.assignProject(deliveryOfficer)
projectAssignment.assignProject(testData.deliveryOfficer)
projectTaskList.getNotificationMessage().should('contain.text', 'Project is assigned');
projectTaskList.getAssignedUser().should('contain.text', deliveryOfficer);
projectList.filterProjectList(projectName);
projectList.getNthProjectDeliveryOfficer().should('contain.text', deliveryOfficer);
projectTaskList.getAssignedUser().should('contain.text', testData.deliveryOfficer);
projectList.filterProjectList(testData.projectName);
projectList.getNthProjectDeliveryOfficer().should('contain.text', testData.deliveryOfficer);

// ---------------
// School Overview
// ---------------

projectList.selectProject(testData.projectName);
projectTaskList.selectSchoolOverview();
//PAN
schoolOverview.changePan(testData.pan);
schoolOverview.getPan().should('contain.text', testData.pan);
//Viability issues
schoolOverview.changeViabilityIssues(true);
schoolOverview.getViabilityIssues().should('contain.text', 'Yes');
schoolOverview.changeViabilityIssues(false);
schoolOverview.getViabilityIssues().should('contain.text', 'No');
//Financial deficit
schoolOverview.changeFinancialDeficit(true);
schoolOverview.getFinancialDeficit().should('contain.text', 'Yes');
schoolOverview.changeFinancialDeficit(false);
schoolOverview.getFinancialDeficit().should('contain.text', 'No');
//PFI + details
schoolOverview.changePFI(true, testData.pfiDescription);
schoolOverview.getPFI().should('contain.text', 'Yes');
schoolOverview.getPFIDetails().should('contain.text', testData.pfiDescription);
//Distance plus details
schoolOverview.changeDistance(testData.distance, testData.distanceDecription);
schoolOverview.getDistance().should('contain.text', testData.distance);
schoolOverview.getDistanceDetails().should('contain.text', testData.distanceDecription);
//MP
schoolOverview.changeMP(testData.mp);
schoolOverview.getMP().should('contain.text', testData.mp);
//Complete
schoolOverview.markComplete();
cy.confirmContinueBtn().click();
projectTaskList.getSchoolOverviewStatus().should('contain.text', 'Completed')
})
})
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
/// <reference types ='Cypress'/>

export const selectors = {
assignInput: '[id="delivery-officer"]',
unassignLink: '[id="unassign-link"]',
saveButton: '[class="govuk-button"]'
};

export const path = 'project-assignment';
import BasePage from "./BasePage";

class ProjectAssignment {
export default class ProjectAssignment extends BasePage {
static selectors = {
assignInput: '[id="delivery-officer"]',
unassignLink: '[id="unassign-link"]',
saveButton: '[class="govuk-button"]'
};

checkProjectAssignmentPage() {
cy.url().should('include', path);
}
static path = 'project-assignment';

assignProject(deliveryOfficer) {
this.checkProjectAssignmentPage();
cy.get(selectors.assignInput).click()
cy.get(selectors.assignInput).type(`${deliveryOfficer}{enter}`);
cy.get(selectors.saveButton).click();
static assignProject(deliveryOfficer) {
cy.checkPath(this.path);
cy.get(this.selectors.assignInput).click()
cy.get(this.selectors.assignInput).type(`${deliveryOfficer}{enter}`);
cy.get(this.selectors.saveButton).click();
};

unassignProject() {
this.checkProjectAssignmentPage();
cy.get(selectors.unassignLink).click()
static unassignProject() {
cy.checkPath(this.path)
cy.get(this.selectors.unassignLink).click()
};

};

export default new ProjectAssignment();
Original file line number Diff line number Diff line change
@@ -1,49 +1,48 @@
/// <reference types ='Cypress'/>

export const path = 'project-list';

import BasePage from './BasePage'

export default new class projectList extends BasePage {
export default class projectList extends BasePage {

static path = 'project-list';

checkProjectListPage() {
cy.url().should('include', path);
static checkProjectListPage() {
cy.url().should('include', this.path);
}

getNthProject(n = 0){
static getNthProject(n = 0) {
this.checkProjectListPage();
return cy.get(`[id="school-name-${n}"]`);
}

getNthProjectDeliveryOfficer(n = 0){
static getNthProjectDeliveryOfficer(n = 0) {
this.checkProjectListPage();
return cy.get(`[id="delivery-officer-${n}"]`);
}

filterProjectList( titleFilter ) {
static filterProjectList(titleFilter) {
const filterQuery = `?Title=${encodeURIComponent(titleFilter)}`;
cy.visit(`${Cypress.env('url')}/${path}${filterQuery}`)
cy.visit(`${Cypress.env('url')}/${this.path}${filterQuery}`)
};

selectFirstItem(){
static selectFirstItem() {
this.checkProjectListPage();
this.getNthProject().click();
}

selectProject(projectName = 'Gloucester School') {
static selectProject(projectName = 'Gloucester school') {
this.filterProjectList(projectName);
this.selectFirstItem();
return cy.url().then(url => this.getIdFromUrl(url));
};

selectVoluntaryProject() {
static selectVoluntaryProject() {
cy.login({titleFilter: 'Voluntary Cypress Project'});
cy.get('[id="school-name-0"]').click();

return cy.url().then(url => this.getIdFromUrl(url));
};

getIdFromUrl(url) {
static getIdFromUrl(url) {
const urlSplit = url.toString().split('/');
for (let i = urlSplit.length - 1; i > 0; i--) {
const potentialId = parseInt(urlSplit[i]);
Expand All @@ -53,4 +52,4 @@ export default new class projectList extends BasePage {

return '';
};
};
};
Original file line number Diff line number Diff line change
@@ -1,31 +1,42 @@
/// <reference types ='Cypress'/>

export const selectors = {
assignProjectButton: 'a[href*="project-assignment"]',
assignedUser: '[data-id="assigned-user"]',
notificationMessage: '[id="notification-message"]'
}
import BasePage from "./BasePage";

export const path = 'task-list';
export default class ProjectTaskList extends BasePage {

class ProjectTaskList {

checkProjectPage() {
cy.url().should('include', path);
static selectors = {
assignProjectButton: 'a[href*="project-assignment"]',
assignedUser: '[data-id="assigned-user"]',
notificationMessage: '[id="notification-message"]',
schoolOverviewLink: 'a[href*="/school-overview"]',
schoolOverviewStatus: '[id="school-overview-status"]'
}

selectAssignProject() {
cy.get(selectors.assignProjectButton).click();
static path = 'task-list';

static selectAssignProject() {
cy.checkPath(this.path);
cy.get(this.selectors.assignProjectButton).click();
};

getAssignedUser() {
return cy.get(selectors.assignedUser);
static getAssignedUser() {
cy.checkPath(this.path);
return cy.get(this.selectors.assignedUser);
}

getNotificationMessage() {
return cy.get(selectors.notificationMessage);
static getNotificationMessage() {
cy.checkPath(this.path);
return cy.get(this.selectors.notificationMessage);
}

};
static selectSchoolOverview() {
cy.checkPath(this.path);
cy.get(this.selectors.schoolOverviewLink).click()
}

export default new ProjectTaskList();
static getSchoolOverviewStatus() {
cy.checkPath(this.path);
return cy.get(this.selectors.schoolOverviewStatus);
}

};
Loading

0 comments on commit 8dda945

Please sign in to comment.