Skip to content

Commit

Permalink
🪟 🚦 E2E: Fix duplicated database object warning (#20926)
Browse files Browse the repository at this point in the history
* replace "cypress-postgres" with "pg-promise" npm package

* update cypress config

* update userDefineConnection type and naming

* Update airbyte-webapp-e2e-tests/cypress/plugins/index.ts

Co-authored-by: Mark Berger <mark.berger@globallogic.com>

Co-authored-by: Mark Berger <mark.berger@globallogic.com>
  • Loading branch information
2 people authored and jbfbell committed Jan 13, 2023
1 parent cf876b1 commit 9ba1fce
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 88 deletions.
22 changes: 21 additions & 1 deletion airbyte-webapp-e2e-tests/cypress/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,33 @@

import Cypress from "cypress";

const pgp = require("pg-promise")();
const cypressConfig = require(require("path").resolve("cypress.json"));

interface dbConfig {
user: string;
host: string;
database: string;
password: string;
port: number;
}

function dbConnection(query: any, userDefineConnection: dbConfig) {
let connection = cypressConfig.db;
if (userDefineConnection !== undefined) {
connection = userDefineConnection;
}
const db = pgp(connection);
return db.any(query).finally(db.$pool.end);
}

/**
* @type {Cypress.PluginConfig}
*/
module.exports = (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
on("task", {
dbQuery: (query) => require("cypress-postgres")(query.query, query.connection),
dbQuery: (query) => dbConnection(query.query, query.connection),
});
};
143 changes: 57 additions & 86 deletions airbyte-webapp-e2e-tests/package-lock.json

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

2 changes: 1 addition & 1 deletion airbyte-webapp-e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"@typescript-eslint/eslint-plugin": "^5.27.1",
"@typescript-eslint/parser": "^5.27.1",
"cypress": "^9.2.0",
"cypress-postgres": "^1.1.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-prettier": "^4.0.0",
"pg-promise": "^10.15.4",
"prettier": "^2.6.2",
"typescript": "^4.5.4"
}
Expand Down

0 comments on commit 9ba1fce

Please sign in to comment.