Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
forgetso committed Jan 14, 2024
1 parent 1a5a4dd commit 4542594
Show file tree
Hide file tree
Showing 18 changed files with 799 additions and 228 deletions.
4 changes: 4 additions & 0 deletions _locales/ar/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"message": "تعبير منتظم (التعبيرات العادية)",
"description": "checkbox isRegex"
},
"replaceHTML": {
"message": "Replace HTML",
"description": "checkbox replaceHTML"
},
"replaceAll": {
"message": "استبدال الكل",
"description": "checkbox replaceAll"
Expand Down
4 changes: 4 additions & 0 deletions _locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"message": "Regulärer Ausdruck",
"description": "checkbox isRegex"
},
"replaceHTML": {
"message": "Replace HTML",
"description": "checkbox replaceHTML"
},
"replaceAll": {
"message": "Alle ersetzen",
"description": "checkbox replaceAll"
Expand Down
4 changes: 4 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"message": "Regular expression",
"description": "checkbox isRegex"
},
"replaceHTML": {
"message": "Replace HTML",
"description": "checkbox replaceHTML"
},
"replaceAll": {
"message": "Replace all",
"description": "checkbox replaceAll"
Expand Down
4 changes: 4 additions & 0 deletions _locales/es/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"message": "Expresión Regular",
"description": "checkbox isRegex"
},
"replaceHTML": {
"message": "Replace HTML",
"description": "checkbox replaceHTML"
},
"replaceAll": {
"message": "Reemplazar Todo",
"description": "checkbox replaceAll"
Expand Down
4 changes: 4 additions & 0 deletions _locales/hi/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"message": "नियमित अभिव्यक्ति",
"description": "checkbox isRegex"
},
"replaceHTML": {
"message": "Replace HTML",
"description": "checkbox replaceHTML"
},
"replaceAll": {
"message": "सभी को बदलें",
"description": "checkbox replaceAll"
Expand Down
4 changes: 4 additions & 0 deletions _locales/ja/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"message": "正規表現",
"description": "チェックボックス 正規表現"
},
"replaceHTML": {
"message": "Replace HTML",
"description": "checkbox replaceHTML"
},
"replaceAll": {
"message": "すべて置換",
"description": "チェックボックス すべて置換"
Expand Down
335 changes: 334 additions & 1 deletion _locales/ko/messages.json

Large diffs are not rendered by default.

335 changes: 334 additions & 1 deletion _locales/pt_PT/messages.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions _locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"message": "Регулярное выражение",
"description": "checkbox isRegex"
},
"replaceHTML": {
"message": "Replace HTML",
"description": "checkbox replaceHTML"
},
"replaceAll": {
"message": "Заменить все",
"description": "checkbox replaceAll"
Expand Down
4 changes: 4 additions & 0 deletions _locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"message": "正则表达式",
"description": "复选框 正则表达式"
},
"replaceHTML": {
"message": "Replace HTML",
"description": "checkbox replaceHTML"
},
"replaceAll": {
"message": "替换所有",
"description": "复选框 替换所有"
Expand Down
6 changes: 6 additions & 0 deletions assets/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@
>?
<input name="isRegex" id="isRegex" type="checkbox" class="form-check-input" />
</div>
<div class="form-check">
<label for="replaceHTML" class="form-check-label" data-locale="replaceHTML"
>Replace HTML</label
>?
<input name="replaceHTML" id="replaceHTML" type="checkbox" class="form-check-input" />
</div>
<div class="form-check mb-3">
<label for="save" class="form-check-label" data-locale="saveApplyPageReload"
>Save and apply on page reload?</label
Expand Down
1 change: 1 addition & 0 deletions src/background/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export function getDefaultStorage(): SearchReplacePopupStorage {
visibleOnly: true,
wholeWord: false,
isRegex: false,
replaceHTML: false,
replaceAll: true,
save: false,
},
Expand Down
12 changes: 0 additions & 12 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
import { RichTextEditor, SelectorType } from './types'
export const ELEMENT_FILTER = /(HTML|HEAD|SCRIPT|STYLE|IFRAME)/i
export const INPUT_TEXTAREA_FILTER = /(INPUT|TEXTAREA)/
export const GMAIL_APPLICATION_NAME = 'Gmail'
export const GOOGLE_MAIL_DOMAIN = 'mail.google.com'
export const WORDPRESS_ADMIN_CLASS = 'wp-admin'
export const WORDPRESS_VERSION_6_SELECTOR = 'body[class*=version-6]'
export const RICH_TEXT_EDITOR_TINY_MCE: RichTextEditor = {
editor: { type: SelectorType.id, value: ['#tinymce'], iframe: false },
container: { type: SelectorType.class, value: ['.mce-edit-area'], iframe: true },
}
export const RICH_TEXT_EDITOR_GUTENBERG_DOCUMENT: RichTextEditor = {
container: { type: SelectorType.attribute, value: ['[name="editor-canvas"]'], iframe: true },
editor: { type: SelectorType.attribute, value: ['[role="document"]', '[role="textbox"]'], iframe: false },
}
export const RICH_TEXT_EDITORS: RichTextEditor[] = [RICH_TEXT_EDITOR_TINY_MCE, RICH_TEXT_EDITOR_GUTENBERG_DOCUMENT]

export const HINTS = {
gmail: 'Hint: Gmail detected. Check "Visible content only?" when editing draft emails.',
Expand Down
32 changes: 18 additions & 14 deletions src/cypress/e2e/searchreplace.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ describe('Search Replace ', () => {
false,
false,
false,
false,
true,
false,
iframes,
false,
ELEMENT_FILTER
).then((result) => {
console.log(`result`, result)
expect(result.count.original).to.equal(7)
expect(result.searchReplaceResult.count.original).to.equal(7)
})
).then(() => {
console.log(`after wrap`)
Expand All @@ -70,13 +70,13 @@ describe('Search Replace ', () => {
true,
false,
false,
false,
true,
false,
iframes,
false,
ELEMENT_FILTER
).then((result) => {
expect(result.count.original).to.equal(5)
expect(result.searchReplaceResult.count.original).to.equal(5)
})
).then(() => {
console.log(`after wrap`)
Expand All @@ -99,13 +99,13 @@ describe('Search Replace ', () => {
false,
false,
false,
false,
true,
false,
iframes,
false,
ELEMENT_FILTER
).then((result) => {
expect(result.count.original).to.equal(0)
expect(result.searchReplaceResult.count.original).to.equal(0)
})
).then(() => {
console.log(`after wrap`)
Expand All @@ -128,13 +128,13 @@ describe('Search Replace ', () => {
false,
false,
false,
false,
true,
false,
iframes,
false,
ELEMENT_FILTER
).then((result) => {
expect(result.count.original).to.equal(4)
expect(result.searchReplaceResult.count.original).to.equal(4)
})
).then(() => {
console.log(`after wrap`)
Expand All @@ -157,13 +157,13 @@ describe('Search Replace ', () => {
true,
false,
false,
false,
true,
false,
iframes,
false,
ELEMENT_FILTER
).then((result) => {
expect(result.count.original).to.equal(3)
expect(result.searchReplaceResult.count.original).to.equal(3)
})
).then(() => {
console.log(`after wrap`)
Expand All @@ -186,13 +186,15 @@ describe('Search Replace ', () => {
false,
false,
false,
false,
true,
false,
iframes,
false,
ELEMENT_FILTER
).then((result) => {
expect(result.count.original - result.count.replaced).to.equal(0)
expect(
result.searchReplaceResult.count.original - result.searchReplaceResult.count.replaced
).to.equal(0)
})
).then(() => {
console.log(`after wrap`)
Expand All @@ -217,11 +219,13 @@ describe('Search Replace ', () => {
false,
false,
false,
iframes,
false,
iframes,
ELEMENT_FILTER
).then((result) => {
expect(result.count.original - result.count.replaced).to.equal(6)
expect(
result.searchReplaceResult.count.original - result.searchReplaceResult.count.replaced
).to.equal(6)
})
).then(() => {
console.log(`after wrap`)
Expand Down
2 changes: 2 additions & 0 deletions src/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ function getInputValues(replaceAll: boolean): SearchReplaceInstance {
const visibleOnly = (<HTMLInputElement>document.getElementById('visibleOnly')).checked
const wholeWord = (<HTMLInputElement>document.getElementById('wholeWord')).checked
const isRegex = (<HTMLInputElement>document.getElementById('isRegex')).checked
const replaceHTML = (<HTMLInputElement>document.getElementById('replaceHTML')).checked
const save = (<HTMLInputElement>document.getElementById('save')).checked
const instance: SearchReplaceInstance = {
searchTerm,
Expand All @@ -397,6 +398,7 @@ function getInputValues(replaceAll: boolean): SearchReplaceInstance {
visibleOnly,
wholeWord,
isRegex,
replaceHTML,
replaceAll,
save,
},
Expand Down
Loading

0 comments on commit 4542594

Please sign in to comment.