-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tests): move e2e tests for consultation-portal to their app
- Loading branch information
1 parent
6cf5d56
commit e7d5e93
Showing
9 changed files
with
295 additions
and
7 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
139 changes: 139 additions & 0 deletions
139
apps/consultation-portal/e2e/consultation-portal-authenticated.spec.ts
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,139 @@ | ||
import { | ||
BrowserContext, | ||
expect, | ||
test, | ||
icelandicAndNoPopupUrl, | ||
urls, | ||
session, | ||
} from '@island.is/testing/e2e' | ||
|
||
test.describe('Consultation portal authenticated', { tag: '@fast' }, () => { | ||
let context: BrowserContext | ||
test.use({ baseURL: urls.islandisBaseUrl }) | ||
|
||
test.beforeAll(async ({ browser }) => { | ||
context = await session({ | ||
browser: browser, | ||
storageState: 'consultation-auth.json', | ||
idsLoginOn: { | ||
nextAuth: { nextAuthRoot: `${urls.islandisBaseUrl}/samradsgatt` }, | ||
}, | ||
phoneNumber: '0102989', | ||
homeUrl: `${urls.islandisBaseUrl}/samradsgatt`, | ||
authTrigger: async (page) => { | ||
await page.goto('/samradsgatt') | ||
await page.getByTestId('menu-login-btn').click() | ||
return `${urls.islandisBaseUrl}/samradsgatt` | ||
}, | ||
}) | ||
}) | ||
|
||
test.afterAll(async () => { | ||
if (context) { | ||
await context.close() | ||
} | ||
}) | ||
|
||
test('logged in user should be shown instead of login', async () => { | ||
const page = await context.newPage() | ||
await page.goto(icelandicAndNoPopupUrl('/samradsgatt')) | ||
|
||
await expect( | ||
page.getByRole('button', { name: 'Gervimaður Ameríku' }), | ||
).toBeVisible() | ||
await expect(page.getByTestId('menu-login-btn')).not.toBeVisible() | ||
|
||
await page.close() | ||
}) | ||
|
||
test('subscriptions page should show logged in state', async () => { | ||
const page = await context.newPage() | ||
await page.goto(icelandicAndNoPopupUrl('/samradsgatt')) | ||
|
||
await page.getByTestId('subscriptions-btn').click() | ||
await expect(page.getByTestId('subscriptions-title')).toBeVisible() | ||
await expect(page.getByTestId('action-card')).toBeVisible() | ||
await expect( | ||
page.getByRole('button', { | ||
name: 'Skrá mig inn', | ||
}), | ||
).not.toBeVisible() | ||
|
||
await page.close() | ||
}) | ||
|
||
test('my subscriptions page should show logged in state', async () => { | ||
const page = await context.newPage() | ||
await page.goto(icelandicAndNoPopupUrl('/samradsgatt/minaraskriftir')) | ||
await expect(page.getByTestId('subscriptions-title')).toBeVisible() | ||
await expect(page.getByTestId('action-card')).not.toBeVisible() | ||
|
||
await page.close() | ||
}) | ||
|
||
test('advices page should show logged in state', async () => { | ||
const page = await context.newPage() | ||
await page.goto(icelandicAndNoPopupUrl('/samradsgatt')) | ||
|
||
await page.goto('/umsagnir') | ||
await expect(page.getByTestId('actionCard')).not.toBeVisible() | ||
|
||
await page.close() | ||
}) | ||
|
||
test('logout button should be visible', async () => { | ||
const page = await context.newPage() | ||
await page.goto(icelandicAndNoPopupUrl('/samradsgatt')) | ||
|
||
await page.getByRole('button', { name: 'Gervimaður Ameríku' }).click() | ||
await expect(page.getByRole('button', { name: 'Útskrá' })).toBeVisible() | ||
|
||
await page.close() | ||
}) | ||
|
||
// Additional tests | ||
test('user should be able to navigate to profile page', async () => { | ||
const page = await context.newPage() | ||
await page.goto(icelandicAndNoPopupUrl('/samradsgatt')) | ||
|
||
await page.getByRole('button', { name: 'Gervimaður Ameríku' }).click() | ||
await page.getByRole('link', { name: 'Mínar síður' }).click() | ||
await expect(page.getByTestId('profile-page')).toBeVisible() | ||
|
||
await page.close() | ||
}) | ||
|
||
test('user should be able to update profile information', async () => { | ||
const page = await context.newPage() | ||
await page.goto(icelandicAndNoPopupUrl('/samradsgatt/minar-sidur')) | ||
|
||
await page.getByTestId('edit-profile-btn').click() | ||
await page.fill('input[name="name"]', 'Updated Name') | ||
await page.getByTestId('save-profile-btn').click() | ||
await expect(page.getByTestId('profile-name')).toHaveText('Updated Name') | ||
|
||
await page.close() | ||
}) | ||
|
||
test('user should be able to view notifications', async () => { | ||
const page = await context.newPage() | ||
await page.goto(icelandicAndNoPopupUrl('/samradsgatt')) | ||
|
||
await page.getByRole('button', { name: 'Gervimaður Ameríku' }).click() | ||
await page.getByRole('link', { name: 'Tilkynningar' }).click() | ||
await expect(page.getByTestId('notifications-page')).toBeVisible() | ||
|
||
await page.close() | ||
}) | ||
|
||
test('user should be able to log out', async () => { | ||
const page = await context.newPage() | ||
await page.goto(icelandicAndNoPopupUrl('/samradsgatt')) | ||
|
||
await page.getByRole('button', { name: 'Gervimaður Ameríku' }).click() | ||
await page.getByRole('button', { name: 'Útskrá' }).click() | ||
await expect(page.getByTestId('menu-login-btn')).toBeVisible() | ||
|
||
await page.close() | ||
}) | ||
}) |
112 changes: 112 additions & 0 deletions
112
apps/consultation-portal/e2e/consultation-portal-unauthenticated.spec.ts
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,112 @@ | ||
import { | ||
BrowserContext, | ||
expect, | ||
test, | ||
icelandicAndNoPopupUrl, | ||
urls, | ||
session, | ||
} from '@island.is/testing/e2e' | ||
|
||
test.describe('Consultation portal unathenticated', { tag: '@fast' }, () => { | ||
let context: BrowserContext | ||
const authLink = new RegExp(`^${urls.authUrl}`) | ||
|
||
test.use({ baseURL: `${urls.islandisBaseUrl}/samradsgatt` }) | ||
|
||
test.beforeAll(async ({ browser, baseURL }) => { | ||
context = await session({ | ||
browser: browser, | ||
storageState: 'consultation-no-auth.json', | ||
idsLoginOn: false, | ||
homeUrl: baseURL, | ||
}) | ||
}) | ||
test.afterAll(async () => { | ||
await context.close() | ||
}) | ||
|
||
test('nav links on front page should be visible', async () => { | ||
const page = await context.newPage() | ||
await page.goto(icelandicAndNoPopupUrl('/samradsgatt')) | ||
|
||
await expect(page.getByTestId('all-cases-btn')).toBeVisible() | ||
await expect(page.getByTestId('subscriptions-btn')).toBeVisible() | ||
await expect(page.getByTestId('advices-btn')).toBeVisible() | ||
await expect(page.getByTestId('menu-login-btn')).toBeVisible() | ||
|
||
await page.close() | ||
}) | ||
|
||
test('subscriptions page should show logged out state', async () => { | ||
const page = await context.newPage() | ||
await page.goto(icelandicAndNoPopupUrl('/samradsgatt')) | ||
|
||
await page.getByTestId('subscriptions-btn').click() | ||
await expect(page.getByTestId('subscriptions-title')).toBeVisible() | ||
await expect(page.getByTestId('tab-content')).not.toBeVisible() | ||
await expect(page.getByTestId('action-card')).toBeVisible() | ||
page | ||
.getByRole('button', { | ||
name: 'Skrá mig inn', | ||
}) | ||
.click() | ||
await page.waitForURL(authLink) | ||
|
||
await page.close() | ||
}) | ||
|
||
test('my subscriptions page should be empty and redirect user to login', async () => { | ||
const page = await context.newPage() | ||
await page.goto(icelandicAndNoPopupUrl('/samradsgatt')) | ||
|
||
await page.getByTestId('subscriptions-btn').click() | ||
await expect(page.getByTestId('tab-content')).not.toBeVisible() | ||
|
||
page | ||
.getByRole('link', { | ||
name: 'Hægt er að afskrá sig hér', | ||
}) | ||
.click() | ||
await page.waitForURL(`**/minaraskriftir`) | ||
await expect(page.getByTestId('tab-content')).not.toBeVisible() | ||
await page.waitForURL(authLink) | ||
|
||
await page.close() | ||
}) | ||
|
||
test('advices page should show logged out state', async () => { | ||
const page = await context.newPage() | ||
await page.goto(icelandicAndNoPopupUrl('/samradsgatt')) | ||
|
||
await page.getByTestId('advices-btn').click() | ||
await expect(page.getByTestId('action-card')).toBeVisible() | ||
page | ||
.getByRole('button', { | ||
name: 'Skrá mig inn', | ||
}) | ||
.click() | ||
await page.waitForURL(authLink) | ||
|
||
await page.close() | ||
}) | ||
|
||
test('login button should redirect to login', async () => { | ||
const page = await context.newPage() | ||
await page.goto(icelandicAndNoPopupUrl('/samradsgatt')) | ||
|
||
page.getByTestId('menu-login-btn').click() | ||
await page.waitForURL(authLink) | ||
|
||
await page.close() | ||
}) | ||
|
||
test('card should show up on frontpage and show case when clicked', async () => { | ||
const page = await context.newPage() | ||
await page.goto(icelandicAndNoPopupUrl('/samradsgatt')) | ||
|
||
await page.getByTestId('front-page-card').first().click() | ||
await expect(page.getByTestId('short-description')).toBeVisible() | ||
|
||
await page.close() | ||
}) | ||
}) |
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,9 @@ | ||
import { createPlaywrightConfig } from '@island.is/testing/e2e' | ||
|
||
const consultationPortalConfig = createPlaywrightConfig({ | ||
webServerUrl: 'http://localhost:4200/', | ||
app: 'consultation-portal', | ||
dependencies: ['api'], | ||
}) | ||
|
||
export default consultationPortalConfig |
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const proxyConfig = { | ||
'/api/graphql': { | ||
target: process.env.API_URL ?? 'http://localhost:4444', | ||
secure: false, | ||
}, | ||
} | ||
|
||
export default proxyConfig |
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