Skip to content

Commit

Permalink
Merge pull request #1018 from necyberteam/md-dev
Browse files Browse the repository at this point in the history
Md dev
  • Loading branch information
a-pasquale authored Nov 29, 2023
2 parents 8b04228 + 76b9925 commit 3378605
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 78 deletions.
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions tests/cypress/cypress/e2e/accessmatch/community-overview.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
This test is specifically focused on the Community Overview Page tested for an unauthenticated user.
This test checks for major functions like:
Page Title,
CTA Functionality
Popular Tags
*/

describe("Unauthenticated user tests the Community Overview Page", () => {
it("Should test Community Overview Page for unauthenticated user", () => {
// login user with the "unauthenticated" role
cy.visit("/community/overview");

//Page Title
cy.get(".page-title").contains("Community");

//Call to action function
cy.verifyCallToActionBlock(
"/community/overview",
"Join the CSSN",
"/user/login?destination=/cssn%23join-cssn"
);

//Popular Tags tested?
});
});
44 changes: 44 additions & 0 deletions tests/cypress/cypress/e2e/accessmatch/match-overview.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
This test is specifically focused on the Match Overview Page tested for an unauthenticated user.
This test checks for major functions like:
Page Title,
CTA Functionality
Match Enagagements section
*/

describe("Unauthenticated user tests the Match Overview Page", () => {
it("Should test Match Overview Page for unauthenticated user", () => {
// login user with the "unauthenticated" role
cy.visit("/match/overview");

//Page Title
cy.get(".page-title > .field").contains("Match Services Overview");

//Call to action function
cy.verifyCallToActionBlock(
"/match/overview",
"Request an engagement",
"/node/add/match_engagement?type=plus"
);

//Match Engagements Header
cy.get(".m-0").contains("MATCH Engagements");

//Match Engagements Btn
cy.get(".btn")
.should("exist")
.contains("All Engagements")
.should("have.attr", "href", "/match/engagements");

//Individual Match Engagement
cy.get(":nth-child(2) > .card > .card-body").contains(
"GPU-accelerated ice sheet flow modeling"
);
cy.get(":nth-child(2) > .card > .card-body").contains(
"University of North Dakota"
);
cy.get(":nth-child(2) > .card > .card-body").contains(
"Status: In Progress"
);
});
});
23 changes: 23 additions & 0 deletions tests/cypress/cypress/e2e/accessmatch/video-learning-center.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
This test is specifically focused on the Video Learning Center Page tested for an unauthenticated user.
This test checks for major functions like:
Page Title,
CTA Functionality
*/

