Skip to content

Commit

Permalink
Merge branch 'main' into feature/147236-PRU_TASK_LIST
Browse files Browse the repository at this point in the history
  • Loading branch information
dneed-nimble authored Jan 24, 2024
2 parents a31614b + 35ad2ff commit 62df68b
Show file tree
Hide file tree
Showing 28 changed files with 9,425 additions and 3,578 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/build-and-push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ jobs:

- name: Run cypress (staging)
if: needs.set-env.outputs.environment == 'staging'
run: npm run cy:run -- --env url='${{ secrets.AZURE_ENDPOINT }}',grep='-dao',authorizationHeader='${{ secrets.CYPRESS_TEST_SECRET }}, academisationApiUrl=${{secrets.CYPRESS_ACADEMISATION_API_URL}}, academisationApiKey=${{ secrets.CYPRESS_ACADEMISATION_API_KEY}}'
run: npm run cy:run -- --env url='${{ secrets.AZURE_ENDPOINT }}',grep='-dao',cypressTestSecret='${{ secrets.CYPRESS_TEST_SECRET }}, academisationApiUrl=${{secrets.CYPRESS_ACADEMISATION_API_URL}}, academisationApiKey=${{ secrets.CYPRESS_ACADEMISATION_API_KEY}}'
env:
db: ${{ secrets.DB_CONNECTION_STRING }}

- name: Run cypress (dev)
if: needs.set-env.outputs.environment == 'dev'
run: npm run cy:run -- --env url='${{ secrets.AZURE_ENDPOINT }}',authorizationHeader='${{ secrets.CYPRESS_TEST_SECRET }}, academisationApiUrl=${{secrets.CYPRESS_ACADEMISATION_API_URL}}, academisationApiKey=${{ secrets.CYPRESS_ACADEMISATION_API_KEY}}'
run: npm run cy:run -- --env url='${{ secrets.AZURE_ENDPOINT }}',cypressTestSecret='${{ secrets.CYPRESS_TEST_SECRET }}, academisationApiUrl=${{secrets.CYPRESS_ACADEMISATION_API_URL}}, academisationApiKey=${{ secrets.CYPRESS_ACADEMISATION_API_KEY}}'
env:
db: ${{ secrets.DB_CONNECTION_STRING }}

Expand All @@ -173,3 +173,9 @@ jobs:
with:
name: screenshots-${{ needs.set-env.outputs.environment }}
path: Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress/screenshots

- name: Report results
if: always()
run: npm run cy:notify -- --custom-text="Environment ${{ needs.set-env.outputs.environment }}, See more information https://github.com/DFE-Digital/prepare-academy-conversions/actions/runs/${{github.run_id}}"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
2 changes: 1 addition & 1 deletion .github/workflows/security-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
ZAP_API_KEY: ${{ secrets.ZAP_API_KEY }}
ZAP_ADDRESS: ${{ env.ZAP_ADDRESS }}
ZAP_PORT: ${{ env.ZAP_PORT }}
run: npm run cy:run -- --env url=$URL,authorizationHeader=$API_KEY
run: npm run cy:run -- --env url=$URL,cypressTestSecret=$API_KEY

- name: Get git sha
if: '!cancelled()'
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -479,4 +479,5 @@ backend.vars
/terraform/Brewfile.lock.json

# sonar cloud
/Dfe.PrepareConversions/.sonarlint
/Dfe.PrepareConversions/.sonarlint
Dfe.PrepareConversions/Dfe.PrepareConversions.CypressTests/cypress.env.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { generateZapReport } from './cypress/plugins/generateZapReport'

