Skip to content

Commit

Permalink
Reduce atb test flakiness. (duckduckgo#2092)
Browse files Browse the repository at this point in the history
  • Loading branch information
sammacbeth authored Jul 6, 2023
1 parent 6c40a77 commit e65fc29
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions integration-test/atb.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, expect, mockAtb } from './helpers/playwrightHarness'
import backgroundWait from './helpers/backgroundWait'
import backgroundWait, { forSetting } from './helpers/backgroundWait'

test.describe('install workflow', () => {
test('postinstall page: should open the postinstall page correctly', async ({
Expand Down Expand Up @@ -127,7 +127,7 @@ test.describe('search workflow', () => {
let lastWeeksAtb
let twoWeeksAgoAtb

test.beforeAll(async ({ context, routeExtensionRequests }) => {
test.beforeAll(async ({ context }) => {
// grab current atb data
let data = await fetch('https://duckduckgo.com/atb.js')
data = await data.json()
Expand All @@ -138,11 +138,11 @@ test.describe('search workflow', () => {
mockAtb.version = data.version
mockAtb.majorVersion = data.majorVersion
mockAtb.minorVersion = data.minorVersion

await backgroundWait.forExtensionLoaded(context)
})

test.beforeEach(async ({ backgroundPage, context }) => {
await backgroundWait.forExtensionLoaded(context)
await forSetting(backgroundPage, 'atb')
await backgroundPage.evaluate((atb) => globalThis.dbg.settings.updateSetting('atb', atb), twoWeeksAgoAtb)
})

Expand All @@ -165,6 +165,7 @@ test.describe('search workflow', () => {
// run a search
await page.goto('https://duckduckgo.com/?q=test', { waitUntil: 'networkidle' })

await forSetting(backgroundPage, 'set_atb')
const newSetAtb = await backgroundPage.evaluate(() => globalThis.dbg.settings.getSetting('set_atb'))
const atb = await backgroundPage.evaluate(() => globalThis.dbg.settings.getSetting('atb'))
expect(newSetAtb).toEqual(todaysAtb)
Expand All @@ -179,6 +180,7 @@ test.describe('search workflow', () => {
// run a search
await page.goto('https://duckduckgo.com/?q=test', { waitUntil: 'networkidle' })

await forSetting(backgroundPage, 'set_atb')
const newSetAtb = await backgroundPage.evaluate(() => globalThis.dbg.settings.getSetting('set_atb'))
const atb = await backgroundPage.evaluate(() => globalThis.dbg.settings.getSetting('atb'))
expect(newSetAtb).toEqual(todaysAtb)
Expand Down

0 comments on commit e65fc29

Please sign in to comment.