Skip to content

Commit

Permalink
chore: fix last card test
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Oct 21, 2024
1 parent ee55943 commit 4eb4ce9
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions cypress/e2e/claim-gift-card.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ const permitConfig = {
FRONTEND_URL: "http://localhost:8080",
};

async function createPermitUrl(config: PermitConfig) {
const permit = await generateErc20Permit(config);
cy.wrap(permit).as("permitUrl");
return permit;
}

describe("Gift Cards", () => {
beforeEach(() => {
let permitUrl: string;

beforeEach(async () => {
cy.clearAllCookies();
cy.clearAllLocalStorage();
cy.clearAllSessionStorage();
Expand All @@ -26,8 +34,9 @@ describe("Gift Cards", () => {
});

it("should show redeem info", async () => {
const permitUrl = await generateErc20Permit(permitConfig);
cy.visit(`/${permitUrl.split("?")[1]}`);
permitUrl = await createPermitUrl(permitConfig);
expect(permitUrl).to.be.a("string");
cy.visit(`/?${permitUrl.split("?")[1]}`);

cy.wait("@getBestCard");
cy.wait(2000);
Expand All @@ -39,10 +48,12 @@ describe("Gift Cards", () => {
});

it("should claim a gift card", async () => {
const customPermitConfig = { ...permitConfig, AMOUNT_IN_ETH: "30.0" };
const testPermitConfig = { ...permitConfig, AMOUNT_IN_ETH: "30.0" };
permitUrl = await createPermitUrl(testPermitConfig);
expect(permitUrl).to.be.a("string");

const permitUrl = await generateErc20Permit(customPermitConfig);
cy.visit(`/${permitUrl.split("?")[1]}`);
cy.wrap(permitUrl).as("permitUrl");
cy.visit(`/?${permitUrl.split("?")[1]}`);
cy.wait(2000);

cy.wait("@getBestCard");
Expand Down Expand Up @@ -75,10 +86,12 @@ describe("Gift Cards", () => {
});

it("should reveal a redeem code after claim", () => {
cy.visit(
"/?claim=W3sidHlwZSI6ImVyYzIwLXBlcm1pdCIsInBlcm1pdCI6eyJwZXJtaXR0ZWQiOnsidG9rZW4iOiIweGU5MUQxNTNFMGI0MTU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QwODY1NzE0MDkxMzAwIiwiZGVhZGxpbmUiOiIxMTU3OTIwODkyMzczMTYxOTU0MjM1NzA5ODUwMDg2ODc5MDc4NTMyNjk5ODQ2NjU2NDA1NjQwMzk0NTc1ODQwMDc5MTMxMjk2Mzk5MzUifSwidHJhbnNmZXJEZXRhaWxzIjp7InRvIjoiMHhmMzlGZDZlNTFhYWQ4OEY2RjRjZTZhQjg4MjcyNzljZmZGYjkyMjY2IiwicmVxdWVzdGVkQW1vdW50IjoiOTAwMDAwMDAwMDAwMDAwMDAwMCJ9LCJvd25lciI6IjB4NzA5OTc5NzBDNTE4MTJkYzNBMDEwQzdkMDFiNTBlMGQxN2RjNzlDOCIsInNpZ25hdHVyZSI6IjB4N2RhZjExM2E1MDRmNjFjOTkwODRkYzZkYWVlNmRkMWRmOGEzYjhiMzllNTQ3ZWRhYjEyM2E3NDE2MGE1ZWE0NjBkODI4N2ZhYzUwOWFhNzkzZmE2NzkzZGU5ODliZWE5ODhjYzc0MDI0YTlmZDI2MDIyNjZhNDNmODUwOWFhMmQxYiIsIm5ldHdvcmtJZCI6MzEzMzd9XQ=="
);
cy.wait("@getBestCard");
expect(permitUrl).to.be.a("string");
cy.get("@permitUrl").then((url: JQuery<HTMLElement>) => {
cy.visit(`/?${url.text().split("?")[1]}`);
cy.wait(2000);
cy.wait("@getBestCard");
});

cy.get("#gift-cards").should("exist").and("include.text", "Your virtual card");
cy.get("#redeem-code > h3").eq(0).should("have.text", "Redeem code");
Expand Down

0 comments on commit 4eb4ce9

Please sign in to comment.