export default defineConfig({
video: false,
retries: 2,
retries: 0,
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/// <reference types="Cypress" />
import projectList from "../../pages/projectList";


describe('Filteration Tests', { tags: ['@dev', '@stage'] }, () => {

const currentDate = new Date();
const nextYearDate = new Date();
nextYearDate.setFullYear(currentDate.getFullYear() + 1);
const oneMonthAgoDate = new Date();
oneMonthAgoDate.setMonth(currentDate.getMonth() - 1);
const nextMonthDate = new Date();
nextMonthDate.setMonth(currentDate.getMonth() + 1);

const testData = {
projectName: 'Sponsored Cypress Project',
completedText: 'Completed',
projectAssignment: {
deliveryOfficer: 'Richika Dogra',
assignedOfficerMessage: 'Project is assigned',
},
schoolOverview: {
pan: '98765',
pfiDescription: 'PFI Description',
distance: '15',
distanceDecription: 'Distance description',
mp: 'Important Politician, Independent',
},
budget: {
endOfFinanicalYear: currentDate,
forecastedRevenueCurrentYear: 20,
forecastedCapitalCurrentYear: 10,
endOfNextFinancialYear: nextYearDate,
forecastedRevenueNextYear: 15,
forecastedCapitalNextYear: 12
},
pupilForecast: {
additionalInfomation: 'Pupil Forecast Additional Information'
},
rationale: 'This is why this school should become an academy',
risksAndIssues: 'Here are the risks and issues for this conversion',
localAuthority: {
comment: 'Comment',
sharepointLink: 'https://sharepoint.com'
},
performanceInfo: 'Additional Information',
keyStages: [4, 5]
}

before(() => {

})

beforeEach(() => {
projectList.selectProject(testData.projectName)
})

it('Should filter projects by region', () => {
// Visit the home page or the initial project list page
cy.visit(`${Cypress.env('url')}/`);
// Check if the Region accordion section is not expanded
cy.get('[data-cy="select-projectlist-filter-region"]').should('have.attr', 'aria-expanded', 'false').then(($accordion) => {
const isAccordionExpanded = $accordion.attr('aria-expanded') === 'true';

// If the accordion is not expanded, click to expand it
if (!isAccordionExpanded) {
cy.get('[data-cy="select-projectlist-filter-region"]').click();
}
// Select the region checkbox
cy.get('#filter-project-region-east-midlands').check();
cy.get('#filter-project-region-east-of-england').check();
cy.get('#filter-project-region-london').check();
cy.get('#filter-project-region-north-east').check();

// Apply the selections
cy.get('[data-cy="select-projectlist-filter-apply"]').click();

// Assert that the results are updated based on the selected regions
for (let i = 0; i < 10; i++) {
const regionSelector = `#region-${i}`;

// Ensure that the selected regions are present in the results
cy.get(regionSelector).each(($regionElement) => {
const region = $regionElement.text();
expect(region).to.satisfy((text) => {
return (
text.includes('East Midlands') ||
text.includes('East of England') ||
text.includes('London') ||
text.includes('North East')
);
});
});
}

// Clear the filters
cy.get('[data-cy="clear-filter"]').click();
});
});

it('Filter by Project Status', () => {
// Visit the home page or the initial project list page
cy.visit(`${Cypress.env('url')}/`);

// Check if the Project Status accordion section is not expanded
cy.get('[data-cy="select-projectlist-filter-project-status"]').should('have.attr', 'aria-expanded', 'false').then(($accordion) => {
const isAccordionExpanded = $accordion.attr('aria-expanded') === 'true';

// If the accordion is not expanded, click to expand it
if (!isAccordionExpanded) {
cy.get('[data-cy="select-projectlist-filter-project-status"]').click();
}

const projectStatuses = ['Approved', 'Approved with conditions', 'Declined', 'Deferred', 'Pre advisory board'];

// Select each project status checkbox and check the URL
projectStatuses.forEach((statusToFilter) => {
// Select the project status checkbox
cy.get(`[data-cy="select-projectlist-filter-status-${statusToFilter}"]`).check();

// Perform actions to apply the filter by project status
cy.get('[data-cy="select-projectlist-filter-apply"]').click();

// Log the actual URL to help debug the issue
cy.url().then((url) => {
cy.log(`Actual URL for ${statusToFilter}: ${url}`);

// Add assertions to check if the filter applied correctly
cy.get('[id^="project-status-"]').invoke('text').then((text) => {
// Convert text to an array if it's not already
const texts = Array.isArray(text) ? text : [text];

// Check each text for inclusion (case-insensitive)
texts.forEach((individualText) => {
expect(individualText.toLowerCase()).to.include(statusToFilter.toLowerCase());
});
});
});

// Clear the filter
cy.get('[data-cy="clear-filter"]').click();

});

});
});

});


Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,6 @@ describe('Sponsored conversion journey', { tags: ['@dev', '@stage'] }, () => {
cy.confirmContinueBtn().click();
}
});
})


});
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('Voluntary conversion', { tags: ['@dev', '@stage'] }, () => {
// Do the spin up a project journey
})

