-
Notifications
You must be signed in to change notification settings - Fork 134
/
client.test.js
110 lines (96 loc) · 3.77 KB
/
client.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import { v4 as uuid } from 'uuid';
describe('Igbo API Homepage', () => {
before(() => {
cy.visit('/');
});
describe('Desktop', () => {
beforeEach(() => {
cy.viewport('macbook-16');
});
it('execute JS in browser and renders API homepage', () => {
cy.get('h1').contains('The First African Language API');
cy.contains('An unexpected error has occurred.').should('not.exist');
});
it('render the About page', () => {
cy.get('li').contains('About').click();
cy.findByText('Contact');
cy.contains('Email:');
});
it('render the Privacy page', () => {
cy.findByText('Privacy').click();
cy.findByText('Privacy Policy').should('exist');
});
it('render the Terms or Service page', () => {
cy.findByText('Terms of Service').click();
cy.findByText('Terms and Conditions').should('exist');
});
describe('Try it Out', () => {
it('enter a word and select flag', () => {
cy.visit('/');
cy.findByTestId('try-it-out-input').clear().type('biko');
cy.findByTestId('dialects-flag').click();
cy.get('button').contains('Submit').click();
cy.get('input[value="http://localhost:8080/api/v1/words?keyword=biko&dialects=true"]');
});
});
describe('Register Account', () => {
beforeEach(() => {
cy.visit('/signup');
});
it('render the Sign Up page', () => {
cy.findByText('Sign up.');
});
it('fill out the sign up form and submit for developer account', () => {
const email = `${uuid()}@testing.com`;
cy.intercept('POST', '**developers').as('postDeveloper');
cy.findByTestId('signup-name-input').clear().type('Developer');
cy.findByTestId('signup-email-input').clear().type(email);
cy.findByTestId('signup-password-input').clear().type('password');
cy.findByText('Create account').click();
cy.wait('@postDeveloper').then((res) => {
expect(res.response.statusCode).to.equal(200);
cy.findByText('Success! Check your email');
});
});
it('fill out the sign up form and submit for developer account and get an error', () => {
const email = `${uuid()}@testing.com`;
cy.intercept('POST', '**developers').as('postDeveloper');
cy.findByTestId('signup-name-input').clear().type('Developer');
cy.findByTestId('signup-email-input').clear().type(email);
cy.findByTestId('signup-password-input').clear().type('password');
cy.findByText('Create account').click();
cy.wait('@postDeveloper');
cy.reload();
cy.findByTestId('signup-name-input').clear().type('Developer');
cy.findByTestId('signup-email-input').clear().type(email);
cy.findByTestId('signup-password-input').clear().type('password');
cy.findByText('Create account').click();
cy.wait('@postDeveloper').then((res) => {
expect(res.response.statusCode).to.equal(400);
cy.findByText('Create account').should('not.exist');
cy.findByText('Success! Check your email').should('not.exist');
});
});
});
});
describe('Mobile', () => {
beforeEach(() => {
cy.viewport('iphone-6');
});
it('render the About page', () => {
cy.findByAltText('down arrow as menu icon').click();
cy.get('button').contains('About').click();
cy.findByText('Contact');
cy.contains('Email:');
});
it('render the Sign up page', () => {
cy.findByAltText('down arrow as menu icon').click();
cy.get('button').contains('Get an API Key').click();
cy.findByText('Sign up.');
});
it('navigate to Nkọwa okwu', () => {
cy.visit('/');
cy.get('.demo-inputs-container').contains('Nkọwa okwu').click();
});
});
});