Skip to content

Instantly share code, notes, and snippets.

View maxhoheiser's full-sized avatar

Max maxhoheiser

View GitHub Profile
@maxhoheiser
maxhoheiser / firehose_redshift_cdk_app.py
Created March 4, 2024 20:16
CDK Python app deploying firehose data stream with kinesis as source and redshift as target
import random
import string
import aws_cdk as cdk
import aws_cdk.aws_ec2 as ec2
import aws_cdk.aws_iam as iam
import aws_cdk.aws_kinesis as kinesis
import aws_cdk.aws_kinesisfirehose as firehose
import aws_cdk.aws_logs as logs
import aws_cdk.aws_redshift as redshift
Cypress.Commands.add("disconnectAllAccountsFromAllDapps", () => {
cy.visit(`/`);
cy.get("[data-cy=metamaskButton]").then(($btn) => {
if ($btn.text() !== "Connect Wallet") {
cy.switchToAccount(1);
cy.disconnectMetamaskWalletFromDapp().should("be.true");
cy.switchMetamaskAccount(2).should("be.true");
cy.disconnectMetamaskWalletFromDapp().should("be.true");
cy.switchMetamaskAccount(3).should("be.true");
cy.disconnectMetamaskWalletFromDapp().should("be.true");
@maxhoheiser
maxhoheiser / commands.js
Created March 30, 2022 09:36
Custom cypress login command
const publicKeys = {
// admin
[1]: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
// user
[2]: "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
[3]: "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
};
Cypress.Commands.add(
"switchToAccount",
@maxhoheiser
maxhoheiser / commands.js
Created March 30, 2022 09:33
Example cypress custom command
import "@testing-library/cypress/add-commands";
Cypress.Commands.add("login", () => {
cy.visit(`/`);
cy.findByRole("button", {
name: "Connect Wallet",
})
.click()
.then(() => {
cy.acceptMetamaskAccess().should("be.true");
@maxhoheiser
maxhoheiser / index.d.js
Created March 22, 2022 16:51
Example type definition for new Cypress custom command
/**
* Confirm metamask request for public encryption key
* @example
* cy.confirmMetamaskEncryptionPublicKeyRequest()
*/
confirmMetamaskEncryptionPublicKeyRequest(): Chainable<Subject>;
/**
* Reject metamask request for public encryption key
* @example
* cy.rejectMetamaskEncryptionPublicKeyRequest()
@maxhoheiser
maxhoheiser / index.js
Created March 22, 2022 16:46
Example addition of custom code to Cypress plugins/index.js
confirmMetamaskEncryptionPublicKeyRequest: async () => {
const confirmed = await metamask.confirmEncryptionPublicKeyRequest();
return confirmed;
},
rejectMetamaskEncryptionPublicKeyRequest: async () => {
const rejected = await metamask.rejectEncryptionPublicKeyRequest();
return rejected;
},
@maxhoheiser
maxhoheiser / index.js
Created March 22, 2022 16:37
Example custom Cypress command in index.js
Cypress.Commands.add('confirmMetamaskEncryptionPublicKeyRequest', () => {
return cy.task('confirmMetamaskEncryptionPublicKeyRequest');
});
Cypress.Commands.add('rejectMetamaskEncryptionPublicKeyRequest', () => {
return cy.task('rejectMetamaskEncryptionPublicKeyRequest');
});
@maxhoheiser
maxhoheiser / metamask.js
Last active March 22, 2022 16:33
Example function to handle puppeteer integration
const {
encryptionPublicKeyPageElements,
} = require('../pages/metamask/notification-page');
confirmEncryptionPublicKeyRequest: async () => {
const notificationPage = await puppeteer.switchToMetamaskNotification();
await puppeteer.waitAndClick(
encryptionPublicKeyPageElements.confirmEncryptionPublicKeyButton,
notificationPage,
);
@maxhoheiser
maxhoheiser / notification-page.js
Created March 17, 2022 13:56
Example page extention
const confirmEncryptionPublicKeyButton = `${notificationPage} .request-encryption-public-key__footer__sign-button`;
const rejectEncryptionPublicKeyButton = `${notificationPage} .request-encryption-public-key__footer__cancel-button`;
module.exports.encryptionPublicKeyPageElements = {
confirmEncryptionPublicKeyButton,
rejectEncryptionPublicKeyButton,
};
@maxhoheiser
maxhoheiser / decrypt-message.spec.js
Created March 17, 2022 13:27
Example decrypt message test
describe("Decrypt message", () => {
before(() => {
cy.login();
cy.switchToAccountOne();
cy.visit(`${Cypress.config().baseUrl}/redeem/12`);
});
it("Should decrypt public key", () => {
cy.findByRole("button", { name: /redeem via metamask/i }).click();
cy.confirmMetamaskDecryptionRequest().then((accepted) => {
expect(accepted).to.be.true;