/
sandbox.cy.ts
77 lines (59 loc) · 2.31 KB
/
sandbox.cy.ts
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
import { podUrl, webId } from 'cypress-solid';
describe('Solid interactions', () => {
beforeEach(() => {
cy.solidReset();
cy.visit('/');
});
it('Logs in', () => {
// Arrange
cy.contains('Log in with Solid');
// Act
cy.get('[aria-label="Login url"]').type(webId()).type('{enter}');
cy.solidLogin();
// Assert
cy.contains('Hello, Alice Cooper');
});
it('Logs out', () => {
// Arrange
cy.get('[aria-label="Login url"]').type(webId()).type('{enter}');
cy.solidLogin();
// Act
cy.contains('Log out').click();
// Assert
cy.contains('Hello, Alice Cooper').should('not.exist');
});
it('Creates tasks', () => {
// Arrange
cy.intercept('PATCH', podUrl('/tasks/*')).as('createTask');
cy.get('[aria-label="Login url"]').type(webId()).type('{enter}');
cy.solidLogin();
// Act
cy.contains('No tasks yet, create one.');
cy.get('[aria-label="Task name"]').type('Learn to use cypress-solid{enter}');
// Assert
cy.contains('No tasks yet, create one.').should('not.exist');
cy.contains('Learn to use cypress-solid');
cy.fixture('create-task.sparql').then((sparql) => {
cy.get('@createTask').its('response.statusCode').should('eq', 201);
cy.get('@createTask').its('request.body').should('be.sparql', sparql);
});
});
it('Loads tasks', () => {
// Arrange
cy.solidCreateContainer('/tasks/', 'Tasks');
cy.solidCreateDocument('/tasks/task', 'task.ttl');
cy.solidCreateDocument('/tasks/deleted-task', 'deleted-task.ttl');
cy.solidDeleteDocument('/tasks/deleted-task');
cy.solidCreateDocument('/settings/privateTypeIndex', 'privateTypeIndex.ttl');
cy.solidUpdateDocument('/profile/card', 'register-type-index.sparql');
// Act
cy.get('[aria-label="Login url"]').type(webId()).type('{enter}');
cy.solidLogin();
// Assert
cy.contains('This task was seeded in Cypress');
cy.contains('This task should be deleted').should('not.exist');
cy.fixture('task.ttl').then((turtle) => {
cy.solidReadDocument('/tasks/task').should('be.turtle', turtle);
});
});
});