-
Notifications
You must be signed in to change notification settings - Fork 27
/
taxonomy.test.js
111 lines (101 loc) · 3.43 KB
/
taxonomy.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
111
const { randomName } = require('../support/functions');
describe('Admin can create and update podcast taxonomy', () => {
before(() => {
cy.login();
cy.deleteAllTerms('podcasting_podcasts');
});
after(() => {
cy.deleteAllTerms('podcasting_podcasts');
});
it('Can see taxonomy menu item', () => {
cy.visit('/wp-admin');
cy.get(
'#toplevel_page_edit-tags-taxonomy-podcasting_podcasts-amp-podcasts-true .wp-menu-name'
).should('have.text', 'Podcasts');
});
it('Can visit taxonomy page', () => {
cy.visit(
'/wp-admin/edit-tags.php?taxonomy=podcasting_podcasts&podcasts=true'
);
cy.get('h1').should('have.text', 'Podcasts');
cy.get('.form-wrap h2').should('have.text', 'Add New Podcast');
cy.get('.notice').should(
'contain.text',
'Once at least one podcast exists'
);
});
it('Can add a new taxonomy', () => {
cy.uploadMedia('tests/cypress/fixtures/example.jpg');
cy.createTerm('Remote work', 'podcasting_podcasts', {
beforeSave: () => {
cy.get('#podcasting_talent_name').type('Person Doe');
cy.get('#podcasting_summary').type('Lorem ipsum dolor');
cy.get('#image-podcasting_image').click();
cy.get('#menu-item-browse').click();
cy.get('.attachments-wrapper').click();
cy.get('.media-button-select').click();
},
});
cy.get('.row-title').should('have.text', 'Remote work');
});
it('Can edit taxonomy', () => {
cy.visit(
'/wp-admin/edit-tags.php?taxonomy=podcasting_podcasts&podcasts=true'
);
cy.get('.row-title').should('have.text', 'Remote work').click();
cy.url().should('contain', 'http://localhost:8889/wp-admin/term.php');
cy.get('#name').click().clear();
cy.get('#name').type('Distributed');
cy.get('#slug').click().clear();
cy.get('input[type="submit"]').click();
cy.url().should('contain', 'http://localhost:8889/wp-admin/term.php');
cy.visit(
'/wp-admin/edit-tags.php?taxonomy=podcasting_podcasts&podcasts=true'
);
cy.get('.row-title').should('have.text', 'Distributed');
});
it('Can delete taxonomy', () => {
cy.visit(
'/wp-admin/edit-tags.php?taxonomy=podcasting_podcasts&podcasts=true'
);
cy.get('.row-title').should('have.text', 'Distributed').click();
cy.url().should('contain', 'http://localhost:8889/wp-admin/term.php');
cy.on('window:confirm', () => true);
cy.get('.delete').click();
cy.url().should(
'contain',
'http://localhost:8889/wp-admin/edit-tags.php'
);
cy.get('.wp-list-table').should('contain.text', 'No podcasts found');
});
const tests = {
0: 'n/a',
serial: 'Serial',
episodic: 'Episodic',
};
for (const [typeOfShowKey, typeOfShowName] of Object.entries(tests)) {
it(`Can add taxonomy with ${typeOfShowName} type of show`, () => {
const podcastName = 'Podcast ' + randomName();
cy.uploadMedia('tests/cypress/fixtures/example.jpg');
cy.createTerm(podcastName, 'podcasting_podcasts', {
beforeSave: () => {
cy.get('#podcasting_type_of_show').select(typeOfShowName);
cy.get('#podcasting_talent_name').type('Person Doe');
cy.get('#podcasting_summary').type('Lorem ipsum dolor');
cy.get('#image-podcasting_image').click();
cy.get('#menu-item-browse').click();
cy.get('.attachments-wrapper').click();
cy.get('.media-button-select').click();
},
}).then((term) => {
cy.visit(
`/wp-admin/term.php?taxonomy=podcasting_podcasts&tag_ID=${term.term_id}`
);
cy.get('#podcasting_type_of_show').should(
'have.value',
typeOfShowKey
);
});
});
}
});