-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
240 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM node:20 | ||
FROM node:20-bookworm | ||
|
||
WORKDIR /app | ||
|
||
|
@@ -8,6 +8,8 @@ RUN npm install | |
|
||
COPY . . | ||
|
||
RUN npx -y [email protected] install --with-deps | ||
|
||
RUN npm run build | ||
|
||
CMD ["npm", "run", "dev"] |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,24 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
|
||
export default defineConfig({ | ||
testDir: './test', | ||
testMatch: /.*\.e2e-spec\.ts$/, | ||
fullyParallel: true, | ||
forbidOnly: !!process.env.CI, | ||
retries: process.env.CI ? 2 : 0, | ||
workers: process.env.CI ? 1 : undefined, | ||
use: { | ||
baseURL: 'http://localhost:3000', | ||
}, | ||
webServer: { | ||
command: 'npm run dev', | ||
url: 'http://localhost:3000', | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
], | ||
}) |
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,48 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('Access the custom news feed page', async ({ page }) => { | ||
await page.goto('/custom-news-feed', { waitUntil: 'networkidle' }) | ||
const header = page.getByRole('img', { name: 'News Aggregator' }) | ||
expect(header).toBeVisible() | ||
}) | ||
|
||
test('Access preferences tab', async ({ page }) => { | ||
await page.goto('/custom-news-feed', { waitUntil: 'networkidle' }) | ||
const prefTabBtn = page.getByRole('button', { name: 'Preferences' }) | ||
await prefTabBtn.click() | ||
|
||
expect( | ||
page.getByRole('heading', { name: 'Edit your article preferences' }), | ||
).toBeVisible() | ||
}) | ||
|
||
test('Add author preference', async ({ page }) => { | ||
await page.goto('/custom-news-feed', { waitUntil: 'networkidle' }) | ||
const prefTabBtn = page.getByRole('button', { name: 'Preferences' }) | ||
await prefTabBtn.click() | ||
const authorInput = page.getByPlaceholder('Add your authors') | ||
const addAuthorBtn = page.getByTestId('add-author') | ||
await authorInput.fill('Test') | ||
await addAuthorBtn.click() | ||
|
||
const badger = page.getByTestId('author-badger') | ||
badger.isVisible() | ||
expect(await badger.isVisible()).toBe(true) | ||
}) | ||
|
||
test('Change category and source preference', async ({ page }) => { | ||
await page.goto('/custom-news-feed', { waitUntil: 'networkidle' }) | ||
const prefTabBtn = page.getByRole('button', { name: 'Preferences' }) | ||
await prefTabBtn.click() | ||
|
||
const categoryChk = page.getByText('World') | ||
const sourceChk = page.getByText('The Guardian') | ||
let savePrefBtn = page.getByRole('button', { name: 'Save' }) | ||
|
||
await categoryChk.check() | ||
await sourceChk.check() | ||
expect(await savePrefBtn.isEnabled()).toBe(true) | ||
await savePrefBtn.click() | ||
savePrefBtn = page.getByRole('button', { name: 'Save' }) | ||
expect(await savePrefBtn.isDisabled()).toBe(true) | ||
}) |
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,79 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('Access the home page', async ({ page }) => { | ||
await page.goto('/', { waitUntil: 'networkidle' }) | ||
const header = page.getByRole('img', { name: 'News Aggregator' }) | ||
expect(header).toBeVisible() | ||
}) | ||
|
||
test('Open search modal and search', async ({ page }) => { | ||
await page.goto('/', { waitUntil: 'networkidle' }) | ||
const button = page.getByTestId('dialog-button') | ||
await button.click() | ||
|
||
const searchinput = page.getByPlaceholder('Search') | ||
const submit = page.getByTestId('submit_btn') | ||
|
||
await searchinput.fill('Brazil') | ||
await submit.click() | ||
|
||
await page.waitForTimeout(3000) | ||
const list = page.getByRole('list').nth(1) | ||
|
||
const article = await list.getByTestId('article-card').all() | ||
|
||
await expect(article.length).toBeGreaterThan(1) | ||
}) | ||
|
||
test('Open search modal and search with filters', async ({ page }) => { | ||
await page.goto('/', { waitUntil: 'networkidle' }) | ||
const button = page.getByTestId('dialog-button') | ||
await button.click() | ||
|
||
const searchinput = page.getByPlaceholder('Search') | ||
const submit = page.getByTestId('submit_btn') | ||
const filterBtn = page.getByTestId('open_close_filters') | ||
const categoryBtn = page | ||
.locator('button') | ||
.filter({ hasText: 'Select a category' }) | ||
const sourceFilter = page | ||
.locator('button') | ||
.filter({ hasText: 'Select a source' }) | ||
await searchinput.fill('Economy') | ||
await filterBtn.click() | ||
await categoryBtn.click() | ||
const categoryBusiness = page.getByLabel('Business') | ||
|
||
await categoryBusiness.click() | ||
await sourceFilter.click() | ||
const sourceTheGuardian = page.getByLabel('The Guardian') | ||
await sourceTheGuardian.click() | ||
|
||
await submit.click() | ||
|
||
await page.waitForTimeout(3000) | ||
const list = page.getByRole('list').nth(1) | ||
|
||
const article = await list.getByTestId('article-card').all() | ||
|
||
await expect(article.length).toBeGreaterThan(1) | ||
}) | ||
|
||
test('Access news feed', async ({ page }) => { | ||
await page.goto('/', { waitUntil: 'networkidle' }) | ||
const link = page.getByRole('link', { name: 'News feed' }) | ||
await link.click() | ||
await page.waitForTimeout(1000) | ||
|
||
expect(page.url()).toContain('/custom-news-feed') | ||
}) | ||
|
||
test('Change to next page', async ({ page }) => { | ||
await page.goto('/', { waitUntil: 'networkidle' }) | ||
const nextPageBtn = page.getByRole('button', { name: 'Next' }) | ||
await nextPageBtn.click() | ||
await page.waitForTimeout(1000) | ||
const previousBtn = page.getByRole('button', { name: 'Previous' }) | ||
|
||
expect(await previousBtn.isEnabled()).toBe(true) | ||
}) |