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

Fix mutation observer and testing #12

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ coverage
static
build
.storybook
/demo
/cypress
/package
.vitebook/.cache
storybook-static
25 changes: 25 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: End-to-end tests
on: [pull_request]
jobs:
cypress-run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Prepare
run: |
npm install
npm run build
npm run demo:install
- name: Cypress run
uses: cypress-io/github-action@v2
with:
start: npm run preview, npm run demo:dev
browser: chrome
headless: true
- name: Upload artifacts
uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
12 changes: 11 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Lint
on: [push]
jobs:
run-linter:
run-main-linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -10,3 +10,13 @@ jobs:
node-version: '16.x'
- run: npm install
- run: npm run lint
run-demo-linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16.x'
- run: npm install
- run: npm run demo:lint
continue-on-error: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ dist-ssr
*.njsproj
*.sln
*.sw?

cypress/screenshots
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ package
CHANGELOG.md
.changeset
.github
/demo
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,37 @@ You can do it before submitting your form and attach the result to your request.
});
</script>
```

## Running demo instance

### Install dependencies

```sh
npm run demo:install
```

### Run demo dev server

```sh
npm run demo:dev
```

### Run demo application

```sh
npm install # install guardian dependencies
npm run demo:install # install the demo app dependencies
npm run build # build guardian
npm preview # this command will block your terminal, please open a new tab to continue; this command will provide the built guardian files
npm run demo:dev # this command will block your terminal, please open a new tab to continue; this command will run the demo app's development server
```

### Run e2e tests

Running the cypress tests:

```sh
npm run cypress:open # this command will start the e2e test framework
# or
npx cypress run --headless -b chrome # this command will run tests in headless mode
```
11 changes: 11 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"baseUrl": "http://localhost:3000",
"video": false,
"supportFile": false,
"pluginsFile": false,
"fixturesFolder": false,
"retries": {
"runMode": 2,
"openMode": 0
}
}
53 changes: 53 additions & 0 deletions cypress/integration/utm.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const sessionId = 'aksdjakslfjsa';

before(() => {
cy.intercept('**/api/guardian/session', {
data: {
session_id: sessionId
}
});
});

describe('Check UTM param detection and values', () => {
it('Navigate to UTM page', () => {
cy.visit('/');

cy.contains('UTM').click();

cy.location('pathname', { timeout: 10000 }).should('include', '/utm');

cy.get('h1').contains('UTM params');
});
it('Waits until event details loaded', () => {
pressRefreshAndWait();
cy.get('div.event-details div', { timeout: 10000 });
});
it('Check the detected utm params', () => {
pressRefreshAndWait();
cy.get('.utm_source_detected > div > h2').contains('utm_source_detected');
cy.get('.utm_source_detected .utm_source_detected_value').contains('buffer');

pressRefreshAndWait();
cy.get('.utm_medium_detected > div > h2').contains('utm_medium_detected');
cy.get('.utm_medium_detected .utm_medium_detected_value').contains('blog');

pressRefreshAndWait();
cy.get('.utm_campaign_detected > div > h2').contains('utm_campaign_detected');
cy.get('.utm_campaign_detected .utm_campaign_detected_value').contains(
'2-social-strategies'
);

pressRefreshAndWait();
cy.get('.utm_term_detected > div > h2').contains('utm_term_detected');
cy.get('.utm_term_detected .utm_term_detected_value').contains('term1');

pressRefreshAndWait();
cy.get('.utm_content_detected > div > h2').contains('utm_content_detected');
cy.get('.utm_content_detected .utm_content_detected_value').contains('blogpost');
});
});

function pressRefreshAndWait() {
cy.get('.refresh-events', { timeout: 10000 }).click();
cy.get('div.event-details .progress-events', { timeout: 10000 }).should('not.exist');
}
15 changes: 15 additions & 0 deletions demo/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution');

module.exports = {
root: true,
extends: [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/eslint-config-typescript/recommended',
'@vue/eslint-config-prettier'
],
env: {
'vue/setup-compiler-macros': true
}
};
28 changes: 28 additions & 0 deletions demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
.DS_Store
dist
dist-ssr
coverage
*.local

/cypress/videos/
/cypress/screenshots/

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
6 changes: 6 additions & 0 deletions demo/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
singleQuote: true,
trailingComma: 'none',
printWidth: 100,
tabWidth: 4
};
3 changes: 3 additions & 0 deletions demo/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["johnsoncodehk.volar", "johnsoncodehk.vscode-typescript-vue-plugin"]
}
46 changes: 46 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# demo

This template should help get you started developing with Vue 3 in Vite.

## Recommended IDE Setup

[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.vscode-typescript-vue-plugin).

## Type Support for `.vue` Imports in TS

TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.

If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:

1. Disable the built-in TypeScript Extension
1) Run `Extensions: Show Built-in Extensions` from VSCode's command palette
2) Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.

## Customize configuration

See [Vite Configuration Reference](https://vitejs.dev/config/).

## Project Setup

```sh
npm install
```

### Compile and Hot-Reload for Development

```sh
npm run dev
```

### Type-Check, Compile and Minify for Production

```sh
npm run build
```

### Lint with [ESLint](https://eslint.org/)

```sh
npm run lint
```
1 change: 1 addition & 0 deletions demo/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
20 changes: 20 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vuetify 3 Vite Preview</title>
<script src="http://localhost:4173/guardian.umd.js"></script>
<script>
new Guardian('http://localhost:8001/', 'pub_0wUsHIlrkK1I6ADno5MfT10UjhR').process();
borosr marked this conversation as resolved.
Show resolved Hide resolved
</script>
</head>

<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>

</html>
Loading