Skip to content

Commit

Permalink
more clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSero committed Jun 24, 2024
1 parent c10a1ff commit 4e5d50a
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 33 deletions.
4 changes: 2 additions & 2 deletions packages/cache/test/createCache.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { afterAll, afterEach, describe, expect, it, vi } from 'vitest'

import path from 'node:path'
import * as GetUniqueWalletSetupFunctions from '@synthetixio/synpress-cache'
import * as TriggerCacheCreation from '@synthetixio/synpress-cache'
import * as GetUniqueWalletSetupFunctions from '../src/utils/getUniqueWalletSetupFunctions'
import * as TriggerCacheCreation from '../src/utils/triggerCacheCreation'
import type { BrowserContext, Page } from 'playwright-core'
import { createCache } from '../src/createCache'

Expand Down
4 changes: 2 additions & 2 deletions packages/cache/test/downloadFile.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import path from 'node:path'
import { downloadFile } from '@synthetixio/synpress-cache'
import axios from 'axios'
import { fs, vol } from 'memfs'
import { http, HttpResponse } from 'msw'
import { setupServer } from 'msw/node'
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
import { downloadFile } from '../src'

const ROOT_DIR = '/tmp'
const FILE_NAME = 'duck.txt'
Expand Down Expand Up @@ -149,4 +149,4 @@ describe('downloadFile', () => {
expect(axiosGetSpy).toHaveBeenCalledOnce()
})
})
})
})
4 changes: 2 additions & 2 deletions packages/cache/test/ensureCacheDirExists.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'node:path'
import { CACHE_DIR_NAME } from '@synthetixio/synpress-cache'
import { ensureCacheDirExists } from '@synthetixio/synpress-cache'
import { CACHE_DIR_NAME } from '../src'
import { ensureCacheDirExists } from '../src/ensureCacheDirExists'
import fs from 'fs-extra'
import { afterAll, afterEach, describe, expect, it, vi } from 'vitest'

Expand Down
4 changes: 2 additions & 2 deletions packages/cache/test/unzipArchive.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'node:path'
import { unzipArchive } from '@synthetixio/synpress-cache'
import { fs, vol } from 'memfs'
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { unzipArchive } from '../src/unzipArchive'
import {
ARCHIVE_CONTENTS,
createTestZipArchive,
Expand Down Expand Up @@ -139,4 +139,4 @@ describe('unzipArchive', () => {
expect(fs.readFileSync(NESTED_FILE_OUTPUT_PATH, 'utf8')).toBe(ARCHIVE_CONTENTS[NESTED_FILE_NAME])
})
})
})
})
2 changes: 1 addition & 1 deletion packages/cache/test/utils/bytesToMegabytes.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bytesToMegabytes } from '@synthetixio/synpress-cache'
import { bytesToMegabytes } from "../../src"
import { describe, expect, it } from 'vitest'

describe('bytesToMegabytes', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createCacheForWalletSetupFunction } from '@synthetixio/synpress-cache'
import * as WaitForExtensionOnLoadPage from '@synthetixio/synpress-cache'
import { createCacheForWalletSetupFunction } from '../../src'
import * as WaitForExtensionOnLoadPage from '../../src/utils/waitForExtensionOnLoadPage'
import { chromium } from 'playwright-core'
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest'

Expand Down
4 changes: 2 additions & 2 deletions packages/cache/test/utils/createTempContextDir.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os from 'node:os'
import path from 'node:path'
import { createTempContextDir } from '@synthetixio/synpress-cache'
import { fs, vol } from 'memfs'
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { createTempContextDir } from '../../src/utils/createTempContextDir'

const BROWSER_NAME = 'chromium'
const TEST_ID = 'test-id'
Expand Down Expand Up @@ -67,4 +67,4 @@ describe('createTempContextDir', () => {
expect(fs.readdirSync(ROOT_DIR)).toHaveLength(1)
expect(fs.existsSync(tempDirPath)).toBeTruthy()
})
})
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getUniqueWalletSetupFunctions } from '@synthetixio/synpress-cache'
import { getUniqueWalletSetupFunctions } from "../../src"
import { afterAll, describe, expect, it, vi } from 'vitest'

