Skip to content

Commit

Permalink
Merge pull request #712 from bcgov/GRAD2-3188
Browse files Browse the repository at this point in the history
Added cypress
  • Loading branch information
suzalflueck authored Jan 13, 2025
2 parents 7b15eb5 + 0a659de commit ef8d08d
Show file tree
Hide file tree
Showing 9 changed files with 2,096 additions and 5 deletions.
12 changes: 7 additions & 5 deletions frontend/src/components/Batch/Forms/FormInputs/StudentInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import TRAXService from "@/services/TRAXService.js";
import SchoolService from "@/services/SchoolService.js";
import StudentService from "@/services/StudentService.js";
import GraduationReportService from "@/services/GraduationReportService.js";
import { useAppStore } from "@/store/modules/app";
import { useVuelidate } from "@vuelidate/core";
import { mapActions, mapState } from "pinia";
import { useBatchRequestFormStore } from "../../../../store/modules/batchRequestFormStore";
Expand Down Expand Up @@ -182,8 +183,8 @@ export default {
lastName: student.data[0].legalLastName,
dob: student.data[0].dob,
status: studentGRADStatus.data.studentStatusName,
schoolOfRecord: studentGRADStatus.data.schoolOfRecord,
schoolAtGrad: studentGRADStatus.data.schoolAtGrad,
schoolOfRecord: this.getSchoolById(studentGRADStatus.data.schoolOfRecordId)?.displayNameNoSpecialChars ?? this.getSchoolById(studentGRADStatus.data.schoolOfRecordId)?.displayName,
schoolAtGrad: this.getSchoolById(studentGRADStatus.data.schoolAtGradId)?.displayNameNoSpecialChars ?? this.getSchoolById(studentGRADStatus.data.schoolAtGradId)?.displayName,
program: studentGRADStatus.data.program,
};
if (studentGRADStatus.data.studentStatusName == "Merged") {
Expand Down Expand Up @@ -248,13 +249,14 @@ export default {
},
computed: {
computed: {
...mapState(useBatchRequestFormStore, [
...mapState(useBatchRequestFormStore, [
"getBatchRequest",
"getBatchRunTime",
"getCredential",
]),
},
...mapState(useAppStore, {
getSchoolById: "getSchoolById"
}),
isEmpty() {
return this.students.length > 0;
},
Expand Down
4 changes: 4 additions & 0 deletions testing/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/local.json
cypress.env.json
.env
node_modules/
12 changes: 12 additions & 0 deletions testing/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { defineConfig } = require("cypress");

module.exports = defineConfig({
chromeWebSecurity: false,
defaultCommandTimeout: 10000,
e2e: {
baseUrl: 'https://dev.grad.gov.bc.ca',
setupNodeEvents(on, config) {

},
},
});
9 changes: 9 additions & 0 deletions testing/cypress/e2e/studentSearch/studentPenSearch.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
describe('Student Search', () => {
context('with PEN', () => {
it('login', () => {
cy.login(['khyono', ''])

// cy.should('contain.text', 'PEN Search')
})
})
})
45 changes: 45 additions & 0 deletions testing/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
import { Routes } from "../../../frontend/src/utils/constants"
import selectors from "./selectors"

function createLoginSession(username, password) {
cy.session([username, password], () => {
cy.visit(Routes.LOGIN)
cy.get(selectors.login.idirLoginBtn).click()
cy.get(selectors.login.user).type(Cypress.env('username'))
cy.get(selectors.login.password).type(Cypress.env('password'))
cy.get(selectors.login.idirSubmitBtn).click()
cy.pause()
cy.contains('PEN Search')
})
}

Cypress.Commands.add('login', createLoginSession)

Cypress.on('uncaught:exception', (err, runnable) => {
return false
})
17 changes: 17 additions & 0 deletions testing/cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example support/e2e.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'
10 changes: 10 additions & 0 deletions testing/cypress/support/selectors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default {
login : {
username: '#username',
user: '#user',
password: '#password',
loginBtn: '#kc-login',
idirLoginBtn: '#social-idir',
idirSubmitBtn: 'input[value=Continue]'
}
}
Loading

0 comments on commit ef8d08d

Please sign in to comment.