correction test

feature/ga
Eric 4 years ago
parent fa394760ac
commit e73c965078

@ -18,7 +18,7 @@ EMAIL_SERVER_HOST=mail50.lwspanel.com
EMAIL_SERVER_PORT=587
EMAIL_FROM=contact@dsp-archiwebo21-ad-ec-cb-mt.fr
# DATABASE_URL="postgres://postgres:postgrespwd@127.0.0.1:5454/thetiptop"
DATABASE_URL="postgres://postgres:postgrespwd@127.0.0.1:5454/thetiptop"
API_KEY=1234

@ -8,6 +8,7 @@ const customJestConfig = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
moduleDirectories: ['node_modules', '<rootDir>/'],
testEnvironment: 'jest-environment-jsdom',
testRegex: '(/__tests__/.*|(\\.|/)(test))\\.[jt]sx?$'
}
module.exports = createJestConfig(customJestConfig)

3143
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,5 +1,5 @@
{
"name": "hello-next",
"name": "thetiptop",
"version": "1.0.0",
"description": "",
"keywords": [],
@ -10,9 +10,7 @@
"build": "next build",
"start": "next start",
"db": "npx prisma migrate reset --force",
"test": "jest --ci && playwright test",
"test-e2e" : "playwright test",
"test-dev" : "jest --watch"
"test": "playwright test"
},
"dependencies": {
"@hookform/resolvers": "^2.9.10",
@ -44,6 +42,7 @@
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^14.4.3",
"@tomfreudenberg/next-auth-mock": "^0.5.5",
"@types/chance": "^1.1.3",
"@types/jest": "^29.2.4",
"@types/next-auth": "3.13.0",

@ -41,7 +41,7 @@ type Props = {
csrfToken: Token
}
const MainPage = ({ csrfToken }: Props) => {
const Connexion = ({ csrfToken }: Props) => {
const { data: session } = useSession();
const validationSchema = Yup.object().shape({
@ -182,6 +182,6 @@ const MainPage = ({ csrfToken }: Props) => {
</>)
};
export default MainPage;
export default Connexion;

@ -51,7 +51,7 @@ type ResponseData = {
const MainPage = () => {
const Index = () => {
const { data: session } = useSession();
const [response, setResponse] = useState<ResponseData | null>(null)
@ -193,6 +193,7 @@ const MainPage = () => {
<div className="form-group mx-auto my-3 w-100">
<input type="text"
id="codeInput" aria-describedby="codeHelp"
data-testid="codeInput"
placeholder="A293049430..."
minLength={10}
maxLength={10}
@ -204,23 +205,18 @@ const MainPage = () => {
<div className="invalid-feedback alert alert-danger">{errors.codeCadeau?.message}</div>
</div>
<div className="form-group mx-auto my-3 w-100">
<button type="submit" className={`${style['aButton']} btn btn-primary`}>Découvrir mon cadeau !</button>
<button type="submit" data-testid="submit" className={`${style['aButton']} btn btn-primary`}>Découvrir mon cadeau !</button>
</div>
</form>
</div>
</div>}
{winAnimation && <div className="col-12 align-items-center d-flex flex-column">
<div className={`${style['cadeau-bloc-content']} col-12 col-md-6`} onClick={() => setWinAnimation(false)}
>
<div className={`${style['cadeau-bloc']}`}>
<h1>Vous avez gagnez : un {response.winProduct.nomProduit.toLowerCase()} !</h1>
</div>
</div>
<div className={`${style['imageWrapper']}`}>
<Image
src={arrowUp}
@ -231,22 +227,11 @@ const MainPage = () => {
className={`${style['rotatingImage']}`}
/>
</div>
<div className="row">
<button onClick={getCadeau} className={`${style['aButton']} btn btn-primary`}>Voir mes cadeaux !</button>
<button onClick={() => setWinAnimation(false)} className={`${style['aButton']} btn btn-primary mt-2`}>Rejouer un ticket !</button>
</div>
</div>}
</div>
<div className={`${style['footerGrass']} position-absolute`}>
<Image
@ -261,4 +246,4 @@ const MainPage = () => {
);
};
export default MainPage;
export default Index;

@ -252,7 +252,7 @@ const MonCompte = (props: Props) => {
<th scope="row">{++index}</th>
<td>{info.codeCadeau}</td>
<td>{info.produit.nomProduit}</td>
<td>{info.produit.retrait ? '❌ déja récupéré' : '✔️ venir me chercher !'}</td>
<td>{!info.produit.retrait ? '❌ déja récupéré' : '✔️ venir me chercher !'}</td>
</tr>
})}
</tbody>

@ -0,0 +1,77 @@
import { PlaywrightTestConfig, devices } from '@playwright/test'
import path from 'path'
// Use process.env.PORT by default and fallback to port 3000
const PORT = process.env.PORT || 3000
// Set webServer.url and use.baseURL with the location of the WebServer respecting the correct set port
const baseURL = `http://localhost:${PORT}`
// Reference: https://playwright.dev/docs/test-configuration
const config: PlaywrightTestConfig = {
// Timeout per test
timeout: 30 * 1000,
// Test directory
testDir: path.join(__dirname, 'e2e'),
// If a test fails, retry it additional 2 times
retries: 2,
// Artifacts folder where screenshots, videos, and traces are stored.
outputDir: 'test-results/',
// Run your local dev server before starting the tests:
// https://playwright.dev/docs/test-advanced#launching-a-development-web-server-during-the-tests
webServer: {
command: 'npm run dev',
url: baseURL,
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
},
use: {
// Use baseURL so to make navigations relative.
// More information: https://playwright.dev/docs/api/class-testoptions#test-options-base-url
baseURL,
// Retry a test if its failing with enabled tracing. This allows you to analyse the DOM, console logs, network traffic etc.
// More information: https://playwright.dev/docs/trace-viewer
trace: 'retry-with-trace',
// All available context options: https://playwright.dev/docs/api/class-browser#browser-new-context
// contextOptions: {
// ignoreHTTPSErrors: true,
// },
},
projects: [
{
name: 'Desktop Chrome',
use: {
...devices['Desktop Chrome'],
},
},
// {
// name: 'Desktop Firefox',
// use: {
// ...devices['Desktop Firefox'],
// },
// },
// {
// name: 'Desktop Safari',
// use: {
// ...devices['Desktop Safari'],
// },
// },
// Test against mobile viewports.
// {
// name: 'Mobile Chrome',
// use: {
// ...devices['Pixel 5'],
// },
// },
// {
// name: 'Mobile Safari',
// use: devices['iPhone 12'],
// },
],
}
export default config

@ -1,18 +0,0 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
describe('Index', () => {
it('should show win content if the ticket code is valid', () => {
const button = screen.getByRole('button', {
name: /Découvrir mon cadeau \.js!/i,
})
expect(button).toBeInTheDocument()
})
it('should test code', () => {
})
})
Loading…
Cancel
Save