Skip to content

Commit

Permalink
Add live-testing script (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Dec 30, 2023
1 parent 5ae1112 commit d0cd3de
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 3 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/live-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI
on:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm install
- run: npm install web-ext
- run: npm run upload
env:
CID: ${{ secrets.CLIENT_ID }}
CS: ${{ secrets.CLIENT_SECRET }}
RT: ${{ secrets.REFRESH_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
node_modules
npm-debug.log
web-ext-artifacts
.env
test/extension/manifest.json
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
"index.js"
],
"scripts": {
"test": "xo && vitest"
"test": "xo && vitest run",
"upload": "npm run bundle && npm run test:upload",
"prebundle": "dot-json test/extension/manifest.json version $(utc-version)",
"bundle": "web-ext build --filename live-test.zip --overwrite-dest",
"postbundle": "git restore test/extension/manifest.json",
"test:upload": "eval $(cat .env) node test/live-test.js"
},
"xo": {
"rules": {
Expand All @@ -38,15 +43,17 @@
"space": 4
},
"devDependencies": {
"dot-json": "^1.3.0",
"fetch-mock": "^9.11.0",
"node-fetch": "^2.7.0",
"utc-version": "^2.0.2",
"vitest": "^1.0.4",
"xo": "^0.56.0"
},
"engines": {
"node": ">=18"
},
"webExt": {
"sourceDir": "live-test"
"sourceDir": "test/extension"
}
}
2 changes: 1 addition & 1 deletion live-test/manifest.json → test/extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "TESTING: chrome-webstore-upload demo",
"version": "1.0.0",
"version": "1.0.7",
"manifest_version": 3,
"description": "Demo extension to test the deployer",
"action": {
Expand Down
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions test/live-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import fs from 'node:fs';
import process from 'node:process';
import chromeWebstoreUpload from '../index.js';

const myZipFile = fs.createReadStream('./web-ext-artifacts/live-test.zip');

const store = chromeWebstoreUpload({
extensionId: 'nphhdjlnhlicpjcpanamejkfehegdclg',
clientId: process.env.CID,
clientSecret: process.env.CS,
refreshToken: process.env.RT,
});

const token = await store.fetchToken();
console.log({ token });
const upload = await store.uploadExisting(myZipFile, token);
console.log({ upload });
const publish = await store.publish('trustedTesters', token);
console.log({ publish });

0 comments on commit d0cd3de

Please sign in to comment.