Skip to content

Fix console errors: SW partial response caching, deprecated meta tag, unused preload#1726

Merged
pethers merged 6 commits intomainfrom
copilot/fix-console-errors
Mar 25, 2026
Merged

Fix console errors: SW partial response caching, deprecated meta tag, unused preload#1726
pethers merged 6 commits intomainfrom
copilot/fix-console-errors

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

  • Fix 1: Service Worker partial response (206) caching β€” response.status !== 206 check
  • Fix 2: Remove deprecated X-UA-Compatible meta tag β€” IE/Chrome Frame discontinued
  • Fix 3: Remove unused logo preload β€” React-loaded asset triggers timeout warning
  • Fix 4: GET-only caching guard β€” event.request.method === "GET" prevents non-GET cache failures
  • Fix 5: Return cache.put() from .then() β€” rejections properly propagate to .catch() handler
  • Fix 6: Wrap cache write in event.waitUntil() β€” keeps SW alive until cache write completes
  • Fix 7: Relax test assertions β€” behavioral regexes that verify event.waitUntil(), caches.open().then() β†’ cache.put() β†’ .catch() chain without enforcing specific formatting
  • All fixes applied to both public/sw.js and docs/sw.js
  • 35 tests passing

✨ Let Copilot coding agent set things up for you β€” coding agent works faster and does higher quality work when set up for your repo.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 25, 2026

Dependency Review

βœ… No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA fef8a2f.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

…ta tag and unused preload

- Fix service worker cache.put() error on status 206 (partial responses)
  by adding response.status !== 206 check before caching
- Remove deprecated X-UA-Compatible meta tag (IE/Chrome Frame discontinued)
- Remove unused preload for black-trigram.png (loaded by React component,
  not consumed fast enough causing browser warning)
- Update docs/ deployed files with same fixes
- Add tests for partial response filtering, deprecated meta tag removal,
  and preload removal

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Hack23/blacktrigram/sessions/8ab46ff8-8857-4b9b-8ccb-3b7d507d1fd3
@github-actions github-actions bot added documentation Documentation updates testing Testing improvements test-coverage-impact Impacts test coverage labels Mar 25, 2026
Copilot AI changed the title [WIP] Fix console errors and address service worker issues Fix console errors: SW partial response caching, deprecated meta tag, unused preload Mar 25, 2026
Copilot AI requested a review from pethers March 25, 2026 11:36
@pethers pethers marked this pull request as ready for review March 25, 2026 11:38
@pethers pethers requested a review from Copilot March 25, 2026 11:38
@github-actions
Copy link
Copy Markdown
Contributor

πŸ“Έ Automated UI Screenshots

πŸ“‹ Screenshots Captured (8)

# Screenshot
1 01-splash-screen.png - 01 splash screen.png
2 02-intro-screen-menu.png - 02 intro screen menu.png
3 03-intro-screen-archetype-selector.png - 03 intro screen archetype selector.png
4 04-controls-screen.png - 04 controls screen.png
5 05-philosophy-screen.png - 05 philosophy screen.png
6 06-training-screen.png - 06 training screen.png
7 07-combat-screen-practice.png - 07 combat screen practice.png
8 08-combat-screen-versus.png - 08 combat screen versus.png

πŸ“¦ Download Screenshots

πŸ“₯ Download all screenshots from workflow artifacts

Screenshots are preserved as workflow artifacts for 30 days.


πŸ€– Generated by Playwright automation

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes production console warnings/errors by hardening Service Worker caching against HTTP 206 (Partial Content) responses and cleaning up deprecated/unused HTML tags in the deployed entrypoints.

Changes:

  • Update SW fetch caching to skip HTTP 206 responses (Range requests) before calling cache.put().
  • Remove deprecated X-UA-Compatible meta tag and an unused preload link from index.html (and docs/index.html).
  • Add unit tests asserting the 206 filter and the absence of the removed HTML tags.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
public/sw.js Excludes 206 responses from being cached to prevent cache.put() errors.
docs/sw.js Mirrors the SW 206 exclusion in the docs deployment.
index.html Removes deprecated X-UA-Compatible and an unused image preload link.
docs/index.html Mirrors index.html cleanup for docs deployment.
src/test/service-worker.test.ts Adds tests covering the 206 filter and HTML cleanup expectations.
Comments suppressed due to low confidence (1)

