Skip to content

Commit

Permalink
Style updates (#447)
Browse files Browse the repository at this point in the history
* style updates

* style updates

* style updates

* revert changes to dev/lib/handlebars

* revert changes to dev/lib/handlebars

* revert changes to dev/lib/handlebars
  • Loading branch information
Casheeew authored Dec 25, 2023
1 parent e0659a8 commit 8e95d99
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 26 deletions.
6 changes: 3 additions & 3 deletions dev/dictionary-validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ async function validateDictionaryBanks(mode, zip, fileNameFormat, schema) {
* @param {import('dev/dictionary-validate').Schemas} schemas
*/
export async function validateDictionary(mode, archive, schemas) {
const fileName = 'index.json';
const indexFile = archive.files[fileName];
const indexFileName = 'index.json';
const indexFile = archive.files[indexFileName];
if (!indexFile) {
throw new Error('No dictionary index found in archive');
}
Expand All @@ -93,7 +93,7 @@ export async function validateDictionary(mode, archive, schemas) {
jsonSchema.validate(index);
} catch (e) {
const e2 = e instanceof Error ? e : new Error(`${e}`);
e2.message += `\n(in file ${fileName})}`;
e2.message += `\n(in file ${indexFileName})}`;
throw e2;
}

Expand Down
2 changes: 1 addition & 1 deletion dev/manifest-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class ManifestUtil {
_applyModifications(manifest, modifications) {
if (Array.isArray(modifications)) {
for (const modification of modifications) {
// rename to path2 to avoid clashing with imported `node:path` module.
// Rename to path2 to avoid clashing with imported `node:path` module.
const {action, path: path2} = modification;
switch (action) {
case 'set':
Expand Down
2 changes: 1 addition & 1 deletion ext/js/display/search-display-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export class SearchDisplayController {

/** */
_onCopy() {
// ignore copy from search page
// Ignore copy from search page
const selection = window.getSelection();
this._clipboardMonitor.setPreviousText(selection !== null ? selection.toString().trim() : '');
}
Expand Down
4 changes: 2 additions & 2 deletions ext/js/pages/settings/settings-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import {TranslationTextReplacementsController} from './translation-text-replacem
/**
* @param {GenericSettingController} genericSettingController
*/
async function setupGenericSettingsController(genericSettingController) {
async function setupGenericSettingController(genericSettingController) {
await genericSettingController.prepare();
await genericSettingController.refresh();
}
Expand Down Expand Up @@ -107,7 +107,7 @@ async function main() {
dictionaryImportController.prepare();

const genericSettingController = new GenericSettingController(settingsController);
preparePromises.push(setupGenericSettingsController(genericSettingController));
preparePromises.push(setupGenericSettingController(genericSettingController));

const audioController = new AudioController(settingsController, modalController);
audioController.prepare();
Expand Down
2 changes: 1 addition & 1 deletion ext/js/templates/sandbox/anki-template-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ export class AnkiTemplateRenderer {
/**
* @type {import('template-renderer').HelperFunction<string>}
*/
_formatGlossary(args, context, options) {
_formatGlossary(args, _context, options) {
const [dictionary, content] = /** @type {[dictionary: string, content: import('dictionary-data').TermGlossary]} */ (args);
const data = options.data.root;
if (typeof content === 'string') { return this._stringToMultiLineHtml(this._escape(content)); }
Expand Down
1 change: 0 additions & 1 deletion test/deinflector.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -962,5 +962,4 @@ function main() {
testDeinflections();
}


main();
4 changes: 2 additions & 2 deletions test/dictionary-data-validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import {fileURLToPath} from 'node:url';
import path from 'path';
import {describe, test} from 'vitest';
import {describe, it} from 'vitest';
import * as dictionaryValidate from '../dev/dictionary-validate.js';
import {createDictionaryArchive} from '../dev/util.js';

Expand Down Expand Up @@ -46,7 +46,7 @@ describe('Dictionary validation', () => {
];
const schemas = dictionaryValidate.getSchemas();
describe.each(testCases)('Test dictionary $name', ({name, valid}) => {
test(`Should be ${valid ? 'valid' : 'invalid'}`, async ({expect}) => {
it(`should be ${valid ? 'valid' : 'invalid'}`, async ({expect}) => {
const archive = createTestDictionaryArchive(name);
if (valid) {
await expect(dictionaryValidate.validateDictionary(null, archive, schemas)).resolves.not.toThrow();
Expand Down
14 changes: 7 additions & 7 deletions test/playwright/integration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
} from './playwright-util';

test.beforeEach(async ({context}) => {
// wait for the on-install welcome.html tab to load, which becomes the foreground tab
// Wait for the on-install welcome.html tab to load, which becomes the foreground tab
const welcome = await context.waitForEvent('page');
await welcome.close(); // close the welcome tab so our main tab becomes the foreground tab -- otherwise, the screenshot can hang
});
Expand All @@ -44,7 +44,7 @@ test('search clipboard', async ({page, extensionId}) => {
});

test('anki add', async ({context, page, extensionId}) => {
// mock anki routes
// Mock anki routes
/** @type {?(value: unknown) => void} */
let resolve = null;
const addNotePromise = new Promise((res) => {
Expand All @@ -58,10 +58,10 @@ test('anki add', async ({context, page, extensionId}) => {
}
});

// open settings
// Open settings
await page.goto(`chrome-extension://${extensionId}/settings.html`);

// load in test dictionary
// Load in test dictionary
const dictionary = createDictionaryArchive(path.join(root, 'test/data/dictionaries/valid-dictionary1'), 'valid-dictionary1');
const testDictionarySource = await dictionary.generateAsync({type: 'arraybuffer'});
await page.locator('input[id="dictionary-import-file-input"]').setInputFiles({
Expand All @@ -71,11 +71,11 @@ test('anki add', async ({context, page, extensionId}) => {
});
await expect(page.locator('id=dictionaries')).toHaveText('Dictionaries (1 installed, 1 enabled)', {timeout: 5 * 60 * 1000});

// connect to anki
// Connect to anki
await page.locator('.toggle', {has: page.locator('[data-setting="anki.enable"]')}).click();
await expect(page.locator('#anki-error-message')).toHaveText('Connected');

// prep anki deck
// Prep anki deck
await page.locator('[data-modal-action="show,anki-cards"]').click();
await page.locator('select.anki-card-deck').selectOption('Mock Deck');
await page.locator('select.anki-card-model').selectOption('Mock Model');
Expand All @@ -85,7 +85,7 @@ test('anki add', async ({context, page, extensionId}) => {
await page.locator('#anki-cards-modal > div > div.modal-footer > button:nth-child(2)').click();
await writeToClipboardFromPage(page, '読むの例文');

// add to anki deck
// Add to anki deck
await page.goto(`chrome-extension://${extensionId}/search.html`);
await expect(async () => {
await page.locator('#search-textbox').clear();
Expand Down
16 changes: 8 additions & 8 deletions test/playwright/visual.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ import {pathToFileURL} from 'url';
import {expect, root, test} from './playwright-util';

test.beforeEach(async ({context}) => {
// wait for the on-install welcome.html tab to load, which becomes the foreground tab
// Wait for the on-install welcome.html tab to load, which becomes the foreground tab
const welcome = await context.waitForEvent('page');
welcome.close(); // close the welcome tab so our main tab becomes the foreground tab -- otherwise, the screenshot can hang
});

test('visual', async ({page, extensionId}) => {
// open settings
// Open settings
await page.goto(`chrome-extension://${extensionId}/settings.html`);

await expect(page.locator('id=dictionaries')).toBeVisible();

// get the locator for the disk usage indicator so we can later mask it out of the screenshot
// Get the locator for the disk usage indicator so we can later mask it out of the screenshot
const storage_locator = page.locator('.storage-use-finite >> xpath=..');

// take a simple screenshot of the settings page
// Take a simple screenshot of the settings page
await expect.soft(page).toHaveScreenshot('settings-fresh.png', {mask: [storage_locator]});

// load in jmdict_english.zip
// Load in jmdict_english.zip
await page.locator('input[id="dictionary-import-file-input"]').setInputFiles(path.join(root, 'dictionaries/jmdict_english.zip'));
await expect(page.locator('id=dictionaries')).toHaveText('Dictionaries (1 installed, 1 enabled)', {timeout: 5 * 60 * 1000});

// take a screenshot of the settings page with jmdict loaded
// Take a screenshot of the settings page with jmdict loaded
await expect.soft(page).toHaveScreenshot('settings-jmdict-loaded.png', {mask: [storage_locator]});

/**
Expand All @@ -55,10 +55,10 @@ test('visual', async ({page, extensionId}) => {

const box = (await el.boundingBox()) || {x: 0, y: 0, width: 0, height: 0};

// find the popup frame if it exists
// Find the popup frame if it exists
let popup_frame = page.frames().find((f) => f.url().includes('popup.html'));

// otherwise prepare for it to be attached
// Otherwise prepare for it to be attached
let frame_attached;
if (popup_frame === undefined) {
frame_attached = page.waitForEvent('frameattached');
Expand Down

0 comments on commit 8e95d99

Please sign in to comment.