Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more tests #484

Open
wants to merge 9 commits into
base: feature/a11ymap
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added e2e/1000015934.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 81 additions & 0 deletions e2e/fotos-to-add.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { test, expect } from '@playwright/test';
import { skipOnboarding } from './skipOnboarding';
import getBaseURL from './lib/base-url';
const baseURL = getBaseURL();
import { skipOnMobiles, skipOnDesktops } from './lib/device-type';
const dialogSelector = 'dialog[data-state="open"]';

async function waitForDialogToBeStable(page) {
const dialog = await page.$(dialogSelector);
// Needed to wait for the dialog to be fully opaque/non-transparent before running the accessibility scan
await dialog?.waitForElementState('stable');
}

test('has base URL', async ({ page }) => {
await page.goto(baseURL);

});

test('upload a photo', async ({ page }) => {
try {
await page.goto(baseURL);
await skipOnboarding(page);
await page.goto(baseURL + '/amenities/way:30050297');
// Click on the "Add new image" link
await page.getByRole('link', { name: 'Add new image' }).click();
await page.getByRole('button', { name: 'Continue' }).click();
await page.getByRole('button', { name: 'Select image' }).click();
// Upload an image
await page.locator('input[type=file]').setInputFiles('./e2e/1000015934.jpg');
await page.getByRole('button', { name: 'Upload image' }).click();
}
catch (error) {
console.error('Test failed with error:', error.message);
console.error(error.stack);
throw error;
}
});


test.describe("when the menu is closed", () => {
test('has correct ARIA snapshot on desktops', async ({ page }) => {

skipOnMobiles();
await page.goto(baseURL);
await skipOnboarding(page);
// On desktops, the greater part of the navigation is always visible.
await expect(page.getByRole('banner')).toMatchAriaSnapshot(`
- banner:
- link "Home":
- img
- text: Find wheelchair accessible places.
- navigation:
- list:
- listitem:
- link "Get involved"
- listitem:
- link "News"
- listitem:
- link "Press"
- listitem:
- link "Events"
- listitem:
- link "Add a new place"
- button "Show menu"
`);
});


test('has correct ARIA snapshot on mobiles', async ({ page }) => {
skipOnDesktops();
await page.goto(baseURL);
await skipOnboarding(page);
await expect(page.getByRole('banner')).toMatchAriaSnapshot(`
- banner:
- link "Home":
- img "Wheelmap logo"
- navigation:
- button "Show menu"
`);
});
});
1 change: 1 addition & 0 deletions e2e/main-menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ test.describe("when the menu is closed", () => {
`);
});


test('has correct ARIA snapshot on mobiles', async ({ page }) => {
skipOnDesktops();
await expect(page.getByRole('banner')).toMatchAriaSnapshot(`
Expand Down
104 changes: 104 additions & 0 deletions e2e/menu-links-working.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { test, expect } from '@playwright/test';
import { skipOnboarding } from './skipOnboarding';
import getBaseURL from './lib/base-url';
const baseURL = getBaseURL();
import { skipOnMobiles, skipOnDesktops } from './lib/device-type';
const dialogSelector = 'dialog[data-state="open"]';

test.beforeEach(async ({ page }) => {
// Go to the starting url before each test.
await page.goto(baseURL);
await skipOnboarding(page);
});

test('Get involved', async ({ page }) => {
try {
await page.waitForURL('https://feature-a11ymap.wheelmap.tech/');
// Wait for the new tab to open
const newTabPromise = page.waitForEvent("popup");
await page.getByRole('banner').getByRole('link', { name: 'Get involved' }).click();
const newTab = await newTabPromise;
await newTab.waitForLoadState();
// Check if the URL and title of the new tab are correct
await expect(newTab).toHaveURL("https://news.wheelmap.org/en/wheelmap-ambassador-program-2021/");
await expect(newTab).toHaveTitle("Wheelmap Ambassador Program 2021 – Wheelmap.org");
}
catch (error) {
console.error('Test failed with error:', error.message);
console.error(error.stack);
throw error;
}
});

test('News', async ({ page }) => {

try {
await page.waitForURL('https://feature-a11ymap.wheelmap.tech/');
// Wait for the new tab to open
const newTabPromise = page.waitForEvent('popup');
await page.getByRole('banner').getByRole('link', { name: 'News' }).click();
const newTab = await newTabPromise;
await newTab.waitForLoadState();
// Check if the URL of the new tab is correct
await expect(newTab).toHaveURL('https://news.wheelmap.org/en/#news');
}
catch (error) {
console.error('Test failed with error:', error.message);
console.error(error.stack);
throw error;
}
});

test('Press', async ({ page }) => {

try {
await page.waitForURL('https://feature-a11ymap.wheelmap.tech/');
// Wait for the new tab to open
const newTabPromise = page.waitForEvent('popup');
await page.getByRole('banner').getByRole('link', { name: 'Press' }).click();
const newTab = await newTabPromise;
await newTab.waitForLoadState();
// Check if the URL of the new tab is correct
await expect(newTab).toHaveURL('https://news.wheelmap.org/en/press/');
}
catch (error) {
console.error('Test failed with error:', error.message);
console.error(error.stack);
throw error;
}
});

test('Events', async ({ page }) => {

try {
await page.waitForURL('https://feature-a11ymap.wheelmap.tech/');
await page.getByRole('banner').getByRole('link', { name: 'Events' }).click();
// Check if the URL is correct
await expect(page).toHaveURL('https://feature-a11ymap.wheelmap.tech/events');
}
catch (error) {
console.error('Test failed with error:', error.message);
console.error(error.stack);
throw error;
}
});

test('Add a new place', async ({ page }) => {

try {
await page.waitForURL('https://feature-a11ymap.wheelmap.tech/');
// Wait for the new tab to open
const newTabPromise = page.waitForEvent('popup');
await page.getByRole('banner').getByRole('link', { name: 'Add a new place' }).click();
const newTab = await newTabPromise;
await newTab.waitForLoadState();
// Check if the URL of the new tab is correct
await expect(newTab).toHaveURL('https://wheelmap.pro/organizations/LPb4y2ri7b6fLxLFa/survey-projects/wx4mM8xFiQAsB5aLi/show?step=data.osm_place');
}

catch (error) {
console.error('Test failed with error:', error.message);
console.error(error.stack);
throw error;
}
});
Loading