public/sw.js:92

  • cache.put(event.request, ...) will reject for non-GET requests (Cache API only supports GET). Since this fetch handler runs for all requests, add a guard like event.request.method === "GET" (or early-return) before attempting to cache to avoid future console errors/unhandled rejections if the app ever makes POST/PUT requests.
        // Only cache successful, complete, non-opaque responses
        // Skip partial responses (206) as Cache API does not support them
        if (response.ok && response.status !== 206 && response.type !== "opaque") {
          // Clone response for caching (responses can only be used once)
          const responseClone = response.clone();
          
          // Cache for offline fallback only
          caches.open(CACHE_NAME).then((cache) => {
            cache.put(event.request, responseClone);
          });

public/sw.js Outdated
Comment on lines 83 to 88
// Only cache successful, complete, non-opaque responses
// Skip partial responses (206) as Cache API does not support them
if (response.ok && response.status !== 206 && response.type !== "opaque") {
// Clone response for caching (responses can only be used once)
const responseClone = response.clone();

Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The caching side-effect (caches.open(...).then(cache => cache.put(...))) doesn’t handle rejections. Even with the 206 filter, cache.put can still reject (e.g., quota errors, non-GET requests), which can show up as unhandled promise rejections in the SW. Consider adding a .catch(...) (and/or wrapping the cache write in event.waitUntil(...)) to suppress console noise and ensure the SW stays alive long enough to complete the cache write.

Copilot uses AI. Check for mistakes.
docs/sw.js Outdated
Comment on lines 83 to 88
// Only cache successful, complete, non-opaque responses
// Skip partial responses (206) as Cache API does not support them
if (response.ok && response.status !== 206 && response.type !== "opaque") {
// Clone response for caching (responses can only be used once)
const responseClone = response.clone();

Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as public/sw.js: cache.put(event.request, ...) will reject for non-GET requests. Add a guard (e.g., event.request.method === "GET") before caching so a future POST/PUT request doesn’t trigger SW console errors.

Copilot uses AI. Check for mistakes.

// Cache API rejects put() with status 206 (Partial Content)
// The SW must filter these out before calling cache.put()
expect(swSource).toContain('response.status !== 206');
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is asserting an exact string ('response.status !== 206'), which is fragile to harmless refactors/formatting. A regex assertion (e.g., matching status compared to 206 with arbitrary whitespace) or a more behavioral test approach would reduce churn while still ensuring 206 responses aren’t cached.

Suggested change
expect(swSource).toContain('response.status !== 206');
expect(swSource).toMatch(/response\.status\s*!==?\s*206/);

Copilot uses AI. Check for mistakes.
it('should not preload assets that are loaded by React components', () => {
// Preloading assets used by React components causes "not used within a few seconds" warnings
// because React takes time to bootstrap and mount the component that uses the asset
expect(indexHtml).not.toContain('rel="preload"');
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect(indexHtml).not.toContain('rel="preload"') is case/quote sensitive and can miss <link rel='preload'> or different attribute ordering. Using a case-insensitive regex for rel\s*=\s*["']preload["'] (or checking for <link tags with rel preload) would make the test reliably enforce the intent.

Suggested change
expect(indexHtml).not.toContain('rel="preload"');
// Use a case-insensitive regex to catch rel='preload' with any quotes/spacing/case
expect(indexHtml).not.toMatch(/rel\s*=\s*["']preload["']/i);

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown
Contributor

πŸ“Έ Automated UI Screenshots

πŸ“‹ Screenshots Captured (8)

# Screenshot
1 01-splash-screen.png - 01 splash screen.png
2 02-intro-screen-menu.png - 02 intro screen menu.png
3 03-intro-screen-archetype-selector.png - 03 intro screen archetype selector.png
4 04-controls-screen.png - 04 controls screen.png
5 05-philosophy-screen.png - 05 philosophy screen.png
6 06-training-screen.png - 06 training screen.png
7 07-combat-screen-practice.png - 07 combat screen practice.png
8 08-combat-screen-versus.png - 08 combat screen versus.png

πŸ“¦ Download Screenshots

πŸ“₯ Download all screenshots from workflow artifacts

Screenshots are preserved as workflow artifacts for 30 days.


πŸ€– Generated by Playwright automation

@pethers
Copy link
Copy Markdown
Member

pethers commented Mar 25, 2026

@copilot apply changes based on the comments in this thread

…rites, regex-based test assertions

- Add event.request.method === "GET" guard before caching in sw.js
- Add .catch() to cache.put() promise to suppress quota/write errors
- Use regex assertions in tests for 206 status and preload checks
- Add tests for GET-only caching and cache write error handling
- Apply same fixes to docs/sw.js

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Hack23/blacktrigram/sessions/809ecb62-8166-4fc0-9380-a90d075a6322
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 25, 2026

@copilot apply changes based on the comments in this thread

Applied all 4 review comments in b77d1a5:

  • public/sw.js + docs/sw.js: Added event.request.method === "GET" guard before caching, and .catch() on the cache.put() promise to suppress quota/write rejections
  • src/test/service-worker.test.ts: Switched to regex assertions (/response\.status\s*!==?\s*206/ and /rel\s*=\s*["']preload["']/i) for resilience to formatting changes
  • Added 2 new tests for the GET-only guard and cache write error handling (35 total, all passing)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

public/sw.js Outdated
Comment on lines 96 to 100
caches.open(CACHE_NAME).then((cache) => {
cache.put(event.request, responseClone);
}).catch(() => {
// Silently ignore cache write failures (e.g., quota exceeded)
});
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .catch() here only handles failures from caches.open(...). If cache.put(...) rejects (e.g., quota exceeded, request/response not cacheable), that rejection is currently unhandled because the cache.put promise is not returned or caught. Return cache.put(...) from the .then(...) callback (or attach a .catch() directly to cache.put) so cache write failures are actually suppressed as intended.

Suggested change
caches.open(CACHE_NAME).then((cache) => {
cache.put(event.request, responseClone);
}).catch(() => {
// Silently ignore cache write failures (e.g., quota exceeded)
});
caches.open(CACHE_NAME)
.then((cache) => {
return cache.put(event.request, responseClone);
})
.catch(() => {
// Silently ignore cache write failures (e.g., quota exceeded)
});

Copilot uses AI. Check for mistakes.
docs/sw.js Outdated
Comment on lines 96 to 100
caches.open(CACHE_NAME).then((cache) => {
cache.put(event.request, responseClone);
}).catch(() => {
// Silently ignore cache write failures (e.g., quota exceeded)
});
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as in public/sw.js: the .catch() is attached to caches.open(...) but the cache.put(...) promise is not returned/caught, so cache.put rejections can still surface as unhandled promise rejections in the SW. Return cache.put(...) from the .then(...) (or catch on cache.put) to reliably suppress cache write failures.

Suggested change
caches.open(CACHE_NAME).then((cache) => {
cache.put(event.request, responseClone);
}).catch(() => {
// Silently ignore cache write failures (e.g., quota exceeded)
});
caches
.open(CACHE_NAME)
.then((cache) => cache.put(event.request, responseClone))
.catch(() => {
// Silently ignore cache write failures (e.g., quota exceeded)
});

Copilot uses AI. Check for mistakes.
Comment on lines +88 to +89
// unhandled promise rejections in the service worker
expect(swSource).toMatch(/\.catch\s*\(/);
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test only asserts that some .catch( exists in sw.js, but it doesn’t verify that cache.put(...) failures are actually handled (which requires returning the cache.put promise from the .then(...) or catching the cache.put promise directly). Consider tightening the assertion to specifically match cache.put(...).catch or then((cache) => return cache.put(...)) so the test guards against the unhandled-rejection regression it’s meant to prevent.

Suggested change
// unhandled promise rejections in the service worker
expect(swSource).toMatch(/\.catch\s*\(/);
// unhandled promise rejections in the service worker. Ensure that
// cache.put(...) is part of a handled promise chain.
expect(swSource).toMatch(/cache\.put\([^)]*\)\.catch\s*\(|then\(\s*cache\s*=>\s*cache\.put\(/);

Copilot uses AI. Check for mistakes.
Comment on lines +252 to +256
it('should not preload assets that are loaded by React components', () => {
// Preloading assets used by React components causes "not used within a few seconds" warnings
// because React takes time to bootstrap and mount the component that uses the asset
// Use a case-insensitive regex to catch rel='preload' with any quotes/spacing/case
expect(indexHtml).not.toMatch(/rel\s*=\s*["']preload["']/i);
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion forbids any <link rel="preload"> in index.html, including legitimate preloads (e.g., critical fonts/CSS) that might be added later. Since the change is specifically removing the unused logo preload, it would be more maintainable to assert the absence of that specific preload (e.g., black-trigram.png with rel=preload) rather than banning all preload usage.

Suggested change
it('should not preload assets that are loaded by React components', () => {
// Preloading assets used by React components causes "not used within a few seconds" warnings
// because React takes time to bootstrap and mount the component that uses the asset
// Use a case-insensitive regex to catch rel='preload' with any quotes/spacing/case
expect(indexHtml).not.toMatch(/rel\s*=\s*["']preload["']/i);
it('should not preload logo asset that is loaded by React components', () => {
// Preloading assets used exclusively by React components (like the black trigram logo)
// can cause "not used within a few seconds" warnings because React takes time to bootstrap
// and mount the component that uses the asset.
// Assert specifically that black-trigram.png is not preloaded with rel="preload",
// while allowing other legitimate preloads (e.g., critical fonts or CSS).
expect(indexHtml).not.toMatch(
/<link[^>]+rel\s*=\s*["']preload["'][^>]+href\s*=\s*["'][^"']*black-trigram\.png["']/i
);

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown
Contributor

πŸ“Έ Automated UI Screenshots

πŸ“‹ Screenshots Captured (8)

# Screenshot
1 01-splash-screen.png - 01 splash screen.png
2 02-intro-screen-menu.png - 02 intro screen menu.png
3 03-intro-screen-archetype-selector.png - 03 intro screen archetype selector.png
4 04-controls-screen.png - 04 controls screen.png
5 05-philosophy-screen.png - 05 philosophy screen.png
6 06-training-screen.png - 06 training screen.png
7 07-combat-screen-practice.png - 07 combat screen practice.png
8 08-combat-screen-versus.png - 08 combat screen versus.png

πŸ“¦ Download Screenshots

πŸ“₯ Download all screenshots from workflow artifacts

Screenshots are preserved as workflow artifacts for 30 days.


πŸ€– Generated by Playwright automation

@pethers
Copy link
Copy Markdown
Member

pethers commented Mar 25, 2026

@copilot apply changes based on the comments in this thread

- Return cache.put() from .then() callback so its rejections are caught
  by the .catch() handler in both public/sw.js and docs/sw.js
- Tighten test assertion to verify cache.put() is in a handled promise chain
- Narrow preload test to only assert black-trigram.png is not preloaded,
  allowing legitimate future preloads (e.g., critical fonts/CSS)

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Hack23/blacktrigram/sessions/5860e0ea-df8c-4c08-9252-899271be367f
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 25, 2026

@copilot apply changes based on the comments in this thread

Applied all 4 review comments in c03d5f2:

  • public/sw.js + docs/sw.js: Return cache.put() from the .then() callback so its rejections propagate to the .catch() handler
  • src/test/service-worker.test.ts: Tightened the cache write test to verify cache.put() is in a handled promise chain (not just any .catch())
  • src/test/service-worker.test.ts: Narrowed preload test to only assert black-trigram.png is not preloaded, allowing legitimate future preloads

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

docs/sw.js Outdated
Comment on lines +96 to +103
caches
.open(CACHE_NAME)
.then((cache) => {
return cache.put(event.request, responseClone);
})
.catch(() => {
// Silently ignore cache write failures (e.g., quota exceeded)
});
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as public/sw.js: the cache write promise chain isn’t passed to event.waitUntil(...), so the SW may terminate before cache.put() completes, making offline caching unreliable. Consider event.waitUntil(caches.open(...).then(...).catch(...)) around this chain.

Suggested change
caches
.open(CACHE_NAME)
.then((cache) => {
return cache.put(event.request, responseClone);
})
.catch(() => {
// Silently ignore cache write failures (e.g., quota exceeded)
});
event.waitUntil(
caches
.open(CACHE_NAME)
.then((cache) => {
return cache.put(event.request, responseClone);
})
.catch(() => {
// Silently ignore cache write failures (e.g., quota exceeded)
})
);

Copilot uses AI. Check for mistakes.
public/sw.js Outdated
Comment on lines +96 to +103
caches
.open(CACHE_NAME)
.then((cache) => {
return cache.put(event.request, responseClone);
})
.catch(() => {
// Silently ignore cache write failures (e.g., quota exceeded)
});
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cache write is started asynchronously but the fetch event doesn’t use event.waitUntil(...) to extend the service worker lifetime for caches.open(...).then(cache.put...). That can make offline caching unreliable because the SW may terminate once respondWith resolves, before the cache.put() finishes. Wrap the cache-write promise chain in event.waitUntil(...) (still with the .catch(...) to swallow quota/write errors).

Copilot uses AI. Check for mistakes.
Comment on lines +89 to +90
expect(swSource).toMatch(/cache\.put\([^)]*\);\s*\n\s*}\)\s*\n\s*\.catch\s*\(|then\(\s*\(cache\)\s*=>\s*\{\s*\n\s*return cache\.put\(/);

Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test’s regex doesn’t actually guarantee that cache.put() is in a handled promise chain: the second alternative matches then(... return cache.put( even if there is no subsequent .catch(...). Consider splitting into clearer assertions (e.g., one that return cache.put( appears inside the caches.open(...).then(...) callback, and another that the chain includes a .catch( after it), or tighten the regex so it requires .catch after the then block.

Suggested change
expect(swSource).toMatch(/cache\.put\([^)]*\);\s*\n\s*}\)\s*\n\s*\.catch\s*\(|then\(\s*\(cache\)\s*=>\s*\{\s*\n\s*return cache\.put\(/);
expect(swSource).toMatch(/caches\.open\([^)]*\)\s*\.then\(\s*(?:\(\s*cache\s*\)|cache)\s*=>\s*\{/);
expect(swSource).toMatch(/cache\.put\([^)]*\)[\s\S]*?\.catch\s*\(/);

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown
Contributor

πŸ“Έ Automated UI Screenshots

πŸ“‹ Screenshots Captured (8)

# Screenshot
1 01-splash-screen.png - 01 splash screen.png
2 02-intro-screen-menu.png - 02 intro screen menu.png
3 03-intro-screen-archetype-selector.png - 03 intro screen archetype selector.png
4 04-controls-screen.png - 04 controls screen.png
5 05-philosophy-screen.png - 05 philosophy screen.png
6 06-training-screen.png - 06 training screen.png
7 07-combat-screen-practice.png - 07 combat screen practice.png
8 08-combat-screen-versus.png - 08 combat screen versus.png

πŸ“¦ Download Screenshots

πŸ“₯ Download all screenshots from workflow artifacts

Screenshots are preserved as workflow artifacts for 30 days.


πŸ€– Generated by Playwright automation

@pethers
Copy link
Copy Markdown
Member

pethers commented Mar 25, 2026

@copilot apply changes based on the comments in this thread

- public/sw.js + docs/sw.js: Wrap caches.open().then(cache.put()).catch()
  in event.waitUntil() to keep SW alive until cache write completes
- src/test/service-worker.test.ts: Split into clearer assertions for
  caches.open().then() structure, return cache.put() with .catch(),
  and event.waitUntil() wrapper

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Hack23/blacktrigram/sessions/bee6acf2-a8ba-4741-9559-9d61f576f1a3
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 25, 2026

@copilot apply changes based on the comments in this thread

Applied all 3 review comments in 7eca698:

  • public/sw.js + docs/sw.js: Wrapped cache write chain in event.waitUntil(...) to keep SW alive until cache.put() completes
  • src/test/service-worker.test.ts: Split into 3 clearer assertions β€” event.waitUntil(, caches.open().then((cache) => {, and return cache.put() followed by .catch(

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment on lines +88 to +92
// cache.put(...) is returned inside caches.open().then() and followed by .catch(),
// and the entire chain is wrapped in event.waitUntil() to keep the SW alive.
expect(swSource).toMatch(/event\.waitUntil\s*\(/);
expect(swSource).toMatch(/caches\s*\n?\s*\.open\([^)]*\)\s*\n?\s*\.then\(\s*\(cache\)\s*=>\s*\{/);
expect(swSource).toMatch(/return cache\.put\([^)]*\)[\s\S]*?\.catch\s*\(/);
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex in this test is more prescriptive about formatting than necessary (e.g., it requires .then((cache) => { with parentheses and a block). This makes the test likely to fail on harmless refactors (implicit return, then(cache => ...), or different whitespace) even if the SW still correctly returns cache.put() and handles errors. Consider relaxing the pattern to assert the behavioral requirements (open cache β†’ return cache.put(...) β†’ .catch(...) within event.waitUntil) without enforcing a specific arrow-function formatting.

Suggested change
// cache.put(...) is returned inside caches.open().then() and followed by .catch(),
// and the entire chain is wrapped in event.waitUntil() to keep the SW alive.
expect(swSource).toMatch(/event\.waitUntil\s*\(/);
expect(swSource).toMatch(/caches\s*\n?\s*\.open\([^)]*\)\s*\n?\s*\.then\(\s*\(cache\)\s*=>\s*\{/);
expect(swSource).toMatch(/return cache\.put\([^)]*\)[\s\S]*?\.catch\s*\(/);
// cache.put(...) is invoked as part of the caches.open().then() chain,
// followed by .catch(), and the entire chain is wrapped in event.waitUntil()
// to keep the SW alive during the async work.
expect(swSource).toMatch(/event\.waitUntil\s*\(/);
expect(swSource).toMatch(/caches\s*\.\s*open\([^)]*\)[\s\S]*?\.then\([\s\S]*cache\.put\([^)]*\)[\s\S]*?\.catch\s*\(/);

Copilot uses AI. Check for mistakes.
@pethers
Copy link
Copy Markdown
Member

pethers commented Mar 25, 2026

@copilot apply changes based on the comments in this thread

@github-actions
Copy link
Copy Markdown
Contributor

πŸ“Έ Automated UI Screenshots

πŸ“‹ Screenshots Captured (8)

# Screenshot
1 01-splash-screen.png - 01 splash screen.png
2 02-intro-screen-menu.png - 02 intro screen menu.png
3 03-intro-screen-archetype-selector.png - 03 intro screen archetype selector.png
4 04-controls-screen.png - 04 controls screen.png
5 05-philosophy-screen.png - 05 philosophy screen.png
6 06-training-screen.png - 06 training screen.png
7 07-combat-screen-practice.png - 07 combat screen practice.png
8 08-combat-screen-versus.png - 08 combat screen versus.png

πŸ“¦ Download Screenshots

πŸ“₯ Download all screenshots from workflow artifacts

Screenshots are preserved as workflow artifacts for 30 days.


πŸ€– Generated by Playwright automation

Replace 3 prescriptive assertions (requiring specific parentheses, block
style, and return keyword) with 2 behavioral assertions that verify:
- event.waitUntil() wraps the chain
- caches.open().then() contains cache.put() followed by .catch()

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Hack23/blacktrigram/sessions/ca681c44-a97e-4ec4-b2f1-8afe011f4195
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 25, 2026

@copilot apply changes based on the comments in this thread

Applied in fef8a2f: Replaced 3 prescriptive assertions (enforcing specific parentheses/block style/return keyword) with 2 behavioral assertions β€” one for event.waitUntil( and one combined regex that verifies caches.open().then() contains cache.put() followed by .catch() without enforcing arrow-function formatting.

@github-actions
Copy link
Copy Markdown
Contributor

πŸ“Έ Automated UI Screenshots

πŸ“‹ Screenshots Captured (8)

# Screenshot
1 01-splash-screen.png - 01 splash screen.png
2 02-intro-screen-menu.png - 02 intro screen menu.png
3 03-intro-screen-archetype-selector.png - 03 intro screen archetype selector.png
4 04-controls-screen.png - 04 controls screen.png
5 05-philosophy-screen.png - 05 philosophy screen.png
6 06-training-screen.png - 06 training screen.png
7 07-combat-screen-practice.png - 07 combat screen practice.png
8 08-combat-screen-versus.png - 08 combat screen versus.png

πŸ“¦ Download Screenshots

πŸ“₯ Download all screenshots from workflow artifacts

Screenshots are preserved as workflow artifacts for 30 days.


πŸ€– Generated by Playwright automation

@pethers pethers merged commit f231738 into main Mar 25, 2026
14 checks passed
@pethers pethers deleted the copilot/fix-console-errors branch March 25, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation updates test-coverage-impact Impacts test coverage testing Testing improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants