Skip to content

Commit

Permalink
Merge branch 'main' into check_anal_id
Browse files Browse the repository at this point in the history
  • Loading branch information
jaasonw committed Oct 26, 2022
2 parents f9cfc41 + b9631d3 commit df8e4c1
Show file tree
Hide file tree
Showing 79 changed files with 1 addition and 278 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 0 additions & 50 deletions src/routes/(site)/about/page.test.ts
@@ -1,58 +1,8 @@
import type { TestInfo } from '@playwright/test';
import { expect, test } from '@playwright/test';
import path from 'node:path';

test.describe.configure({ mode: 'parallel' });

// setupSnapshot is a helper that creates handles the necessary boilerplate
// for snapshot testing. It returns a function that can be called after the
// snapshot test has executed.
//
// See:
// https://github.com/microsoft/playwright/issues/14527#issuecomment-1143352769
export function setupSnapshot(testInfo: TestInfo) {
const snapshotDir = testInfo.snapshotDir;
const snapshotSuffix = testInfo.snapshotSuffix;
const projectName = testInfo.project.name;

testInfo.snapshotDir = path.resolve(snapshotDir, '..', 'screenshots');
testInfo.snapshotSuffix = '';
testInfo.project.name = '';

return {
data: { projectName },
cleanupSnapshot() {
testInfo.snapshotDir = snapshotDir;
testInfo.snapshotSuffix = snapshotSuffix;
testInfo.project.name = projectName;
},
};
}

test('about page has expected h1', async ({ page }) => {
await page.goto('/about');
expect(await page.textContent('h1')).toBe('About us');
});

test('about page matches screenshot', async ({ page }, testInfo) => {
const { cleanupSnapshot, data } = setupSnapshot(testInfo);

if (testInfo.project.use.viewport) {
await page.setViewportSize(testInfo.project.use.viewport);
}

if (testInfo.project.use.colorScheme) {
await page.emulateMedia({
colorScheme: testInfo.project.use.colorScheme,
});
}

await page.goto('/about', { waitUntil: 'networkidle' });
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot({
name: `page-${data.projectName}.png`,
maxDiffPixelRatio: 0.1,
threshold: 1,
});

cleanupSnapshot();
});
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
27 changes: 0 additions & 27 deletions src/routes/(site)/blog/[id]/page.test.ts
@@ -1,34 +1,7 @@
import type { TestInfo } from '@playwright/test';
import { expect, test } from '@playwright/test';
import path from 'node:path';

test.describe.configure({ mode: 'parallel' });

// setupSnapshot is a helper that creates handles the necessary boilerplate
// for snapshot testing. It returns a function that can be called after the
// snapshot test has executed.
//
// See:
// https://github.com/microsoft/playwright/issues/14527#issuecomment-1143352769
export function setupSnapshot(testInfo: TestInfo) {
const snapshotDir = testInfo.snapshotDir;
const snapshotSuffix = testInfo.snapshotSuffix;
const projectName = testInfo.project.name;

testInfo.snapshotDir = path.resolve(snapshotDir, '..', 'screenshots');
testInfo.snapshotSuffix = '';
testInfo.project.name = '';

return {
data: { projectName },
cleanupSnapshot() {
testInfo.snapshotDir = snapshotDir;
testInfo.snapshotSuffix = snapshotSuffix;
testInfo.project.name = projectName;
},
};
}

