-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
4,246 additions
and
4,642 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ uploads | |
modules/core/presentation/assets/css/main.min.css | ||
bin/ | ||
logs/ | ||
migrations/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,45 @@ | ||
const util = require("node:util"); | ||
const cp = require("node:child_process"); | ||
const { defineConfig } = require("cypress"); | ||
const { Pool } = require("pg"); | ||
|
||
const exec = util.promisify(cp.exec); | ||
const { env } = process; | ||
const pool = new Pool({ | ||
connectionString: `postgres://${env.DB_USER}:${env.DB_PASSWORD}@${env.DB_HOST}:${env.DB_PORT}/${env.DB_NAME}`, | ||
}); | ||
|
||
async function resetDatabase() { | ||
const client = await pool.connect(); | ||
try { | ||
const res = await client.query( | ||
"SELECT tablename FROM pg_tables WHERE schemaname = 'public';", | ||
); | ||
for (const row of res.rows) { | ||
await client.query(`TRUNCATE TABLE ${row.tablename} RESTART IDENTITY CASCADE;`); | ||
} | ||
} finally { | ||
client.release(); | ||
} | ||
return null; | ||
} | ||
|
||
async function seedDatabase() { | ||
await exec("cd .. && go run cmd/seed/main.go"); | ||
return null; | ||
} | ||
|
||
module.exports = defineConfig({ | ||
e2e: { | ||
defaultCommandTimeout: 15000, | ||
requestTimeout: 20000, | ||
responseTimeout: 20000, | ||
pageLoadTimeout: 60000, | ||
setupNodeEvents(on, config) { | ||
// implement node event listeners here | ||
}, | ||
}, | ||
e2e: { | ||
defaultCommandTimeout: 15000, | ||
requestTimeout: 20000, | ||
responseTimeout: 20000, | ||
pageLoadTimeout: 60000, | ||
setupNodeEvents(on, config) { | ||
on("task", { | ||
resetDatabase, | ||
seedDatabase, | ||
}); | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,14 +12,19 @@ const login = (email, password) => { | |
}; | ||
|
||
describe("user auth and registration flow", () => { | ||
before(() => { | ||
cy.task("resetDatabase"); | ||
cy.task("seedDatabase"); | ||
}); | ||
|
||
afterEach(() => { | ||
cy.visit("http://localhost:3200/logout"); | ||
}); | ||
|
||
it("creates a user and displays changes in users table", () => { | ||
login("[email protected]", "TestPass123!"); | ||
cy.visit("http://localhost:3200/users"); | ||
cy.get('a[href="/users/new"]').filter(':visible').click(); | ||
cy.get('a[href="/users/new"]').filter(":visible").click(); | ||
cy.get("[name=FirstName]").type("Test"); | ||
cy.get("[name=LastName]").type("User"); | ||
cy.get("[name=MiddleName]").type("Mid"); | ||
|
@@ -28,10 +33,7 @@ describe("user auth and registration flow", () => { | |
cy.get("[name=UILanguage]").select(2); | ||
cy.get("[x-ref=trigger]").click(); | ||
cy.get("ul[x-ref=list]").should("be.visible"); | ||
cy.get("ul[x-ref=list]") | ||
.find("li") | ||
.first() | ||
.click(); | ||
cy.get("ul[x-ref=list]").find("li").first().click(); | ||
cy.get("[id=save-btn]").click(); | ||
cy.visit("http://localhost:3200/users"); | ||
cy.get("tbody tr").should("have.length", 2); | ||
|
@@ -43,4 +45,28 @@ describe("user auth and registration flow", () => { | |
cy.url().should("include", "/users"); | ||
cy.get("tbody tr").should("have.length", 2); | ||
}); | ||
|
||
it("edits a user and displays changes in users table", () => { | ||
login("[email protected]", "TestPass123!"); | ||
cy.visit("http://localhost:3200/users"); | ||
|
||
cy.get("tbody tr").contains("td", "Test User").parent("tr").find("td a").click(); | ||
cy.url().should("include", "/users/"); | ||
cy.get("[name=FirstName]").clear().type("TestNew"); | ||
cy.get("[name=LastName]").clear().type("UserNew"); | ||
cy.get("[name=MiddleName]").clear().type("MidNew"); | ||
cy.get("[name=Email]").clear().type("[email protected]"); | ||
cy.get("[name=UILanguage]").select(1); | ||
cy.get("[id=save-btn]").click(); | ||
|
||
cy.visit("http://localhost:3200/users"); | ||
cy.get("tbody tr").should("have.length", 2); | ||
cy.get("tbody tr").should("contain.text", "TestNew UserNew MidNew"); | ||
cy.get("tbody tr").should("contain.text", "[email protected]"); | ||
|
||
cy.visit("http://localhost:3200/logout"); | ||
login("[email protected]", "TestPass123!"); | ||
cy.visit("http://localhost:3200/users"); | ||
cy.url().should("include", "/users"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"dependencies": { | ||
"cypress": "^13.15.0" | ||
"cypress": "^13.15.0", | ||
"pg": "^8.13.3" | ||
} | ||
} |
Oops, something went wrong.