describe("Unauthenticated user tests the Video Learning Center Page", () => {
it("Should test Video Learning Center Page for unauthenticated user", () => {
// login user with the "unauthenticated" role
cy.visit("/video-learning-center");

//Page Title
cy.get(".page-title").contains("ACCESS Support Video Learning Center");

//Call to action function
cy.verifyCallToActionBlock(
"/video-learning-center",
"ACCESS CI YouTube Channel",
"https://www.youtube.com/c/ACCESSforCI"
);
});
});
146 changes: 73 additions & 73 deletions tests/cypress/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Verify all images load.
*/
Cypress.Commands.add('verifyImages', () => {
cy.get('img').each(($img) => cy.wrap($img).verifyImage());
Cypress.Commands.add("verifyImages", () => {
cy.get("img").each(($img) => cy.wrap($img).verifyImage());
});

/**
Expand All @@ -14,8 +14,8 @@ Cypress.Commands.add('verifyImages', () => {
* .get('img')
* .verifyImage();
*/
Cypress.Commands.add('verifyImage', { prevSubject: true }, ($img) => {
const url = ($img[0]?.src || $img[0]?.srcset);
Cypress.Commands.add("verifyImage", { prevSubject: true }, ($img) => {
const url = $img[0]?.src || $img[0]?.srcset;
if (url) {
cy.request(url).then((response) => {
// verify the image response is 200, and has a non-zero length body
Expand Down Expand Up @@ -49,28 +49,25 @@ Cypress.Commands.add('verifyImage', { prevSubject: true }, ($img) => {
* crumbs are present and have the expected hrefs.
*
*/
Cypress.Commands.add('checkBreadcrumbs', (crumbs) => {
Cypress.Commands.add("checkBreadcrumbs", (crumbs) => {
var crumb, href;
for ([crumb, href] of crumbs) {
if (href) {
cy.get('.breadcrumb')
cy.get(".breadcrumb")
.contains(crumb)
.should('have.attr', 'href')
.and('contain', href);
.should("have.attr", "href")
.and("contain", href);
} else {
cy.get('.breadcrumb')
.contains(crumb)
.should('not.have.attr', 'href');
cy.get(".breadcrumb").contains(crumb).should("not.have.attr", "href");
}

}
});

/**
* Logs out the user.
*/
Cypress.Commands.add('drupalLogout', () => {
cy.visit('/user/logout');
Cypress.Commands.add("drupalLogout", () => {
cy.visit("/user/logout");
});

/**
Expand All @@ -81,31 +78,30 @@ Cypress.Commands.add('drupalLogout', () => {
* @param {string} password
* The password for the user's account.
*/
Cypress.Commands.add('loginAs', (username, password) => {
Cypress.Commands.add("loginAs", (username, password) => {
cy.drupalLogout();
cy.visit('/f64816be-34ca-4d5b-975a-687cb374ddf7');
cy.get('#edit-name')
.type(username);
cy.get('#edit-pass').type(password, {
cy.visit("/f64816be-34ca-4d5b-975a-687cb374ddf7");
cy.get("#edit-name").type(username);
cy.get("#edit-pass").type(password, {
log: false,
});
cy.get('.form-submit').contains('Log in').click();
cy.get(".form-submit").contains("Log in").click();
});

/**
* Logs a user in by their uid via drush uli.
*/
Cypress.Commands.add('loginUserByUid', (uid) => {
cy.drush('user-login', [], { uid, uri: Cypress.env('baseUrl') })
.its('stdout')
* Logs a user in by their uid via drush uli.
*/
Cypress.Commands.add("loginUserByUid", (uid) => {
cy.drush("user-login", [], { uid, uri: Cypress.env("baseUrl") })
.its("stdout")
.then(function (url) {
cy.visit(url);
});
});

/**
* Custom command to verify the existence of a button within the "region-cta" block
*/
* Custom command to verify the existence of a button within the "region-cta" block
*/
Cypress.Commands.add("verifyCallToActionBlock", (url, text, href) => {
// Visit the specified URL
cy.visit(url);
Expand All @@ -115,35 +111,37 @@ Cypress.Commands.add("verifyCallToActionBlock", (url, text, href) => {
cy.get("#cta")
.should("exist")
.contains(text)
.should("have.attr", "href", href);
.should("have.attr", "href")
.and("contain", href);
});

/**
* Deletes last node created.
*/
Cypress.Commands.add('deleteLastNode', () => {
cy.visit('/admin/content');
cy.get('tbody > :nth-child(1) > .views-field-title > a').click();
cy.get('#block-dingo-local-tasks > ul > :nth-child(3) > a').click({ force: true });
* Deletes last node created.
*/
Cypress.Commands.add("deleteLastNode", () => {
cy.visit("/admin/content");
cy.get("tbody > :nth-child(1) > .views-field-title > a").click();
cy.get("#block-dingo-local-tasks > ul > :nth-child(3) > a").click({
force: true,
});
cy.get('[value="Delete"]').click();
});

/**
* Logs a user in by their uid via drush uli.
*/
Cypress.Commands.add('drushUli', () => {
cy.task('log', 'in drushUli');

cy.drush('uli', ['--uri=' + Cypress.config('baseUrl')], {})
.then((result) => {
cy.task('log', 'result = ' + JSON.stringify(result));
if (result.code !== 0) {
throw new Error(result.stderr);
} else {
cy.task('log', 'drushUli trying to visit "' + result.stdout + '"');
cy.visit(result.stdout);
}
});
* Logs a user in by their uid via drush uli.
*/
Cypress.Commands.add("drushUli", () => {
cy.task("log", "in drushUli");

cy.drush("uli", ["--uri=" + Cypress.config("baseUrl")], {}).then((result) => {
cy.task("log", "result = " + JSON.stringify(result));
if (result.code !== 0) {
throw new Error(result.stderr);
} else {
cy.task("log", 'drushUli trying to visit "' + result.stdout + '"');
cy.visit(result.stdout);
}
});
});

/**
Expand All @@ -157,10 +155,12 @@ Cypress.Commands.add('drushUli', () => {
* our Cypress tests don't crash if the drush command returns an error (e.g.
* if we try to delete a user account that does not exist.)
*/
Cypress.Commands.add('drush', (command, args = [], options = {}) => {
cy.task('log', 'in drush, command = "' + command + '"');
const ee = `drush ${command} ${stringifyArguments(args)} ${stringifyOptions(options)} -y`;
cy.task("log", 'in drush, about to exec this: ' + ee);
Cypress.Commands.add("drush", (command, args = [], options = {}) => {
cy.task("log", 'in drush, command = "' + command + '"');
const ee = `drush ${command} ${stringifyArguments(args)} ${stringifyOptions(
options
)} -y`;
cy.task("log", "in drush, about to exec this: " + ee);
return cy.exec(ee, { failOnNonZeroExit: false });
});

Expand All @@ -171,8 +171,8 @@ Cypress.Commands.add('drush', (command, args = [], options = {}) => {
* @returns
*/
function stringifyArguments(args) {
return args.join(' ');
};
return args.join(" ");
}

/**
* Returns a string from an array of options.
Expand All @@ -181,25 +181,25 @@ function stringifyArguments(args) {
* @returns
*/
function stringifyOptions(options) {
return Object.keys(options).map(option => {
let output = `--${option}`;

if (options[option] === true) {
return output;
}
return Object.keys(options)
.map((option) => {
let output = `--${option}`;

if (options[option] === false) {
return '';
}

if (typeof options[option] === 'string') {
output += `="${options[option]}"`;
} else {
output += `=${options[option]}`
}
if (options[option] === true) {
return output;
}

return output;
}).join(' ')
};
if (options[option] === false) {
return "";
}

if (typeof options[option] === "string") {
output += `="${options[option]}"`;
} else {
output += `=${options[option]}`;
}

return output;
})
.join(" ");
}
Original file line number Diff line number Diff line change
Expand Up @@ -1100,11 +1100,12 @@ display:
options:
query_comment: ''
disable_sql_rewrite: false
distinct: false
distinct: true
replica: false
query_tags: { }
contextual_filters_or: false
relationships: { }
group_by: false
header: { }
footer: { }
display_extenders: { }
Expand Down

0 comments on commit 3378605

Please sign in to comment.