vi.mock('../../src/utils/getWalletSetupFiles', async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/cache/test/utils/getWalletSetupFiles.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'node:path'
import { getWalletSetupFiles } from '@synthetixio/synpress-cache'
import { fs, vol } from 'memfs'
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { getWalletSetupFiles } from '../../src/utils/getWalletSetupFiles'

const ROOT_DIR = '/tmp'
const DUMMY_CONTENT = 'Hello world! 👋'
Expand Down Expand Up @@ -75,4 +75,4 @@ describe('getWalletSetupFiles', () => {
expect(setupFiles).toContain('quack.setup.js')
expect(setupFiles).toContain('quack.setup.mjs')
})
})
})
2 changes: 1 addition & 1 deletion packages/cache/test/utils/getWalletSetupFuncHash.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WALLET_SETUP_FUNC_HASH_LENGTH, getWalletSetupFuncHash } from '@synthetixio/synpress-cache'
import { WALLET_SETUP_FUNC_HASH_LENGTH, getWalletSetupFuncHash } from '../../src'
import { describe, expect, it } from 'vitest'

const EXPECTED_HASH = 'b940c886be3c1a041ddd'
Expand Down
2 changes: 1 addition & 1 deletion packages/cache/test/utils/importWalletSetupFile.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { importWalletSetupFile } from '@synthetixio/synpress-cache'
import { importWalletSetupFile } from "../../src"
import { afterAll, describe, expect, it, vi } from 'vitest'

vi.mock('../../src/ensureCacheDirExists', async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/cache/test/utils/isDirEmpty.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'node:path'
import { isDirEmpty } from '@synthetixio/synpress-cache'
import { fs, vol } from 'memfs'
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { isDirEmpty } from '../../src/utils/isDirEmpty'

const ROOT_DIR = '/tmp'
const FILE_PATH = path.join(ROOT_DIR, 'file.txt')
Expand Down Expand Up @@ -41,4 +41,4 @@ describe('isDirEmpty', () => {
const isEmpty = await isDirEmpty(ROOT_DIR)
expect(isEmpty).toEqual(false)
})
})
})
2 changes: 1 addition & 1 deletion packages/cache/test/utils/removeTempContextDir.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { removeTempContextDir } from '@synthetixio/synpress-cache'
import { removeTempContextDir } from "../../src"
import { afterAll, describe, expect, it, vi } from 'vitest'

const PATH = 'Happy Quack Path'
Expand Down
20 changes: 9 additions & 11 deletions packages/cache/test/utils/triggerCacheCreation.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import path from 'node:path'
import * as EnsureCacheDirExists from '@synthetixio/synpress-utils'
import * as CreateCacheForWalletSetupFunction from '@synthetixio/synpress-utils'
import { triggerCacheCreation } from '@synthetixio/synpress-utils'
import fsExtra from 'fs-extra'
import { fs, vol } from 'memfs'
import type { BrowserContext, Page } from 'playwright-core'
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vitest'

import path from 'node:path'
import fsExtra from 'fs-extra'
import type { WalletSetupFunction } from '../../src'
import * as EnsureCacheDirExists from '../../src/ensureCacheDirExists'
import * as CreateCacheForWalletSetupFunction from '../../src/utils/createCacheForWalletSetupFunction'
import { triggerCacheCreation } from '../../src/utils/triggerCacheCreation'

const ROOT_DIR = '/tmp'
const EXTENSION_PATH = path.join(ROOT_DIR, 'extension')

Expand Down Expand Up @@ -57,10 +58,7 @@ describe('triggerCacheCreation', () => {
const testSetupFunction = vi.fn()

function prepareSetupFunctions(hashes: string[]) {
const setupFunctions = new Map<
string,
{ fileName: string; setupFunction: (context: BrowserContext, walletPage: Page) => Promise<void> }
>()
const setupFunctions = new Map<string, { fileName: string; setupFunction: WalletSetupFunction }>()

for (const hash of hashes) {
setupFunctions.set(hash, { fileName: path.join(ROOT_DIR, `${hash}.ts`), setupFunction: testSetupFunction })
Expand Down Expand Up @@ -187,4 +185,4 @@ describe('triggerCacheCreation', () => {
expectCreateCacheForWalletSetupFunction(3, setupFunctions, 'hash3')
})
})
})
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { waitForExtensionOnLoadPage } from '@synthetixio/synpress-cache'
import { waitForExtensionOnLoadPage } from '../../src/utils/waitForExtensionOnLoadPage'
import { errors as playwrightErrors } from 'playwright-core'
import { afterAll, afterEach, describe, expect, it, vi } from 'vitest'

Expand Down

0 comments on commit 4e5d50a

Please sign in to comment.