-
Notifications
You must be signed in to change notification settings - Fork 6
/
load_more.ts
62 lines (58 loc) · 1.62 KB
/
load_more.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
/// <reference types="cypress" />
/// <reference path="../../support/commands.ts" />
import schema from '../../../schema.json';
import { Mocks_AllOperations } from '../../src/mock-types';
describe('load more', () => {
beforeEach(() => {
cy.server();
cy.mockGraphql({ schema });
cy.route('/sockjs-node', {});
});
it('Should show submit button when logged in', () => {
cy.mockGraphqlOps<Mocks_AllOperations>({
operations: {
CurrentUserForLayout: {
currentUser: {
login: 'Tim Griesser',
avatar_url: 'https://avatars1.githubusercontent.com/u/154748?v=4',
},
},
},
});
cy.visit('/');
cy.get('[data-e2e="submit_btn"]').should('have.attr', 'href', '/submit');
cy.mockGraphqlOps<Mocks_AllOperations>({
operations: {
CurrentUserForLayout: {
currentUser: null,
},
},
});
cy.reload();
cy.get('[data-e2e="submit_btn"]').should('not.exist');
});
it('Should show submit button when logged in', () => {
cy.mockGraphqlOps<Mocks_AllOperations>({
operations: {
CurrentUserForLayout: {
currentUser: null,
},
},
});
cy.visit('/');
cy.get('[data-e2e="submit_btn"]').should('not.exist');
});
it('Renders an empty state', () => {
cy.mockGraphqlOps<Mocks_AllOperations>({
operations: {
Feed: {
feed: [],
},
},
});
cy.visit('/');
// Broken because of SSR. Need to dig in more.
// cy.get('[data-e2e="empty_state"]').should('be.visible');
cy.get('[data-e2e="feed"]').should('be.visible');
});
});