Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEST pw fix #1

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1
2 changes: 0 additions & 2 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ jobs:
playwright:
timeout-minutes: 60
runs-on: ubuntu-latest
env:
PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS: 1
steps:
- name: Remove all fonts
run: rm -rf /usr/share/fonts
Expand Down
3 changes: 0 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,5 @@
"source.fixAll.eslint": true,
},
"eslint.format.enable": true,
"playwright.env": {
"PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS": 1
},
"javascript.preferences.importModuleSpecifierEnding": "js",
}
5 changes: 0 additions & 5 deletions ext/js/display/display-audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ import {PopupMenu} from '../dom/popup-menu.js';
import {AudioSystem} from '../media/audio-system.js';
import {yomichan} from '../yomichan.js';

/* global
* AudioSystem
* PopupMenu
*/

export class DisplayAudio {
constructor(display) {
this._display = display;
Expand Down
11 changes: 0 additions & 11 deletions ext/js/display/popup-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,6 @@ import {DisplayProfileSelection} from './display-profile-selection.js';
import {DisplayResizer} from './display-resizer.js';
import {Display} from './display.js';

/* global
* Display
* DisplayAnki
* DisplayAudio
* DisplayProfileSelection
* DisplayResizer
* DocumentFocusController
* HotkeyHandler
* JapaneseUtil
*/

(async () => {
try {
const documentFocusController = new DocumentFocusController();
Expand Down
4 changes: 0 additions & 4 deletions ext/js/pages/settings/dictionary-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ import {EventListenerCollection, log} from '../../core.js';
import {DictionaryWorker} from '../../language/dictionary-worker.js';
import {yomichan} from '../../yomichan.js';

/* global
* DictionaryWorker
*/

class DictionaryEntry {
constructor(dictionaryController, fragment, index, dictionaryInfo) {
this._dictionaryController = dictionaryController;
Expand Down
6 changes: 0 additions & 6 deletions ext/js/pages/settings/popup-preview-frame-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ import {HotkeyHandler} from '../../input/hotkey-handler.js';
import {yomichan} from '../../yomichan.js';
import {PopupPreviewFrame} from './popup-preview-frame.js';

/* global
* HotkeyHandler
* PopupFactory
* PopupPreviewFrame
*/

(async () => {
try {
await yomichan.prepare();
Expand Down
4 changes: 1 addition & 3 deletions ext/js/templates/sandbox/template-renderer-media-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/* global
* Handlebars
*/
import {Handlebars} from '../../../lib/handlebars.js';

export class TemplateRendererMediaProvider {
constructor() {
Expand Down
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"css": "^3.0.0",
"dexie": "^3.2.4",
"dexie-export-import": "^4.0.7",
"dotenv": "^16.3.1",
"esbuild": "^0.19.5",
"eslint": "^8.52.0",
"eslint-plugin-header": "^3.1.1",
Expand Down
6 changes: 3 additions & 3 deletions playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// @ts-check
const {defineConfig, devices} = require('@playwright/test');
import {defineConfig, devices} from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
import 'dotenv/config';

/**
* @see https://playwright.dev/docs/test-configuration
*/
module.exports = defineConfig({
export default defineConfig({
testDir: './test/playwright',
snapshotPathTemplate: '{testDir}/__screenshots__/{testFilePath}/{arg}{ext}',
/* Maximum time one test can run for. */
Expand Down
12 changes: 6 additions & 6 deletions test/playwright/global.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

const {test: setup} = require('@playwright/test');
const {ManifestUtil} = require('../../dev/manifest-util');
const {root} = require('./playwright-util');
const path = require('path');
const fs = require('fs');
import {test as setup} from '@playwright/test';
import fs from 'fs';
import path from 'path';
import {ManifestUtil} from '../../dev/manifest-util';
import {root} from './playwright-util';

const manifestPath = path.join(root, 'ext/manifest.json');
const copyManifestPath = path.join(root, 'ext/manifest-old.json');
Expand All @@ -29,4 +29,4 @@ setup('use test manifest', () => {
const variant = manifestUtil.getManifest('chrome-playwright');
fs.renameSync(manifestPath, copyManifestPath);
fs.writeFileSync(manifestPath, ManifestUtil.createManifestString(variant).replace('$YOMITAN_VERSION', '0.0.0.0'));
});
});
10 changes: 5 additions & 5 deletions test/playwright/global.teardown.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

const {test: teardown} = require('@playwright/test');
const {root} = require('./playwright-util');
const path = require('path');
const fs = require('fs');
import {test as teardown} from '@playwright/test';
import fs from 'fs';
import path from 'path';
import {root} from './playwright-util';

const manifestPath = path.join(root, 'ext/manifest.json');
const copyManifestPath = path.join(root, 'ext/manifest-old.json');

teardown('bring back original manifest', () => {
fs.renameSync(copyManifestPath, manifestPath);
});
});
18 changes: 9 additions & 9 deletions test/playwright/integration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

const path = require('path');
const {
test,
import path from 'path';
import {createDictionaryArchive} from '../../dev/util';
import {
expect,
root,
mockModelFieldNames,
mockModelFieldsToAnkiValues,
expectedAddNoteBody,
mockAnkiRouteHandler,
mockModelFieldNames,
mockModelFieldsToAnkiValues,
root,
test,
writeToClipboardFromPage
} = require('./playwright-util');
const {createDictionaryArchive} = require('../../dev/util');
} from './playwright-util';

test.beforeEach(async ({context}) => {
// wait for the on-install welcome.html tab to load, which becomes the foreground tab
Expand Down Expand Up @@ -91,4 +91,4 @@ test('anki add', async ({context, page, extensionId}) => {
await page.locator('[data-mode="term-kanji"]').click();
const addNoteReqBody = await addNotePromise;
expect(addNoteReqBody).toMatchObject(expectedAddNoteBody);
});
});
10 changes: 6 additions & 4 deletions test/playwright/playwright-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

const path = require('path');
const {test: base, chromium} = require('@playwright/test');
import {test as base, chromium} from '@playwright/test';
import path from 'path';
import {fileURLToPath} from 'url';

export const root = path.join(__dirname, '..', '..');
const dirname = path.dirname(fileURLToPath(import.meta.url));
export const root = path.join(dirname, '..', '..');

export const test = base.extend({
context: async ({ }, use) => {
Expand Down Expand Up @@ -106,4 +108,4 @@ const ankiRouteResponses = {
'canAddNotes': Object.assign({body: JSON.stringify([true, true])}, baseAnkiResp),
'storeMediaFile': Object.assign({body: JSON.stringify('mock_audio.mp3')}, baseAnkiResp),
'addNote': Object.assign({body: JSON.stringify(102312488912)}, baseAnkiResp)
};
};
12 changes: 6 additions & 6 deletions test/playwright/visual.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

const path = require('path');
import path from 'path';

const {
test,
import {
expect,
root
} = require('./playwright-util');
root,
test
} from './playwright-util';

test.beforeEach(async ({context}) => {
// wait for the on-install welcome.html tab to load, which becomes the foreground tab
Expand Down Expand Up @@ -97,4 +97,4 @@ test('visual', async ({page, extensionId}) => {
await screenshot(2, i, el, {x: 15, y: 15});
i++;
}
});
});
Loading