Skip to content

Commit

Permalink
test(frontend): homepage basic snapshots (logged in and logged out)
Browse files Browse the repository at this point in the history
  • Loading branch information
DenysKarmazynDFINITY committed Aug 15, 2024
1 parent d8bc290 commit 11e1df3
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 8 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,3 @@ backend-v*.wasm.gz
/blob-report/
/playwright/.cache/
pocket-ic

e2e/*-snapshots/*Chrome-darwin.png
44 changes: 39 additions & 5 deletions e2e/homepage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,45 @@
import { expect, test } from '@playwright/test';
import { testWithII } from '@dfinity/internet-identity-playwright';
import { expect, test, type Page } from '@playwright/test';

const testUrl = '/';

test('should display not logged in homepage', async ({ page }) => {
await page.goto(testUrl);
const hideHeroAnimation = async (page: Page): Promise<void> => {
await page
.getByTestId('three-background-canvas')
.evaluate((element) => (element.style.display = 'none'));
};

await page.getByTestId('login-button').waitFor();
test.describe('logged out user', () => {
test.beforeEach(async ({ page }) => {
await page.goto(testUrl);

await expect(page).toHaveScreenshot();
await page.getByTestId('login-button').waitFor();
});

test('should display logged out hero and blurred tokens', async ({ page }) => {
await hideHeroAnimation(page);

await expect(page).toHaveScreenshot({
fullPage: true
});
});
});

testWithII.describe('logged in user', () => {
testWithII.beforeEach(async ({ page, iiPage }) => {
await page.goto(testUrl);

await iiPage.signInWithNewIdentity();

await page.getByTestId('exchange-balance-output').waitFor();
await page.getByTestId('tokens-skeletons-initialized').waitFor();
});

testWithII('should display logged in hero and tokens', async ({ page }) => {
await hideHeroAnimation(page);

await expect(page).toHaveScreenshot({
fullPage: true
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<span class="text-off-white block">
<output
class={`break-all text-5xl font-bold ${totalUsd === 0 ? 'opacity-50' : 'opacity-100'} inline-block mt-8`}
data-tid="exchange-balance-output"
>
{#if $exchangeInitialized}
{formatUSD(totalUsd)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{#if $erc20UserTokensNotInitialized}
<SkeletonCards rows={5} />
{:else}
<div in:fade>
<div in:fade data-tid="tokens-skeletons-initialized">
<slot />
</div>
{/if}
1 change: 1 addition & 0 deletions src/frontend/src/lib/components/ui/ThreeBackground.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ void main(){
renderer = new WebGLRenderer();
renderer.domElement.style.width = '100%';
renderer.domElement.style.height = '100%';
renderer.domElement.setAttribute('data-tid', 'three-background-canvas');
container.appendChild(renderer.domElement);
material = new ShaderMaterial({
Expand Down

0 comments on commit 11e1df3

Please sign in to comment.