test('blog post h1 matches page title', async ({ page }) => {
await page.goto('/blog/272');
expect(await page.title()).toContain(await page.textContent('h1'));
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
50 changes: 0 additions & 50 deletions src/routes/(site)/nodebuds/page.test.ts
@@ -1,58 +1,8 @@
import type { TestInfo } from '@playwright/test';
import { expect, test } from '@playwright/test';
import path from 'node:path';

test.describe.configure({ mode: 'parallel' });

// setupSnapshot is a helper that creates handles the necessary boilerplate
// for snapshot testing. It returns a function that can be called after the
// snapshot test has executed.
//
// See:
// https://github.com/microsoft/playwright/issues/14527#issuecomment-1143352769
export function setupSnapshot(testInfo: TestInfo) {
const snapshotDir = testInfo.snapshotDir;
const snapshotSuffix = testInfo.snapshotSuffix;
const projectName = testInfo.project.name;

testInfo.snapshotDir = path.resolve(snapshotDir, '..', 'screenshots');
testInfo.snapshotSuffix = '';
testInfo.project.name = '';

return {
data: { projectName },
cleanupSnapshot() {
testInfo.snapshotDir = snapshotDir;
testInfo.snapshotSuffix = snapshotSuffix;
testInfo.project.name = projectName;
},
};
}

test('nodebuds page has expected h1', async ({ page }) => {
await page.goto('/nodebuds');
expect(await page.textContent('h1')).toBe('Personalized for your success');
});

test('nodebuds page matches screenshot', async ({ page }, testInfo) => {
const { cleanupSnapshot, data } = setupSnapshot(testInfo);

if (testInfo.project.use.viewport) {
await page.setViewportSize(testInfo.project.use.viewport);
}

if (testInfo.project.use.colorScheme) {
await page.emulateMedia({
colorScheme: testInfo.project.use.colorScheme,
});
}

await page.goto('/nodebuds', { waitUntil: 'networkidle' });
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot({
name: `page-${data.projectName}.png`,
maxDiffPixelRatio: 0.1,
threshold: 1,
});

cleanupSnapshot();
});
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
50 changes: 0 additions & 50 deletions src/routes/(site)/privacy/page.test.ts
@@ -1,58 +1,8 @@
import type { TestInfo } from '@playwright/test';
import { expect, test } from '@playwright/test';
import path from 'node:path';

test.describe.configure({ mode: 'parallel' });

// setupSnapshot is a helper that creates handles the necessary boilerplate
// for snapshot testing. It returns a function that can be called after the
// snapshot test has executed.
//
// See:
// https://github.com/microsoft/playwright/issues/14527#issuecomment-1143352769
export function setupSnapshot(testInfo: TestInfo) {
const snapshotDir = testInfo.snapshotDir;
const snapshotSuffix = testInfo.snapshotSuffix;
const projectName = testInfo.project.name;

testInfo.snapshotDir = path.resolve(snapshotDir, '..', 'screenshots');
testInfo.snapshotSuffix = '';
testInfo.project.name = '';

return {
data: { projectName },
cleanupSnapshot() {
testInfo.snapshotDir = snapshotDir;
testInfo.snapshotSuffix = snapshotSuffix;
testInfo.project.name = projectName;
},
};
}

test('privacy page has expected h1', async ({ page }) => {
await page.goto('/privacy');
expect(await page.textContent('h1')).toBe('Privacy Policy');
});

test('events page matches screenshot', async ({ page }, testInfo) => {
const { cleanupSnapshot, data } = setupSnapshot(testInfo);

if (testInfo.project.use.viewport) {
await page.setViewportSize(testInfo.project.use.viewport);
}

if (testInfo.project.use.colorScheme) {
await page.emulateMedia({
colorScheme: testInfo.project.use.colorScheme,
});
}

await page.goto('/privacy', { waitUntil: 'networkidle' });
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot({
name: `page-${data.projectName}.png`,
maxDiffPixelRatio: 0.1,
threshold: 1,
});

cleanupSnapshot();
});
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
51 changes: 0 additions & 51 deletions src/routes/(site)/quiz/page.test.ts
@@ -1,58 +1,7 @@
import type { TestInfo } from '@playwright/test';
import { expect, test } from '@playwright/test';
import path from 'node:path';

test.describe.configure({ mode: 'parallel' });

// setupSnapshot is a helper that creates handles the necessary boilerplate
// for snapshot testing. It returns a function that can be called after the
// snapshot test has executed.
//
// See:
// https://github.com/microsoft/playwright/issues/14527#issuecomment-1143352769
export function setupSnapshot(testInfo: TestInfo) {
const snapshotDir = testInfo.snapshotDir;
const snapshotSuffix = testInfo.snapshotSuffix;
const projectName = testInfo.project.name;

testInfo.snapshotDir = path.resolve(snapshotDir, '..', 'screenshots');
testInfo.snapshotSuffix = '';
testInfo.project.name = '';

return {
data: { projectName },
cleanupSnapshot() {
testInfo.snapshotDir = snapshotDir;
testInfo.snapshotSuffix = snapshotSuffix;
testInfo.project.name = projectName;
},
};
}

test('teams page has expected h1', async ({ page }) => {
await page.goto('/quiz');
expect(await page.textContent('h1')).toBe('ACM TEAM QUIZ');
});

test('quiz page matches screenshot', async ({ page }, testInfo) => {
const { cleanupSnapshot, data } = setupSnapshot(testInfo);

if (testInfo.project.use.viewport) {
await page.setViewportSize(testInfo.project.use.viewport);
}

if (testInfo.project.use.colorScheme) {
await page.emulateMedia({
colorScheme: testInfo.project.use.colorScheme,
});
}

await page.goto('/quiz', { waitUntil: 'networkidle' });
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot({
name: `page-${data.projectName}.png`,
maxDiffPixelRatio: 0.1,
threshold: 1,
});

cleanupSnapshot();
});
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
50 changes: 0 additions & 50 deletions src/routes/(site)/teams/page.test.ts
@@ -1,58 +1,8 @@
import type { TestInfo } from '@playwright/test';
import { expect, test } from '@playwright/test';
import path from 'node:path';

test.describe.configure({ mode: 'parallel' });

// setupSnapshot is a helper that creates handles the necessary boilerplate
// for snapshot testing. It returns a function that can be called after the
// snapshot test has executed.
//
// See:
// https://github.com/microsoft/playwright/issues/14527#issuecomment-1143352769
export function setupSnapshot(testInfo: TestInfo) {
const snapshotDir = testInfo.snapshotDir;
const snapshotSuffix = testInfo.snapshotSuffix;
const projectName = testInfo.project.name;

testInfo.snapshotDir = path.resolve(snapshotDir, '..', 'screenshots');
testInfo.snapshotSuffix = '';
testInfo.project.name = '';

return {
data: { projectName },
cleanupSnapshot() {
testInfo.snapshotDir = snapshotDir;
testInfo.snapshotSuffix = snapshotSuffix;
testInfo.project.name = projectName;
},
};
}

test('teams page has expected h1', async ({ page }) => {
await page.goto('/teams');
expect(await page.textContent('h1')).toBe('Meet the Teams');
});

test('teams page matches screenshot', async ({ page }, testInfo) => {
const { cleanupSnapshot, data } = setupSnapshot(testInfo);

if (testInfo.project.use.viewport) {
await page.setViewportSize(testInfo.project.use.viewport);
}

if (testInfo.project.use.colorScheme) {
await page.emulateMedia({
colorScheme: testInfo.project.use.colorScheme,
});
}

await page.goto('/teams', { waitUntil: 'networkidle' });
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot({
name: `page-${data.projectName}.png`,
maxDiffPixelRatio: 0.1,
threshold: 1,
});

cleanupSnapshot();
});
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.

0 comments on commit df8e4c1

Please sign in to comment.