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

783 run the cypress tests against the procaptcha bundle #785

Merged
merged 64 commits into from
Nov 21, 2023
Merged
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
42ecca4
Move cypress tests into shared package
forgetso Nov 10, 2023
71f33ee
sort out deps and references
forgetso Nov 11, 2023
973d76d
Run cypress tests over both demos
forgetso Nov 14, 2023
59a8134
package-lock.json and remove unused commands
forgetso Nov 14, 2023
2aab067
remove build command from demos and just serve them using vite instead
forgetso Nov 14, 2023
fc3902c
Import contracts
forgetso Nov 14, 2023
c938ee7
Fix vite config path
forgetso Nov 14, 2023
a1ef053
Import contracts and fix bundle command in workflow
forgetso Nov 14, 2023
924d60e
fix bundle command
forgetso Nov 14, 2023
d951165
Change cypress selector to work for both demos
forgetso Nov 14, 2023
ac7b0a3
Import contracts
forgetso Nov 14, 2023
73cef23
Try making the array into a selection
forgetso Nov 14, 2023
26eb579
make sure checkbox is checked
forgetso Nov 14, 2023
b49b9e9
Add a replacer for the demo bundle HTML files
forgetso Nov 14, 2023
cdd4237
add some debug
forgetso Nov 14, 2023
7b4c454
- Use vite for cypress tests
forgetso Nov 15, 2023
207578e
Import contracts and lint
forgetso Nov 15, 2023
b4bb8b8
fix up tests
forgetso Nov 15, 2023
8d3d162
deps
forgetso Nov 15, 2023
12da39c
reduce logging
forgetso Nov 15, 2023
6eb27f4
Fix cypress tests for react client-example
forgetso Nov 16, 2023
50183f6
Remove the need for dapp to be a contract in setup scripts
forgetso Nov 16, 2023
03bf38f
Merge branch 'main' into 783-run-the-cypress-tests-against-the-procap…
forgetso Nov 16, 2023
d74f867
Import contracts
forgetso Nov 16, 2023
1900d62
package-lock.json
forgetso Nov 16, 2023
986acd6
Fix dapp setup script
forgetso Nov 16, 2023
2669b37
Get rid of polkadotJS warnings
forgetso Nov 16, 2023
058fc3a
Try changing the order in beforeAll
forgetso Nov 16, 2023
5de035b
Try changing order in tests
forgetso Nov 16, 2023
2a47d5b
Fix client-example vite dev server
forgetso Nov 16, 2023
ff987a8
Turn watch off for cypress and client-example. Reduce log output
forgetso Nov 16, 2023
75d43c9
Import contracts
forgetso Nov 16, 2023
29d33ea
Use tsc build of server instead of bundle
forgetso Nov 16, 2023
8fc87db
remove timeout
forgetso Nov 16, 2023
4bda10d
Try to get client-example running alongside bundle
forgetso Nov 17, 2023
f2e2fc1
try production mode
forgetso Nov 17, 2023
facb899
Use concurrently to serve multiple vite instances at once
forgetso Nov 17, 2023
6735a08
Reduce logging
forgetso Nov 17, 2023
57b8399
fix some ts errors in client-example vite config
forgetso Nov 17, 2023
8dca052
linting and fix concurrently command
forgetso Nov 17, 2023
546e160
Use cypress run instead of open
forgetso Nov 17, 2023
b35b056
import contracts
forgetso Nov 17, 2023
51d58cc
remove noisy logs
forgetso Nov 17, 2023
d0792a8
trigger workflow
forgetso Nov 17, 2023
08dda76
Try adding a sleep before the tests
forgetso Nov 17, 2023
d9f4bc4
Set cypress to listen on all addresses instead of localhost
forgetso Nov 17, 2023
c0e71e9
Increase timeout
forgetso Nov 17, 2023
c7943f7
debug cypress
forgetso Nov 17, 2023
60f0c46
Check that the checkbox is visible on-page
forgetso Nov 17, 2023
6f59765
try hacky solution
forgetso Nov 18, 2023
b60e6ba
Try return
forgetso Nov 20, 2023
3180471
trim vite config
forgetso Nov 20, 2023
2eac100
simplify cypress chain
forgetso Nov 20, 2023
7b35cda
try xvfb-run
forgetso Nov 20, 2023
3a8e793
run headed
forgetso Nov 20, 2023
e0f17e2
Use the same dapp site key in all template env files
forgetso Nov 20, 2023
7f7612f
Update env.development in scripts
forgetso Nov 20, 2023
9d438e9
Use run instead of open
forgetso Nov 20, 2023
a268cb8
Use correct success flag
forgetso Nov 20, 2023
96e0dbf
Test using dev bundle of procaptcha
forgetso Nov 20, 2023
63a8900
Import contracts
forgetso Nov 20, 2023
bc0e029
Import contracts
forgetso Nov 20, 2023
9e730ec
Import contracts
forgetso Nov 20, 2023
0e807dd
lint
forgetso Nov 20, 2023
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
Prev Previous commit
Next Next commit
simplify cypress chain
forgetso committed Nov 20, 2023
commit 2eac100ebe779d6dfc5fa22c53988f35e3be639a
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -96,8 +96,8 @@ jobs:

- name: Run the cypress tests on client-example
run: |
npx concurrently "npm run start:server" "npm run start:provider" "npm run start:demo" "sleep 10s && DEBUG=cypress:* npm -w @prosopo/cypress-shared run cypress:run:client-example" --success "last" --kill-others
npx concurrently "npm run start:server" "npm run start:provider" "npm run start:demo" "sleep 10s && npm -w @prosopo/cypress-shared run cypress:run:client-example" --success "last" --kill-others

