[web] reduce log noise in CI (#27961)

* [web] reduce noise from CollectPayPalPastDueInvoiceTest

* [web] reduce noise for frontend tests that use Range.getClientRects

* [web] avoid nesting <li> elements in ProjectToolsMoreDropdownButton

RenameProjectMenuItem/CopyProjectMenuItem will return <li> elements.

* [web] avoid clicking on links that navigate away in JSDom

* [web] add mock for location change in JSDom

* [web] add fallback stripe subscription data for test

3.8k lines of log noise!

GitOrigin-RevId: 7adab182487a6c07ac9809c60802e498a0edb0ec
This commit is contained in:
Jakob Ackermann
2025-08-19 08:05:50 +00:00
committed by Copybot
parent 016fcffd56
commit d697f00525
6 changed files with 21 additions and 30 deletions
@@ -2,12 +2,10 @@ import sinon from 'sinon'
import chai, { expect } from 'chai'
import chaiAsPromised from 'chai-as-promised'
import sinonChai from 'sinon-chai'
import CollectPaypalPastDueInvoice from '../../../scripts/recurly/collect_paypal_past_due_invoice.mjs'
import { collectPastDueInvoices } from '../../../scripts/recurly/collect_paypal_past_due_invoice.mjs'
import RecurlyWrapper from '../../../app/src/Features/Subscription/RecurlyWrapper.js'
import OError from '@overleaf/o-error'
const { main } = CollectPaypalPastDueInvoice
chai.use(chaiAsPromised)
chai.use(sinonChai)
@@ -213,7 +211,7 @@ describe('CollectPayPalPastDueInvoice', function () {
it('collects one valid invoice', async function () {
fakeApiRequests([200])
const r = await main()
const r = await collectPastDueInvoices()
expect(r).to.eql({
INVOICES_COLLECTED: [200],
INVOICES_COLLECTED_SUCCESS: [200],
@@ -224,7 +222,7 @@ describe('CollectPayPalPastDueInvoice', function () {
it('collects several pages', async function () {
// 10 invoices, from 200 to 209
fakeApiRequests([...Array(10).keys()].map(i => i + 200))
const r = await main()
const r = await collectPastDueInvoices()
expect(r).to.eql({
INVOICES_COLLECTED: [200, 201, 202, 203, 204, 205, 206, 207, 208, 209],
@@ -253,7 +251,7 @@ describe('CollectPayPalPastDueInvoice', function () {
it("resolves when no invoices are processed so we don't fail in staging", async function () {
fakeApiRequests([404])
const r = await main()
const r = await collectPastDueInvoices()
expect(r).to.eql({
INVOICES_COLLECTED: [404],
INVOICES_COLLECTED_SUCCESS: [],
@@ -263,7 +261,7 @@ describe('CollectPayPalPastDueInvoice', function () {
it('doesnt reject when there are no invoices', async function () {
fakeApiRequests([])
const r = await main()
const r = await collectPastDueInvoices()
expect(r).to.eql({
INVOICES_COLLECTED: [],
INVOICES_COLLECTED_SUCCESS: [],
@@ -273,7 +271,7 @@ describe('CollectPayPalPastDueInvoice', function () {
it("resolves when collection is partially successful so we don't fail in prod", async function () {
fakeApiRequests([200, 404])
const r = await main()
const r = await collectPastDueInvoices()
expect(r).to.eql({
INVOICES_COLLECTED: [200, 404],
INVOICES_COLLECTED_SUCCESS: [200],
@@ -8,3 +8,8 @@ if (process.env.VERBOSE_LOGGING === 'true') {
debugConsole.warn = () => {}
debugConsole.error = () => {}
}
before(function () {
// Range.getClientRects doesn't exist yet in jsdom
window.Range.prototype.getClientRects = () => [] as any as DOMRectList
})
@@ -340,8 +340,6 @@ describe('<CurrentPlanWidget />', function () {
'/learn/how-to/Overleaf_premium_features'
)
fireEvent.click(links[0])
window.metaAttributesCache.delete('ol-usersBestSubscription')
})
}
@@ -37,15 +37,10 @@ describe('CodeMirror scroll position extension', function () {
sinon
.stub(HTMLElement.prototype, 'getBoundingClientRect')
.returns({ top: 100, left: 0, right: 500, bottom: 200 } as DOMRect)
// Range.getClientRects doesn't exist yet in jsdom
window.Range.prototype.getClientRects = sinon.stub().returns([])
})
afterEach(function () {
sinon.restore()
// @ts-ignore
delete window.Range.prototype.getClientRects
})
it('stores scroll position when the view is destroyed', async function () {