|
const { Navalia } = require('navalia'); |
|
const navalia = new Navalia(); |
|
|
|
describe('My Page', () => { |
|
|
|
afterAll(() => { |
|
return navalia.kill(); |
|
}); |
|
|
|
it.concurrent('should have a username input', () => { |
|
return navalia.run((chrome) => chrome.goto('http://localhost:3000/') |
|
.then(() => chrome.exists('[data-test="username"]')) |
|
.then((exists) => expect(exists).toEqual(true))); |
|
}); |
|
|
|
it.concurrent('should have a password input', () => { |
|
return navalia.run((chrome) => chrome.goto('http://localhost:3000/') |
|
.then(() => chrome.exists('[data-test="password"]')) |
|
.then((exists) => expect(exists).toEqual(true))); |
|
}); |
|
|
|
it.concurrent('should have a submit button', () => { |
|
return navalia.run((chrome) => chrome.goto('http://localhost:3000/') |
|
.then(() => chrome.exists('[data-test="submit"]')) |
|
.then((exists) => expect(exists).toEqual(true))); |
|
}); |
|
|
|
it.concurrent('should show an error if no username is filled out', () => { |
|
return navalia.run((chrome) => chrome.goto('http://localhost:3000/') |
|
.then(() => chrome.click('[data-test="submit"]')) |
|
.then(() => chrome.html('[data-test="error"]')) |
|
.then((html) => expect(html).toContain('Username is required'))); |
|
}); |
|
|
|
it.concurrent('should show a password error if a username is filled but no password', () => { |
|
return navalia.run((chrome) => chrome.goto('http://localhost:3000/') |
|
.then(() => chrome.type('[data-test="username"]', '[email protected]')) |
|
.then(() => chrome.click('[data-test="submit"]')) |
|
.then(() => chrome.html('[data-test="error"]')) |
|
.then((html) => expect(html).toContain('Password is required'))); |
|
}); |
|
|
|
it.concurrent('dismisses username errors', () => { |
|
return navalia.run((chrome) => chrome.goto('http://localhost:3000/') |
|
.then(() => chrome.click('[data-test="submit"]')) |
|
.then(() => chrome.click('[data-test="error"] button')) |
|
.then(() => chrome.exists('[data-test="error"]')) |
|
.then((errorPersists) => expect(errorPersists).toEqual(false))); |
|
}); |
|
|
|
it.concurrent('dismisses password errors', () => { |
|
return navalia.run((chrome) => chrome.goto('http://localhost:3000/') |
|
.then(() => chrome.type('[data-test="username"]', '[email protected]')) |
|
.then(() => chrome.click('[data-test="submit"]')) |
|
.then(() => chrome.click('[data-test="error"] button')) |
|
.then(() => chrome.exists('[data-test="error"]')) |
|
.then((errorPersists) => expect(errorPersists).toEqual(false))); |
|
}); |
|
|
|
it.concurrent('should show no errors if both username and password are filled out', () => { |
|
return navalia.run((chrome) => chrome.goto('http://localhost:3000/') |
|
.then(() => chrome.type('[data-test="username"]', '[email protected]')) |
|
.then(() => chrome.type('[data-test="password"]', '1234foobarbaz')) |
|
.then(() => chrome.click('[data-test="submit"]')) |
|
.then(() => chrome.exists('[data-test="error"]')) |
|
.then((errorExists) => expect(errorExists).toEqual(false))); |
|
}); |
|
}); |