-
-
Notifications
You must be signed in to change notification settings - Fork 93
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
Add several tests to templates #109
Merged
Merged
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
f496cb6
Simplify create command via CLI
cezaraugusto 5ba9274
Add tests for the CLI
cezaraugusto 73da596
Add tests for the "init" template
cezaraugusto a3d59f0
Add tests/update ChatGPT template
cezaraugusto bb9b325
Split tests into CLI + Create
cezaraugusto 99edae8
Add fixtures for the upcoming build test
cezaraugusto 52c2363
Add build tests
cezaraugusto c03b8b3
Add build tests
cezaraugusto a2c3870
cli/create/build tests ok
cezaraugusto 030c9b6
Normalize fixture files
cezaraugusto 0f63265
Fix create deleting the folder before build runs
cezaraugusto 4902e8b
cli/create/build command tests ok
cezaraugusto edf96cd
Re-use test helper methods
cezaraugusto ed25ae9
Update all templates to use similar structure
cezaraugusto 0e59d3a
Add tests for the "create" command against templates
cezaraugusto 6754582
Add fixtures for all templates
cezaraugusto 2366199
Fix failing build test for chatgpt
cezaraugusto 19e0a34
Prevent naming conflict spot by Jest
cezaraugusto aa640a6
Add cli tests to ci
cezaraugusto a84cf9f
Add a way for turbo to pipe CI tests
cezaraugusto 052147d
Add new test scripts to package.json
cezaraugusto 2334ca7
Update CI scripts
cezaraugusto 3bc347c
Update Preact template
cezaraugusto acad020
Lint files
cezaraugusto 0c2c9ba
Update lock file
cezaraugusto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: extension:build | ||
on: push | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install modules | ||
run: yarn | ||
- name: Run compiler | ||
run: yarn compile | ||
- name: Run `extenion build` command | ||
run: yarn test:build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: extension:cli | ||
on: push | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install modules | ||
run: yarn | ||
- name: Run compiler | ||
run: yarn compile | ||
- name: Run `extenion` cli without arguments | ||
run: yarn test:cli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: extension:create | ||
on: push | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install modules | ||
run: yarn | ||
- name: Run compiler | ||
run: yarn compile | ||
- name: Run extenion create command | ||
run: yarn test:create |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code refactoring is very good. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
testMatch: ['**/*.spec.ts'] | ||
testEnvironment: 'node' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
// ██████╗██╗ ██╗ | ||
// ██╔════╝██║ ██║ | ||
// ██║ ██║ ██║ | ||
// ██║ ██║ ██║ | ||
// ╚██████╗███████╗██║ | ||
// ╚═════╝╚══════╝╚═╝ | ||
|
||
import path from 'path' | ||
import {ALL_TEMPLATES, DEFAULT_TEMPLATE, BROWSERS} from './fixtures/constants' | ||
import { | ||
extensionProgram, | ||
distFileExists, | ||
removeAllTemplateFolders | ||
} from './fixtures/helpers' | ||
|
||
describe('extension build', () => { | ||
beforeEach(async () => { | ||
await removeAllTemplateFolders() | ||
}) | ||
|
||
describe('running built-in templates', () => { | ||
it.each(ALL_TEMPLATES)( | ||
`builds an extension created via "$name" template`, | ||
async (template) => { | ||
const extensionPath = path.join(__dirname, 'fixtures', template.name) | ||
await extensionProgram(`build ${extensionPath}`) | ||
|
||
// Expect manifest file to exist | ||
expect( | ||
distFileExists(template.name, BROWSERS[0], 'manifest.json') | ||
).toBeTruthy() | ||
|
||
// TODO: cezaraugusto test ui context files output | ||
|
||
if (template.name !== 'init') { | ||
expect( | ||
distFileExists(template.name, BROWSERS[0], 'icons/icon_16.png') | ||
).toBeTruthy() | ||
expect( | ||
distFileExists(template.name, BROWSERS[0], 'icons/icon_48.png') | ||
).toBeTruthy() | ||
} | ||
}, | ||
80000 | ||
) | ||
}) | ||
|
||
describe('using the --browser flag', () => { | ||
it.each(ALL_TEMPLATES)( | ||
`builds the "$name" extension template across all browsers`, | ||
async (template) => { | ||
const extensionPath = path.join(__dirname, 'fixtures', template.name) | ||
// Firefox is skippeed because it can't handle service workers. | ||
const [chrome, edge /*, firefox */] = BROWSERS | ||
|
||
await extensionProgram(`build ${extensionPath} --browser=chrome,edge`) | ||
|
||
expect(distFileExists(template.name, chrome)).toBeTruthy() | ||
expect(distFileExists(template.name, edge)).toBeTruthy() | ||
}, | ||
50000 | ||
) | ||
}) | ||
|
||
describe.skip('using the --polyfill flag', () => { | ||
it.skip.each(ALL_TEMPLATES)( | ||
`builds an extension created via "$name" template with the polyfill code`, | ||
async (template) => { | ||
const extensionPath = path.join(__dirname, 'fixtures', template.name) | ||
|
||
await extensionProgram(`build ${extensionPath} --polyfill`) | ||
|
||
// TODO cezaraugusto test this | ||
}, | ||
50000 | ||
) | ||
}) | ||
|
||
describe('using the --zip flag', () => { | ||
it.each([DEFAULT_TEMPLATE])( | ||
`builds and zips the distribution files of an extension created via "$name" template`, | ||
async (template) => { | ||
const extensionPath = path.join(__dirname, 'fixtures', template.name) | ||
|
||
await extensionProgram(`build ${extensionPath} --zip`) | ||
|
||
expect(distFileExists(template.name, 'chrome')).toBeTruthy() | ||
}, | ||
50000 | ||
) | ||
|
||
it.each([DEFAULT_TEMPLATE])( | ||
`builds and zips the source files of an extension created via "$name" template`, | ||
async (template) => { | ||
const extensionPath = path.join(__dirname, 'fixtures', template.name) | ||
|
||
await extensionProgram(`build ${extensionPath} --zip-source`) | ||
|
||
expect( | ||
distFileExists( | ||
template.name, | ||
BROWSERS[0], | ||
`${template.name}-1.0-source.zip` | ||
) | ||
).toBeTruthy() | ||
}, | ||
50000 | ||
) | ||
|
||
it.each([DEFAULT_TEMPLATE])( | ||
`builds and zips the source files of an extension created via "$name" template with a custom output name using the --zip-filename flag`, | ||
async (template) => { | ||
const extensionPath = path.join(__dirname, 'fixtures', template.name) | ||
|
||
await extensionProgram( | ||
`build ${extensionPath} --zip --zip-filename ${template.name}-nice` | ||
) | ||
|
||
expect( | ||
distFileExists(template.name, BROWSERS[0], `${template.name}-nice.zip`) | ||
).toBeTruthy() | ||
}, | ||
50000 | ||
) | ||
}) | ||
}) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The statement that imports
semver
can be deleted.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, deleted