- name: Run the cypress tests on client-bundle-example
run: |
npx concurrently "npm run start:server" "npm run start:provider" "npm run start:bundle" "sleep 10s && DEBUG=cypress:* npm -w @prosopo/cypress-shared run cypress:run:client-bundle-example" --success "last" --kill-others
npx concurrently "npm run start:server" "npm run start:provider" "npm run start:bundle" "sleep 10s && npm -w @prosopo/cypress-shared run cypress:run:client-bundle-example" --success "last" --kill-others
5 changes: 2 additions & 3 deletions demos/cypress-shared/cypress.config.js
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@
import { builtinModules } from 'module'
import { defineConfig } from 'cypress'
import builtIns from 'rollup-plugin-node-builtins'
import nodeResolve from '@rollup/plugin-node-resolve'
import vitePreprocessor from 'cypress-vite'
const external = [...builtinModules, ...builtinModules.map((m) => `node:${m}`)]
export default defineConfig({
@@ -26,8 +25,8 @@ export default defineConfig({
vitePreprocessor({
watch: false,
esbuild: {
platform: 'browser'
= },
platform: 'browser',
},
resolve: {
alias: {
fs: builtIns().resolveId('fs'),
41 changes: 17 additions & 24 deletions demos/cypress-shared/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -37,30 +37,23 @@ function clickIAmHuman(): Cypress.Chainable<Captcha[]> {

return cy
.wait('@getCaptcha', { timeout: 36000 })
.then(() => {
return cy
.get('@getCaptcha')
.its('response')

.then((response) => {
expect(response).to.not.be.undefined
expect(response?.statusCode).to.equal(200)
expect(response?.body).to.have.property('captchas')
const captchas = response?.body.captchas.map(
({ captcha }: { captcha: CaptchaWithProof }) => captcha
)
console.log('-----------------------------captchas', captchas, 'length', captchas.length)
expect(captchas).to.have.lengthOf(2)
expect(captchas[0]).to.have.property('items')
console.log(
'-----------------------------captchas[0].items',
captchas[0].items,
'length',
captchas[0].items.length
)
expect(captchas[0].items).to.have.lengthOf(9)
return captchas
})
.its('response')
.then((response) => {
expect(response).to.not.be.undefined
expect(response?.statusCode).to.equal(200)
expect(response?.body).to.have.property('captchas')
const captchas = response?.body.captchas.map(({ captcha }: { captcha: CaptchaWithProof }) => captcha)
console.log('-----------------------------captchas', captchas, 'length', captchas.length)
expect(captchas).to.have.lengthOf(2)
expect(captchas[0]).to.have.property('items')
console.log(
'-----------------------------captchas[0].items',
captchas[0].items,
'length',
captchas[0].items.length
)
expect(captchas[0].items).to.have.lengthOf(9)
return captchas
})
.as('captchas')
}

Unchanged files with check annotations Beta

const contracts = readdirSync(contractsDir, { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name)
const packages = [...crates, ...contracts]

Check warning on line 166 in protocol/dev/src/cli.ts

GitHub Actions / check

'packages' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 166 in protocol/dev/src/cli.ts

GitHub Actions / check

'packages' is assigned a value but never used
const packagePaths = [
...crates.map((p) => path.join(cratesDir, p)),
...contracts.map((p) => path.join(contractsDir, p)),
]
const targetDir = path.join(repoDir, 'protocol/target')

Check warning on line 171 in protocol/dev/src/cli.ts

GitHub Actions / check

'targetDir' is assigned a value but never used. Allowed unused vars must match /^_/u

Check warning on line 171 in protocol/dev/src/cli.ts

GitHub Actions / check

'targetDir' is assigned a value but never used
const cargoCacheDir = path.join(repoDir, 'protocol/cargo-cache')
// console.log(`repoDir: ${repoDir}`)
const gasLimit = (await _genValidGasLimitAndValue(this.nativeAPI, __options)).gasLimit as WeightV2
const storageDepositLimit = __options?.storageDepositLimit
const tx = code.tx['new']!({ gasLimit, storageDepositLimit, value: __options?.value })

Check warning on line 28 in contracts/captcha/src/constructors/captcha.ts

GitHub Actions / check

Forbidden non-null assertion
let response
try {
response = await _signAndSend(this.nativeAPI.registry, tx, this.signer, (event: any) => event)

Check warning on line 32 in contracts/captcha/src/constructors/captcha.ts

GitHub Actions / check

Unexpected any. Specify a different type
} catch (error) {
console.log(error)
}
result: response as SignAndSendSuccessResponse,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
address: (response as SignAndSendSuccessResponse)!.result!.contract.address.toString(),

Check warning on line 41 in contracts/captcha/src/constructors/captcha.ts

GitHub Actions / check

Forbidden non-null assertion

Check warning on line 41 in contracts/captcha/src/constructors/captcha.ts

GitHub Actions / check

Forbidden non-null assertion
}
}
/**
const gasLimit = (await _genValidGasLimitAndValue(this.nativeAPI, __options)).gasLimit as WeightV2
const storageDepositLimit = __options?.storageDepositLimit
const tx = code.tx['newPanic']!({ gasLimit, storageDepositLimit, value: __options?.value })

Check warning on line 54 in contracts/captcha/src/constructors/captcha.ts

GitHub Actions / check

Forbidden non-null assertion
let response
try {
response = await _signAndSend(this.nativeAPI.registry, tx, this.signer, (event: any) => event)

Check warning on line 58 in contracts/captcha/src/constructors/captcha.ts

GitHub Actions / check

Unexpected any. Specify a different type
} catch (error) {
console.log(error)
}