From 09ff4c421592362a31330f25cffb0ceaf8948701 Mon Sep 17 00:00:00 2001 From: Dharmesh Date: Sun, 12 May 2024 18:44:33 +0530 Subject: [PATCH] 329 target only the base url (#279) * feat: Add URL match option in ConfigSettingsModal The code changes add a new form group in the `ConfigSettingsModal` component to allow users to select the URL match option. This is achieved by adding a new property `url_match` to the `Configuration` type and updating the form group in the component. The commit also includes updates to the `URL_MATCH` enum in the `config-model.ts` file. Recent user commits and repository commits are not relevant for generating the commit message. * refactor: Remove unused files and configurations for acf-options-page-e2e * refactor: Remove unused files and configurations for acf-options-page-e2e * chore: Remove setupFiles from jest.config.ts --- apps/acf-extension-e2e/.eslintrc.json | 10 ---- apps/acf-extension-e2e/jest.config.ts | 17 ------- apps/acf-extension-e2e/project.json | 18 ------- .../src/acf-extension/acf-extension.spec.ts | 12 ----- apps/acf-extension-e2e/src/test-setup.ts | 1 - apps/acf-extension-e2e/tsconfig.json | 13 ----- apps/acf-extension-e2e/tsconfig.spec.json | 9 ---- apps/acf-options-page-e2e/.eslintrc.json | 10 ---- apps/acf-options-page-e2e/cypress.config.ts | 6 --- apps/acf-options-page-e2e/project.json | 30 ----------- apps/acf-options-page-e2e/src/e2e/app.cy.ts | 13 ----- .../src/fixtures/example.json | 4 -- .../src/support/app.po.ts | 1 - .../src/support/commands.ts | 33 ------------ apps/acf-options-page-e2e/src/support/e2e.ts | 17 ------- apps/acf-options-page-e2e/tsconfig.json | 10 ---- .../src/modal/config-settings.modal.tsx | 50 ++++++++++--------- libs/acf/common/src/lib/model/config-model.ts | 6 +++ libs/acf/store/src/lib/config-storage.ts | 4 +- libs/core/common/jest.config.ts | 1 - 20 files changed, 35 insertions(+), 230 deletions(-) delete mode 100644 apps/acf-extension-e2e/.eslintrc.json delete mode 100644 apps/acf-extension-e2e/jest.config.ts delete mode 100644 apps/acf-extension-e2e/project.json delete mode 100644 apps/acf-extension-e2e/src/acf-extension/acf-extension.spec.ts delete mode 100644 apps/acf-extension-e2e/src/test-setup.ts delete mode 100644 apps/acf-extension-e2e/tsconfig.json delete mode 100644 apps/acf-extension-e2e/tsconfig.spec.json delete mode 100644 apps/acf-options-page-e2e/.eslintrc.json delete mode 100644 apps/acf-options-page-e2e/cypress.config.ts delete mode 100644 apps/acf-options-page-e2e/project.json delete mode 100644 apps/acf-options-page-e2e/src/e2e/app.cy.ts delete mode 100644 apps/acf-options-page-e2e/src/fixtures/example.json delete mode 100644 apps/acf-options-page-e2e/src/support/app.po.ts delete mode 100644 apps/acf-options-page-e2e/src/support/commands.ts delete mode 100644 apps/acf-options-page-e2e/src/support/e2e.ts delete mode 100644 apps/acf-options-page-e2e/tsconfig.json diff --git a/apps/acf-extension-e2e/.eslintrc.json b/apps/acf-extension-e2e/.eslintrc.json deleted file mode 100644 index 8852e20b..00000000 --- a/apps/acf-extension-e2e/.eslintrc.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - } - ] -} diff --git a/apps/acf-extension-e2e/jest.config.ts b/apps/acf-extension-e2e/jest.config.ts deleted file mode 100644 index 755e5721..00000000 --- a/apps/acf-extension-e2e/jest.config.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* eslint-disable */ -export default { - displayName: 'acf-extension-e2e', - preset: '../..//jest.preset.js', - setupFiles: ['/src/test-setup.ts'], - testEnvironment: 'node', - transform: { - '^.+\\.[tj]s$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - }, - ], - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../..//coverage/acf-extension-e2e', -}; diff --git a/apps/acf-extension-e2e/project.json b/apps/acf-extension-e2e/project.json deleted file mode 100644 index 2bfe1154..00000000 --- a/apps/acf-extension-e2e/project.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "acf-extension-e2e", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "implicitDependencies": ["acf-extension"], - "targets": { - "e2e": { - "executor": "@nx/jest:jest", - "outputs": ["{workspaceRoot}/coverage/{e2eProjectRoot}"], - "options": { - "jestConfig": "apps/acf-extension-e2e/jest.config.ts" - } - }, - "lint": { - "executor": "@nx/eslint:lint", - "outputs": ["{options.outputFile}"] - } - } -} diff --git a/apps/acf-extension-e2e/src/acf-extension/acf-extension.spec.ts b/apps/acf-extension-e2e/src/acf-extension/acf-extension.spec.ts deleted file mode 100644 index 887c507f..00000000 --- a/apps/acf-extension-e2e/src/acf-extension/acf-extension.spec.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { execSync } from 'child_process'; -import { join } from 'path'; - -describe('CLI tests', () => { - it('should print a message', () => { - const cliPath = join(process.cwd(), 'dist/apps/acf-extension'); - - const output = execSync(`node ${cliPath}`).toString(); - - expect(output).toMatch(/Hello World/); - }); -}); diff --git a/apps/acf-extension-e2e/src/test-setup.ts b/apps/acf-extension-e2e/src/test-setup.ts deleted file mode 100644 index 8337712e..00000000 --- a/apps/acf-extension-e2e/src/test-setup.ts +++ /dev/null @@ -1 +0,0 @@ -// diff --git a/apps/acf-extension-e2e/tsconfig.json b/apps/acf-extension-e2e/tsconfig.json deleted file mode 100644 index ed633e1d..00000000 --- a/apps/acf-extension-e2e/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.spec.json" - } - ], - "compilerOptions": { - "esModuleInterop": true - } -} diff --git a/apps/acf-extension-e2e/tsconfig.spec.json b/apps/acf-extension-e2e/tsconfig.spec.json deleted file mode 100644 index 2a5e4dff..00000000 --- a/apps/acf-extension-e2e/tsconfig.spec.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../..//dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"] - }, - "include": ["jest.config.ts", "src/**/*.ts"] -} diff --git a/apps/acf-options-page-e2e/.eslintrc.json b/apps/acf-options-page-e2e/.eslintrc.json deleted file mode 100644 index 696cb8b1..00000000 --- a/apps/acf-options-page-e2e/.eslintrc.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": ["plugin:cypress/recommended", "../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - } - ] -} diff --git a/apps/acf-options-page-e2e/cypress.config.ts b/apps/acf-options-page-e2e/cypress.config.ts deleted file mode 100644 index bc91e98d..00000000 --- a/apps/acf-options-page-e2e/cypress.config.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { defineConfig } from 'cypress'; -import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset'; - -export default defineConfig({ - e2e: nxE2EPreset(__dirname), -}); diff --git a/apps/acf-options-page-e2e/project.json b/apps/acf-options-page-e2e/project.json deleted file mode 100644 index e1f704f3..00000000 --- a/apps/acf-options-page-e2e/project.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "acf-options-page-e2e", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "apps/acf-options-page-e2e/src", - "projectType": "application", - "targets": { - "e2e": { - "executor": "@nx/cypress:cypress", - "options": { - "cypressConfig": "apps/acf-options-page-e2e/cypress.config.ts", - "devServerTarget": "acf-options-page:serve:development", - "testingType": "e2e" - }, - "configurations": { - "production": { - "devServerTarget": "acf-options-page:serve:production" - }, - "ci": { - "devServerTarget": "acf-options-page:serve-static" - } - } - }, - "lint": { - "executor": "@nx/eslint:lint", - "outputs": ["{options.outputFile}"] - } - }, - "tags": [], - "implicitDependencies": ["acf-options-page"] -} diff --git a/apps/acf-options-page-e2e/src/e2e/app.cy.ts b/apps/acf-options-page-e2e/src/e2e/app.cy.ts deleted file mode 100644 index ad35b665..00000000 --- a/apps/acf-options-page-e2e/src/e2e/app.cy.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { getGreeting } from '../support/app.po'; - -describe('acf-options-page', () => { - beforeEach(() => cy.visit('/')); - - it('should display welcome message', () => { - // Custom command example, see `../support/commands.ts` file - cy.login('my-email@something.com', 'myPassword'); - - // Function helper example, see `../support/app.po.ts` file - getGreeting().contains('Welcome acf-options-page'); - }); -}); diff --git a/apps/acf-options-page-e2e/src/fixtures/example.json b/apps/acf-options-page-e2e/src/fixtures/example.json deleted file mode 100644 index 294cbed6..00000000 --- a/apps/acf-options-page-e2e/src/fixtures/example.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "Using fixtures to represent data", - "email": "hello@cypress.io" -} diff --git a/apps/acf-options-page-e2e/src/support/app.po.ts b/apps/acf-options-page-e2e/src/support/app.po.ts deleted file mode 100644 index 32934246..00000000 --- a/apps/acf-options-page-e2e/src/support/app.po.ts +++ /dev/null @@ -1 +0,0 @@ -export const getGreeting = () => cy.get('h1'); diff --git a/apps/acf-options-page-e2e/src/support/commands.ts b/apps/acf-options-page-e2e/src/support/commands.ts deleted file mode 100644 index 310f1fa0..00000000 --- a/apps/acf-options-page-e2e/src/support/commands.ts +++ /dev/null @@ -1,33 +0,0 @@ -// *********************************************** -// This example commands.js shows you how to -// create various custom commands and overwrite -// existing commands. -// -// For more comprehensive examples of custom -// commands please read more here: -// https://on.cypress.io/custom-commands -// *********************************************** - -// eslint-disable-next-line @typescript-eslint/no-namespace -declare namespace Cypress { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - interface Chainable { - login(email: string, password: string): void; - } -} -// -// -- This is a parent command -- -Cypress.Commands.add('login', (email, password) => { - console.log('Custom command example: Login', email, password); -}); -// -// -- This is a child command -- -// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) -// -// -// -- This is a dual command -- -// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) -// -// -// -- This will overwrite an existing command -- -// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) diff --git a/apps/acf-options-page-e2e/src/support/e2e.ts b/apps/acf-options-page-e2e/src/support/e2e.ts deleted file mode 100644 index 3d469a6b..00000000 --- a/apps/acf-options-page-e2e/src/support/e2e.ts +++ /dev/null @@ -1,17 +0,0 @@ -// *********************************************************** -// This example support/index.js is processed and -// loaded automatically before your test files. -// -// This is a great place to put global configuration and -// behavior that modifies Cypress. -// -// You can change the location of this file or turn off -// automatically serving support files with the -// 'supportFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/configuration -// *********************************************************** - -// Import commands.js using ES2015 syntax: -import './commands'; diff --git a/apps/acf-options-page-e2e/tsconfig.json b/apps/acf-options-page-e2e/tsconfig.json deleted file mode 100644 index cc509a73..00000000 --- a/apps/acf-options-page-e2e/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "sourceMap": false, - "outDir": "../../dist/out-tsc", - "allowJs": true, - "types": ["cypress", "node"] - }, - "include": ["src/**/*.ts", "src/**/*.js", "cypress.config.ts"] -} diff --git a/apps/acf-options-page/src/modal/config-settings.modal.tsx b/apps/acf-options-page/src/modal/config-settings.modal.tsx index e6c16628..c4d22f2b 100644 --- a/apps/acf-options-page/src/modal/config-settings.modal.tsx +++ b/apps/acf-options-page/src/modal/config-settings.modal.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { Card, Col, Form, FormControl, Modal, Row } from 'react-bootstrap'; -import { LOAD_TYPES, START_TYPES, defaultHotkey } from '@dhruv-techapps/acf-common'; +import { LOAD_TYPES, START_TYPES, URL_MATCH, defaultHotkey } from '@dhruv-techapps/acf-common'; import { Trans, useTranslation } from 'react-i18next'; import { HotkeyPopover } from '../popover'; @@ -15,7 +15,7 @@ import { REGEX } from '../util'; const ConfigSettingsModal = () => { const { t } = useTranslation(); - const { visible, message, dev } = useAppSelector(configSettingsSelector); + const { visible, message } = useAppSelector(configSettingsSelector); const config = useAppSelector(selectedConfigSelector); const dispatch = useAppDispatch(); @@ -71,7 +71,7 @@ const ConfigSettingsModal = () => { {t('modal.configSettings.title')} - + @@ -172,26 +172,30 @@ const ConfigSettingsModal = () => { - {dev ? ( - - - {t('configuration.startTime')}  - - {t('error.startTime')} - - ) : ( - <> - Start Time : - - Try - - Schedule URL - - our new browser extension. -
it's used to schedule webpage / URL at particular day and time. -
- - )} + + + {t('configuration.startTime')}  + + {t('error.startTime')} + + +
+
+
+ + + + + + + {Object.entries(URL_MATCH).map((condition) => ( + + ))} + + URL Match + diff --git a/libs/acf/common/src/lib/model/config-model.ts b/libs/acf/common/src/lib/model/config-model.ts index d2ac188d..4eee51f2 100644 --- a/libs/acf/common/src/lib/model/config-model.ts +++ b/libs/acf/common/src/lib/model/config-model.ts @@ -19,6 +19,11 @@ export enum CONFIG_SOURCE { WEB = 'web', } +export enum URL_MATCH { + REGEX = 'regex', + EXACT = 'exact', +} + export type Configuration = { url: string; enable: boolean; @@ -35,6 +40,7 @@ export type Configuration = { batch?: Batch; source?: CONFIG_SOURCE; new?: boolean; + url_match?: URL_MATCH; }; export const getDefaultConfig = (source?: CONFIG_SOURCE, actions?: Array): Configuration => ({ diff --git a/libs/acf/store/src/lib/config-storage.ts b/libs/acf/store/src/lib/config-storage.ts index 1c89d959..ef55a2ca 100644 --- a/libs/acf/store/src/lib/config-storage.ts +++ b/libs/acf/store/src/lib/config-storage.ts @@ -1,4 +1,4 @@ -import { Configuration, LOCAL_STORAGE_KEY, START_TYPES } from '@dhruv-techapps/acf-common'; +import { Configuration, LOCAL_STORAGE_KEY, START_TYPES, URL_MATCH } from '@dhruv-techapps/acf-common'; export type GetConfigResult = { autoConfig: Configuration | undefined; @@ -17,7 +17,7 @@ export class ConfigStorage { configs .filter((config) => config.enable && config.url) .forEach((config) => { - if (this.urlMatcher(config.url, href)) { + if (config.url_match !== URL_MATCH.EXACT && this.urlMatcher(config.url, href)) { manualConfigs.push(config); if (!autoConfig && config.startType === START_TYPES.AUTO) { autoConfig = config; diff --git a/libs/core/common/jest.config.ts b/libs/core/common/jest.config.ts index ba17f12c..679c5dc4 100644 --- a/libs/core/common/jest.config.ts +++ b/libs/core/common/jest.config.ts @@ -8,5 +8,4 @@ export default { }, moduleFileExtensions: ['ts', 'js', 'html'], coverageDirectory: '../../../coverage/libs/core/common', - setupFiles: ['./jest.setup.js'], // Optional: if you need a setup file };