mirror of
https://github.com/cupcakearmy/cryptgeon.git
synced 2024-12-22 08:16:28 +00:00
commit
98a03c25e6
16
.github/workflows/test.yml
vendored
Normal file
16
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
name: test
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
text:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Install
|
||||
run: |
|
||||
docker compose build
|
||||
npm ci
|
||||
npm run test:run
|
@ -50,7 +50,8 @@
|
||||
password: password,
|
||||
id: response.id,
|
||||
}
|
||||
} catch {
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
error = 'could not create note.'
|
||||
} finally {
|
||||
loading = false
|
||||
@ -69,6 +70,7 @@
|
||||
label="share link"
|
||||
value="{window.location.origin}/note/{result.id}/{result.password}"
|
||||
copy
|
||||
data-testid="note-share-link"
|
||||
/>
|
||||
<br />
|
||||
<p>
|
||||
@ -84,11 +86,16 @@
|
||||
{:else}
|
||||
<form on:submit|preventDefault={submit}>
|
||||
<fieldset disabled={loading}>
|
||||
<TextArea label="note" bind:value={note.contents} placeholder="..." />
|
||||
<TextArea
|
||||
label="note"
|
||||
bind:value={note.contents}
|
||||
placeholder="..."
|
||||
data-testid="input-note"
|
||||
/>
|
||||
|
||||
<div class="bottom">
|
||||
<Switch label="advanced" bind:value={advanced} />
|
||||
<Button type="submit">create</Button>
|
||||
<Button type="submit" data-testid="button-create">create</Button>
|
||||
</div>
|
||||
|
||||
{#if error}
|
||||
|
@ -55,10 +55,12 @@
|
||||
|
||||
{#if !loading}
|
||||
{#if !exists}
|
||||
<p class="error-text">note was not found or was already deleted.</p>
|
||||
<p class="error-text" data-testid="note-not-found">
|
||||
note was not found or was already deleted.
|
||||
</p>
|
||||
{:else if note && !error}
|
||||
<p class="error-text">you will not get the chance to see the note again.</p>
|
||||
<div class="note">
|
||||
<div class="note" data-testid="note-result">
|
||||
{note.contents}
|
||||
</div>
|
||||
<br />
|
||||
@ -67,7 +69,7 @@
|
||||
<form on:submit|preventDefault={show}>
|
||||
<fieldset>
|
||||
<p>click below to show and delete the note if the counter has reached it's limit</p>
|
||||
<Button type="submit">show note</Button>
|
||||
<Button type="submit" data-testid="button-show">show note</Button>
|
||||
{#if error}
|
||||
<br />
|
||||
<p class="error-text">
|
||||
|
5
cypress.json
Normal file
5
cypress.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"fixturesFolder": false,
|
||||
"pluginsFile": false,
|
||||
"supportFile": false
|
||||
}
|
2
cypress/.gitignore
vendored
Normal file
2
cypress/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
screenshots
|
||||
videos
|
41
cypress/integration/main.spec.js
Normal file
41
cypress/integration/main.spec.js
Normal file
@ -0,0 +1,41 @@
|
||||
function createNote(options = {}) {
|
||||
Object.assign(options, {
|
||||
text: `Revaluation battle selfish derive suicide revaluation society love superiority salvation spirit virtues revaluation. Aversion sexuality play burying mountains intentions battle reason strong burying war insofar inexpedient war. Fearful intentions selfish madness suicide.`,
|
||||
})
|
||||
cy.visit('http://localhost:5000')
|
||||
const text = options.text
|
||||
cy.get('[data-testid=input-note]').type(text)
|
||||
cy.get('[data-testid=button-create]').click()
|
||||
cy.wait(500)
|
||||
return cy
|
||||
.get('[data-testid=note-share-link]')
|
||||
.invoke('val')
|
||||
.then((link) => {
|
||||
return [link, text]
|
||||
})
|
||||
}
|
||||
|
||||
describe('Basics', () => {
|
||||
it('Share note', () => {
|
||||
createNote().then(([link, text]) => {
|
||||
cy.visit(link)
|
||||
cy.get('[data-testid=button-show]').click()
|
||||
cy.wait(250)
|
||||
cy.get('[data-testid=note-result]').should('have.text', text)
|
||||
})
|
||||
})
|
||||
|
||||
it('Check destroyed', () => {
|
||||
createNote().then(([link, text]) => {
|
||||
// Check the first time
|
||||
cy.visit(link)
|
||||
cy.get('[data-testid=button-show]').click()
|
||||
cy.wait(250)
|
||||
cy.get('[data-testid=note-result]').should('have.text', text)
|
||||
|
||||
// Should not exists anymore
|
||||
cy.visit(link)
|
||||
cy.get('[data-testid=note-not-found]').should('exist')
|
||||
})
|
||||
})
|
||||
})
|
@ -15,4 +15,4 @@ services:
|
||||
depends_on:
|
||||
- memcached
|
||||
ports:
|
||||
- 80:5000
|
||||
- 5000:5000
|
||||
|
4572
package-lock.json
generated
4572
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -3,9 +3,14 @@
|
||||
"dev:docker": "docker-compose up memcached",
|
||||
"dev:backend": "cargo watch -x 'run --bin cryptgeon'",
|
||||
"dev:front": "npm --prefix client run dev",
|
||||
"dev": "run-p dev:*"
|
||||
"dev": "run-p dev:*",
|
||||
"test:server": "docker compose up --build",
|
||||
"test:cypress": "cypress run --headless",
|
||||
"test:run": "start-server-and-test test:server http://localhost:5000 test:cypress"
|
||||
},
|
||||
"devDependencies": {
|
||||
"npm-run-all": "^4.1.5"
|
||||
"cypress": "^7.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"start-server-and-test": "^1.12.1"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user