forked from keystonejs/keystone
-
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.
Integration tests admin UI (keystonejs#6260)
* navigation tests * more navigation related tests * commit out bad test * update schema.graphql * update nav tests * update schema.graphql * update tests.yml to include navigation admin-ui test * fix tests * add determinism to init.test.ts * update nav test to be a bit more deterministic * update init.test.ts * rename seedData fn and move it to utils module * remove log * update util for better errors * remove unnecessary try catch
- Loading branch information
1 parent
a90f62e
commit 9c0681c
Showing
8 changed files
with
177 additions
and
26 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
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,75 @@ | ||
import { Browser, Page } from 'playwright'; | ||
import { adminUITests } from './utils'; | ||
|
||
adminUITests('./tests/test-projects/basic', browserType => { | ||
let browser: Browser = undefined as any; | ||
let page: Page = undefined as any; | ||
|
||
beforeAll(async () => { | ||
browser = await browserType.launch(); | ||
page = await browser.newPage(); | ||
await page.goto('http://localhost:3000'); | ||
}); | ||
test('Nav contains a Dashboard route by default', async () => { | ||
await page.waitForSelector('nav a:has-text("Dashboard")'); | ||
}); | ||
test('When at the index, the Dashboard NavItem is selected', async () => { | ||
const element = await page.waitForSelector('nav a:has-text("Dashboard")'); | ||
const ariaCurrent = await element?.getAttribute('aria-current'); | ||
expect(ariaCurrent).toBe('location'); | ||
}); | ||
test('When navigated to a List route, the representative list NavItem is selected', async () => { | ||
await page.goto('http://localhost:3000/tasks'); | ||
const element = await page.waitForSelector('nav a:has-text("Tasks")'); | ||
const ariaCurrent = await element?.getAttribute('aria-current'); | ||
expect(ariaCurrent).toBe('location'); | ||
}); | ||
test('Can access all list pages via the navigation', async () => { | ||
await page.goto('http://localhost:3000'); | ||
await Promise.all([ | ||
page.waitForNavigation({ | ||
url: 'http://localhost:3000/tasks', | ||
}), | ||
page.click('nav a:has-text("Tasks")'), | ||
]); | ||
await Promise.all([ | ||
page.waitForNavigation({ | ||
url: 'http://localhost:3000/people', | ||
}), | ||
page.click('nav a:has-text("People")'), | ||
]); | ||
}); | ||
test('Can not access hidden lists via the navigation', async () => { | ||
await Promise.all([page.waitForNavigation(), page.goto('http://localhost:3000')]); | ||
await page.waitForSelector('nav'); | ||
const navItems = await page.$$('nav li a'); | ||
const navLinks = await Promise.all( | ||
navItems.map(navItem => { | ||
return navItem.getAttribute('href'); | ||
}) | ||
); | ||
expect(navLinks.length).toBe(3); | ||
expect(navLinks.includes('/secretplans')).toBe(false); | ||
}); | ||
test('When navigated to an Item view, the representative list NavItem is selected', async () => { | ||
await page.goto('http://localhost:3000'); | ||
await page.click('button[title="Create Task"]'); | ||
await page.fill('id=label', 'Test Task'); | ||
await Promise.all([page.waitForNavigation(), page.click('button[type="submit"]')]); | ||
const element = await page.waitForSelector('nav a:has-text("Tasks")'); | ||
const ariaCurrent = await element?.getAttribute('aria-current'); | ||
expect(ariaCurrent).toBe('location'); | ||
}); | ||
test('When pressing a list view nav item from an item view, the correct route should be reached', async () => { | ||
await page.goto('http://localhost:3000'); | ||
await page.click('button[title="Create Task"]'); | ||
await page.fill('id=label', 'Test Task'); | ||
await Promise.all([page.waitForNavigation(), page.click('button[type="submit"]')]); | ||
await Promise.all([page.waitForNavigation(), page.click('nav a:has-text("Tasks")')]); | ||
|
||
expect(page.url()).toBe('http://localhost:3000/tasks'); | ||
}); | ||
afterAll(async () => { | ||
await browser.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
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