Skip to content

Commit

Permalink
Revert "chore(tests): temporarily disable getCrumb tests on CI"
Browse files Browse the repository at this point in the history
This reverts commit 4827e3f.
  • Loading branch information
gadicc committed Oct 4, 2024
1 parent d0fea98 commit a234d60
Showing 1 changed file with 68 additions and 75 deletions.
143 changes: 68 additions & 75 deletions src/lib/getCrumb.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,77 +17,70 @@ describe("getCrumb", () => {
});
afterAll(consoleRestore);

// XXX TODO failing on CI why?? seems to not be using cached copy just for this file?
if (!process.env.CI)
describe("_getCrumb", () => {
it("finds crumb in context", async () => {
const fetch = await env.fetchDevel();
describe("_getCrumb", () => {
it("finds crumb in context", async () => {
const fetch = await env.fetchDevel();

const crumb = await _getCrumb(
new ExtendedCookieJar(),
fetch,
{ devel: true },
logger,
"https://finance.yahoo.com/quote/AAPL",
"getCrumb-quote-AAPL.json",
true,
);
expect(crumb).toBe("mloUP8q7ZPH");
});
const crumb = await _getCrumb(
new ExtendedCookieJar(),
fetch,
{ devel: true },
logger,
"https://finance.yahoo.com/quote/AAPL",
"getCrumb-quote-AAPL.json",
true,
);
expect(crumb).toBe("mloUP8q7ZPH");
});

it("ditto with shared cookie jar (don't use it for other tests)", async () => {
const fetch = await env.fetchDevel();
it("ditto with shared cookie jar (don't use it for other tests)", async () => {
const fetch = await env.fetchDevel();

const crumb = await _getCrumb(
cookieJar,
fetch,
{ devel: true },
logger,
);
expect(crumb).toBe("mloUP8q7ZPH");
});
const crumb = await _getCrumb(cookieJar, fetch, { devel: true }, logger);
expect(crumb).toBe("mloUP8q7ZPH");
});

it("re-uses cookie", async () => {
const fetch = await env.fetchDevel();
it("re-uses cookie", async () => {
const fetch = await env.fetchDevel();

let crumb = await _getCrumb(
cookieJar,
fetch,
{ devel: true },
logger,
"https://finance.yahoo.com/quote/AAPL",
);
expect(crumb).toBe("mloUP8q7ZPH");
let crumb = await _getCrumb(
cookieJar,
fetch,
{ devel: true },
logger,
"https://finance.yahoo.com/quote/AAPL",
);
expect(crumb).toBe("mloUP8q7ZPH");

// TODO, at tests to see how many times fetch was called, etc.
// TODO, at tests to see how many times fetch was called, etc.

crumb = await _getCrumb(
cookieJar,
crumb = await _getCrumb(
cookieJar,
fetch,
{ devel: true },
logger,
"https://finance.yahoo.com/quote/AAPL",
);
expect(crumb).toBe("mloUP8q7ZPH");
});

it("throws on no cookies", async () => {
const fetch = await env.fetchDevel();

await expect(() =>
_getCrumb(
new ExtendedCookieJar(),
fetch,
{ devel: true },
logger,
"https://finance.yahoo.com/quote/AAPL",
);
expect(crumb).toBe("mloUP8q7ZPH");
});

it("throws on no cookies", async () => {
const fetch = await env.fetchDevel();

await expect(() =>
_getCrumb(
new ExtendedCookieJar(),
fetch,
{ devel: true },
logger,
"https://finance.yahoo.com/quote/AAPL",
"getCrumb-quote-AAPL-no-cookies.fake.json",
true,
),
).rejects.toThrowError(/No set-cookie/);
});

/*
"getCrumb-quote-AAPL-no-cookies.fake.json",
true,
),
).rejects.toThrowError(/No set-cookie/);
});

/*
test for commented out code.
it("throws on no context", async () => {
const fetch = await env.fetchDevel();
Expand Down Expand Up @@ -138,23 +131,23 @@ describe("getCrumb", () => {
});
*/

it("redirect https://guce.yahoo.com/consent?brandType=nonEu", async () => {
// consoleRestore();
const fetch = await env.fetchDevel();
it("redirect https://guce.yahoo.com/consent?brandType=nonEu", async () => {
// consoleRestore();
const fetch = await env.fetchDevel();

const crumb = await _getCrumb(
new ExtendedCookieJar(),
fetch,
{ devel: true },
logger,
"https://finance.yahoo.com/quote/AAPL",
"getCrumb-quote-AAPL-pre-consent-VPN-UK.json",
true,
);
expect(crumb).toBe("mloUP8q7ZPH");
// consoleSilent();
});
const crumb = await _getCrumb(
new ExtendedCookieJar(),
fetch,
{ devel: true },
logger,
"https://finance.yahoo.com/quote/AAPL",
"getCrumb-quote-AAPL-pre-consent-VPN-UK.json",
true,
);
expect(crumb).toBe("mloUP8q7ZPH");
// consoleSilent();
});
});

describe("getCrumb", () => {
it("works", async () => {
Expand Down

0 comments on commit a234d60

Please sign in to comment.