You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flagon.apache.org by jk...@apache.org on 2024/06/13 16:30:51 UTC
(flagon-useralejs) branch 419-ext-test created (now 4efe17a)
This is an automated email from the ASF dual-hosted git repository.
jky pushed a change to branch 419-ext-test
in repository https://gitbox.apache.org/repos/asf/flagon-useralejs.git
at 4efe17a Migrate to Playwright
This branch includes the following new commits:
new 4efe17a Migrate to Playwright
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(flagon-useralejs) 01/01: Migrate to Playwright
Posted by jk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jky pushed a commit to branch 419-ext-test
in repository https://gitbox.apache.org/repos/asf/flagon-useralejs.git
commit 4efe17a9c1a9efd87689eb716a488d67efb79932
Author: Jason Young <ja...@protonmail.com>
AuthorDate: Thu Jun 13 09:30:31 2024 -0700
Migrate to Playwright
---
.gitignore | 4 ++
build/UserALEWebExtension/background.d.ts | 19 ------
build/UserALEWebExtension/background.js | 19 ------
build/UserALEWebExtension/content.d.ts | 19 ------
build/UserALEWebExtension/globals.d.ts | 19 ------
build/UserALEWebExtension/messageTypes.d.ts | 19 ------
build/UserALEWebExtension/options.d.ts | 19 ------
build/attachHandlers.d.ts | 19 ------
build/configure.d.ts | 19 ------
build/getInitialSettings.d.ts | 19 ------
build/main.d.ts | 19 ------
build/packageLogs.d.ts | 19 ------
build/sendLogs.d.ts | 19 ------
build/utils/auth/index.d.ts | 19 ------
build/utils/headers/index.d.ts | 19 ------
build/utils/index.d.ts | 19 ------
cypress.config.ts | 25 --------
Dockerfile => example/Dockerfile | 0
example/index.js | 10 ++++
example/server.js | 7 +++
jest.config.ts | 7 +--
journey/tsconfig.json | 8 ---
journey/userale.journey.cy.ts | 89 -----------------------------
package-lock.json | 67 +++++++++++++++++++++-
package.json | 10 ++--
test/e2e/package.config.ts | 71 +++++++++++++++++++++++
test/e2e/spec/package.spec.ts | 46 +++++++++++++++
test/e2e/spec/shared.spec.ts | 86 ++++++++++++++++++++++++++++
tsconfig.json | 2 +-
29 files changed, 297 insertions(+), 420 deletions(-)
diff --git a/.gitignore b/.gitignore
index 5361215..361e434 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,3 +24,7 @@ DS_store
cypress
tsconfig.tsbuildinfo
.rollup.cache
+/test-results/
+/playwright-report/
+/blob-report/
+/playwright/.cache/
diff --git a/build/UserALEWebExtension/background.d.ts b/build/UserALEWebExtension/background.d.ts
index 70be523..cb0ff5c 100644
--- a/build/UserALEWebExtension/background.d.ts
+++ b/build/UserALEWebExtension/background.d.ts
@@ -1,20 +1 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
export {};
diff --git a/build/UserALEWebExtension/background.js b/build/UserALEWebExtension/background.js
index 03d3ad3..33ee343 100644
--- a/build/UserALEWebExtension/background.js
+++ b/build/UserALEWebExtension/background.js
@@ -1,22 +1,3 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
/******************************************************************************
Copyright (c) Microsoft Corporation.
diff --git a/build/UserALEWebExtension/content.d.ts b/build/UserALEWebExtension/content.d.ts
index 70be523..cb0ff5c 100644
--- a/build/UserALEWebExtension/content.d.ts
+++ b/build/UserALEWebExtension/content.d.ts
@@ -1,20 +1 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
export {};
diff --git a/build/UserALEWebExtension/globals.d.ts b/build/UserALEWebExtension/globals.d.ts
index c1716a1..32d9220 100644
--- a/build/UserALEWebExtension/globals.d.ts
+++ b/build/UserALEWebExtension/globals.d.ts
@@ -1,22 +1,3 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
/// <reference types="firefox-webext-browser" />
import type { Logging } from "@/types";
export declare var browser: typeof globalThis.browser;
diff --git a/build/UserALEWebExtension/messageTypes.d.ts b/build/UserALEWebExtension/messageTypes.d.ts
index 00d1826..5ae0f50 100644
--- a/build/UserALEWebExtension/messageTypes.d.ts
+++ b/build/UserALEWebExtension/messageTypes.d.ts
@@ -1,22 +1,3 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
export declare const CONFIG_CHANGE: string;
export declare const ADD_LOG: string;
export declare const HTTP_SESSION: string;
diff --git a/build/UserALEWebExtension/options.d.ts b/build/UserALEWebExtension/options.d.ts
index 70be523..cb0ff5c 100644
--- a/build/UserALEWebExtension/options.d.ts
+++ b/build/UserALEWebExtension/options.d.ts
@@ -1,20 +1 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
export {};
diff --git a/build/attachHandlers.d.ts b/build/attachHandlers.d.ts
index 1e57d68..5f2e4eb 100644
--- a/build/attachHandlers.d.ts
+++ b/build/attachHandlers.d.ts
@@ -1,22 +1,3 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
import { Events, Logging, Settings } from "@/types";
import { Configuration } from "@/configure";
/**
diff --git a/build/configure.d.ts b/build/configure.d.ts
index 8027c39..95d8550 100644
--- a/build/configure.d.ts
+++ b/build/configure.d.ts
@@ -1,22 +1,3 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
import type { Settings } from "@/types";
export declare class Configuration {
[key: string]: Settings.ConfigValueTypes;
diff --git a/build/getInitialSettings.d.ts b/build/getInitialSettings.d.ts
index ead4737..d770acd 100644
--- a/build/getInitialSettings.d.ts
+++ b/build/getInitialSettings.d.ts
@@ -1,22 +1,3 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
import type { Settings } from "./types";
/**
* Extracts the initial configuration settings from the
diff --git a/build/main.d.ts b/build/main.d.ts
index 2d09cda..38425ad 100644
--- a/build/main.d.ts
+++ b/build/main.d.ts
@@ -1,22 +1,3 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
import type { Settings, Logging } from "@/types";
export declare let started: boolean;
export { defineCustomDetails as details } from "@/attachHandlers";
diff --git a/build/packageLogs.d.ts b/build/packageLogs.d.ts
index a34e759..c22077e 100644
--- a/build/packageLogs.d.ts
+++ b/build/packageLogs.d.ts
@@ -1,22 +1,3 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
import { Callbacks, Logging } from "@/types";
import { Configuration } from "@/configure";
export declare let logs: Array<Logging.Log>;
diff --git a/build/sendLogs.d.ts b/build/sendLogs.d.ts
index 5965dd6..8f27589 100644
--- a/build/sendLogs.d.ts
+++ b/build/sendLogs.d.ts
@@ -1,22 +1,3 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
/// <reference types="node" />
import { Configuration } from "@/configure";
import { Logging } from "@/types";
diff --git a/build/utils/auth/index.d.ts b/build/utils/auth/index.d.ts
index fad65ea..17e330d 100644
--- a/build/utils/auth/index.d.ts
+++ b/build/utils/auth/index.d.ts
@@ -1,22 +1,3 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
import { Configuration } from "@/configure";
import { Callbacks } from "@/types";
export declare let authCallback: Callbacks.AuthCallback | null;
diff --git a/build/utils/headers/index.d.ts b/build/utils/headers/index.d.ts
index 6a5fc71..bcba618 100644
--- a/build/utils/headers/index.d.ts
+++ b/build/utils/headers/index.d.ts
@@ -1,22 +1,3 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
import { Configuration } from "@/configure";
import { Callbacks } from "@/types";
export declare let headersCallback: Callbacks.HeadersCallback | null;
diff --git a/build/utils/index.d.ts b/build/utils/index.d.ts
index 42b406a..0c3dea9 100644
--- a/build/utils/index.d.ts
+++ b/build/utils/index.d.ts
@@ -1,21 +1,2 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
export { authCallback, updateAuthHeader, registerAuthCallback, resetAuthCallback, verifyCallback as verifyAuthCallback, } from "./auth";
export { headersCallback, updateCustomHeaders, registerHeadersCallback, resetHeadersCallback, verifyCallback as verifyHeadersCallback, } from "./headers";
diff --git a/cypress.config.ts b/cypress.config.ts
deleted file mode 100644
index 8fcdb14..0000000
--- a/cypress.config.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-const { defineConfig } = require('cypress')
-
-module.exports = defineConfig({
- video: false,
- e2e: {
- specPattern: 'journey/**/*.cy.{js,jsx,ts,tsx}',
- supportFile: false
- },
-})
\ No newline at end of file
diff --git a/Dockerfile b/example/Dockerfile
similarity index 100%
rename from Dockerfile
rename to example/Dockerfile
diff --git a/example/index.js b/example/index.js
index bd0dfa1..0712665 100644
--- a/example/index.js
+++ b/example/index.js
@@ -19,6 +19,16 @@
* (be careful of your form data and auth workflows!)
*/
const changeMe = "me";
+
+fetch('/config')
+ .then(response => response.json())
+ .then(data => {
+ if (data.disableUserale) {
+ window.userale.stop();
+ }
+ })
+ .catch(error => console.error('Error:', error));
+
window.userale.options({
userId: changeMe,
logDetails: true,
diff --git a/example/server.js b/example/server.js
index 94accdb..c007f4f 100644
--- a/example/server.js
+++ b/example/server.js
@@ -23,6 +23,8 @@ const path = require('path');
const logDirectory = path.resolve(__dirname, '../logs');
const logPath = path.resolve(logDirectory, 'logs_' + (new Date()).getTime() + '.json');
+const disableUserale = process.argv[2] === '--disableUserale';
+
try {
fs.lstatSync(logDirectory);
} catch (e) {
@@ -64,6 +66,11 @@ app.get('/', function (req, res) {
res.sendFile('index.html', { root: __dirname });
});
+// Endpoint to send the flag status
+app.get('/config', (req, res) => {
+ res.json({ disableUserale });
+});
+
app.post('/', function (req, res) {
const body = typeof req.body === "string" ? JSON.parse(req.body) : req.body
diff --git a/jest.config.ts b/jest.config.ts
index 764a5f2..4390242 100644
--- a/jest.config.ts
+++ b/jest.config.ts
@@ -176,10 +176,9 @@ const config: Config = {
// testLocationInResults: false,
// The glob patterns Jest uses to detect test files
- // testMatch: [
- // "**/__tests__/**/*.[jt]s?(x)",
- // "**/?(*.)+(spec|test).[tj]s?(x)"
- // ],
+ testMatch: [
+ "**/test/?(*.)+(spec|test).[tj]s?(x)"
+ ],
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
diff --git a/journey/tsconfig.json b/journey/tsconfig.json
deleted file mode 100644
index 2cc298e..0000000
--- a/journey/tsconfig.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "compilerOptions": {
- "target": "es5",
- "lib": ["es5", "dom"],
- "types": ["cypress", "node"]
- },
- "include": ["../node_modules/cypress", "./**/*.ts"]
- }
\ No newline at end of file
diff --git a/journey/userale.journey.cy.ts b/journey/userale.journey.cy.ts
deleted file mode 100644
index d417abd..0000000
--- a/journey/userale.journey.cy.ts
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import { validate } from 'jsonschema';
-
-describe('Userale logging', () => {
- beforeEach(() => {
- cy.intercept('POST', 'http://localhost:8000/').as('backend')
- })
-
- it('sends a page load log', () => {
- cy.visit('http://localhost:8000')
- cy.wait('@backend').then(xhr => {
- const body = xhr.request.body
- const pageLoadLog = body[0]
- expect(pageLoadLog['details']['pageLoadTime']).to.be.greaterThan(0)
- expect(pageLoadLog).to.contain({
- logType: 'custom',
- type: 'load'
- })
- })
- });
-
- it('builds the correct path in a log', () => {
- cy.visit('http://localhost:8000')
- cy.wait('@backend')
- cy.contains(/click me/i).click()
- cy.wait('@backend').then(xhr => {
- const body = xhr.request.body
- const buttonClickLog = body.find(log => log.target === 'button#test_button')
- const actualPath = buttonClickLog.path
- const expectedPath = ["button#test_button", "div.container", "body", "html", "#document", "Window"]
- expect(actualPath).to.deep.equal(expectedPath)
- })
- });
-
- it('executes added callbacks', () => {
- cy.visit('http://localhost:8000')
- cy.wait('@backend')
- cy.contains(/click me/i).click()
- cy.wait('@backend').then(xhr => {
- const body = xhr.request.body
- const buttonClickLog = body.find(
- log => log.target === 'button#test_button'
- && log.logType === 'custom')
-
- expect(buttonClickLog).to.have.property('customLabel');
-
- const actualValue = buttonClickLog.customLabel
- const expectedValue = 'map & packageLog Example'
- expect(actualValue).to.equal(expectedValue)
- })
- });
-
- it('produces valid logs', () => {
- cy.visit('http://localhost:8000');
- cy.wait('@backend').then(xhr => {
- var schema = require('../example/log.schema.json');
- for(const log of xhr.request.body) {
- const result = validate(log, schema);
- // result.errors
- expect(result.valid).to.equal(true);
- }
- })
- cy.contains(/click me/i).click();
- cy.wait('@backend').then(xhr => {
- var schema = require('../example/log.schema.json');
- for(const log of xhr.request.body) {
- const result = validate(log, schema);
- // result.errors
- expect(result.valid).to.equal(true);
- }
- })
- });
-
-});
diff --git a/package-lock.json b/package-lock.json
index 77ae80b..b79625f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -17,6 +17,7 @@
"@babel/preset-typescript": "^7.24.1",
"@babel/register": "^7.22.15",
"@eslint/js": "^9.2.0",
+ "@playwright/test": "^1.44.1",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.0.1",
@@ -28,6 +29,7 @@
"@types/firefox-webext-browser": "^120.0.3",
"@types/jest": "^29.5.12",
"@types/jsdom": "^21.1.6",
+ "@types/node": "^20.14.2",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"@typescript/lib-dom": "npm:@types/web@^0.0.144",
@@ -3365,6 +3367,21 @@
"node": ">= 8"
}
},
+ "node_modules/@playwright/test": {
+ "version": "1.44.1",
+ "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.44.1.tgz",
+ "integrity": "sha512-1hZ4TNvD5z9VuhNJ/walIjvMVvYkZKf71axoF/uiAqpntQJXpG64dlXhoDXE3OczPuTuvjf/M5KWFg5VAVUS3Q==",
+ "dev": true,
+ "dependencies": {
+ "playwright": "1.44.1"
+ },
+ "bin": {
+ "playwright": "cli.js"
+ },
+ "engines": {
+ "node": ">=16"
+ }
+ },
"node_modules/@rollup/plugin-babel": {
"version": "6.0.4",
"resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-6.0.4.tgz",
@@ -4013,9 +4030,9 @@
"dev": true
},
"node_modules/@types/node": {
- "version": "20.12.12",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz",
- "integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==",
+ "version": "20.14.2",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.2.tgz",
+ "integrity": "sha512-xyu6WAMVwv6AKFLB+e/7ySZVr/0zLCzOa7rSpq6jNwpqOrUbcACDWC+53d4n2QHOnDou0fbIsg8wZu/sxrnI4Q==",
"dev": true,
"dependencies": {
"undici-types": "~5.26.4"
@@ -11338,6 +11355,50 @@
"node": ">=4"
}
},
+ "node_modules/playwright": {
+ "version": "1.44.1",
+ "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.44.1.tgz",
+ "integrity": "sha512-qr/0UJ5CFAtloI3avF95Y0L1xQo6r3LQArLIg/z/PoGJ6xa+EwzrwO5lpNr/09STxdHuUoP2mvuELJS+hLdtgg==",
+ "dev": true,
+ "dependencies": {
+ "playwright-core": "1.44.1"
+ },
+ "bin": {
+ "playwright": "cli.js"
+ },
+ "engines": {
+ "node": ">=16"
+ },
+ "optionalDependencies": {
+ "fsevents": "2.3.2"
+ }
+ },
+ "node_modules/playwright-core": {
+ "version": "1.44.1",
+ "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.44.1.tgz",
+ "integrity": "sha512-wh0JWtYTrhv1+OSsLPgFzGzt67Y7BE/ZS3jEqgGBlp2ppp1ZDj8c+9IARNW4dwf1poq5MgHreEM2KV/GuR4cFA==",
+ "dev": true,
+ "bin": {
+ "playwright-core": "cli.js"
+ },
+ "engines": {
+ "node": ">=16"
+ }
+ },
+ "node_modules/playwright/node_modules/fsevents": {
+ "version": "2.3.2",
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
+ "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
+ "dev": true,
+ "hasInstallScript": true,
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
+ }
+ },
"node_modules/prelude-ls": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
diff --git a/package.json b/package.json
index 44edca3..580f692 100644
--- a/package.json
+++ b/package.json
@@ -11,13 +11,11 @@
"license:check": "license-eye -c .licenserc.yaml header check",
"license:fix": "license-eye -c .licenserc.yaml header fix",
"build": "tsc && npm run clean && rollup -c --bundleConfigAsCjs rollup.config.js",
- "postbuild": "npm run license:fix",
"clean": "rm -rf ./build",
- "test": "npm run test:unit && npm run journey:ci",
+ "test": "npm run test:unit && npm run test:e2e:all",
"test:unit": "jest",
- "journey": "cypress run",
- "journey:debug": "cypress open",
- "journey:ci": "start-server-and-test example:run 8000 journey",
+ "test:e2e:package": "playwright test -c ./test/e2e/package.config.ts",
+ "test:e2e:all": "npm run test:e2e:package",
"example:run": "node example/server.js",
"example:watch": "nodemon -w ./example example/server.js",
"prepare": "husky",
@@ -64,6 +62,7 @@
"@babel/preset-typescript": "^7.24.1",
"@babel/register": "^7.22.15",
"@eslint/js": "^9.2.0",
+ "@playwright/test": "^1.44.1",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.0.1",
@@ -75,6 +74,7 @@
"@types/firefox-webext-browser": "^120.0.3",
"@types/jest": "^29.5.12",
"@types/jsdom": "^21.1.6",
+ "@types/node": "^20.14.2",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"@typescript/lib-dom": "npm:@types/web@^0.0.144",
diff --git a/test/e2e/package.config.ts b/test/e2e/package.config.ts
new file mode 100644
index 0000000..1a43034
--- /dev/null
+++ b/test/e2e/package.config.ts
@@ -0,0 +1,71 @@
+import { defineConfig, devices } from "@playwright/test";
+
+/**
+ * See https://playwright.dev/docs/test-configuration.
+ */
+export default defineConfig({
+ testDir: "..",
+ /* Run tests in files in parallel */
+ fullyParallel: true,
+ /* Fail the build on CI if you accidentally left test.only in the source code. */
+ forbidOnly: !!process.env.CI,
+ /* Retry on CI only */
+ retries: process.env.CI ? 2 : 0,
+ /* Opt out of parallel tests on CI. */
+ workers: process.env.CI ? 1 : undefined,
+ /* Reporter to use. See https://playwright.dev/docs/test-reporters */
+ reporter: "html",
+ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
+ use: {
+ /* Base URL to use in actions like `await page.goto('/')`. */
+ baseURL: "http://127.0.0.1:8000",
+
+ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
+ trace: "on-first-retry",
+ },
+
+ /* Configure projects for major browsers */
+ projects: [
+ {
+ name: "chromium",
+ use: { ...devices["Desktop Chrome"] },
+ },
+
+ {
+ name: "firefox",
+ use: { ...devices["Desktop Firefox"] },
+ },
+
+ {
+ name: "webkit",
+ use: { ...devices["Desktop Safari"] },
+ },
+
+ /* Test against mobile viewports. */
+ // {
+ // name: 'Mobile Chrome',
+ // use: { ...devices['Pixel 5'] },
+ // },
+ // {
+ // name: 'Mobile Safari',
+ // use: { ...devices['iPhone 12'] },
+ // },
+
+ /* Test against branded browsers. */
+ // {
+ // name: 'Microsoft Edge',
+ // use: { ...devices['Desktop Edge'], channel: 'msedge' },
+ // },
+ // {
+ // name: 'Google Chrome',
+ // use: { ...devices['Desktop Chrome'], channel: 'chrome' },
+ // },
+ ],
+
+ /* Run your local dev server before starting the tests */
+ webServer: {
+ command: "npm run example:run",
+ url: "http://127.0.0.1:8000",
+ reuseExistingServer: !process.env.CI,
+ },
+});
diff --git a/test/e2e/spec/package.spec.ts b/test/e2e/spec/package.spec.ts
new file mode 100644
index 0000000..64a2023
--- /dev/null
+++ b/test/e2e/spec/package.spec.ts
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { test, expect } from "@playwright/test";
+
+test.beforeEach(async ({ page }) => {
+ const requestPromise = page.waitForRequest(
+ (request) => request.method() === "POST",
+ );
+ await page.goto("/");
+ await requestPromise;
+});
+
+test.describe("Userale custom logging", () => {
+ test("executes added callbacks", async ({ page }) => {
+ const requestPromise = page.waitForRequest(
+ (request) => request.method() === "POST",
+ );
+ await page.getByText("Click Me!", { exact: true }).click();
+ const request = await requestPromise;
+ const body = await request.postDataJSON();
+
+ const buttonClickLog = body.find(
+ (log: { target: string; logType: string }) =>
+ log.target === "button#test_button" && log.logType === "custom",
+ );
+ expect(buttonClickLog).toHaveProperty("customLabel");
+
+ const actualValue = buttonClickLog.customLabel;
+ const expectedValue = "map & packageLog Example";
+ expect(actualValue).toBe(expectedValue);
+ });
+});
diff --git a/test/e2e/spec/shared.spec.ts b/test/e2e/spec/shared.spec.ts
new file mode 100644
index 0000000..187347a
--- /dev/null
+++ b/test/e2e/spec/shared.spec.ts
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { validate } from "jsonschema";
+import { test, expect } from "@playwright/test";
+
+test.beforeEach(async ({ page }) => {
+ const requestPromise = page.waitForRequest(
+ (request) => request.method() === "POST",
+ );
+ await page.goto("/");
+ await requestPromise;
+});
+
+test.describe("Userale logging", () => {
+ test("sends a page load log", async ({ page }) => {
+ const requestPromise = page.waitForRequest(
+ (request) => request.method() === "POST",
+ );
+ await page.goto("/");
+ const request = await requestPromise;
+
+ const body = await request.postDataJSON();
+
+ const pageLoadLog = body[0];
+ expect(pageLoadLog["details"]["pageLoadTime"]).toBeGreaterThan(0);
+ expect(pageLoadLog).toEqual(
+ expect.objectContaining({
+ logType: "custom",
+ type: "load",
+ }),
+ );
+ });
+
+ test("builds the correct path in a log", async ({ page }) => {
+ const requestPromise = page.waitForRequest(
+ (request) => request.method() === "POST",
+ );
+ await page.getByText("Click Me!", { exact: true }).click();
+ const request = await requestPromise;
+ const body = await request.postDataJSON();
+
+ const buttonClickLog = body.find(
+ (log: { target: string }) => log.target === "button#test_button",
+ );
+ const actualPath = buttonClickLog.path;
+ const expectedPath = [
+ "button#test_button",
+ "div.container",
+ "body",
+ "html",
+ "#document",
+ "Window",
+ ];
+ expect(actualPath).toEqual(expectedPath);
+ });
+
+ test("produces valid logs", async ({ page }) => {
+ const requestPromise = page.waitForRequest(
+ (request) => request.method() === "POST",
+ );
+ await page.goto("/");
+ await page.getByText("Click Me!", { exact: true }).click();
+ const request = await requestPromise;
+ const body = await request.postDataJSON();
+
+ var schema = require("../../example/log.schema.json");
+ for (const log of body) {
+ const result = validate(log, schema);
+ expect(result.valid).toBe(true);
+ }
+ });
+});
diff --git a/tsconfig.json b/tsconfig.json
index 86f228b..853b8a4 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -33,5 +33,5 @@
"typeRoots": ["node_modules/@types/"],
},
"include": ["src", "test", "src/types.d.ts"],
- "exclude": ["cypress.config.ts", "node_modules", "build", "logs", "journey", "example"],
+ "exclude": ["node_modules", "build", "logs", "example"],
}