Skip to content

Commit f2b20ce

Browse files
Port to Cookie Connoisseur the test for patching Sugar frenzy not disappearing sometimes.
1 parent ffe874c commit f2b20ce

File tree

2 files changed

+42
-18
lines changed

2 files changed

+42
-18
lines changed

old-test.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,6 @@ function testImplicitAssumptions() {
66
}
77
testImplicitAssumptions();
88

9-
function testSugarFrenzyPatch() {
10-
Util.wipeSave();
11-
Game.Earn(1e9); // Unlock lumps
12-
Game.Upgrades['Sugar craving'].earn();
13-
Util.Ascend(); Util.Reincarnate();
14-
Game.lumps = 1;
15-
Game.Upgrades['Sugar frenzy'].click();
16-
console.assert(Game.Upgrades['Sugar frenzy'].bought == 0); // Check it is still present
17-
18-
Game.lumps = 1;
19-
document.getElementById('prefsButton').click();
20-
document.getElementById('SpiceButtonpatchSugarFrenzyPersistence').click();
21-
Game.Upgrades['Sugar frenzy'].click();
22-
console.assert(Game.Upgrades['Sugar frenzy'].bought == 1); // Check the patch works
23-
24-
console.log("Finished testSugarFrenzyPatch()");
25-
}
26-
279
function test777buffs() {
2810
let unlockHC = function() {
2911
Game.Upgrades['Heavenly chip secret'].earn();

test/sugar-frenzy-patch.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* Test the patch for Sugar frenzy not disappearing if the player has only one lump.
2+
*/
3+
4+
import { test, expect } from '@playwright/test';
5+
import { Page } from 'playwright';
6+
import { setupCookieClickerPage, CCSave } from 'cookie-connoisseur';
7+
8+
let saveGame = {
9+
prefs: {
10+
showBackupWarning: false,
11+
},
12+
cookies: 1e12,
13+
cookiesEarned: 1e12,
14+
lumps: 1,
15+
lumpsTotal: 1,
16+
ownedUpgrades: ['Sugar craving'],
17+
};
18+
19+
test.describe('Sugar frenzy patch', () => {
20+
test('works', async ({ page }) => {
21+
await setupCookieClickerPage(page, {saveGame});
22+
await page.evaluate(() => Game.LoadMod('https://staticvariablejames.github.io/SpicedCookies/Spice.js'));
23+
await page.waitForFunction(() => 'Spiced cookies' in Game.mods);
24+
25+
await page.click('text=Options');
26+
await page.click('#SpiceButtonpatchSugarFrenzyPersistence');
27+
await page.click('text=Options');
28+
29+
await page.click('#upgrade0'); // First upgrade in the store == Sugar frenzy switch
30+
31+
await page.pause();
32+
expect(await page.evaluate(() => 'Sugar frenzy' in Game.buffs)).toBe(true);
33+
expect(await page.evaluate(() => Game.Upgrades['Sugar frenzy'].bought)).toBe(1);
34+
});
35+
36+
test('is not present in the vanilla game', async ({ page }) => {
37+
await setupCookieClickerPage(page, {saveGame});
38+
await page.click('#upgrade0');
39+
expect(await page.evaluate(() => 'Sugar frenzy' in Game.buffs)).toBe(true);
40+
expect(await page.evaluate(() => Game.Upgrades['Sugar frenzy'].bought)).toBe(0);
41+
});
42+
});

0 commit comments

Comments
 (0)