-
-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implemented playwright test e2e
- Loading branch information
Showing
12 changed files
with
1,779 additions
and
1,090 deletions.
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
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 |
---|---|---|
|
@@ -154,8 +154,6 @@ export default function RolesCreate() { | |
return | ||
} | ||
|
||
const userId = await login(email) | ||
|
||
try { | ||
const roleData: RolesInsert = { | ||
language: formData.language === 'Português' ? 'Portuguese' : 'English', | ||
|
@@ -178,6 +176,7 @@ export default function RolesCreate() { | |
|
||
const newRole = await createRole(roleData, '[email protected]') | ||
await createRoleOwner(newRole.id, userID) | ||
console.log('should redirect') | ||
router.push(`/vaga/${newRole.id}`) | ||
|
||
form.reset({ | ||
|
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
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,96 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test.describe('Fluxo de Criação de Vaga e Visualização no Dashboard', () => { | ||
test('deve criar uma vaga e visualizá-la no dashboard', async ({ | ||
page, | ||
context, | ||
}) => { | ||
test.setTimeout(60000) | ||
// 1. Navegar para a página inicial e simular login | ||
await page.goto('/') | ||
await page.evaluate(() => { | ||
localStorage.setItem('loginEmail', '[email protected]') | ||
}) | ||
|
||
// 2. Navegar para a página de criação de vaga | ||
await page.goto('/vagas/publique') | ||
|
||
// 3. Preencher o formulário de vaga sem selecionar skills | ||
await page.fill('input[name="title"]', 'Desenvolvedor React') | ||
await page.fill('input[name="company"]', 'Empresa Teste') | ||
await page.fill('input[name="url"]', 'https://teste.com/vaga') | ||
await page.fill('input[name="country"]', 'Brasil') | ||
await page.selectOption('select[name="language"]', 'Português') | ||
await page.selectOption('select[name="currency"]', 'BRL') | ||
await page.fill('input[name="salary"]', '5000') | ||
await page.fill('input[name="minimumYears"]', '2') | ||
await page.fill( | ||
'input[name="description"]', | ||
'<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ea voluptatem impedit illum quam, explicabo repudiandae rerum id praesentium cumque et, labore a non quis modi. Iure suscipit placeat laudantium ex?</p>' | ||
) | ||
|
||
// 4. Tentar enviar o formulário sem selecionar skills | ||
await page.click('button:has-text("Enviar")') | ||
|
||
// 5. Verificar se aparece uma mensagem de erro | ||
await expect( | ||
page.locator('text=Adicione ao menos uma habilidade.') | ||
).toBeVisible() | ||
|
||
// 6. Agora, selecionar uma skill | ||
await page.click('text=TypeScript, React, .NET') | ||
await page.waitForTimeout(2000) | ||
await page.keyboard.type('React') | ||
await page.keyboard.press('Enter') | ||
await page.click('text=Quais habilidades são necessárias para a vaga?') | ||
|
||
// 7. Enviar o formulário novamente | ||
await page.click('button:has-text("Enviar")') | ||
|
||
// 8. Verificar se foi redirecionado para a página da vaga | ||
await expect(page).toHaveURL(/\/vaga\/[a-f0-9-]+/) | ||
|
||
// 9. Verificar se a vaga foi criada corretamente | ||
await expect(page.locator('[data-testid="role-title"]')).toContainText( | ||
'Desenvolvedor React' | ||
) | ||
await expect(page.locator('[data-testid="role-company"]')).toContainText( | ||
'Empresa Teste' | ||
) | ||
await page.waitForTimeout(2000) | ||
|
||
// 10. Navegar para o dashboard | ||
await page.goto('/vagas/publique') | ||
await page.reload({ timeout: 10000, waitUntil: 'networkidle' }) | ||
await page.waitForTimeout(4000) | ||
await page.click('text=Ir para o Dashboard') | ||
|
||
// 11. Verificar se a vaga aparece no dashboard | ||
await expect(page.locator('[data-testid="dashboard-title"]')).toContainText( | ||
'Dashboard de Vagas' | ||
) | ||
await expect(page.locator('[data-testid="job-card-title"]')).toContainText( | ||
'Desenvolvedor React' | ||
) | ||
await expect( | ||
page.locator('[data-testid="job-card-company"]') | ||
).toContainText('Empresa Teste') | ||
|
||
// 12. Clicar na vaga no dashboard e verificar se leva à página da vaga em uma nova aba | ||
const [newPage] = await Promise.all([ | ||
context.waitForEvent('page'), | ||
page.click('text=Desenvolvedor React'), | ||
]) | ||
|
||
await newPage.waitForLoadState('networkidle') | ||
|
||
await expect(newPage).toHaveURL(/\/vaga\/[0-9a-fA-F-]{36}/) | ||
|
||
await expect(newPage.locator('[data-testid="role-title"]')).toContainText( | ||
'Desenvolvedor React' | ||
) | ||
await expect(newPage.locator('[data-testid="role-company"]')).toContainText( | ||
'Empresa Teste' | ||
) | ||
}) | ||
}) |
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,82 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
import { expect } from '@playwright/test' | ||
import { matchers } from 'playwright-expect' | ||
|
||
expect.extend(matchers) | ||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// import dotenv from 'dotenv'; | ||
// import path from 'path'; | ||
// dotenv.config({ path: path.resolve(__dirname, '.env') }); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: './e2e', | ||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: 1, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: 'html', | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
baseURL: 'http://localhost:3000', | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
|
||
// { | ||
// name: 'firefox', | ||
// use: { ...devices['Desktop Firefox'] }, | ||
// }, | ||
|
||
// { | ||
// name: 'webkit', | ||
// use: { ...devices['Desktop Safari'] }, | ||
// }, | ||
|
||
/* Test against mobile viewports. */ | ||
// { | ||
// name: 'Mobile Chrome', | ||
// use: { ...devices['Pixel 5'] }, | ||
// }, | ||
// { | ||
// name: 'Mobile Safari', | ||
// use: { ...devices['iPhone 12'] }, | ||
// }, | ||
|
||
/* Test against branded browsers. */ | ||
// { | ||
// name: 'Microsoft Edge', | ||
// use: { ...devices['Desktop Edge'], channel: 'msedge' }, | ||
// }, | ||
// { | ||
// name: 'Google Chrome', | ||
// use: { ...devices['Desktop Chrome'], channel: 'chrome' }, | ||
// }, | ||
], | ||
|
||
/* Run your local dev server before starting the tests */ | ||
// webServer: { | ||
// command: 'npm run start', | ||
// url: 'http://127.0.0.1:3000', | ||
// reuseExistingServer: !process.env.CI, | ||
// }, | ||
}) |
Oops, something went wrong.