diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 1625799..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: CI Tests -on: - push: - branches: - - main - pull_request: - branches: - - main -jobs: - test: - timeout-minutes: 60 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 20 - - name: Install dependencies - run: yarn - - name: Build - run: yarn build - - name: Jest tests - run: yarn test - - name: Install Playwright Browsers - run: yarn playwright install --with-deps - - name: Run Playwright tests - run: yarn playwright test - - uses: actions/upload-artifact@v3 - if: always() - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 diff --git a/manifest.config.ts b/manifest.config.ts index 210af92..fd58c21 100644 --- a/manifest.config.ts +++ b/manifest.config.ts @@ -16,15 +16,15 @@ export default defineManifest(async () => ({ default_title: 'popup', default_popup: 'src/popup/index.html', default_icon: { - '16': 'logo16.png', - '48': 'logo48.png', - '128': 'logo128.png', + '16': 'assets/logo16.png', + '48': 'assets/logo48.png', + '128': 'assets/logo128.png', }, }, icons: { - '16': 'logo16.png', - '48': 'logo48.png', - '128': 'logo128.png', + '16': 'assets/logo16.png', + '48': 'assets/logo48.png', + '128': 'assets/logo128.png', }, background: { service_worker: 'src/background/index.ts', diff --git a/package.json b/package.json index 5a26182..d23c4e8 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ }, "devDependencies": { "@crxjs/vite-plugin": "^1.0.14", - "@playwright/test": "^1.39.0", "@thedutchcoder/postcss-rem-to-px": "^0.0.2", "@types/chrome": "^0.0.268", "@types/node": "^20.8.9", diff --git a/playwright.config.ts b/playwright.config.ts deleted file mode 100644 index 6908bef..0000000 --- a/playwright.config.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { defineConfig, devices } from '@playwright/test' - -/** - * Read environment variables from file. - * https://github.com/motdotla/dotenv - */ -// require('dotenv').config(); - -/** - * See https://playwright.dev/docs/test-configuration. - */ -export default defineConfig({ - testDir: './tests/e2e', - /* Run tests in files in parallel */ - fullyParallel: true, - /* Fail the build on CI if you accidentally left test.only in the source code. */ - forbidOnly: !!process.env.CI, - /* Retry on CI only */ - retries: process.env.CI ? 2 : 0, - /* Opt out of parallel tests on CI. */ - workers: process.env.CI ? 1 : undefined, - /* Reporter to use. See https://playwright.dev/docs/test-reporters */ - reporter: 'html', - /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ - use: { - /* Base URL to use in actions like `await page.goto('/')`. */ - // baseURL: 'http://127.0.0.1:3000', - - /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ - trace: 'on-first-retry', - }, - - /* Configure projects for major browsers */ - projects: [ - { - name: 'chromium', - use: { ...devices['Desktop Chrome'] }, - }, - - // { - // name: 'firefox', - // use: { ...devices['Desktop Firefox'] }, - // }, - - // { - // name: 'webkit', - // use: { ...devices['Desktop Safari'] }, - // }, - - /* Test against mobile viewports. */ - // { - // name: 'Mobile Chrome', - // use: { ...devices['Pixel 5'] }, - // }, - // { - // name: 'Mobile Safari', - // use: { ...devices['iPhone 12'] }, - // }, - - /* Test against branded browsers. */ - // { - // name: 'Microsoft Edge', - // use: { ...devices['Desktop Edge'], channel: 'msedge' }, - // }, - // { - // name: 'Google Chrome', - // use: { ..devices['Desktop Chrome'], channel: 'chrome' }, - // }, - ], - - /* Run your local dev server before starting the tests */ - // webServer: { - // command: 'npm run start', - // url: 'http://127.0.0.1:3000', - // reuseExistingServer: !process.env.CI, - // }, -}) diff --git a/public/logo128.png b/public/assets/logo128.png similarity index 100% rename from public/logo128.png rename to public/assets/logo128.png diff --git a/public/logo16.png b/public/assets/logo16.png similarity index 100% rename from public/logo16.png rename to public/assets/logo16.png diff --git a/public/logo48.png b/public/assets/logo48.png similarity index 100% rename from public/logo48.png rename to public/assets/logo48.png diff --git a/src/utils/allProgress.ts b/src/utils/allProgress.ts index de96ebb..cd92ce7 100644 --- a/src/utils/allProgress.ts +++ b/src/utils/allProgress.ts @@ -1,4 +1,4 @@ -export default async function allProgress(promise: Promise[], callback: (progress: number) => void) { +export async function allProgress(promise: Promise[], callback: (progress: number) => void) { let d = 0 callback(0) for (const p of promise) { diff --git a/src/utils/getLinkId.ts b/src/utils/getLinkId.ts index 7c09442..f34986c 100644 --- a/src/utils/getLinkId.ts +++ b/src/utils/getLinkId.ts @@ -1,4 +1,4 @@ -export default function getLinkId(link: string) { +export function getLinkId(link: string) { if (!link) return '' return new URL(link).searchParams.get('id') } diff --git a/src/utils/index.ts b/src/utils/index.ts index e2dfd4d..160c4c2 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,4 +1,3 @@ -export { default as pipe } from './pipe' -export { default as allProgress } from './allProgress' -export { default as getLinkId } from './getLinkId' +export { allProgress } from './allProgress' +export { getLinkId } from './getLinkId' export * from './cheerioUtils' diff --git a/src/utils/mapElement.ts b/src/utils/mapElement.ts deleted file mode 100644 index f8aa037..0000000 --- a/src/utils/mapElement.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type * as cheerio from 'cheerio' - -export function mapElement( - element: cheerio.Cheerio, - map: (i: number, el: T) => M[] | M | null | undefined, -): M[] { - return element.map(map).get() -} diff --git a/src/utils/pipe.ts b/src/utils/pipe.ts deleted file mode 100644 index b884930..0000000 --- a/src/utils/pipe.ts +++ /dev/null @@ -1,7 +0,0 @@ -export default function pipe(value: T, ...funcs: ((value: T) => T)[]) { - let acc = value - for (const f of funcs) { - acc = f(acc) - } - return acc -} diff --git a/tests/e2e/content.spec.ts b/tests/e2e/content.spec.ts deleted file mode 100644 index f08cd6f..0000000 --- a/tests/e2e/content.spec.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { expect, test } from './fixtures.js' - -test('popup page test', async ({ page, extensionId }) => { - console.log(`chrome-extension://${extensionId}/src/pages/popup/index.html`) - await page.goto(`chrome-extension://${extensionId}/src/pages/popup/index.html`) - - await expect(page.locator('p')).toHaveText('가천대학교 사이버캠퍼스 확장 프로그램') -}) diff --git a/tests/e2e/fixtures.ts b/tests/e2e/fixtures.ts deleted file mode 100644 index 682fe4c..0000000 --- a/tests/e2e/fixtures.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { test as base, expect, chromium, type BrowserContext } from '@playwright/test' -import path from 'path' - -const test = base.extend<{ - context: BrowserContext - extensionId: string -}>({ - context: async ({}, use) => { - const pathToExtension = path.join(path.resolve(), './dist') - const context = await chromium.launchPersistentContext('', { - headless: false, - args: [`--headless=new`, `--disable-extensions-except=${pathToExtension}`, `--load-extension=${pathToExtension}`], - }) - await use(context) - await context.close() - }, - extensionId: async ({ context }, use) => { - let [background] = context.serviceWorkers() - if (!background) background = await context.waitForEvent('serviceworker') - - const extensionId = background.url().split('/')[2] - await use(extensionId) - }, -}) - -export { test, expect } diff --git a/tests/unit/util.test.ts b/tests/unit/util.test.ts deleted file mode 100644 index 8659202..0000000 --- a/tests/unit/util.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { allProgress, getLinkId } from '@/utils' - -describe('getLinkId 테스트', () => { - test('올바른 링크 입력시 id 값을 반환한다.', () => { - const link = 'https://cyber.gachon.ac.kr/mod/assign/view.php?id=650292' - expect(getLinkId(link)).toBe('650292') - }) - - test('링크가 없을 경우 빈 문자열을 반환한다.', () => { - const link = '' - const link2 = undefined - expect(getLinkId(link)).toBe('') - expect(getLinkId(link2)).toBe('') - }) -}) - -describe('pipe 테스트', () => { - test('함수를 인자로 받아서 함수를 리턴한다.', () => { - const add = (a: number) => (b: number) => a + b - const add10 = add(10) - expect(add10(5)).toBe(15) - }) -}) - -describe('allProgress 테스트', () => { - test('프로미스 배열을 받아서 프로미스 배열을 반환한다.', async () => { - const fakePrmoise = (time: number) => - new Promise(resolve => { - setTimeout(() => { - resolve(time) - }, time) - }) - const promise = [fakePrmoise(1000), fakePrmoise(2000)] - const callback = jest.fn() - const a = await allProgress(promise, callback) - expect(a).toEqual([1000, 2000]) - expect(callback).toBeCalledTimes(3) - - const array = [0, 50, 100] - array.forEach(progress => { - expect(callback).toBeCalledWith(progress) - }) - }) -})