-
Notifications
You must be signed in to change notification settings - Fork 27
/
onboarding.test.js
71 lines (60 loc) · 2 KB
/
onboarding.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
const { randomName } = require('../support/functions');
describe('Onboarding tests', () => {
before(() => {
cy.login();
});
beforeEach(() => {
cy.uploadMedia('tests/cypress/fixtures/example.jpg');
cy.activatePlugin('simple-podcasting');
cy.deleteAllTerms('podcasting_podcasts');
cy.deactivatePlugin('simple-podcasting');
cy.visit('/wp-admin/options.php');
cy.get('body').then(($body) => {
if ($body.find('#simple_podcasting_onboarding').length !== 0) {
cy.get('#simple_podcasting_onboarding')
.click()
.type('{selectAll}no');
cy.get('.submit input[type=submit]').click();
}
});
cy.activatePlugin('simple-podcasting');
});
it('Should indicate errors', () => {
cy.url().should('include', 'simple-podcasting-onboarding');
cy.url().should('include', 'step=1');
cy.get('#simple-podcasting__create-podcast-button')
.closest('form')
.submit();
cy.contains('Taxonomy error: A podcast name is required..');
});
it('Should pass onboarding', () => {
cy.url().should('include', 'simple-podcasting-onboarding');
cy.url().should('include', 'step=1');
const podcastName = 'Onboarding ' + randomName();
cy.get('input[name=podcast-name]').click().type(podcastName);
cy.get('input[name="podcast-artist"]').type('Person Doe');
cy.get('textarea[name="podcast-description"]').type(
'Lorem ipsum dolor'
);
cy.get('#simple-podcasting__upload-cover-image').click();
cy.get('#menu-item-browse').click();
cy.get('.attachments-wrapper').click();
cy.get('.media-button-select').click();
cy.get('select[name=podcast-category]').select('Arts');
cy.get('#simple-podcasting__create-podcast-button')
.closest('form')
.submit();
cy.url().should('include', 'step=2');
cy.visit(
'/wp-admin/edit-tags.php?taxonomy=podcasting_podcasts&podcasts=true'
);
// Podcast was created.
cy.contains(podcastName);
// Option was saved.
cy.visit('/wp-admin/options.php');
cy.get('#simple_podcasting_onboarding').should(
'have.value',
'completed'
);
});
});