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

#4734 Use separate mock api for each test #4928

Merged
merged 73 commits into from Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
88e04cd
remove unnecessary eslint-disable
sosnovsky Jan 13, 2023
957c9c0
Merge branch 'master' into feature/issue-4734-one-mock-per-test
sosnovsky Jan 13, 2023
808c3b5
Merge branch 'master' into feature/issue-4734-one-mock-per-test
sosnovsky Jan 16, 2023
6341593
choose random port for tests
sosnovsky Jan 16, 2023
bc37919
improve test port setting
sosnovsky Jan 16, 2023
e930393
add default mock api
sosnovsky Jan 16, 2023
f24f68c
separate port for each test
sosnovsky Jan 18, 2023
0fa7882
Merge branch 'master' into feature/issue-4734-one-mock-per-test
sosnovsky Jan 18, 2023
a6e8f6f
get extension id once
sosnovsky Jan 18, 2023
9de3ba3
Merge branch 'master' into feature/issue-4734-one-mock-per-test
sosnovsky Jan 19, 2023
1b10bed
Merge branch 'master' into feature/issue-4734-one-mock-per-test
sosnovsky Jan 19, 2023
be0f6e1
Merge branch 'master' into feature/issue-4734-one-mock-per-test
sosnovsky Jan 20, 2023
cffd6f9
make tests independent
sosnovsky Jan 20, 2023
61b7385
Merge branch 'master' into feature/issue-4734-one-mock-per-test
sosnovsky Jan 20, 2023
e856a3c
fix extensionDir path
sosnovsky Jan 23, 2023
1d3ba2e
update setMaxListeners
sosnovsky Jan 23, 2023
23b6016
add debug info
sosnovsky Jan 23, 2023
44f5901
more logs
sosnovsky Jan 23, 2023
431ea85
update WKD_API_HOST
sosnovsky Jan 24, 2023
5e76fab
update consts
sosnovsky Jan 24, 2023
eb82ec3
debug
sosnovsky Jan 24, 2023
6c5a2db
test ContactStore
sosnovsky Jan 24, 2023
aefb067
run all unit tests
sosnovsky Jan 24, 2023
e01e558
run only unit tests
sosnovsky Jan 24, 2023
cf52c48
fix unit mock port
sosnovsky Jan 24, 2023
f97c74b
run all wkd tests
sosnovsky Jan 24, 2023
f00a3b7
separate gmail tests
sosnovsky Jan 24, 2023
92ba040
disable gmail
sosnovsky Jan 24, 2023
bded044
disable gmail
sosnovsky Jan 24, 2023
e266f15
remove acct param
sosnovsky Jan 24, 2023
89b1cf7
add logging
sosnovsky Jan 24, 2023
42a1f62
Merge branch 'master' into feature/issue-4734-one-mock-per-test
sosnovsky Jan 24, 2023
111b0f4
more logging
sosnovsky Jan 24, 2023
d335745
new logs
sosnovsky Jan 24, 2023
972bba3
log oauth url
sosnovsky Jan 24, 2023
0dee435
log errors
sosnovsky Jan 24, 2023
eabe325
log current consts
sosnovsky Jan 25, 2023
67f8741
log extension dir
sosnovsky Jan 25, 2023
523da50
log extension files
sosnovsky Jan 25, 2023
ac260aa
update config script
sosnovsky Jan 25, 2023
69f58c9
update config script
sosnovsky Jan 25, 2023
6bd8795
update config script
sosnovsky Jan 25, 2023
2b79af1
check test
sosnovsky Jan 25, 2023
9ef650c
run all tests
sosnovsky Jan 25, 2023
575d8db
Merge branch 'master' into feature/issue-4734-one-mock-per-test
sosnovsky Jan 25, 2023
b898a08
fix unit tests
sosnovsky Jan 25, 2023
4491785
use port for send message strategy
sosnovsky Jan 26, 2023
eb97dd6
fix flaky tests
sosnovsky Jan 26, 2023
49316d3
split standard tests
sosnovsky Jan 26, 2023
92ca335
use browser pool
sosnovsky Jan 27, 2023
42b63da
fix settings tests
sosnovsky Jan 27, 2023
2d13a1c
fix compose and settings tests
sosnovsky Jan 27, 2023
695f8af
Merge branch 'master' into feature/issue-4734-one-mock-per-test
sosnovsky Jan 27, 2023
2cc88d1
fix for settings tests
sosnovsky Jan 30, 2023
d287a1e
Merge branch 'master' into feature/issue-4734-one-mock-per-test
sosnovsky Jan 30, 2023
0ed4b9f
fix email parsing
sosnovsky Jan 30, 2023
ef18cef
fix setup tests
sosnovsky Jan 30, 2023
77473e4
use custom port for send strategies
sosnovsky Jan 30, 2023
dc3acc5
fix typo
sosnovsky Jan 31, 2023
78cb6f9
fix fes mock endpoints
sosnovsky Jan 31, 2023
71d43cd
Merge branch 'master' into feature/issue-4734-one-mock-per-test
sosnovsky Jan 31, 2023
5569bd2
fix mock email parsing
sosnovsky Jan 31, 2023
9adca86
code cleanup
sosnovsky Jan 31, 2023
87dab76
fix mock errors handling
sosnovsky Jan 31, 2023
963aa56
code cleanup
sosnovsky Jan 31, 2023
6cb9221
code cleanup
sosnovsky Jan 31, 2023
f796a3f
increase concurrency
sosnovsky Jan 31, 2023
6e5370d
Merge branch 'master' into feature/issue-4734-one-mock-per-test
sosnovsky Feb 1, 2023
94503e3
close mock api on test end
sosnovsky Feb 1, 2023
33c6860
fix mock api close
sosnovsky Feb 1, 2023
efe8f74
code cleanup
sosnovsky Feb 1, 2023
9851558
remove closeMockApi from AvaContext
sosnovsky Feb 1, 2023
27033c6
move closeMockApi to try/finally
sosnovsky Feb 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 1 addition & 4 deletions .eslintrc.js
Expand Up @@ -70,7 +70,6 @@ module.exports = {
leadingUnderscore: 'allow',
},
],
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': ['warn'],
'@typescript-eslint/no-floating-promises': 'error',
Expand Down Expand Up @@ -111,14 +110,13 @@ module.exports = {
'no-control-regex': 0,
'no-debugger': 'error',
'no-empty': 'error',
'no-empty-function': 'error',
'no-empty-pattern': 0,
'no-eval': 'error',
'no-fallthrough': 0,
'no-invalid-this': 'off',
'no-new-wrappers': 'error',
'no-null/no-null': 'error',
'no-only-tests/no-only-tests': ['error', { block: ['ava.default'] }],
'no-only-tests/no-only-tests': ['error'],
'no-prototype-builtins': 0,
'no-shadow': 'off',
'no-throw-literal': 'error',
Expand All @@ -128,7 +126,6 @@ module.exports = {
'no-unsafe-finally': 'error',
'no-unused-expressions': 'off',
'no-unused-labels': 'error',
'no-unused-vars': 0,
'no-use-before-define': 'off',
'no-useless-escape': 0,
'no-var': 'error',
Expand Down
3 changes: 1 addition & 2 deletions conf/tsconfig.test.json
Expand Up @@ -17,7 +17,6 @@
"../test/source/test.ts",
"../test/source/patterns.ts",
"../test/source/async-stack.ts",
"../test/source/buf.ts",
"../test/source/mock.ts"
"../test/source/buf.ts"
]
}
6 changes: 2 additions & 4 deletions extension/chrome/elements/attachment.ts
Expand Up @@ -103,8 +103,7 @@ export class AttachmentDownloadView extends View {
$('img#file-format').attr('src', this.getFileIconSrc());
if (!this.size && this.url) {
// download url of a file that has an unknown size
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.getUrlFileSize(this.url!)
this.getUrlFileSize(this.url)
.then(fileSize => {
if (typeof fileSize !== 'undefined') {
this.size = fileSize;
Expand Down Expand Up @@ -213,8 +212,7 @@ export class AttachmentDownloadView extends View {
console.info('trying to figure out figetUrlFileSizee size');
if (url.indexOf('docs.googleusercontent.getUrlFileSizeom/docs/securesc') !== -1) {
try {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const googleDriveFileId = url.split('/').pop()!.split('?').shift(); // try and catch any errors below if structure is not as expected
const googleDriveFileId = url.split('/').pop()?.split('?').shift(); // try and catch any errors below if structure is not as expected
url = googleDriveFileId ? `https://drive.google.com/uc?export=download&id=${googleDriveFileId}` : url; // attempt to get length headers from Google Drive file if available
} catch (e) {
// leave url as is
Expand Down
3 changes: 1 addition & 2 deletions extension/chrome/elements/backup.ts
Expand Up @@ -72,8 +72,7 @@ View.run(
};

private sendResizeMsg = () => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const desiredHeight = $('#backup_block').height()!;
const desiredHeight = $('#backup_block').height();
BrowserMsg.send.setCss(this.parentTabId, {
selector: `iframe#${this.frameId}`,
css: { height: `${desiredHeight}px` },
Expand Down
Expand Up @@ -17,7 +17,7 @@ declare const filesize: { filesize: Function }; // eslint-disable-line @typescri
export class PgpBlockViewAttachmentsModule {
public includedAttachments: Attachment[] = [];

public constructor(private view: PgpBlockView) {} // eslint-disable-line no-empty-function
public constructor(private view: PgpBlockView) {}

public renderInnerAttachments = (attachments: Attachment[], isEncrypted: boolean) => {
Xss.sanitizeAppend('#pgp_block', '<div id="attachments"></div>');
Expand Down
Expand Up @@ -18,7 +18,6 @@ export class PgpBlockViewDecryptModule {
private msgFetchedFromApi: false | GmailResponseFormat = false;
private isPwdMsgBasedOnMsgSnippet: boolean | undefined;

// eslint-disable-next-line no-empty-function
public constructor(private view: PgpBlockView) {}

public initialize = async (verificationPubs: string[], forcePullMsgFromApi: boolean) => {
Expand Down
Expand Up @@ -16,7 +16,6 @@ import { Str } from '../../../js/common/core/common.js';
export class PgpBlockViewErrorModule {
private debugId = Str.sloppyRandom();

// eslint-disable-next-line no-empty-function
public constructor(private view: PgpBlockView) {}

public renderErr = async (errBoxContent: string, renderRawMsg: string | undefined, errMsg?: string) => {
Expand Down
Expand Up @@ -7,7 +7,7 @@ import { Str } from '../../../js/common/core/common.js';
import { Xss } from '../../../js/common/platform/xss.js';

export class PgpBlockViewQuoteModule {
public constructor(private view: PgpBlockView) {} // eslint-disable-line no-empty-function
public constructor(private view: PgpBlockView) {}

public separateQuotedContentAndRenderText = async (decryptedContent: string, isHtml: boolean) => {
if (isHtml) {
Expand Down
Expand Up @@ -23,7 +23,6 @@ export class PgpBlockViewRenderModule {
private heightHist: number[] = [];
private printMailInfoHtml!: string;

// eslint-disable-next-line no-empty-function
public constructor(private view: PgpBlockView) {}

public initPrintView = async () => {
Expand Down Expand Up @@ -133,14 +132,12 @@ export class PgpBlockViewRenderModule {
</body>
</html>
`;
/* eslint-disable @typescript-eslint/no-non-null-assertion */
w!.document.write(html);
w?.document.write(html);
// Give some time for above dom to load in print dialog
// https://stackoverflow.com/questions/31725373/google-chrome-not-showing-image-in-print-preview
await Ui.time.sleep(250);
w!.window.print();
w!.document.close();
/* eslint-enable @typescript-eslint/no-non-null-assertion */
w?.window.print();
w?.document.close();
};
tomholub marked this conversation as resolved.
Show resolved Hide resolved

public renderText = (text: string) => {
Expand Down
Expand Up @@ -11,7 +11,6 @@ import { Value } from '../../../js/common/core/common.js';
import { BrowserMsg } from '../../../js/common/browser/browser-msg.js';

export class PgpBlockViewSignatureModule {
// eslint-disable-next-line no-empty-function
public constructor(private view: PgpBlockView) {}

public renderPgpSignatureCheckResult = async (
Expand Down
1 change: 0 additions & 1 deletion extension/chrome/settings/setup/setup-create-key.ts
Expand Up @@ -13,7 +13,6 @@ import { OpenPGPKey } from '../../../js/common/core/crypto/pgp/openpgp-key.js';
import { saveKeysAndPassPhrase } from '../../../js/common/helpers.js';

export class SetupCreateKeyModule {
// eslint-disable-next-line no-empty-function
public constructor(private view: SetupView) {}

public actionCreateKeyHandler = async () => {
Expand Down
1 change: 0 additions & 1 deletion extension/chrome/settings/setup/setup-import-key.ts
Expand Up @@ -14,7 +14,6 @@ import { Lang } from '../../../js/common/lang.js';
import { saveKeysAndPassPhrase } from '../../../js/common/helpers.js';

export class SetupImportKeyModule {
// eslint-disable-next-line no-empty-function
public constructor(private view: SetupView) {}

public actionImportPrivateKeyHandle = async (button: HTMLElement) => {
Expand Down
Expand Up @@ -16,7 +16,6 @@ import { processAndStoreKeysFromEkmLocally, saveKeysAndPassPhrase } from '../../
import { Xss } from '../../../js/common/platform/xss.js';

export class SetupWithEmailKeyManagerModule {
// eslint-disable-next-line no-empty-function
public constructor(private view: SetupView) {}

public continueEkmSetupHandler = async () => {
Expand Down
1 change: 0 additions & 1 deletion extension/chrome/settings/setup/setup-recover-key.ts
Expand Up @@ -15,7 +15,6 @@ import { KeyStore } from '../../../js/common/platform/store/key-store.js';
import { saveKeysAndPassPhrase } from '../../../js/common/helpers.js';

export class SetupRecoverKeyModule {
// eslint-disable-next-line no-empty-function
public constructor(private view: SetupView) {}

public actionRecoverAccountHandler = async () => {
Expand Down
1 change: 0 additions & 1 deletion extension/chrome/settings/setup/setup-render.ts
Expand Up @@ -16,7 +16,6 @@ import { KeyImportUi } from '../../../js/common/ui/key-import-ui.js';
export class SetupRenderModule {
public readonly emailDomainsToSkip = ['yahoo', 'live', 'outlook'];

// eslint-disable-next-line no-empty-function
public constructor(private view: SetupView) {}

public renderInitial = async (): Promise<void> => {
Expand Down
1 change: 0 additions & 1 deletion extension/js/common/client-configuration.ts
Expand Up @@ -49,7 +49,6 @@ export class ClientConfigurationError extends UnreportableError {
* These either enforce, alter or forbid various behavior to fit customer needs
*/
export class ClientConfiguration {
// eslint-disable-next-line no-empty-function
protected constructor(private clientConfigurationJson: ClientConfigurationJson, public domainName: string) {}

public static newInstance = async (acctEmail: string): Promise<ClientConfiguration> => {
Expand Down
4 changes: 2 additions & 2 deletions extension/js/common/core/common.ts
Expand Up @@ -23,11 +23,11 @@ export class Str {
let name: string | undefined;
if (full.includes('<') && full.includes('>')) {
email = full
.substr(full.indexOf('<') + 1, full.indexOf('>') - full.indexOf('<') - 1)
.substring(full.indexOf('<') + 1, full.indexOf('>'))
.replace(/["']/g, '')
.trim()
.toLowerCase();
name = full.substr(0, full.indexOf('<')).replace(/["']/g, '').trim();
name = full.substring(0, full.indexOf('<')).replace(/["']/g, '').trim();
} else {
email = full.replace(/["']/g, '').trim().toLowerCase();
}
Expand Down
2 changes: 1 addition & 1 deletion extension/js/common/core/crypto/pgp/pgp-password.ts
Expand Up @@ -111,7 +111,7 @@ export class PgpPwd {
.toUpperCase()
.replace(/[^A-Z0-9]|0|O|1/g, '')
.replace(/(.{4})/g, '$1-')
.substr(0, 19);
.substring(0, 19);
};

private static readableCrackTime = (totalSeconds: number) => {
Expand Down
2 changes: 1 addition & 1 deletion extension/js/common/core/expiration-cache.ts
Expand Up @@ -6,7 +6,7 @@
export class ExpirationCache {
private cache: { [key: string]: { value: string; expiration: number } } = {};

// eslint-disable-next-line @typescript-eslint/naming-convention, no-empty-function
// eslint-disable-next-line @typescript-eslint/naming-convention
public constructor(public EXPIRATION_TICKS: number) {}

public set = (key: string, value?: string, expiration?: number) => {
Expand Down
2 changes: 1 addition & 1 deletion extension/js/common/core/msg-block.ts
Expand Up @@ -32,7 +32,7 @@ export class MsgBlock {
public attachmentMeta?: AttachmentMeta, // only in plainAttachment, encryptedAttachment, decryptedAttachment, encryptedAttachmentLink (not sure if always)
public decryptErr?: DecryptError, // only in decryptErr block, always
public verifyRes?: VerifyRes
) {} // eslint-disable-line no-empty-function
) {}

public static fromContent = (type: MsgBlockType, content: string | Buf, missingEnd = false): MsgBlock => {
return new MsgBlock(type, content, !missingEnd);
Expand Down