Skip to content

Commit

Permalink
Find the gunaha script
Browse files Browse the repository at this point in the history
  • Loading branch information
fbanados committed Jan 20, 2025
1 parent ea1db60 commit 3406f83
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
33 changes: 32 additions & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ Cypress.Commands.overwrite("visit", (originalVisit, url, options) => {
Cypress.Commands.add(
"visitSearch",
{ prevSubject: false },
(searchQuery, baseUrl = urls.crkeng) => {
(searchQuery, baseUrl = urls.crkeng, headers = {}) => {
Cypress.log({
name: "visitSearch",
message: `visiting search page for: ${searchQuery}`,
});
return cy.visit(`${baseUrl}/search?q=${encodeURIComponent(searchQuery)}`, {
escapeComponents: false,
headers
});
}
);
Expand Down Expand Up @@ -134,6 +135,36 @@ Cypress.Commands.add("login", () => {
});
});

Cypress.Commands.add("user_login", (url) => {
cy.visit(url);
cy.get("[name=csrfmiddlewaretoken]")
.should("exist")
.should("have.attr", "value")
.as("csrfToken");
cy.get("@csrfToken").then(function (token) {
cy.request({
method: "POST",
url: url,
form: true,
body: {
username : "test_user",
password : "test",
next: "/",
csrfmiddlewaretoken: token,
},
headers: {
"X-CSRFTOKEN": token,
},
followRedirect: true,
}).then((response) => {
expect(response.status).to.eql(200);
cy.getCookies().then(cookies => {
Cypress.env('cookies', cookies)
})
});
});
});

/**
* This function returns the column header visually to the top of a td element
* (a column header is a th element with scope=col)
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-cypress
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def main():

# Create the gunaha user!
for script in manage_scripts:
with open('./create_gunaha_user') as stdin:
with open( script_dir / 'create_gunaha_user') as stdin:
check_call([script, "shell"], env=m_env, stdin=stdin)

servers = []
Expand Down

0 comments on commit 3406f83

Please sign in to comment.