it('TC01: Voluntary conversion journey ', () => {
it.skip('TC01: Voluntary conversion journey ', () => {
// Go wild Dan!
voluntaryProjectTaskList.voluntaryProjectElementsVisible()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,29 @@ export default class projectList extends BasePage {

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

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

static filterByRegion(region) {
this.filterProjectList({ region: region });
}

static filterByStatus(status) {
this.filterProjectList({ status: status });
}

static filterByAdvisoryBoardDate(advisoryBoardDate) {
this.filterProjectList({ advisoryBoardDate: advisoryBoardDate });
}

static filterByTitle(title) {
this.filterProjectList({ title: title });
}

static selectFirstItem() {
this.checkProjectListPage()
Expand Down Expand Up @@ -53,3 +69,4 @@ export default class projectList extends BasePage {
return ''
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,19 @@
* @type {Cypress.PluginConfig}
*/

/// <reference types="cypress" />

// Load the TypeScript plugin
import * as webpackPreprocessor from '@cypress/webpack-preprocessor';

// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
require('eslint/src/plugin')(config)
}
on('file:preprocessor', webpackPreprocessor());

// Other configurations or plugins...

return config;
};

Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,15 @@ Cypress.Commands.add('generateProjectTempBtn', () => {
})

Cypress.Commands.add('enterDate', (idSelector, day, month, year) => {
cy.get(`[id*="${idSelector}-day"]`).as('day')
cy.get(`[id*="${idSelector}-month"]`).as('month')
cy.get(`[id*="${idSelector}-year"]`).as('year')

cy.get(`@day`).then((dayLoc) => {
dayLoc.should('be.visible')
dayLoc.clear()
dayLoc.type(day)
})
cy.get(`@month`).then((monthLoc) => {
monthLoc.should('be.visible')
monthLoc.clear()
monthLoc.type(month)
})
cy.get(`@year`).then((yearLoc) => {
yearLoc.should('be.visible')
yearLoc.clear()
yearLoc.type(year)
})
})
cy.get(`[id*="${idSelector}-day"]`).as('day');
cy.get(`[id*="${idSelector}-month"]`).as('month');
cy.get(`[id*="${idSelector}-year"]`).as('year');

cy.get('@day').should('be.visible').invoke('val', '').type(day);
cy.get('@month').should('be.visible').invoke('val', '').type(month);
cy.get('@year').should('be.visible').invoke('val', '').type(year);
});


// No Radio Btn
Cypress.Commands.add('NoRadioBtn', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ beforeEach(() => {
cy.intercept(
{ url: Cypress.env('url') + '/**', middleware: true },
//Add authorization to all Cypress requests
(req) => req.headers['Authorization'] = 'Bearer ' + Cypress.env('authorizationHeader'),
(req) => req.headers['Authorization'] = 'Bearer ' + Cypress.env('cypressTestSecret'),
(req) => req.headers['AuthorizationRole'] = 'conversions.create'
)
})
Expand Down
Loading

0 comments on commit 62df68b

Please sign in to comment.