dceky 1.0.22 → 1.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cypress/e2e/profile-test.cy.ts +1 -1
- package/lib/src/commands/handleHarvardKey.d.ts +1 -1
- package/lib/src/commands/handleHarvardKey.js +37 -35
- package/lib/src/commands/handleHarvardKey.js.map +1 -1
- package/lib/src/commands/index.js +6 -4
- package/lib/src/commands/index.js.map +1 -1
- package/lib/src/commands/launchAs.js +70 -68
- package/lib/src/commands/launchAs.js.map +1 -1
- package/lib/src/commands/logIntoPorta.d.ts +22 -0
- package/lib/src/commands/logIntoPorta.js +127 -0
- package/lib/src/commands/logIntoPorta.js.map +1 -0
- package/package.json +2 -2
- package/src/commands/handleHarvardKey.ts +41 -38
- package/src/commands/launchAs.ts +90 -88
- package/src/commands/logIntoPorta.ts +65 -61
- package/lib/commands/assertDoesNotHaveClass.d.ts +0 -18
- package/lib/commands/assertDoesNotHaveClass.js +0 -17
- package/lib/commands/assertDoesNotHaveClass.js.map +0 -1
- package/lib/commands/assertHasClass.d.ts +0 -18
- package/lib/commands/assertHasClass.js +0 -17
- package/lib/commands/assertHasClass.js.map +0 -1
- package/lib/commands/assertNumElements.d.ts +0 -18
- package/lib/commands/assertNumElements.js +0 -17
- package/lib/commands/assertNumElements.js.map +0 -1
- package/lib/commands/clickWithRetry.d.ts +0 -19
- package/lib/commands/clickWithRetry.js +0 -29
- package/lib/commands/clickWithRetry.js.map +0 -1
- package/lib/commands/genTextOfLength.d.ts +0 -20
- package/lib/commands/genTextOfLength.js +0 -20
- package/lib/commands/genTextOfLength.js.map +0 -1
- package/lib/commands/getAttribute.d.ts +0 -20
- package/lib/commands/getAttribute.js +0 -22
- package/lib/commands/getAttribute.js.map +0 -1
- package/lib/commands/getClassName.d.ts +0 -15
- package/lib/commands/getClassName.js +0 -21
- package/lib/commands/getClassName.js.map +0 -1
- package/lib/commands/getCurrentDateInfo.d.ts +0 -21
- package/lib/commands/getCurrentDateInfo.js +0 -25
- package/lib/commands/getCurrentDateInfo.js.map +0 -1
- package/lib/commands/getId.d.ts +0 -15
- package/lib/commands/getId.js +0 -21
- package/lib/commands/getId.js.map +0 -1
- package/lib/commands/getNumElements.d.ts +0 -14
- package/lib/commands/getNumElements.js +0 -19
- package/lib/commands/getNumElements.js.map +0 -1
- package/lib/commands/getSpecialChars.d.ts +0 -14
- package/lib/commands/getSpecialChars.js +0 -16
- package/lib/commands/getSpecialChars.js.map +0 -1
- package/lib/commands/getTitle.d.ts +0 -13
- package/lib/commands/getTitle.js +0 -20
- package/lib/commands/getTitle.js.map +0 -1
- package/lib/commands/handleHarvardKey.d.ts +0 -18
- package/lib/commands/handleHarvardKey.js +0 -56
- package/lib/commands/handleHarvardKey.js.map +0 -1
- package/lib/commands/handleHarvardKey2.d.ts +0 -14
- package/lib/commands/handleHarvardKey2.js +0 -88
- package/lib/commands/handleHarvardKey2.js.map +0 -1
- package/lib/commands/launchAs.d.ts +0 -20
- package/lib/commands/launchAs.js +0 -60
- package/lib/commands/launchAs.js.map +0 -1
- package/lib/commands/launchLTIUsingToken.d.ts +0 -19
- package/lib/commands/launchLTIUsingToken.js +0 -74
- package/lib/commands/launchLTIUsingToken.js.map +0 -1
- package/lib/commands/listSelectLabels.d.ts +0 -15
- package/lib/commands/listSelectLabels.js +0 -24
- package/lib/commands/listSelectLabels.js.map +0 -1
- package/lib/commands/listSelectValues.d.ts +0 -15
- package/lib/commands/listSelectValues.js +0 -26
- package/lib/commands/listSelectValues.js.map +0 -1
- package/lib/commands/navigateToHref.d.ts +0 -19
- package/lib/commands/navigateToHref.js +0 -23
- package/lib/commands/navigateToHref.js.map +0 -1
- package/lib/commands/padWithZeros.d.ts +0 -20
- package/lib/commands/padWithZeros.js +0 -24
- package/lib/commands/padWithZeros.js.map +0 -1
- package/lib/commands/runScript.d.ts +0 -16
- package/lib/commands/runScript.js +0 -25
- package/lib/commands/runScript.js.map +0 -1
- package/lib/commands/typeInto.d.ts +0 -20
- package/lib/commands/typeInto.js +0 -28
- package/lib/commands/typeInto.js.map +0 -1
- package/lib/commands/uniquify.d.ts +0 -15
- package/lib/commands/uniquify.js +0 -25
- package/lib/commands/uniquify.js.map +0 -1
- package/lib/commands/visitCanvasEndpoint.d.ts +0 -27
- package/lib/commands/visitCanvasEndpoint.js +0 -35
- package/lib/commands/visitCanvasEndpoint.js.map +0 -1
- package/lib/commands/visitCanvasGETEndpoint.d.ts +0 -20
- package/lib/commands/visitCanvasGETEndpoint.js +0 -26
- package/lib/commands/visitCanvasGETEndpoint.js.map +0 -1
- package/lib/commands/waitForAtLeastOneElementPresent.d.ts +0 -23
- package/lib/commands/waitForAtLeastOneElementPresent.js +0 -27
- package/lib/commands/waitForAtLeastOneElementPresent.js.map +0 -1
- package/lib/commands/waitForElementVisible.d.ts +0 -14
- package/lib/commands/waitForElementVisible.js +0 -20
- package/lib/commands/waitForElementVisible.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/init.d.ts +0 -6
- package/lib/init.js +0 -69
- package/lib/init.js.map +0 -1
- package/lib/postinstall/helpers/exec.d.ts +0 -8
- package/lib/postinstall/helpers/exec.js +0 -18
- package/lib/postinstall/helpers/exec.js.map +0 -1
- package/lib/setup/checkRequiredFiles.d.ts +0 -6
- package/lib/setup/checkRequiredFiles.js +0 -60
- package/lib/setup/checkRequiredFiles.js.map +0 -1
- package/lib/setup/genEmptyGlobalFile.d.ts +0 -7
- package/lib/setup/genEmptyGlobalFile.js +0 -41
- package/lib/setup/genEmptyGlobalFile.js.map +0 -1
- package/lib/src/commands/launchLTIUsingToken.d.ts +0 -21
- package/lib/src/commands/launchLTIUsingToken.js +0 -76
- package/lib/src/commands/launchLTIUsingToken.js.map +0 -1
- package/lib/src/commands/visitCanvasGETEndpoint.d.ts +0 -20
- package/lib/src/commands/visitCanvasGETEndpoint.js +0 -26
- package/lib/src/commands/visitCanvasGETEndpoint.js.map +0 -1
- package/lib/src/init.d.ts +0 -6
- package/lib/src/init.js +0 -71
- package/lib/src/init.js.map +0 -1
- package/lib/src/node.d.ts +0 -2
- package/lib/src/node.js +0 -10
- package/lib/src/node.js.map +0 -1
|
@@ -2,7 +2,7 @@ declare global {
|
|
|
2
2
|
namespace Cypress {
|
|
3
3
|
interface Chainable {
|
|
4
4
|
/**
|
|
5
|
-
* Handle a HarvardKey login page for a user
|
|
5
|
+
* Handle a HarvardKey login page for a user via UI (form filling with cy.origin(), not API calls)
|
|
6
6
|
* @author Yuen Ler Chow
|
|
7
7
|
* @param name the name of the user environment variable
|
|
8
8
|
* @return Cypress chainable (void) - performs authentication flow, no return value
|
|
@@ -6,43 +6,45 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
/*----------------------------------------*/
|
|
7
7
|
var handleHarvardKey = function () {
|
|
8
8
|
Cypress.Commands.add('handleHarvardKey', function (name) {
|
|
9
|
-
cy.log('🔓 Handling HarvardKey authentication');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// To go the login screen
|
|
21
|
-
// Clicking the button doesn't work for some reason, so we access the href attribute instead
|
|
22
|
-
return cy.navigateToHref('#idp_1001962798_button');
|
|
23
|
-
}).then(function (fullUrl) {
|
|
24
|
-
// Navigate to the Harvard login page using originWithKaixa
|
|
25
|
-
cy.origin('https://harvard.idp.cirrusidentity.com', {
|
|
26
|
-
args: { username: username, password: password, fullUrl: fullUrl },
|
|
27
|
-
}, function (args) {
|
|
9
|
+
cy.log('🔓 Handling HarvardKey authentication via UI');
|
|
10
|
+
// Get user credentials from environment variables
|
|
11
|
+
cy.env([name]).then(function (environment) {
|
|
12
|
+
var userInfo = environment[name];
|
|
13
|
+
if (!userInfo) {
|
|
14
|
+
throw new Error("Could not find ".concat(name, " in environment variables"));
|
|
15
|
+
}
|
|
16
|
+
// Destructure the user info object
|
|
17
|
+
var username = userInfo.username, password = userInfo.password;
|
|
18
|
+
// Get the Harvard login URL using originWithKaixa with auto-initialized functions
|
|
19
|
+
cy.origin('https://apps.cirrusidentity.com', function () {
|
|
28
20
|
Cypress.require('dceky');
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
// To go the login screen
|
|
22
|
+
// Clicking the button doesn't work for some reason, so we access the href attribute instead
|
|
23
|
+
return cy.navigateToHref('#idp_1001962798_button');
|
|
24
|
+
}).then(function (fullUrl) {
|
|
25
|
+
// Navigate to the Harvard login page using originWithKaixa
|
|
26
|
+
cy.origin('https://harvard.idp.cirrusidentity.com', {
|
|
27
|
+
args: { username: username, password: password, fullUrl: fullUrl },
|
|
28
|
+
}, function (args) {
|
|
29
|
+
Cypress.require('dceky');
|
|
30
|
+
var harvardUsername = args.username, harvardPassword = args.password, harvardLoginUrl = args.fullUrl;
|
|
31
|
+
cy.on('uncaught:exception', function (e) {
|
|
32
|
+
// Ignore known HarvardKey errors
|
|
33
|
+
if (!e.message.includes('ready is not defined')) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
});
|
|
38
|
+
// Visit the Harvard login page
|
|
39
|
+
cy.visit(harvardLoginUrl);
|
|
40
|
+
// Wait for and fill in the login form
|
|
41
|
+
cy.waitForElementVisible('#username');
|
|
42
|
+
cy.waitForElementVisible('#password');
|
|
43
|
+
cy.typeInto({ item: '#username', text: harvardUsername });
|
|
44
|
+
cy.typeInto({ item: '#password', text: harvardPassword });
|
|
45
|
+
// Submit the form
|
|
46
|
+
cy.get('input[type="submit"], button[type="submit"], .btn-primary').click();
|
|
36
47
|
});
|
|
37
|
-
// Visit the Harvard login page
|
|
38
|
-
cy.visit(harvardLoginUrl);
|
|
39
|
-
// Wait for and fill in the login form
|
|
40
|
-
cy.waitForElementVisible('#username');
|
|
41
|
-
cy.waitForElementVisible('#password');
|
|
42
|
-
cy.typeInto({ item: '#username', text: harvardUsername });
|
|
43
|
-
cy.typeInto({ item: '#password', text: harvardPassword });
|
|
44
|
-
// Submit the form
|
|
45
|
-
cy.get('input[type="submit"], button[type="submit"], .btn-primary').click();
|
|
46
48
|
});
|
|
47
49
|
});
|
|
48
50
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleHarvardKey.js","sourceRoot":"","sources":["../../../src/commands/handleHarvardKey.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AAsBjC,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,IAAM,gBAAgB,GAAG;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAClB,kBAAkB,EAClB,UACE,IAAY;QAEZ,EAAE,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"handleHarvardKey.js","sourceRoot":"","sources":["../../../src/commands/handleHarvardKey.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AAsBjC,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,IAAM,gBAAgB,GAAG;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAClB,kBAAkB,EAClB,UACE,IAAY;QAEZ,EAAE,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;QAEvD,kDAAkD;QAClD,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,UAAC,WAAW;YAC9B,IAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;YACnC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,MAAM,IAAI,KAAK,CAAC,yBAAkB,IAAI,8BAA2B,CAAC,CAAC;YACrE,CAAC;YAED,mCAAmC;YAC3B,IAAA,QAAQ,GAAe,QAAQ,SAAvB,EAAE,QAAQ,GAAK,QAAQ,SAAb,CAAc;YAExC,kFAAkF;YAClF,EAAE,CAAC,MAAM,CAAC,iCAAiC,EAAE;gBAC3C,OAAO,C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,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,kBAAe,gBAAgB,CAAC"}
|
|
@@ -23,13 +23,14 @@ var handleHarvardKey_1 = __importDefault(require("./handleHarvardKey"));
|
|
|
23
23
|
var launchAs_1 = __importDefault(require("./launchAs"));
|
|
24
24
|
var listSelectLabels_1 = __importDefault(require("./listSelectLabels"));
|
|
25
25
|
var listSelectValues_1 = __importDefault(require("./listSelectValues"));
|
|
26
|
+
var logIntoPorta_1 = __importDefault(require("./logIntoPorta"));
|
|
26
27
|
var navigateToHref_1 = __importDefault(require("./navigateToHref"));
|
|
27
28
|
var padWithZeros_1 = __importDefault(require("./padWithZeros"));
|
|
28
29
|
var runScript_1 = __importDefault(require("./runScript"));
|
|
29
|
-
var typeInto_1 = __importDefault(require("./typeInto"));
|
|
30
|
-
var uniquify_1 = __importDefault(require("./uniquify"));
|
|
31
30
|
var tap_1 = __importDefault(require("./tap"));
|
|
32
31
|
var tapInIFrame_1 = __importDefault(require("./tapInIFrame"));
|
|
32
|
+
var typeInto_1 = __importDefault(require("./typeInto"));
|
|
33
|
+
var uniquify_1 = __importDefault(require("./uniquify"));
|
|
33
34
|
var visitCanvasEndpoint_1 = __importDefault(require("./visitCanvasEndpoint"));
|
|
34
35
|
var waitForAtLeastOneElementPresent_1 = __importDefault(require("./waitForAtLeastOneElementPresent"));
|
|
35
36
|
var waitForElementVisible_1 = __importDefault(require("./waitForElementVisible"));
|
|
@@ -58,13 +59,14 @@ var commands = function () {
|
|
|
58
59
|
(0, launchAs_1.default)();
|
|
59
60
|
(0, listSelectLabels_1.default)();
|
|
60
61
|
(0, listSelectValues_1.default)();
|
|
62
|
+
(0, logIntoPorta_1.default)();
|
|
61
63
|
(0, navigateToHref_1.default)();
|
|
62
64
|
(0, padWithZeros_1.default)();
|
|
63
65
|
(0, runScript_1.default)();
|
|
64
|
-
(0, typeInto_1.default)();
|
|
65
|
-
(0, uniquify_1.default)();
|
|
66
66
|
(0, tap_1.default)();
|
|
67
67
|
(0, tapInIFrame_1.default)();
|
|
68
|
+
(0, typeInto_1.default)();
|
|
69
|
+
(0, uniquify_1.default)();
|
|
68
70
|
(0, visitCanvasEndpoint_1.default)();
|
|
69
71
|
(0, waitForAtLeastOneElementPresent_1.default)();
|
|
70
72
|
(0, waitForElementVisible_1.default)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":";;;;;AAAA,sBAAsB;AACtB,oFAA8D;AAC9D,oEAA8C;AAC9C,0EAAoD;AACpD,gFAA0D;AAC1D,gFAA0D;AAC1D,oGAA8E;AAC9E,sEAAgD;AAChD,gEAA0C;AAC1C,gEAA0C;AAC1C,4EAAsD;AACtD,kDAA4B;AAC5B,sDAAgC;AAChC,oEAA8C;AAC9C,sEAAgD;AAChD,wDAAkC;AAClC,wEAAkD;AAClD,wDAAkC;AAClC,wEAAkD;AAClD,wEAAkD;AAClD,oEAA8C;AAC9C,gEAA0C;AAC1C,0DAAoC;AACpC,wDAAkC;AAClC,wDAAkC;AAClC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":";;;;;AAAA,sBAAsB;AACtB,oFAA8D;AAC9D,oEAA8C;AAC9C,0EAAoD;AACpD,gFAA0D;AAC1D,gFAA0D;AAC1D,oGAA8E;AAC9E,sEAAgD;AAChD,gEAA0C;AAC1C,gEAA0C;AAC1C,4EAAsD;AACtD,kDAA4B;AAC5B,sDAAgC;AAChC,oEAA8C;AAC9C,sEAAgD;AAChD,wDAAkC;AAClC,wEAAkD;AAClD,wDAAkC;AAClC,wEAAkD;AAClD,wEAAkD;AAClD,gEAA0C;AAC1C,oEAA8C;AAC9C,gEAA0C;AAC1C,0DAAoC;AACpC,8CAAwB;AACxB,8DAAwC;AACxC,wDAAkC;AAClC,wDAAkC;AAClC,8EAAwD;AACxD,sGAAgF;AAChF,kFAA4D;AAE5D;;;GAGG;AACH,IAAM,QAAQ,GAAG;IACf,6BAA6B;IAC7B,IAAA,gCAAsB,GAAE,CAAC;IACzB,IAAA,wBAAc,GAAE,CAAC;IACjB,IAAA,2BAAiB,GAAE,CAAC;IACpB,IAAA,8BAAoB,GAAE,CAAC;IACvB,IAAA,8BAAoB,GAAE,CAAC;IACvB,IAAA,wCAA8B,GAAE,CAAC;IACjC,IAAA,yBAAe,GAAE,CAAC;IAClB,IAAA,sBAAY,GAAE,CAAC;IACf,IAAA,sBAAY,GAAE,CAAC;IACf,IAAA,4BAAkB,GAAE,CAAC;IACrB,IAAA,eAAK,GAAE,CAAC;IACR,IAAA,iBAAO,GAAE,CAAC;IACV,IAAA,wBAAc,GAAE,CAAC;IACjB,IAAA,yBAAe,GAAE,CAAC;IAClB,IAAA,kBAAQ,GAAE,CAAC;IACX,IAAA,0BAAgB,GAAE,CAAC;IACnB,IAAA,kBAAQ,GAAE,CAAC;IACX,IAAA,0BAAgB,GAAE,CAAC;IACnB,IAAA,0BAAgB,GAAE,CAAC;IACnB,IAAA,sBAAY,GAAE,CAAC;IACf,IAAA,wBAAc,GAAE,CAAC;IACjB,IAAA,sBAAY,GAAE,CAAC;IACf,IAAA,mBAAS,GAAE,CAAC;IACZ,IAAA,aAAG,GAAE,CAAC;IACN,IAAA,qBAAW,GAAE,CAAC;IACd,IAAA,kBAAQ,GAAE,CAAC;IACX,IAAA,kBAAQ,GAAE,CAAC;IACX,IAAA,6BAAmB,GAAE,CAAC;IACtB,IAAA,yCAA+B,GAAE,CAAC;IAClC,IAAA,+BAAqB,GAAE,CAAC;AAC1B,CAAC,CAAC;AAEF,kBAAe,QAAQ,CAAC"}
|
|
@@ -16,94 +16,96 @@ var launchAs = function () {
|
|
|
16
16
|
cy.visit(baseURL);
|
|
17
17
|
// Get courseId from environment variables if not provided
|
|
18
18
|
if (!courseId) {
|
|
19
|
-
var envCourseId = Cypress.
|
|
19
|
+
var envCourseId = Cypress.expose('courseId');
|
|
20
20
|
if (!envCourseId) {
|
|
21
21
|
throw new Error('Could not find courseId in environment variables');
|
|
22
22
|
}
|
|
23
23
|
courseId = Number.parseInt(envCourseId, 10);
|
|
24
24
|
}
|
|
25
25
|
// Get appName from environment variables if not provided
|
|
26
|
-
appName = appName || Cypress.
|
|
26
|
+
appName = appName || Cypress.expose('appName');
|
|
27
27
|
if (!appName) {
|
|
28
28
|
throw new Error('Could not find appName in environment variables');
|
|
29
29
|
}
|
|
30
30
|
// Get user accessToken from environment variables
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// List external tools in the course
|
|
40
|
-
return (cy
|
|
41
|
-
.request({
|
|
42
|
-
method: 'GET',
|
|
43
|
-
url: "https://canvas.harvard.edu/api/v1/courses/".concat(courseId, "/external_tools"),
|
|
44
|
-
body: {
|
|
45
|
-
per_page: 200,
|
|
46
|
-
access_token: accessToken,
|
|
47
|
-
},
|
|
48
|
-
})
|
|
49
|
-
.then(function (response) {
|
|
50
|
-
// Extract tools from the body
|
|
51
|
-
var externalTools = response.body;
|
|
52
|
-
// Find the external tool of interest
|
|
53
|
-
var matchingTool = externalTools.find(function (externalTool) {
|
|
54
|
-
// Skip non-nav items
|
|
55
|
-
if (
|
|
56
|
-
// No nav
|
|
57
|
-
!externalTool.course_navigation
|
|
58
|
-
// No nav information
|
|
59
|
-
|| typeof externalTool.course_navigation !== 'object') {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
// Skip non-labeled items
|
|
63
|
-
if (!externalTool.course_navigation.text) {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
// Skip if the app name does not match the expected name
|
|
67
|
-
var thisAppName = (externalTool
|
|
68
|
-
.course_navigation
|
|
69
|
-
.text
|
|
70
|
-
.trim()
|
|
71
|
-
.toLowerCase());
|
|
72
|
-
return thisAppName === appName.trim().toLowerCase();
|
|
73
|
-
});
|
|
74
|
-
// Make sure we found the app
|
|
75
|
-
if (!matchingTool) {
|
|
76
|
-
throw new Error("Could not find any apps named \"".concat(appName, "\" in course ").concat(courseId));
|
|
31
|
+
cy.env([name]).then(function (environment) {
|
|
32
|
+
var userInfo = environment[name];
|
|
33
|
+
if (!userInfo) {
|
|
34
|
+
throw new Error("Could not find ".concat(name, " in environment variables"));
|
|
35
|
+
}
|
|
36
|
+
var accessToken = userInfo.accessToken;
|
|
37
|
+
if (!accessToken) {
|
|
38
|
+
throw new Error("Could not find accessToken for ".concat(name, " in environment variables"));
|
|
77
39
|
}
|
|
78
|
-
//
|
|
79
|
-
var toolId = (matchingTool === null || matchingTool === void 0 ? void 0 : matchingTool.id) || 0;
|
|
80
|
-
return cy.wrap(toolId);
|
|
81
|
-
})
|
|
82
|
-
.then(function (toolId) {
|
|
83
|
-
// Request sessionless launch URL
|
|
40
|
+
// List external tools in the course
|
|
84
41
|
return (cy
|
|
85
42
|
.request({
|
|
86
43
|
method: 'GET',
|
|
87
|
-
url: "https://canvas.harvard.edu/api/v1/courses/".concat(courseId, "/external_tools
|
|
44
|
+
url: "https://canvas.harvard.edu/api/v1/courses/".concat(courseId, "/external_tools"),
|
|
88
45
|
body: {
|
|
89
46
|
per_page: 200,
|
|
90
47
|
access_token: accessToken,
|
|
91
48
|
},
|
|
92
49
|
})
|
|
93
|
-
.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
50
|
+
.then(function (response) {
|
|
51
|
+
// Extract tools from the body
|
|
52
|
+
var externalTools = response.body;
|
|
53
|
+
// Find the external tool of interest
|
|
54
|
+
var matchingTool = externalTools.find(function (externalTool) {
|
|
55
|
+
// Skip non-nav items
|
|
56
|
+
if (
|
|
57
|
+
// No nav
|
|
58
|
+
!externalTool.course_navigation
|
|
59
|
+
// No nav information
|
|
60
|
+
|| typeof externalTool.course_navigation !== 'object') {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
// Skip non-labeled items
|
|
64
|
+
if (!externalTool.course_navigation.text) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
// Skip if the app name does not match the expected name
|
|
68
|
+
var thisAppName = (externalTool
|
|
69
|
+
.course_navigation
|
|
70
|
+
.text
|
|
71
|
+
.trim()
|
|
72
|
+
.toLowerCase());
|
|
73
|
+
return thisAppName === appName.trim().toLowerCase();
|
|
74
|
+
});
|
|
75
|
+
// Make sure we found the app
|
|
76
|
+
if (!matchingTool) {
|
|
77
|
+
throw new Error("Could not find any apps named \"".concat(appName, "\" in course ").concat(courseId));
|
|
100
78
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
79
|
+
// Get the toolId for the matching tool
|
|
80
|
+
var toolId = (matchingTool === null || matchingTool === void 0 ? void 0 : matchingTool.id) || 0;
|
|
81
|
+
return cy.wrap(toolId);
|
|
82
|
+
})
|
|
83
|
+
.then(function (toolId) {
|
|
84
|
+
// Request sessionless launch URL
|
|
85
|
+
return (cy
|
|
86
|
+
.request({
|
|
87
|
+
method: 'GET',
|
|
88
|
+
url: "https://canvas.harvard.edu/api/v1/courses/".concat(courseId, "/external_tools/sessionless_launch?id=").concat(toolId),
|
|
89
|
+
body: {
|
|
90
|
+
per_page: 200,
|
|
91
|
+
access_token: accessToken,
|
|
92
|
+
},
|
|
93
|
+
})
|
|
94
|
+
.its('body'));
|
|
95
|
+
})
|
|
96
|
+
.then(function (sessionlessLaunchInfo) {
|
|
97
|
+
cy.on('uncaught:exception', function (e) {
|
|
98
|
+
// Ignore known LTI launch errors
|
|
99
|
+
if (!e.message.includes('postMessage')) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
});
|
|
104
|
+
// Launch via the sessionless launch URL
|
|
105
|
+
var launchURL = sessionlessLaunchInfo.url;
|
|
106
|
+
cy.visit(launchURL);
|
|
107
|
+
}));
|
|
108
|
+
});
|
|
107
109
|
});
|
|
108
110
|
};
|
|
109
111
|
/*----------------------------------------*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launchAs.js","sourceRoot":"","sources":["../../../src/commands/launchAs.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AAkCjC,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,IAAM,QAAQ,GAAG;IACf,OAAO,CAAC,QAAQ,CAAC,GAAG,CAClB,UAAU,EACV,UACE,IAAY,EACZ,IAGM;QAHN,qBAAA,EAAA,SAGM;QAEN,iBAAiB;QACjB,EAAE,CAAC,GAAG,CAAC,iCAAgB,IAAI,CAAE,CAAC,CAAC;QAE/B,mBAAmB;QACb,IAAA,QAAQ,GAAc,IAAI,SAAlB,EAAE,OAAO,GAAK,IAAI,QAAT,CAAU;QAEjC,2CAA2C;QAC3C,IAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC1C,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAElB,0DAA0D;QAC1D,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,IAAM,WAAW,GAAG,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"launchAs.js","sourceRoot":"","sources":["../../../src/commands/launchAs.ts"],"names":[],"mappings":";AAAA,iCAAiC;;AAkCjC,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,IAAM,QAAQ,GAAG;IACf,OAAO,CAAC,QAAQ,CAAC,GAAG,CAClB,UAAU,EACV,UACE,IAAY,EACZ,IAGM;QAHN,qBAAA,EAAA,SAGM;QAEN,iBAAiB;QACjB,EAAE,CAAC,GAAG,CAAC,iCAAgB,IAAI,CAAE,CAAC,CAAC;QAE/B,mBAAmB;QACb,IAAA,QAAQ,GAAc,IAA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C,QAAQ,mDAAyC,MAAM,CAAE;oBAC3G,IAAI,EAAE;wBACJ,QAAQ,EAAE,GAAG;wBACb,YAAY,EAAE,WAAW;qBAC1B;iBACF,CAAC;qBACD,GAAG,CAAC,MAAM,CAAC,CACf,CAAC;YACJ,CAAC,CAAC;iBACD,IAAI,CAAC,UAAC,qBAAqB;gBAC1B,EAAE,CAAC,EAAE,CAAC,oBAAoB,EAAE,UAAC,CAAQ;oBACnC,iCAAiC;oBACjC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;wBACvC,OAAO,IAAI,CAAC;oBACd,CAAC;oBACD,OAAO,KAAK,CAAC;gBACf,CAAC,CAAC,CAAC;gBAEH,wCAAwC;gBACxC,IAAM,SAAS,GAAG,qBAAqB,CAAC,GAAG,CAAC;gBAC5C,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YACtB,CAAC,CAAC,CACL,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,kBAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
namespace Cypress {
|
|
3
|
+
interface Chainable {
|
|
4
|
+
/**
|
|
5
|
+
* Log into Porta via HarvardKey authentication using API requests (no UI interaction).
|
|
6
|
+
*
|
|
7
|
+
* Flow:
|
|
8
|
+
* 1. GET Cirrus Identity discovery page → extract HarvardKey IdP button href
|
|
9
|
+
* 2. GET IdP login page → extract form action and hidden fields
|
|
10
|
+
* 3. POST credentials to the login form
|
|
11
|
+
* 4. POST SAML form to ACS
|
|
12
|
+
*
|
|
13
|
+
* @author Yuen Ler Chow
|
|
14
|
+
* @param name the name of the user environment variable
|
|
15
|
+
* @return Cypress chainable (void) - performs authentication flow, no return value
|
|
16
|
+
*/
|
|
17
|
+
logIntoPorta(name: string): Chainable<void>;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
declare const logIntoPorta: () => void;
|
|
22
|
+
export default logIntoPorta;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/// <reference types="cypress" />
|
|
3
|
+
var __assign = (this && this.__assign) || function () {
|
|
4
|
+
__assign = Object.assign || function(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
return __assign.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
/*----------------------------------------*/
|
|
16
|
+
/* ---------------- Constants ----------------- */
|
|
17
|
+
/*----------------------------------------*/
|
|
18
|
+
// Cirrus Identity discovery page (Request 1)
|
|
19
|
+
var LOGIN_PAGE = 'https://harvard.proxy.cirrusidentity.com/cas/login?service=https%3A%2F%2Fporta-auto.dcex.harvard.edu%2Fcas%2Flogin%2F';
|
|
20
|
+
// Base URL for HarvardKey IdP (Request 2)
|
|
21
|
+
var IDP_BASE_URL = 'https://apps.cirrusidentity.com';
|
|
22
|
+
// HarvardKey IdP button ID on Cirrus discovery page
|
|
23
|
+
var HARVARDKEY_IDP_BUTTON_ID = 'idp_1001962798_button';
|
|
24
|
+
/*----------------------------------------*/
|
|
25
|
+
/* -------------- Helpers --------------- */
|
|
26
|
+
/*----------------------------------------*/
|
|
27
|
+
/**
|
|
28
|
+
* Parse HTML and extract form action URL and hidden input fields.
|
|
29
|
+
* @author Yuen Ler Chow
|
|
30
|
+
* @param html - Raw HTML string to parse
|
|
31
|
+
* @param formSelector - CSS selector for the form (default: 'form')
|
|
32
|
+
* @returns Object with action URL and record of hidden field name/value pairs
|
|
33
|
+
*/
|
|
34
|
+
var getFormData = function (html, formSelector) {
|
|
35
|
+
var _a;
|
|
36
|
+
if (formSelector === void 0) { formSelector = 'form'; }
|
|
37
|
+
var doc = new DOMParser().parseFromString(html, 'text/html');
|
|
38
|
+
var form = doc.querySelector(formSelector);
|
|
39
|
+
var action = (_a = form === null || form === void 0 ? void 0 : form.getAttribute('action')) !== null && _a !== void 0 ? _a : '';
|
|
40
|
+
var fields = {};
|
|
41
|
+
form === null || form === void 0 ? void 0 : form.querySelectorAll('input[type=hidden]').forEach(function (input) {
|
|
42
|
+
var _a;
|
|
43
|
+
var name = input.getAttribute('name');
|
|
44
|
+
if (name)
|
|
45
|
+
fields[name] = (_a = input.getAttribute('value')) !== null && _a !== void 0 ? _a : '';
|
|
46
|
+
});
|
|
47
|
+
return { action: action, fields: fields };
|
|
48
|
+
};
|
|
49
|
+
/*----------------------------------------*/
|
|
50
|
+
/* --------------- Command -------------- */
|
|
51
|
+
/*----------------------------------------*/
|
|
52
|
+
var logIntoPorta = function () {
|
|
53
|
+
Cypress.Commands.add('logIntoPorta', function (name) {
|
|
54
|
+
cy.log('🔓 Handling HarvardKey authentication via API');
|
|
55
|
+
// Get user credentials from environment variables
|
|
56
|
+
cy.env([name]).then(function (environment) {
|
|
57
|
+
var userInfo = environment[name];
|
|
58
|
+
if (!userInfo) {
|
|
59
|
+
throw new Error("Could not find ".concat(name, " in environment variables"));
|
|
60
|
+
}
|
|
61
|
+
var username = userInfo.username, password = userInfo.password;
|
|
62
|
+
// Check if username and password are set
|
|
63
|
+
if (!username || !password) {
|
|
64
|
+
throw new Error("Credential \"".concat(name, "\" is missing username and/or password"));
|
|
65
|
+
}
|
|
66
|
+
var htmlHeaders = { accept: 'text/html' };
|
|
67
|
+
// Request 1: GET Cirrus Identity discovery page
|
|
68
|
+
cy.request({
|
|
69
|
+
url: LOGIN_PAGE,
|
|
70
|
+
followRedirect: true,
|
|
71
|
+
failOnStatusCode: false,
|
|
72
|
+
headers: htmlHeaders,
|
|
73
|
+
}).then(function (discoveryRes) {
|
|
74
|
+
// Parse discovery page for HarvardKey IdP button href
|
|
75
|
+
var btnMatch = discoveryRes.body.match(new RegExp("href=[\"']([^\"']+)[\"'][^>]*id=[\"']".concat(HARVARDKEY_IDP_BUTTON_ID, "[\"']")));
|
|
76
|
+
if (!btnMatch) {
|
|
77
|
+
throw new Error('Could not find HarvardKey IdP button link on discovery page');
|
|
78
|
+
}
|
|
79
|
+
var idpUrl = "".concat(IDP_BASE_URL).concat(btnMatch[1]);
|
|
80
|
+
// Request 2: GET HarvardKey IdP login page
|
|
81
|
+
cy.request({
|
|
82
|
+
url: idpUrl,
|
|
83
|
+
followRedirect: true,
|
|
84
|
+
failOnStatusCode: false,
|
|
85
|
+
headers: htmlHeaders,
|
|
86
|
+
}).then(function (loginPageRes) {
|
|
87
|
+
// Parse login form action and hidden fields
|
|
88
|
+
var _a = getFormData(loginPageRes.body), loginFormUrl = _a.action, loginHiddenFields = _a.fields;
|
|
89
|
+
if (!loginFormUrl) {
|
|
90
|
+
throw new Error('Could not find login form action on HarvardKey page');
|
|
91
|
+
}
|
|
92
|
+
// Request 3: POST credentials to HarvardKey login form
|
|
93
|
+
cy.request({
|
|
94
|
+
method: 'POST',
|
|
95
|
+
url: loginFormUrl,
|
|
96
|
+
form: true,
|
|
97
|
+
followRedirect: true,
|
|
98
|
+
failOnStatusCode: false,
|
|
99
|
+
headers: htmlHeaders,
|
|
100
|
+
body: __assign(__assign({}, loginHiddenFields), { username: username, password: password }),
|
|
101
|
+
}).then(function (authRes) {
|
|
102
|
+
// Parse SAML form from login response
|
|
103
|
+
var _a = getFormData(authRes.body, 'form[action*="saml2-acs"]'), samlFormUrl = _a.action, samlHiddenFields = _a.fields;
|
|
104
|
+
if (!samlFormUrl) {
|
|
105
|
+
throw new Error('Could not find SAML form in login response');
|
|
106
|
+
}
|
|
107
|
+
// Request 4: POST SAML assertion to ACS
|
|
108
|
+
return cy.request({
|
|
109
|
+
method: 'POST',
|
|
110
|
+
url: samlFormUrl,
|
|
111
|
+
form: true,
|
|
112
|
+
followRedirect: true,
|
|
113
|
+
failOnStatusCode: false,
|
|
114
|
+
headers: htmlHeaders,
|
|
115
|
+
body: samlHiddenFields,
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
/*----------------------------------------*/
|
|
124
|
+
/* --------------- Export --------------- */
|
|
125
|
+
/*----------------------------------------*/
|
|
126
|
+
exports.default = logIntoPorta;
|
|
127
|
+
//# sourceMappingURL=logIntoPorta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logIntoPorta.js","sourceRoot":"","sources":["../../../src/commands/logIntoPorta.ts"],"names":[],"mappings":";AAAA,iCAAiC;;;;;;;;;;;;;AA6BjC,4CAA4C;AAC5C,kDAAkD;AAClD,4CAA4C;AAE5C,6CAA6C;AAC7C,IAAM,UAAU,GAAG,uHAAuH,CAAC;AAC3I,0CAA0C;AAC1C,IAAM,YAAY,GAAG,iCAAiC,CAAC;AACvD,oDAAoD;AACpD,IAAM,wBAAwB,GAAG,uBAAuB,CAAC;AAEzD,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C;;;;;;GAMG;AACH,IAAM,WAAW,GAAG,UAAC,IAAY,EAAE,YAAqB;;IAArB,6BAAA,EAAA,qBAAqB;IACtD,IAAM,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAC/D,IAAM,IAAI,GAAG,GAAG,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;IAC7C,IAAM,MAAM,GAAG,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,CAAC,QAAQ,CAAC,mCAAI,EAAE,CAAC;IAClD,IAAM,MAAM,GAA8B,EAAE,CAAC;IAC7C,IAAI,aAAJ,IAAI,u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3D,IAAI,CAAC,WAAW,EAAE,CAAC;4BACjB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;wBAChE,CAAC;wBAED,wCAAwC;wBACxC,OAAO,EAAE,CAAC,OAAO,CAAC;4BAChB,MAAM,EAAE,MAAM;4BACd,GAAG,EAAE,WAAW;4BAChB,IAAI,EAAE,IAAI;4BACV,cAAc,EAAE,IAAI;4BACpB,gBAAgB,EAAE,KAAK;4BACvB,OAAO,EAAE,WAAW;4BACpB,IAAI,EAAE,gBAAgB;yBACvB,CAAC,CAAC;oBACL,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,4CAA4C;AAC5C,4CAA4C;AAC5C,4CAA4C;AAE5C,kBAAe,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dceky",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"description": "Cypress toolkit for Harvard DCE",
|
|
5
5
|
"main": "./lib/src/index.js",
|
|
6
6
|
"types": "./lib/src/index.d.ts",
|
|
@@ -52,6 +52,6 @@
|
|
|
52
52
|
"typescript": "^5.9.3"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"cypress": "^
|
|
55
|
+
"cypress": "^15.11.0"
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -32,52 +32,55 @@ const handleHarvardKey = () => {
|
|
|
32
32
|
) => {
|
|
33
33
|
cy.log('🔓 Handling HarvardKey authentication via UI');
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
// Get user credentials from environment variables
|
|
36
|
+
cy.env([name]).then((environment) => {
|
|
37
|
+
const userInfo = environment[name];
|
|
38
|
+
if (!userInfo) {
|
|
39
|
+
throw new Error(`Could not find ${name} in environment variables`);
|
|
40
|
+
}
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
// Destructure the user info object
|
|
43
|
+
const { username, password } = userInfo;
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Cypress.require('dceky');
|
|
46
|
-
// To go the login screen
|
|
47
|
-
// Clicking the button doesn't work for some reason, so we access the href attribute instead
|
|
48
|
-
return cy.navigateToHref('#idp_1001962798_button');
|
|
49
|
-
}).then((fullUrl: string) => {
|
|
50
|
-
// Navigate to the Harvard login page using originWithKaixa
|
|
51
|
-
cy.origin('https://harvard.idp.cirrusidentity.com', {
|
|
52
|
-
args: { username, password, fullUrl },
|
|
53
|
-
}, (args) => {
|
|
45
|
+
// Get the Harvard login URL using originWithKaixa with auto-initialized functions
|
|
46
|
+
cy.origin('https://apps.cirrusidentity.com', () => {
|
|
54
47
|
Cypress.require('dceky');
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
// To go the login screen
|
|
49
|
+
// Clicking the button doesn't work for some reason, so we access the href attribute instead
|
|
50
|
+
return cy.navigateToHref('#idp_1001962798_button');
|
|
51
|
+
}).then((fullUrl: string) => {
|
|
52
|
+
// Navigate to the Harvard login page using originWithKaixa
|
|
53
|
+
cy.origin('https://harvard.idp.cirrusidentity.com', {
|
|
54
|
+
args: { username, password, fullUrl },
|
|
55
|
+
}, (args) => {
|
|
56
|
+
Cypress.require('dceky');
|
|
57
|
+
const {
|
|
58
|
+
username: harvardUsername,
|
|
59
|
+
password: harvardPassword,
|
|
60
|
+
fullUrl: harvardLoginUrl,
|
|
61
|
+
} = args;
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
cy.on('uncaught:exception', (e: Error) => {
|
|
64
|
+
// Ignore known HarvardKey errors
|
|
65
|
+
if (!e.message.includes('ready is not defined')) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
});
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
// Visit the Harvard login page
|
|
72
|
+
cy.visit(harvardLoginUrl);
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
// Wait for and fill in the login form
|
|
75
|
+
cy.waitForElementVisible('#username');
|
|
76
|
+
cy.waitForElementVisible('#password');
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
cy.typeInto({ item: '#username', text: harvardUsername });
|
|
79
|
+
cy.typeInto({ item: '#password', text: harvardPassword });
|
|
78
80
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
// Submit the form
|
|
82
|
+
cy.get('input[type="submit"], button[type="submit"], .btn-primary').click();
|
|
83
|
+
});
|
|
81
84
|
});
|
|
82
85
|
});
|
|
83
86
|
},
|